致命错误:调试器不支持通道锁定



我正试图在我的项目中使用ocamldebug,以了解为什么我使用的第三方库没有按照我预期的方式运行。

https://ocaml.org/manual/debugger.html

OCaml调试器是通过运行程序ocamldebug来调用的,该程序将字节码可执行文件的名称作为第一个参数

我已将(modes byte exe)添加到我的dune文件中。

当我运行dune build时,我可以看到字节码文件输出,以及exe,作为_build/default/bin/cli.bc

当我将其传递给ocamldebug时,我会得到以下错误:

ocamldebug _build/default/bin/cli.bc
OCaml Debugger version 4.12.0
(ocd) r
Loading program... done.
Fatal error: debugger does not support channel locks
Lost connection with process 33035 (active process)
between time 170000 and time 180000
Restart from time 170000 and try to get closer of the problem ? (y or n)

如果我选择y,控制台似乎会无限期地挂起。

我在这里找到了错误的来源:
https://github.com/ocaml/ocaml/blob/f68acd1a618ac54790a8347fad466084f15a9a9e/runtime/debugger.c#L144

/* The code in this file does not bracket channel I/O operations with
Lock and Unlock, so fail if those are not no-ops. */
if (caml_channel_mutex_lock != NULL ||
caml_channel_mutex_unlock != NULL ||
caml_channel_mutex_unlock_exn != NULL)
caml_fatal_error("debugger does not support channel locks");

但我不知道是什么触发了它。

我的项目使用cmdlinerlwt。。。不过,我认为在执行的早期,它还没有命中任何lwt代码。

ocamldebugcmdliner不兼容吗?

如果是这样的话,那么我想我需要创建一个新的入口点来进行调试。(目前bin/cli是我项目中唯一可执行的工件,我需要调试的代码都在lib/s下(

您的macOS版本的OCaml调试器似乎已损坏。请向OCaml问题跟踪器报告问题,包括您系统的详细信息。我无法在我的机器上复制它,但我使用的是一个相当旧的macOS版本(10.11.6(,我有一个完美工作的4.12调试器。

作为一种变通方法,请尝试使用旧版本的OCaml,因为此通道锁定测试是最近推出的,您可以安装4.12之前的任何版本,

opam switch create 4.11.0 
eval $(opam env)

然后,不要忘记重建您的项目(之前安装所需的依赖项(,

opam install lwt cmdliner
dune build

然后您可以根据自己的喜好使用调试器。

最新更新