-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
runtime: marked free object in span #44614
Comments
I can reproduce
The data in your zombie object looks like gibberish to me: |
@randall77 User with username |
Checked every password used in tests, |
Some more info Compile with
Run with
Will fairly regularly crash with a bad pointer found in the stack frame of It looks like the slot at Still investigating. |
This is a nasty compiler liveness bug. The bug in the OP's code is in I think a simple workaround would be to use unnamed return values. Use Here's a reproducer.
The problem here is that when we move a return value to the heap, it can still contain pointers into the stack. That's a big no-no, as we won't find any stack objects that those stack pointers point to. |
This bug appears from 1.14 onwards. 1.13 and earlier are unaffected. |
@gopherbot please open backport issues. |
Backport issue(s) opened: #44658 (for 1.15), #44659 (for 1.16). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Thanks a lot! @randall77 |
@randall77 Thanks for minimizing the reproducer. I agree this looks like an escape analysis issue. I think the problem is in location.leakTo, that if a parameter flows to a result parameter that itself needs to be heap allocated, we need to record that as a heap leak rather than a result leak. We probably just need to include |
Thank you so much @randall77 |
Further minimized repro:
It should be simply |
I suspect the culprit CL that caused the regression in Go 1.14 is 2620467. |
Change https://golang.org/cl/297289 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This issue is introduced in this commit, causing CI reports "runtime: marked free object in span" or "fatal error: sweep increased allocation count" randomly. Yes, this commit's GitHub action fails for another reason. But testing it locally will report a runtime error.
Testing locally with
GODEBUG=cgocheck=2 GOGC=2 go test -gcflags=-d=checkptr ./... -race
will add probilities to this error.Are we using
unsafe
package?Yes, we are. But since go's StringBuilder itself is also using it, and don't use it doesn't help either, I don't think the problem is caused by using of unsafe package.
Adding
GODEBUG=cgocheck=2
and-gcflags=-d=checkptr
(see this commit) doesn't help either.Errors exist under multiple go versions (1.14, 1.15, 1.16) and os (ubuntu, macOS, ubuntu), but adding
GOGC=2
in go 1.16 ubuntu will add probabilities to this error. (on my machine, 100%)What did you expect to see?
No error because we use
unsafe
package the same asstrings.Builder.String()
did, and remove it doesn't help.What did you see instead?
Full error reports can be found at our repo's GitHub Actions
The text was updated successfully, but these errors were encountered: