-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/cgo: go 1.3 panics on recursive use of typedef #8368
Labels
Milestone
Comments
FYI ran into this one too. The following appears to have fixed it for me, though I'm unsure if it's correct: diff -r 9562b65a3c51 src/cmd/cgo/gcc.go --- a/src/cmd/cgo/gcc.go Wed Jul 16 20:48:57 2014 +1000 +++ b/src/cmd/cgo/gcc.go Wed Jul 16 14:45:19 2014 +0200 @@ -1285,7 +1285,14 @@ if isStructUnionClass(sub.Go) { // Use the typedef name for C code. - typedef[sub.Go.(*ast.Ident).Name].C = t.C + n := sub.Go.(*ast.Ident).Name + if tmp := typedef[n]; tmp == nil { + tt := *t + tt.Go = sub.Go + typedef[n] = &tt + + } + typedef[n].C = t.C } // If we've seen this typedef before, and it |
Also, this issue might be a dup of 8238. FWIW $ clang --version Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix $ uname -a Darwin thunder 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 |
Hi quarnster, Thanks for your patch. Could you please follow the contribution process defined here, http://golang.org/doc/contribute.html. Cheers Dave |
The issue here is similar to issue #8441: the dwarf.TypedefType case code expects when its recursive call to c.Type(dt.Type, pos) finishes that dt.Type has been fully translated already, but that's not the case if a structure type recursively refers to a typedef that refers to itself again. The patch from #2 stops the crash (but so would simply skipping the assignment if typedef[n] is nil), but I don't think it's otherwise correct. In particular, the "typedef[name.Name] = &tt" assignment from the dwarf.StructType case would clobber it. |
CL https://golang.org/cl/122850043 mentions this issue. |
This issue was closed by revision 0da4b2d. Status changed to Fixed. |
Issue #8238 has been merged into this issue. |
Issue #8238 has been merged into this issue. |
adg
added a commit
that referenced
this issue
May 11, 2015
««« CL 122850043 / 0015a2541545 cmd/cgo: fix recursive type mapping Instead of immediately completing pointer type mappings, add them to a queue to allow them to be completed later. This fixes issues caused by Type() returning arbitrary in-progress type mappings. Fixes #8368. Fixes #8441. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/122850043 »»» TBR=rsc R=rsc CC=golang-codereviews https://golang.org/cl/128940043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Instead of immediately completing pointer type mappings, add them to a queue to allow them to be completed later. This fixes issues caused by Type() returning arbitrary in-progress type mappings. Fixes golang#8368. Fixes golang#8441. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/122850043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Instead of immediately completing pointer type mappings, add them to a queue to allow them to be completed later. This fixes issues caused by Type() returning arbitrary in-progress type mappings. Fixes golang#8368. Fixes golang#8441. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/122850043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by Jonathan.Plona:
Attachments:
The text was updated successfully, but these errors were encountered: