-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Container.Remove() race causes crash #2826
Comments
Sometime panic: runtime error: invalid memory address or nil pointer dereference if the Container.Objects was too big |
I’ve tried looking at this but I don’t understand why it is behaving the way it is. Something is strange with the container remove code. This is probably related to #2775. We should obviously track down the cause of this issue, but I would just like to clarify something for future readers. For removing everything at once, the method used above is terribly inefficient. I’d suggest the use of one of the methods mentioned in https://yourbasic.org/golang/clear-slice/ instead. Using that on the container |
maybe iterate |
We should probably keep this open until the underlying issues have been fixed. |
I am not a native english speaker, but this is my explanation https://go.dev/play/p/Kv1G_WSsgWE |
It is much easier to set |
I'm not a english speaker, please forgive my english. Yesterday i found this bug too. Now i find bug reason.
copy(c.Objects[i:], c.Objects[i+1:])
c.Objects[len(c.Objects)-1] = nil // latest object set to nil
c.Objects = c.Objects[:len(c.Objects)-1] I rewrite copy(c.Objects[i:], c.Objects[i+1:])
// set temp array remove object
objs := make([]CanvasObject, len(c.Objects))
for j, o := range c.Objects {
objs[j] = o
}
objs[len(objs)-1] = nil
objs = objs[:len(objs)-1]
c.Objects = objs |
Ready on |
Describe the bug:
To Reproduce:
Steps to reproduce the behaviour:
Populate Cards
to populate dummy cardsRemove All Cards(bug)
to reproduce the bugRemove All Cards(temporary solution)
Example code:
https://go.dev/play/p/7wYM2bYBSaP
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: