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 issue 8368.
Fixes issue 8441.
While playing around with fixes for issue 5253, I noticed a crash in "go tool ...
10 years, 9 months ago
(2014-08-05 19:47:23 UTC)
#2
While playing around with fixes for issue 5253, I noticed a crash in "go tool
cgo -godefs" caused by godefsFields() expecting pointer types to be completed.
I've fixed this in patch set 8 by deferring the godefsFields() calls until after
all pointer types are completed, but I'm not sure how to write a test case for
this since there don't seem to be any existing tests using "cgo -godefs"; the
closest is misc/cgo/testcdefs, which only tests -cdefs.
I've also double checked gcc.go for other code that might expect StarExpr.X to
be resolved, and didn't see anything.
That said, the type rewriting in godefsFields seems somewhat arbitrary; it just
rewrites "unsafe.Pointer" to "*byte" and "*unsafe.Pointer" to "**byte". An even
easier fix would be to remove that type mangling in godefsFields, though I'm not
familiar enough with -godefs/-cdefs to know if there would be other adverse
consequences to that change.
On 2014/08/05 19:47:23, mdempsky wrote: > While playing around with fixes for issue 5253, I ...
10 years, 9 months ago
(2014-08-05 20:52:03 UTC)
#3
On 2014/08/05 19:47:23, mdempsky wrote:
> While playing around with fixes for issue 5253, I noticed a crash in "go tool
> cgo -godefs" caused by godefsFields() expecting pointer types to be completed.
> I've fixed this in patch set 8 by deferring the godefsFields() calls until
after
> all pointer types are completed, but I'm not sure how to write a test case for
> this since there don't seem to be any existing tests using "cgo -godefs"; the
> closest is misc/cgo/testcdefs, which only tests -cdefs.
I have a test for -godefs over in http://codereview.appspot.com/106260044 . I
just noticed that Mikioh gave me a LGTM, I should probably submit that.
https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go File src/cmd/cgo/gcc.go (right): https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go#newcode555 src/cmd/cgo/gcc.go:555: conv.Finish(pos) The name Finish implies that the method will ...
10 years, 9 months ago
(2014-08-06 00:25:47 UTC)
#4
https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go File src/cmd/cgo/gcc.go (right): https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go#newcode555 src/cmd/cgo/gcc.go:555: conv.Finish(pos) On 2014/08/06 00:25:47, iant wrote: > The name ...
10 years, 9 months ago
(2014-08-06 00:42:41 UTC)
#5
https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go
File src/cmd/cgo/gcc.go (right):
https://codereview.appspot.com/122850043/diff/140001/src/cmd/cgo/gcc.go#newco...
src/cmd/cgo/gcc.go:555: conv.Finish(pos)
On 2014/08/06 00:25:47, iant wrote:
> The name Finish implies that the method will be called once after all type
> conversions have been seen. But the code calls it once per type name. A
better
> name might be FinishType or something along those lines.
Done. I was thinking Flush or FlushTypes might be appropriate too, but went
with FinishType per your suggestion. Happy to rename it again if you like
either of those names though.
*** Submitted as https://code.google.com/p/go/source/detail?r=0015a2541545 *** cmd/cgo: fix recursive type mapping Instead of immediately completing pointer ...
10 years, 9 months ago
(2014-08-06 01:17:04 UTC)
#7
*** Submitted as https://code.google.com/p/go/source/detail?r=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 issue 8368.
Fixes issue 8441.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/122850043
Committer: Ian Lance Taylor <iant@golang.org>
Issue 122850043: code review 122850043: cmd/cgo: fix recursive type mapping
(Closed)
Created 10 years, 9 months ago by mdempsky
Modified 10 years, 9 months ago
Reviewers: gobot, dave_cheney.net
Base URL:
Comments: 2