Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Ensure that a device mapper task is referenced until task is complete #33376
DeviceMapper tasks in go use SetFinalizer to clean up C construct
The garbage collector decides that, if a function calls into a
The fix is to use the KeepAlive interface:
The KeepAlive method is effectively an empy reference that fools the
Signed-off-by: Neil Horman firstname.lastname@example.org
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
sorry, forgot to fill out the rest of the information. This pull is based of code review that I preformed while fixing issue #33050. I noticed that the use of SetFinalizer was in voliation of the early reclamation examples provided by the runtime documentation for golang, and the addition of the use of KeepAlive just made sense, as it fit exactly with the provided examples.
@cpuguy83 thanks for the pointer. So this is new to 1.8.
I am surprised that how can newer versions can break existing programs. If this is an optimization, then there should be an option to opt-in.
Now all the programs which have been running fine with older versions, have potential to be broken?
Actually reading https://forum.golangbridge.org/t/curious-about-runtime-keepalive-usage/3530 is a little scary.