Hey, when I'm trying to debug golang program on Windows using git bash console I'm getting assertion failed. Below console output: ~/Documents/tmp $ go build -gcflags "-N -l" hello.go ~/Documents/tmp $ gdb hello.exe GNU gdb (GDB) 7.9.1 Copyright (C) 2015 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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from hello.exe...done. (gdb) list ../../../../src/gdb-7.9.1/gdb/buildsym.c:1759: 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) n This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. ../../../../src/gdb-7.9.1/gdb/buildsym.c:1759: 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) y Command aborted. (gdb)
I face the same issue.
GNU gdb (GDB) 7.10.1 Copyright (C) 2015 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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". ../../../../src/gdb-7.10.1/gdb/buildsym.c:1759: 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] ../../../../src/gdb-7.10.1/gdb/buildsym.c:1759: 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 is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\bin\gdborig.exe'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\lpk.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\usp10.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\bin\libpython2.7.dll'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\Windows\System32\psapi.dll'. Cannot find or open the PDB file. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\lib\python2.7\lib-dynload\_codecs_cn.pyd'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\lib\python2.7\lib-dynload\_multibytecodec.pyd'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\lib\python2.7\lib-dynload\itertools.pyd'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\lib\python2.7\lib-dynload\_collections.pyd'. Module was built without symbols. 'gdborig.exe' (Win32): Loaded 'C:\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\opt\lib\python2.7\lib-dynload\_heapq.pyd'. Module was built without symbols. The thread 0xda4 has exited with code 0 (0x0). The thread 0x1d6c has exited with code 3 (0x3). The thread 0x5d48 has exited with code 3 (0x3). The program '[8468] gdborig.exe' has exited with code 3 (0x3).
I have the same problem in goclipse: GNU gdb (GDB) 7.12 Copyright (C) 2016 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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Loading Go Runtime support. ../../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? This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. (y or n) [answered Y; input not from terminal]
Actually, not a bug - just missing a command line argument (at least for me). The missing argument is "-d $GOROOT" (I am actually debugging Go).
(In reply to Paul C Brown from comment #5) > Actually, not a bug - just missing a command line argument (at least for > me). The missing argument is "-d $GOROOT" (I am actually debugging Go). what argument is it?
I hit the same problem in eclipse(neno3) and goclipse on windows(7) with gdb version 8.0.1, but if I just used the command line in gdb, it works fine. command line in gdb, successful scenario: D:\GoWork\src>go build -gcflags "-N -l" HelloWorld/src/main/main.go D:\GoWork\src>gdb main.exe GNU gdb (GDB) 8.0.1 Copyright (C) 2017 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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from main.exe...done. Loading Go Runtime support. eclipse + go , failed scenario: GNU gdb (GDB) 8.0.1 Copyright (C) 2017 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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Loading Go Runtime support. ../../../../src/gdb-8.0.1/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/>. This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. ../../../../src/gdb-8.0.1/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] main.go: package main import "fmt" func main() { fmt.Println("Hello, World!") } Anyone has any suggestions/solutions? Thanks a lot.
Is this still a problem with newer versions of gdb?
Yes, this still happens with gdb 8.1 that I got from https://nuwen.net/mingw.html (https://nuwen.net/files/mingw/mingw-15.4-without-git.exe to be specific). A simple repro: > cat .\main.go package main import "fmt" func f() { fmt.Printf("Hello from f()\n") } func main() { fmt.Printf("Hello from main\n") f() } > go build main.go -o main.exe > gdb --args .\main.exe GNU gdb (GDB) 8.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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from .\main.exe...done. warning: Unsupported auto-load script at offset 0 in section .debug_gdb_scripts of file C:\Users\kjk\go\src\github.com\kjk\tst\main.exe. Use `info auto-load python-scripts [REGEXP]' to list them. (gdb) br main.f ../../src/gdb/buildsym.c:1764: 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) y Note: I believe this should repro on non-windows as well if gdb is compiled with gdb_assert() enabled. My theory is that it only happens on Windows because on Windows people compile it with gdb_assert() enabled and on non-windows with gdb_assert() disabled. Info about gdb: > gdb --version GNU gdb (GDB) 8.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. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". (gdb) show configuration This GDB was configured as follows: configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-auto-load-dir=$debugdir:$datadir/auto-load --with-auto-load-safe-path=$debugdir:$datadir/auto-load --without-expat --with-gdb-datadir=/c/temp/gcc/dest/share/gdb (relocatable) --with-jit-reader-dir=/c/temp/gcc/dest/lib/gdb (relocatable) --without-libunwind-ia64 --without-lzma --without-guile --with-separate-debug-dir=/c/temp/gcc/dest/lib/debug (relocatable) --without-babeltrace
> ../../src/gdb/buildsym.c:1764: internal-error: void buildsym_init(): Assertion `free_pendings == NULL' failed. > My theory is that it only happens on Windows because on Windows people compile it with gdb_assert() enabled and on non-windows with gdb_assert() disabled. buildsym is used by the symbol readers, so if free_pendings is not null, then it means some symbol reader didn't clean up properly. So, it may not be easily reproducible on other hosts, because they may not be using the same object format. I wonder if you could attach your main.exe file? That might make it simpler to figure out what is wrong.
Created attachment 11109 [details] Go binary generated with go 1.10 on win10 Shows a crash on windows with gdb. build from main.go: package main import "fmt" func f() { fmt.Printf("Hello from f()\n") } func main() { fmt.Printf("Hello from main\n") f() } with: > go build > go version go version go1.10.3 windows/amd64
File attached. My understanding is that Go uses the same symbol format (DWARF) on all platforms, including Windows. The difference might be PE vs. Mach vs. Elf.
Also there is corresponding bug filed for Go at https://github.com/golang/go/issues/21380 The issue might be that Go generates subtly invalid DWARF info in which case Go should fix it as well.
Thanks. Patch is here: https://sourceware.org/ml/gdb-patches/2018-06/msg00736.html I don't know what went wrong here but I guess COFF+DWARF isn't used and/or maintained much.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4735f0edf4265e3e260e10a12921baf17987a020 commit 4735f0edf4265e3e260e10a12921baf17987a020 Author: Tom Tromey <tom@tromey.com> Date: Fri Jun 29 15:10:04 2018 -0600 Use scoped_free_pendings in coff_symtab_read PR gdb/18624 concerns an assertion failure that occurs when setting a breakpoint in a Go program on Windows. What happens here is that coff_symtab_read uses buildsym but does not instantiate scoped_free_pendings. So, the struct pending objects are never released. Later, dwarf2read.c calls buildsym_init, which asserts. This patch fixes the problem by instantiating scoped_free_pendings in coff_symtab_read. Tested using the test executable from the PR. I don't know how to test this more fully. gdb/ChangeLog 2018-07-17 Tom Tromey <tom@tromey.com> PR gdb/18624: * coffread.c (coff_symtab_read): Use scoped_free_pendings.
Fixed.
The gdb-8.2-branch branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=79b38778d788e01e66e82f16bf3d4957439c77d5 commit 79b38778d788e01e66e82f16bf3d4957439c77d5 Author: Tom Tromey <tom@tromey.com> Date: Fri Jun 29 15:10:04 2018 -0600 Use scoped_free_pendings in coff_symtab_read PR gdb/18624 concerns an assertion failure that occurs when setting a breakpoint in a Go program on Windows. What happens here is that coff_symtab_read uses buildsym but does not instantiate scoped_free_pendings. So, the struct pending objects are never released. Later, dwarf2read.c calls buildsym_init, which asserts. This patch fixes the problem by instantiating scoped_free_pendings in coff_symtab_read. Tested using the test executable from the PR. I don't know how to test this more fully. 2018-07-17 Tom Tromey <tom@tromey.com> PR gdb/18624: * coffread.c (coff_symtab_read): Use scoped_free_pendings.
Hi Tom. IIUC, we can close this PR, right?
Yep, I forgot to click the button.