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/list: zero List value breaks after reset #39014
Comments
Because the another assign l = list.List{} Never change the address of l, you can print the memory address of l with:
|
Maybe list.List should disable copy with Line 94 in c2eba53
|
@lsytj0413 Yes, I know why it happens, thank you. Anyway, the comment about |
It's Zero Value when you reassign it,but after you called Remove it's length change to -1(removed one element from an empty list). |
Change https://golang.org/cl/233326 mentions this issue: |
/cc @griesemer |
I'm confirming that the code above reproduces. Resetting the list does not change the pointer to the list. The element still has the pointer to the original list. The Remove() function checks if the pointer to the list is the same as the pointer to list in the element. |
Seems like that could also cause memory leaks. |
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?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: