cgo panic in main·*Prog·loadDebugInfo
gopherbot opened this issue · 21 comments
gopherbot commented
by Sean.Stangl:
What steps will reproduce the problem?
1. Run the tests, for example by src/all.bash.
What is the expected output? What do you see instead?
The test does not pass; instead, the following error is reported:
---------------------------
--- cd ../misc/cgo/stdio
rm -rf *.[568vqo] *.a [568vq].out *.cgo[12].go *.cgo[34].c *.so _obj _test
_testmain.go hello fib chain run.out
cgo file.go
could not determine kind of name for C.CString
could not determine kind of name for C.puts
could not determine kind of name for C.fflushstdout
could not determine kind of name for C.free
throw: runtime·mapaccess1: key not in map
panic PC=0x7f2a0f239a08
throw+0x3e /home/sean/dev/go/src/pkg/runtime/runtime.c:74
throw(0x4de2cf, 0x0)
runtime·mapaccess1+0x74 /home/sean/dev/go/src/pkg/runtime/hashmap.c:769
runtime·mapaccess1(0xf1f18c0, 0x7f2a)
main·*Prog·loadDebugInfo+0xa88 /home/sean/dev/go/src/cmd/cgo/gcc.go:164
main·*Prog·loadDebugInfo(0xf261280, 0x7f2a)
main·main+0x352 /home/sean/dev/go/src/cmd/cgo/main.go:66
main·main()
mainstart+0xf /home/sean/dev/go/src/pkg/runtime/amd64/asm.s:55
mainstart()
goexit /home/sean/dev/go/src/pkg/runtime/proc.c:135
goexit()
make: *** [file.cgo1.go] Ошибка 2
---------------------------
What is your $GOOS? $GOARCH?
linux, amd64.
Which revision are you sync'ed to? (hg log -l 1)
3976:cf1b54c30bc1 (Tue Nov 10 20:11:16 2009 -0800)agl commented
gopherbot commented
gopherbot commented
gopherbot commented
gopherbot commented
I don't have the same error but the same test segfaults on me on AMD64: --- cd ../misc/cgo/stdio rm -rf *.[568vqo] *.a [568vq].out *.cgo[12].go *.cgo[34].c *.so _obj _test _testmain.go hello fib chain run.out cgo file.go 6g -o _go_.6 file.cgo1.go file.cgo2.go 6c -FVw -I/redacted/src/pkg/runtime -D_64BIT file.cgo3.c make: *** [file.cgo3.6] Segmentation fault make: *** Deleting file `file.cgo3.6' $ uname -a Linux heta 2.6.20.5_rsp_3.9 #1 SMP Wed Oct 14 16:24:34 EST 2009 x86_64 x86_64 x86_64 GNU/Linux $ gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat /etc/redhat-release CentOS release 5.3 (Final)
rsc commented
gopherbot commented
gopherbot commented
rsc commented
gopherbot commented
@rsc: I've discovered something strange about this bug: it doesn't occur when my $LANG is en_US.UTF-8. The default $LANG on my system is ru_RU.UTF-8. When I run all.bash with this setting, I always get the following output. ---------------- --- cd ../misc/cgo/stdio rm -rf *.[568vqo] *.a [568vq].out *.cgo[12].go *.cgo[34].c *.so _obj _test _testmain.go hello fib chain run.out cgo file.go could not determine kind of name for C.CString could not determine kind of name for C.puts could not determine kind of name for C.fflushstdout could not determine kind of name for C.free failed to interpret gcc output: cc1: warnings being treated as errors cgo-test: В функции ‘f’: (In the function 'f') cgo-test:0: ошибка: оператор без побочного эффекта (operator without side effect) cgo-test:1: ошибка: оператор без побочного эффекта cgo-test:2: ошибка: оператор без побочного эффекта cgo-test:3: ошибка: оператор без побочного эффекта make: *** [file.cgo1.go] Ошибка 2 (Error 2) ---------------- However, when I set $LANG to en_US.UTF-8 and then run all.bash, I get the following (correct) output, and all tests pass: ---------------- --- cd ../misc/cgo/stdio rm -rf *.[568vqo] *.a [568vq].out *.cgo[12].go *.cgo[34].c *.so _obj _test _testmain.go hello fib chain run.out cgo file.go 6g -o _go_.6 file.cgo1.go file.cgo2.go 6c -FVw -I/home/sean/dev/go/src/pkg/runtime -D_64BIT file.cgo3.c rm -f _obj/stdio.a gopack grc _obj/stdio.a _go_.6 file.cgo3.6 cp _obj/stdio.a /home/sean/dev/go/pkg/linux_amd64/stdio.a gcc -m64 -fPIC -O2 -o file.cgo4.o -c file.cgo4.c gcc -m64 -shared -lpthread -lm -o stdio_file.so file.cgo4.o cp stdio_file.so /home/sean/dev/go/pkg/linux_amd64/./stdio_file.so 6g hello.go 6l -o hello hello.6 6g fib.go 6l -o fib fib.6 6g chain.go 6l -o chain chain.6 rm stdio_file.so file.cgo4.o rm -rf *.[568vqo] *.a [568vq].out *.cgo[12].go *.cgo[34].c *.so _obj _test _testmain.go hello fib chain run.out ---------------- I have changed between the languages many times -- en_US.UTF-8 always succeeds, while ru_RU.UTF-8 always fails. Hopefully this bit of information should help.
gopherbot commented
gopherbot commented
gopherbot commented
Comment 14 by nicolas.b.pierron:
This issue is caused by the translation of error messages of GCC. "cgo" use "gcc" to investigate types of each C symbols by creating a dummy function inside which each symbol is put on his own line. The problem encounter here is that translated error messages do not match the registered error messages. A possible work around would be to set LC_ALL=C before calling "cgo". This could be done in a small shell script. #!/bin/sh LC_ALL=C /path/to/.cgo "@" I am currently looking into fixing this inside src/pkg/cmd/*.go files. I'll add attach a diff on this issue if I succeed to make it work without the script shell hack.
gopherbot commented
Comment 15 by nicolas.b.pierron:
Here is a small patch which fix this issue.
Attachments:
- cgo-set-local-to-match-gcc-error-messages.patch (405 bytes)
rsc commented
rsc commented