StephanTLavavej / mingw-distro

MinGW distro build scripts.
494 stars 55 forks source link

gdb.exe crashing on golang 1.7rc3 unit test TestGdbBacktrace #24

Closed timou closed 7 years ago

timou commented 8 years ago

For the longest time, I've been using the mingw-distro toolchain for building golang on Windows, and for Go to use as it's native gcc. It's been working flawlessly for years. However, recently building the release candidates for go1.7rc3, I'm getting a crash in gdb (fails an assert). Of course, this is a problem with gdb, not the mingw-packaging, but it seems that gdb is packaged without symbols, so I haven't got much further with trying to find the root cause, and I haven't been successful building gdb from sources. Feel free to close or ignore this report as "not a problem with mingw-distro", but would be nice to be able to file a bug report with the gdb and/or gloang teams if possible. Happy to try out a gdb.exe built for DEBUG, if you can provide?

mingw-distro: 14.0

Repro steps:

  1. Install mingw-distro 14.0, add it to PATH.
  2. Check out and build golang 1.4.3. (Run all.bat from src.)
  3. Set GOROOT_BOOTSTRAP to whereever 1.4.3 was built.
  4. Checkout and build golang 1.7rc3. (Run all.bat from src.)

The unit test TestGdbBacktrace should fail, as below:

C:\Code\go17\src\runtime>go test -v -run GdbBacktrace
=== RUN   TestGdbBacktrace
--- FAIL: TestGdbBacktrace (0.36s)
        runtime-gdb_test.go:51: gdb version 7.11
        runtime-gdb_test.go:220: builddir: C:\Users\me\AppData\Local\Temp\go-build866497007
        runtime-gdb_test.go:248: -nx -batch -ex set startup-with-shell off -ex break main.eee -ex run -ex backtrace -ex continue C:\Users\me\AppData\Local\Temp\go-build866497007\a.exe
        runtime-gdb_test.go:250: No symbol "startup" in current context.
                ../../src/gdb/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.
                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/>.

                ../../src/gdb/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.
                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.

        runtime-gdb_test.go:265: could not find '#0.*main\.eee' in backtrace
        runtime-gdb_test.go:266: gdb output:
                No symbol "startup" in current context.
                ../../src/gdb/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.
                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/>.

                ../../src/gdb/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.
                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
exit status 1
FAIL    runtime 0.456s
StephanTLavavej commented 8 years ago

I provide my build scripts for gdb, so you should be able to follow those instructions and avoid stripping debug symbols. Unfortunately, I don't have additional time to contribute to investigating this issue (I build and package gdb only so people won't complain about its absence - I don't use it myself).

StephanTLavavej commented 7 years ago

I'm mildly curious as to whether gdb 7.12 in distro 14.1 fixed this.

timou commented 7 years ago

No, actually. They have even got a new one, sadly, though it appears same root cause. This was using 14.1 and testing against golang master (b63ca1e at the time I tested).

--- FAIL: TestGdbBacktrace (1.76s)
        runtime-gdb_test.go:54: gdb version 7.12
        runtime-gdb_test.go:281: could not find '#0.*main\.eee' in backtrace
        runtime-gdb_test.go:282: gdb output:
                No symbol "startup" in current context.
                ../../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.
                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/>.

                ../../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.
                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: TestGdbAutotmpTypes (1.76s)
        runtime-gdb_test.go:54: gdb version 7.12
        runtime-gdb_test.go:354: could not find struct []main.astruct; in 'info typrs astruct' output
        runtime-gdb_test.go:355: gdb output:
                No symbol "startup" in current context.
                ../../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.
                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/>.

                ../../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.
                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.
timou commented 5 years ago

@StephanTLavavej, just to finally put this to rest, it appears to be fixed in GDB 8.2.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4735f0edf4265e3e260e10a12921baf17987a020

https://github.com/golang/go/issues/21380

C:\Code\go\src\runtime>go test -test.v -test.run=.*TestGdbBacktrace
=== RUN   TestGdbBacktrace
=== PAUSE TestGdbBacktrace
=== CONT  TestGdbBacktrace
--- PASS: TestGdbBacktrace (0.81s)
    runtime-gdb_test.go:66: gdb version 8.2
PASS
ok      runtime 0.880s

C:\Code\go\src\runtime>gdb -version
GNU gdb (GDB) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
StephanTLavavej commented 5 years ago

Thanks for the update.