Make sure closures which are statically allocated by the compiler use black infix headers.#9735
Make sure closures which are statically allocated by the compiler use black infix headers.#9735jhjourdan wants to merge 1 commit intoocaml:trunkfrom
Conversation
… black infix headers. Indeed, we now rely on this in the no-naked-pointers mode, for example in weak.c.
|
Cc @xavierleroy. |
|
Concerning the What do you think is the best to do? |
|
As @damiendoligez mentioned in #9698, we will need to also adapt the ancient library. An alternative solution would be to special-case the infix header in all the places of the runtime where we rely on the fact that out-of-heap headers are black. @xavierleroy: apart from the code in |
|
It's up to @damiendoligez to decide whether the compactor can tolerate white infix headers in out-of-heap closures. Personally I'm reminded of Postel's robustness principle: it is more consistent and less surprising to color infix headers like we color closure headers: black for statically-allocated closures, white for dynamically-allocated closures. |
Not off the top of my head. Generic primitives (comparison, etc) do not check colors. |
|
I must have missed something in #9698. Where is the color of an infix header inspected? That seems like it is always a bug. |
|
In ephemeron_again:
if (child != caml_ephe_none
&& Is_block (child) && Is_in_value_area (child)){
/* ... */
if (Is_white_val (child) && !Is_young (child)){
/* ... */
}
}Where |
|
And indeed, you are right, this is a bug. |
|
That looks very much like it is a bug, probably a variant of #7810. The |
|
Ok, let me try to propose a fix for this. |
Well spotted! Coming back to the present PR: what is the conclusion concerning infix headers in statically-allocated closures? Black or white? |
My position is that infix headers do not in fact have a color, much like blocks on the minor heap. For consistency, the GC color bits should have a consistent value, and all-bits-zero is the obvious choice, matching what the native compiler and bytecode interpreter currently do. (I think that all translates to a vote for "white", since |
Indeed, we now rely on this in the no-naked-pointers mode, for example in weak.c since #9698. The compactor will also rely on this if #9728 gets merged.
I hope there are no other places where infix headers are created outside of the heap.