Add a naked pointers dynamic checker#9947
Conversation
|
Thanks for getting the ball rolling. Just to make sure we're on the same page:
I would expect the naked pointers detector to run in a naked-pointer-tolerant run-time system, so that naked pointers won't crash the runtime immediately and can be flagged and reported at the next major GC. And, yes, no-naked-pointers mode is getting less and less tolerant in the working sources. |
The previous code was running inside the no-naked-pointer runtime, it would make sense however to have the checks performed outside indeed, I can change this if this is the right thing to do. |
|
|
||
| #ifdef NAKED_POINTERS_CHECKER | ||
| Caml_state->checking_pointer_pc = NULL; | ||
| #endif |
There was a problem hiding this comment.
Right, it is not, I will guard it for _WIN32 as well, thank you.
There was a problem hiding this comment.
Same for the definition in domain_state.tbl.
Changes
Outdated
| - #9534: Introduce a naked pointers checker mode to the runtime, | ||
| to print information on relevant values when they are | ||
| inspected by the garbage collector. | ||
| (KC Sivaramakrishnan, with contributions by Stephen Dolan and David Allsopp, |
There was a problem hiding this comment.
You should add yourself here @Engil. And to be consistent with the other entries in the file, perhaps do:
Enguerrand Decorne, KC Sivaramakrishnan, Xavier Leroy, Stephen Dolan, David Allsopp, Nicolás Ojeda Bär, review by ...
Xavier contributed the inline assembly and Nicolás kick-started the work on Windows support.
|
While implementing the move of the checker out of the no-naked-pointer mode, I noticed that the example program provided on #9534 does segfault currently on trunk even with the "default" runtime (so with naked pointers on.). Should I fill in a separate issue for this? |
Yes,please. It's entirely possible that the new two-color marking phase is missing a case or two for naked pointers. Should be easy to fix. |
|
@Engil I've made #9951 to fix #9950. When that is approved, you'll need a |
|
#9951 is merged. We do not load the header anymore and hence, |
|
In order to make progress faster, I "forked" this PR at #9956 to get something that seems to work and has a test suite. |
|
Sure, thank you very much for this. This PR can be closed I believe? |
This pull requests is a rebased version of the naked pointer checker, as discussed in #9534, for introduction in the runtime.
It remains mostly the same as the code that was developed in the RFC, with a few adjustments:
--enable-naked-pointers-checker)major_gctrigger at the end of the program (to force a gc and run the checker even on programs that may terminate before having the opportunity to do so) was reworked as well.checking_pointer_pcis now hidden behind anifdefwhen the checker is not built.While the checker operates mostly the same, heavy changes were brought to the GC, so I could observe different behaviors between this branch and the previous implementation.
One particular thing I observed (and I'm unsure about the correct resolution of this issue, if it qualifies as such), is that now, a few test programs now segfaults in the
no-naked-pointersmode, and as such as well in thenaked-pointer-checkermode, where they used not to.Two simple examples are
Caml_grayininvert_pointer_at(https://github.com/ocaml/ocaml/blob/trunk/runtime/compact.c#L80) is not respected, leading to further mayhem.I'm unsure what is the correct course of action with this observation, and would be happy if anyone had an opinion on the matter.
Maybe there should be a specific adjustment in
no-naked-pointermode I am missing, related to this recent change.I can provided further data on these specific points if it helps.
I added a temporary Changes entry, I quoted the names and reviewers that contributed to the RFC at #9534, but since this PR definitely could use more proofreading (with the recent changes to the GC), I did not meant this was reviewed already. :)
Have a nice day,
Enguerrand.