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
Fatal error: debugger does not support channel locks #10517
Comments
I believe the message |
Does your project use |
@dra27 I think so, yes... indirectly via https://github.com/mirage/irmin/ |
We should have a better error message! But, yes, ocamldebug doesn't work with multithreaded programs. |
ok thanks, good to know looks like I need to temporarily vendor |
If you are certain (and I mean really, really certain) that no threads are ever created, for debugging purposes only, you could recompile ocaml/otherlibs/systhreads/thread.ml Line 69 in f203a5d
commented out or, possibly less unsafely, these 3 lines commented out: ocaml/otherlibs/systhreads/st_stubs.c Lines 469 to 471 in f203a5d
commented out. But you must be absolutely certain that no threads will be created. |
seems pretty clear that |
It would be nice if we could start ocamldebug on a program that was linked with the threads library and fail only when the first thread is actually created. |
Out of curiosity, is this situation going to get better or worse with multi-core OCaml? |
…t threads ocamldebug has never worked with multithreaded programs: multiple threads mess up the communication protocol with the debugger, and the fork()-based checkpointing mechanism breaks too. Up to 4.11, the debugger would work fine until the first thread was created. Then, bizarre errors would be reported. In 4.12 (commit e678885), a check was added, causing any program linked with the threads library to report a fatal error at start-up time when run under the debugger. As reported in ocaml#10517, this check is too strong: some programs just happen to be linked with the threads library, e.g. because they use LWT, but may never start a thread. There's no reason to refuse to debug these programs. This commit reverts the 4.12 change and adds a check in Thread.create that aborts the program if it is run under the debugger. This way, programs linked with the threads library can still be debugged until the point where they create new threads.
See #10594 |
As far as I know, no better and no worse, i.e. the debugger should remain compatible with single-domain, single-thread programs only. |
…t threads ocamldebug has never worked with multithreaded programs: multiple threads mess up the communication protocol with the debugger, and the fork()-based checkpointing mechanism breaks too. Up to 4.11, the debugger would work fine until the first thread was created. Then, bizarre errors would be reported. In 4.12 (commit e678885), a check was added, causing any program linked with the threads library to report a fatal error at start-up time when run under the debugger. As reported in #10517, this check is too strong: some programs just happen to be linked with the threads library, e.g. because they use LWT, but may never start a thread. There's no reason to refuse to debug these programs. This commit reverts the 4.12 change and adds a check in Thread.create that aborts the program if it is run under the debugger. This way, programs linked with the threads library can still be debugged until the point where they create new threads.
…10594) ocamldebug has never worked with multithreaded programs: multiple threads mess up the communication protocol with the debugger, and the fork()-based checkpointing mechanism breaks too. Up to 4.11, the debugger would work fine until the first thread was created. Then, bizarre errors would be reported. In 4.12 (commit e678885), a check was added, causing any program linked with the threads library to report a fatal error at start-up time when run under the debugger. As reported in #10517, this check is too strong: some programs just happen to be linked with the threads library, e.g. because they use LWT, but may never start a thread. There's no reason to refuse to debug these programs. This commit reverts the 4.12 change and adds a check in Thread.create that aborts the program if it is run under the debugger. This way, programs linked with the threads library can still be debugged until the point where they create new threads.
#10594 is merged and adds a clearer error message + the ability to debug the program until it calls |
I'm using OCaml 4.12. My program does have some uses of Thread.create/join, and Mutex.lock/unlock. When running my program using ocamldebug on Linux, it fails very quickly with However, running the same program on Windows/Cygwin does not exhibit this error and ocamldebug goes much further, until it eventually dies with Is there a reason for this difference in behavior? Thanks in advance! |
The Windows/Cygwin behavior you describe is consistent with OCaml 4.11 or earlier. The "debugger does not support channel lock" error was introduced in 4.12 but should show up with Cygwin as well as with other systems. The soon-to-be-released OCaml 4.14.0 should restore a 4.11-like behavior, namely: you can debug up to the point where the program creates its first thread. |
I originally posted this on Stackoverflow, thinking it a problem with my code or some library incompatibility.
https://stackoverflow.com/questions/68394075/fatal-error-debugger-does-not-support-channel-locks
I had a reply there suggesting it was likely an issue with
ocamldebug
and macos and I should report it here, so I'll reproduce details below.Firstly I am on macOS Catalina (10.15.7) on an Intel cpu.
I initially set up my project by:
I have added
(modes byte exe)
to mydune
file.When I run
dune build
I can see the bytecode file output, alongside the exe, as_build/default/bin/cli.bc
When I pass this to
ocamldebug
I get the following error:If I choose
y
the console seems to hang indefinitely.I found the source of the error here:
ocaml/runtime/debugger.c
Line 144 in f68acd1
...but I don't know what might be triggering it.
My project is using
cmdliner
andlwt
...I thought "channel I/O operations" might have something to do with either of those libraries.But the replier on SO seemed to think it was more likely an OS-level issue with my install of
ocamldebug
itself.The text was updated successfully, but these errors were encountered: