Skip to content
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

cgo panic in main·*Prog·loadDebugInfo #21

Closed
gopherbot opened this issue Nov 11, 2009 · 21 comments
Closed

cgo panic in main·*Prog·loadDebugInfo #21

gopherbot opened this issue Nov 11, 2009 · 21 comments

Comments

@gopherbot
Copy link
Contributor

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
Copy link
Contributor

agl commented Nov 11, 2009

Comment 1:

What version of GCC? What distro?
If cgo is generating a .o file, could you attach that too?

@gopherbot
Copy link
Contributor Author

Comment 2 by roblesjm:

I have the same error. I'm using Ubuntu 9.04 (Jaunty).

@gopherbot
Copy link
Contributor Author

Comment 3 by roblesjm:

I forgot to specify my architecture, GOARCH=386.

@gopherbot
Copy link
Contributor Author

Comment 4 by ejdiezfraile:

I have the same error in Ubuntu 8.04 (hardy) hosted in VirtualBox on Windows XP

@gopherbot
Copy link
Contributor Author

Comment 5 by julians37:

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
Copy link
Contributor

rsc commented Nov 11, 2009

Comment 6:

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Nov 11, 2009

Comment 7:

Issue #43 has been merged into this issue.

@gopherbot
Copy link
Contributor Author

Comment 8 by Sean.Stangl:

@1: The GCC version is "gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)"; the distro is
Fedora 11.

@gopherbot
Copy link
Contributor Author

Comment 9 by Sean.Stangl:

@1: Attached generated _cgo_.o.

Attachments:

  1. cgo.o (6600 bytes)

@rsc
Copy link
Contributor

rsc commented Nov 12, 2009

Comment 10:

Sean.Stangl: could you please hg pull -u
and try again?  It won't work but it should 
produce some more useful output when it breaks.
Thanks.

Status changed to WaitingForReply.

@gopherbot
Copy link
Contributor Author

Comment 11 by Sean.Stangl:

@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
Copy link
Contributor Author

Comment 12 by libercv:

Same problem here with es_ES.utf8
It started working as soon as I changed to en_US.utf8
Distro archlinux, gcc version 4.4.2

@gopherbot
Copy link
Contributor Author

Comment 13 by tequilasTeam:

Thanks  Sean.Stangl... problem solve...
Sorry for not writing more, my English is horrible...

@gopherbot
Copy link
Contributor Author

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
Copy link
Contributor Author

Comment 15 by nicolas.b.pierron:

Here is a small patch which fix this issue.

Attachments:

  1. cgo-set-local-to-match-gcc-error-messages.patch (405 bytes)

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 16:

Owner changed to [email protected].

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 17:

Issue #1 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 18:

Thanks for diagnosing this, everyone.

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 19:

Issue #169 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Nov 15, 2009

Comment 20:

This issue was closed by revision 0238fd8.

Status changed to Fixed.

Merged into issue #-.

@rsc
Copy link
Contributor

rsc commented Nov 17, 2009

Comment 21:

Issue #246 has been merged into this issue.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants