-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: internal compiler error: Type.Elem UNSAFEPTR #31174
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
Comments
git bisect points to ca36af2 |
@randall77 A quick fix seems to check if v Type is unsafe pointer:
If you're ok with it, I will send a CL. |
@Gnouc this looks ok to me. Thanks! |
Change https://golang.org/cl/170159 mentions this issue: |
I'm confused by this as well. I can believe the crash, but the provided code doesn't trigger that crash. We need a standalone reproducer (or any reproducer, really, from which we could extract a standalone one). |
@randall77 https://go-review.googlesource.com/c/go/+/170159/3/test/fixedbugs/issue31174.go @cherrymui found it, the error message is a bit confused. |
Thanks, that example crashes for me. But that example uses linkname to access runtime internals. I'm not inclined to fix the Go toolchain to permit this use. |
Yes. But I think it's worth to make the change, even not for fixing this issue. If not, then the function doc should be updated. |
That's because the compiler has control over all calls to |
Yes, if it only crashes with linkname into the runtime, I'm ok with not fixing it. |
Honestly, I don't think that changing the compiler behavior in such a way that folks can't use basically one of the |
Linkname with unexported symbols is not "basically one of the |
We do this all the time for unexported API. The fact that the function named
If you're using #31121 is about exported API, and that's a totally different ballgame. For that we have the Go 1 compatibility guarantee. I think the relevant clause is
But I agree that it's a grey area, and whether #31121 fits in that category isn't as clear cut as this issue is. |
You asked about a workaround. For now, you should be able to use linkname to call mallocgc. newobject is just a very thin wrapper around mallocgc anyway. But to reiterate what Keith and Cherry said, that may also break with no warning at any point in the future. |
ok, I see. if no one want to fix this bug, let's at least do something with the error message. it points to a far different place in sources and first I was thinking that it really don't like my unsafe.Pointer conversion wrappers for some reason, but turns out that it's really just a runtime.newobject linking bug. |
@kirillDanshin I'm afraid we can't. As we're in SSA step, the lex and parse step were done,
error message will point to start of Is that right? @randall77 @cherrymui |
I don't think that is right. This code (the example from the CL, with your
We'd need a self-contained example demonstrating bad behavior to be able to fix it. |
@randall77 Are you sure? With the code above, it reports line 15 for me, which is
|
Very strange. Using your
So it looks like it depends on whether you use Looks like it is the So yes, it would be nice if an ICE at least reported a line number somewhere in the function that caused the compiler to ICE. (Which may not always be possible, but should generally work.) |
@randall77 It seems not possible with current design. In phase 8, top level functions are compiled: go/src/cmd/compile/internal/gc/main.go Line 660 in ce17481
But with go/src/cmd/compile/internal/gc/pgen.go Line 275 in ce17481
and drain later by: go/src/cmd/compile/internal/gc/main.go Line 677 in ce17481
With more than 4 concurrent compilation, all of them will modify the global lineno variable concurrently, so we won't have the right |
Right. We'd have to plumb the line number to the error reporter some other way, so that it uses the function-currently-being-compiled line number instead of the global one. We're on a slow burn to remove all the global variables in the compiler anyway. This would be one step in that direction as well. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
reproducible only on tip
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have a pretty old package with some hacks for optimization.
I use some of its features in my web framework.
In travis, I check if the framework pass the tests on tip.
One of the steps in travis script is the
go get -v
.When go get tries to precompile that old package, it crashes.
So, one of the files looks like this:
Then I've commented out the last func.
Then the file looks like this:
What did you expect to see?
unsafe.Pointer
works as it work two years agoWhat did you see instead?
The text was updated successfully, but these errors were encountered: