-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib-dynlink-private/test.ml failing on the debug runtime #11016
Comments
Thanks for the detective work. This happens in native-code, not in bytecode, right? We don't fully control what I wonder whether the assertion in Symmetrically, I wonder whether we can break the GC invariants here. On the second initialization, we're overwriting values computed during the first initialization, but not going through |
It's indeed a native code issue, not bytecode. I'm also investigating similar failures (still in the debug runtime) with the tail modulo cons test directory. It appears that the same assert triggers (on I have a rough understanding of TRMC, but looking at #9760, quoting:
I assume this assertion may be a bit too strict in regards to TRMC as well? |
I guess you are correct. I didn't know of this assertion! |
Val_unit should work fine, if I read the assertion correctly. The problem with dynlink is that we initialize a location multiple times. |
Indeed, but we used another value than Val_unit to make debugging easier, which also seems to be the purpose of |
We could also relax the assertion in |
Wouldn't this be a problem with OCaml 4 as well, which issues a plain write for initialisation and not |
That's very likely. I'm trying to come up with an example (of double dynlinking) that would crash the GC, but I'll probably need @damiendoligez 's help to construct it. |
I've been trying for a few days to come up with an example to crash it (at least on 5.0), it is quite tricky to exercise. |
As per #11527, double dynlinking can crash the GC on OCaml 4 during compaction, because the dynamic global roots list will contain duplicate entries. I think this is especially likely with Flambda which registers a lot of GC roots per compilation unit. The compactor can't cope with duplicate roots because it will traverse its own encoded pointers without realising they are such. |
Hello,
I am currently investigating the testsuite and I found this case.
The culprit is
lib-dynlink-private/test.ml
.To reproduce:
OCAMLRUNPARAM=v=0 OCAML_CFLAGS=-g USE_RUNTIME=d make one TEST=tests/lib-dynlink-private/test.ml
Reason for the failure: assertion triggered at
memory.c:214
: https://github.com/ocaml/ocaml/blob/trunk/runtime/memory.c#L214After debugging for a little while, I found that this happens during the
test_cow_repeated
segment of the testcaseAssert is tripped when the second run of
test_cow_repeated
happens.Breakdown:
test_cow_repeated
, during entry,caml_initialize
setsc
to42
. (current value,1
likeVal_unit
) (https://github.com/ocaml/ocaml/blob/trunk/testsuite/tests/lib-dynlink-private/plugin2/cow.ml#L3)test_cow_repeated
,c
is set to42
, except it share the same address at the previousc
. Meaning that the address storingc
is changed from42
to42
.On the second run
caml_initialize
then fails the assert check, becausec
is not a minor valueVal_unit
nor any uninitialized debug canary. (Debug_uninit_major
orDebug_uninit_minor
)test_cow_repeated
call. (so,42
, which trigger the assert amemory.c:214
)I am not extremely well versed into
dynlink
's deeper intricacies, so I ended up opening this issue with the following question:Is this behavior normal (is it expected for
c
to end up at the same addresse, with an already initialized state from a previous call toDynlink
), or should the assertion be relaxed to account for what could be a specific trait of dynlink?Thank you,
The text was updated successfully, but these errors were encountered: