New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: gdb 8 on windows crashes reading Go binary #21380

Open
kjk opened this Issue Aug 10, 2017 · 13 comments

Comments

Projects
None yet
@kjk

kjk commented Aug 10, 2017

What version of Go are you using (go version)?

> go version
go version go1.9rc2 windows/amd64

What operating system and processor architecture are you using (go env)?

> go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\kjk\src\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

I'm trying to gather more information on #20975 which involves running the executable on windows under a debugger that understands dwarf debug info (because neither msvc nor windbg do).

I tried:

  • clone repro program https://github.com/kjk/go20975 and run build.ps1 to build it
  • download gdb from https://nuwen.net/mingw.html and unpack under c:\
  • run C:\MinGW\bin\gdb.exe .\go20975.exe to run under dbg
  • enter https://vox.com in text box

What did you expect to see?

When crash happens, I expected to get a human-readable callstack.

What did you see instead?

[New Thread 2176.0xc90]
fatal: morestack on g0
../../src/gdb/buildsym.c:1773: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

The crash happened in the program but it also crashed gdb.

It seems that DWARF information created by Go compiler breaks gdb.

PS C:\Users\kjk\src\go\src\github.com\kjk\go20975> C:\MinGW\bin\gdb.exe --version
GNU gdb (GDB) 8.0
@kjk

This comment has been minimized.

kjk commented Aug 10, 2017

The same happens for gdb 7.11.1 from http://www.msys2.org/

[New Thread 7596.0x1398]
fatal: morestack on g0
buildsym.c:1773: internal-error: buildsym_init: Assertion `free_pendings == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
$ gdb --version
GNU gdb (GDB) 7.11.1
@mvdan

This comment has been minimized.

Member

mvdan commented Aug 10, 2017

@kjk if this worked with 1.8 and if you have the time, bisecting this to a commit made during the 1.9 cycle would be of great help.

@alexbrainman

This comment has been minimized.

Member

alexbrainman commented Aug 11, 2017

This works for me with GNU gdb (GDB) 7.8 and go version devel +6b6b9f69fd Wed Aug 9 05:33:09 2017 +0000 windows/amd64.
I don't have skills or time to debug gdb.

Alex

@tobiaskohlbau

This comment has been minimized.

tobiaskohlbau commented Aug 14, 2017

I'm also on windows and encountered a similar behavior when compiling go from source. The tests TestGdbBacktrace and TestGdbAutompTypes fail to run after compilation, with the exact same internal gdb error as posted here. After the suggestion by Alex Brainman that gdb 7.8 works for him I downloaded an old gdb and was able to confirm this on my machine. In the first try I got GNU gdb (GDB) 7.9.1 which states in the release notes:

Changes in this release include:
Python scripting enhancements.
Source code compilation and injection into the inferior.
New commands, options, convenience variables/options.
MIPS SDE support (mips*-sde*-elf*).
Better handling of signals when debugging threaded programs.

Within the go documentation there exists the comment that go makes use of a extension for gdb. As I'm not familiar with GDB and the extension possibility I would like to give this information as a starting point for other people to debug this error.

Edit: As suggested by mvdan I tried to build 1.8 release branch but got the exact same problem. So it's not a bug which was introduced by go 1.9 itself.

@kjk

This comment has been minimized.

kjk commented Aug 26, 2017

Just noting that some dwarf fix, not necessarily related, was made: 38bd725

@golang golang deleted a comment Aug 26, 2017

@golang golang deleted a comment Aug 26, 2017

@dsnet

This comment has been minimized.

Member

dsnet commented Sep 1, 2017

Go 1.9 has since been released. Is this still an issue? Unfortunately, this was not placed in the right milestone, so it slipped through triaging.

@dsnet dsnet added the WaitingForInfo label Sep 1, 2017

@dsnet dsnet added this to the Go1.9.1 milestone Sep 1, 2017

@tobiaskohlbau

This comment has been minimized.

tobiaskohlbau commented Sep 2, 2017

I've pulled the latest changes (03c3bb5) and retried this issue. It's still failing with the same error:

--- FAIL: TestGdbAutotmpTypes (2.12s)
        runtime-gdb_test.go:55: gdb version 7.12
        runtime-gdb_test.go:379: could not find struct []main.astruct; in 'info typrs astruct' output
        runtime-gdb_test.go:380: gdb output:
                No symbol "startup" in current context.
                ../../gdb-7.12/gdb/buildsym.c:1773: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed.
                A problem internal to GDB has been detected,
                further debugging may prove unreliable.
                Quit this debugging session? (y or n) [answered Y; input not from terminal]

                This is a bug, please report it.  For instructions, see:
                <http://www.gnu.org/software/gdb/bugs/>.

                ../../gdb-7.12/gdb/buildsym.c:1773: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed.
                A problem internal to GDB has been detected,
                further debugging may prove unreliable.
                Create a core file of GDB? (y or n) [answered Y; input not from terminal]

                This application has requested the Runtime to terminate it in an unusual way.
                Please contact the application's support team for more information.
--- FAIL: TestGdbBacktrace (2.56s)
        runtime-gdb_test.go:55: gdb version 7.12
        runtime-gdb_test.go:310: could not find '#0.*main\.eee' in backtrace
        runtime-gdb_test.go:311: gdb output:
                No symbol "startup" in current context.
                ../../gdb-7.12/gdb/buildsym.c:1773: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed.
                A problem internal to GDB has been detected,
                further debugging may prove unreliable.
                Quit this debugging session? (y or n) [answered Y; input not from terminal]

                This is a bug, please report it.  For instructions, see:
                <http://www.gnu.org/software/gdb/bugs/>.

                ../../gdb-7.12/gdb/buildsym.c:1773: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed.
                A problem internal to GDB has been detected,
                further debugging may prove unreliable.
                Create a core file of GDB? (y or n) [answered Y; input not from terminal]

                This application has requested the Runtime to terminate it in an unusual way.
                Please contact the application's support team for more information.
@thanm

This comment has been minimized.

Member

thanm commented Sep 13, 2017

FYI, it looks as though a GDB binutils bug, 18624 was filed back in 2015 for this same issue. Reported for GDB 7.9, but presumably with a version of Go that was a good deal older than 1.9. This would suggest that the problem is not specific to 1.9.

@rsc rsc modified the milestones: Go1.9.1, Go1.9.2 Oct 4, 2017

@rsc

This comment has been minimized.

Contributor

rsc commented Oct 13, 2017

Given that this has been happening since 2015, not for Go 1.9.2.

@rsc rsc modified the milestones: Go1.9.2, Go1.10 Oct 13, 2017

@rsc rsc changed the title from go 1.9rc2 windows/amd64 breaks gdb 8 to cmd/compile: gdb 8 on windows crashes reading Go binary Oct 13, 2017

@thanm thanm modified the milestones: Go1.10, Go1.11 Nov 29, 2017

@dis2

This comment has been minimized.

dis2 commented Mar 18, 2018

For anyone tripping on this: A temporary workaround is to use external linker:

go build -ldflags=-linkmode=external

This seems to make gdb happy (at least on recent windows/msys2)

@gopherbot

This comment has been minimized.

gopherbot commented Mar 24, 2018

Change https://golang.org/cl/102419 mentions this issue: runtime: improve Windows gdb tests

@ALTree ALTree added the OS-Windows label Mar 24, 2018

gopherbot pushed a commit that referenced this issue Apr 7, 2018

runtime: improve Windows gdb tests
This ensures that gdb tests run on Windows by ignoring any line ending.

Works with gdb 7.7, however with gdb 7.9 and 7.12 gets an error
error:

    internal-error: buildsym_init: Assertion `free_pendings == NULL'
    failed.

Updates #21380

Change-Id: I6a6e5b2a1b5efdca4dfce009fcb9c134c87497d6
Reviewed-on: https://go-review.googlesource.com/102419
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
@kjk

This comment has been minimized.

kjk commented Jun 29, 2018

This still happens with gdb 8.1 and go 1.11 (trunk).

I've provided more details in gdb bug tracker: https://sourceware.org/bugzilla/show_bug.cgi?id=18624#c9

@kjk

This comment has been minimized.

kjk commented Jun 29, 2018

This might be a gdb bug that only happens with COFF/PE: https://sourceware.org/ml/gdb-patches/2018-06/msg00736.html

@ianlancetaylor ianlancetaylor removed this from the Go1.11 milestone Jun 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment