-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix gc hole in runtime/gc_ctrl.c #13370
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
Conversation
91638e7 to
57f8c74
Compare
gasche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good catch, thanks!
I'm not fond of the proposed fixes.
-
I think that changing the manual would need substantially more work. The style is inconsistent with the rest of the manual (you use concepts like "to hole" that are not used anywhere else), and I don't think that adding these as extra gc rules fits the purpose and scope of the rest of this manual section, which generally assumes that all temporaries are properly registered as roots. A minimal fix would be would to add an explicit comment to Rule 2 that temporaries are equivalent to local variables but cannot be declared with
CAMLlocal, so temporaries ofvaluetype must be written to registered locals right away to "live in harmony with the GC". -
The code fix feels too clever and annoyingly asymmetric to me. I would be in favor of sticking to the boring style where we register everything, unless there are good performance reasons to do anything more complex. In this case I don't think there are reasons to do complex (obviously the performance of this code could be improved by returning a record of (unboxed) floats instead of a tuple, but no users expressed such a need so far), so I think you should do really simple and have three locals.
cfb8aaa to
8a269e8
Compare
8a269e8 to
2595012
Compare
gasche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation extension is fine and the new code is correct yet simple. Approved. Thanks!
If the evaluation of one of the arguments to caml_alloc_3 triggers a garbage collection, the other arguments will not be valid anymore.
2595012 to
a9acf5a
Compare
|
@Octachron If you are rolling a 5.2.1 release, consider cherry-picking this bugfix PR too 🙏 |
Also for the 4.x LTS release if that is still supported. |
Fix gc hole in runtime/gc_ctrl.c (cherry picked from commit db586e0)
|
Cherry-picked to 5.2 as 57736d1 @DemiMarie , as far as I can see the 4.14 version does not have this issue, since stores every temporary in |
If the evaluation of one of the arguments to caml_alloc_3 triggers a garbage collection, the other arguments will not be valid anymore.
This rule was not documented in the OCaml manual, so I added an explanation of the problem.