ocaml icon indicating copy to clipboard operation
ocaml copied to clipboard

Add debugger flags for sanitizer script

Open tmcgilchrist opened this issue 8 months ago • 3 comments

Fix for https://github.com/ocaml/ocaml/issues/14058

We set the -g -O0 flags to enable generating debug information and disable optimised C for the test suite, which is required by the native-debug tests.

I suspect that the -fno-omit-frame-pointer flag is not required here either, the unwinding should be using CFI. But I haven't found a good way to test that.

cc @OlivierNicole

tmcgilchrist avatar Jun 13 '25 11:06 tmcgilchrist

cf. https://ci.inria.fr/ocaml/job/precheck-sanitizers/9

dra27 avatar Jun 13 '25 12:06 dra27

Thanks for trying to fix this!

For now we get a bunch of times the warning:

clang-18: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled: -fsanitize=bool,builtin,bounds,enum,nonnull-attribute,nullability,object-size,pointer-overflow,returns-nonnull-attribute,shift-exponent,unreachable [-Winvalid-command-line-argument]

which makes the tests fail.

Is it necessary to disable optimization?

OlivierNicole avatar Jun 16 '25 08:06 OlivierNicole

There is now a failure in the following tests on the "normal" CI configuration:

    tests/native-debugger/linux-gdb-amd64.ml
    tests/native-debugger/linux-lldb-amd64.ml

The observed diff in the CI result is as follows:

@@ -20,7 +20,7 @@
 frame 6: caml_main
 frame 7: main
 Breakpoint 3, ocaml_to_c (unit=1) at meander_c.c:XX
-5	    caml_callback(*caml_named_value
+4	value ocaml_to_c (value unit) {
 frame 0: ocaml_to_c
 frame 1: caml_c_call
 frame 2: camlMeander$omain

)

gasche avatar Jun 18 '25 19:06 gasche

Update on the original comment.

I have tried to make the sanitizer script agree with the native-debugger tests but have not managed to get both working with the same set of flags. The santizer tests require at least -Og to work, while native-debugger tests produce better results (accurate backtraces and source locations) with -O0 -g. Additionally the debug tests are not going to benefit from running with a sanitizer, they're primarily testing basic CFI. So I have added those linux debugger tests to OCAMLTEST_SKIP_TESTS which prevents them running with the inria sanitizer script.

https://ci.inria.fr/ocaml/job/precheck-sanitizers/11/consoleFull Which now shows two legitimate failures, neither of which I've looked into:

List of failed tests:
    tests/tsan/exn_in_callback.ml
    tests/weak-ephe-final/weak_array_par.ml

Since this is just a CI script change it doesn't require a change log entry.

tmcgilchrist avatar Jun 19 '25 14:06 tmcgilchrist

Thanks for looking into it!

Which now shows two legitimate failures, neither of which I've looked into:

I think the first one is fixed by #14059 and the second one is #14061.

OlivierNicole avatar Jun 20 '25 08:06 OlivierNicole