Skip to content

Stabilise the native-debugger tests (take 2!) - #13965

Merged
gasche merged 8 commits into
ocaml:trunkfrom
MisterDA:test-meander-no-optimization
Apr 19, 2025
Merged

gasche merged 8 commits into
ocaml:trunkfrom
MisterDA:test-meander-no-optimization

Conversation

@MisterDA

Copy link
Copy Markdown
Contributor

I'm often hit with what @dra27 described in #13762:

There remains something stranger going on with the gdb test, but this is much less frequent and may actually be a canary for something that is not right (or at least not stable) in the runtime:

giving:

--- a/linux-gdb-amd64.reference
+++ b/linux-gdb-amd64.opt.output
@@ -25,7 +25,7 @@
 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

)

It seems lld gives us a clue:

warning: meander was compiled with optimization - stepping may behave oddly;

I've followed that advice by disabling the C compiler optimizations for this particular stub, with ocamltest flags="-g -ccopt -O0" command (which overrides the default -O2), and I don't experience the bug anymore. Is that an acceptable fix/workaround?

I've first discovered this problem on macOS 15 arm64.

  1. My local version of lldb and GitHub Actions' differed, so I updated the GitHub image (available since 2025-04-10).
  2. I then tested it on Asahi Linux arm64, and discovered that Fedora and Ubuntu (a Debian derivative) have a different naming scheme for the library path, which thus need to be sanitized.
  3. I then discovered that GDB 16 (on Arch Linux) and Fedora's have a slightly different versioning scheme, which need to be sanitized.
  4. I tested this patchset in various systems and architectures using Docker, but debuggers don't work well in Docker, because they try disabling ASLR. They don't have permission for it (lucky us). Forbid them from trying. If this causes problems because of moving addresses, we should sanitize them.
  5. Different LLDB versions would output or not trailing blanks. Sanitize them.
  6. Fix some shellcheck warnings and simplify the shell scripts.

cc @dra27, @gasche (who reviewed #13762), and @tmcgilchrist

@gasche

gasche commented Apr 15, 2025

Copy link
Copy Markdown
Member

I tried looking at your patch and the first part of the diff that shows up is a rename of MacOS into macOS, in comments. I think that this is a waste of time. I like the overall idea of making the debugger tests less irritating, I appreciate it and I hope that someone will review it, but not me.

Fixes warnings and spurious failures in the CI.
Debian and Fedora derivatives have different libpaths:

    -Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
    +Using host libthread_db library "/lib64/libthread_db.so.1".

fixup_libthread
This allows running the tests more easily in Docker images. The
sanitization step takes care of removing artifacts of randomization
anyway.
Don't redeclare variables that ocamltest always provides in scripts.
@MisterDA
MisterDA force-pushed the test-meander-no-optimization branch from bebdab8 to d7e5842 Compare April 15, 2025 20:47
@MisterDA

Copy link
Copy Markdown
Contributor Author

I like the overall idea of making the debugger tests less irritating, I appreciate it and I hope that someone will review it, but not me.

Thank you for looking at it!

I tried looking at your patch and the first part of the diff that shows up is a rename of MacOS into macOS, in comments. I think that this is a waste of time.

Noted.

@dra27 dra27 self-assigned this Apr 16, 2025

@tmcgilchrist tmcgilchrist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the thorough investigation and bug fix. Disabling ALSR and optimisations in the C compiler look correct to me. Also updating to Xcode 16 shouldn't be a problem, I've been using that locally and haven't encountered any issues.

@gasche gasche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on behalf of @tmcgilchrist. Thank you both!

@gasche
gasche merged commit 765fcdb into ocaml:trunk Apr 19, 2025
@MisterDA
MisterDA deleted the test-meander-no-optimization branch April 29, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants