Skip to content
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

ocamldebug hangs or crashes on printing lazy values with custom printer #7914

Closed
vicuna opened this issue Feb 8, 2019 · 9 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Feb 8, 2019

Original bug ID: 7914
Reporter: herbelin
Status: new
Resolution: open
Priority: normal
Severity: crash
Version: 4.06.1
Category: tools (ocaml{lex,yacc,dep,debug,...})
Monitored by: @nojb @gasche @diml

Bug description

#6684 was about printing a lazy value in ocamldebug with the generic printer.
It was fixed and this was very helpful. There is however a similar problem when trying to print lazy values with a custom printer. It either crashes with:

Fatal error: exception End_of_file
Segmentation fault

or hangs (presumably on an input_value trying to fetch the lazy value, though not fully sure on the diagnostic).

The same actually happens when printing functions with a custom printer (though the need is probably less common).

I feel a bit powerless to help more.

Steps to reproduce

printf "let n = lazy (1+1) in n" > a.ml
printf "let f n = print_int (Lazy.force n)" > p.ml
ocamlc -g a.ml
ocamlc -c p.ml
ocamldebug ./a.out <<EOF
load_printer p.cmo
install_printer P.f
break @ "a" # 21
run
print n
EOF

@github-actions
Copy link

github-actions bot commented May 6, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 6, 2020
@ghost ghost added the bug label May 6, 2020
@ghost
Copy link

ghost commented May 6, 2020

I can reproduce the issue. I think it's fair to say it's a bug given that it causes a segfault using normal features.

It looks low-priority to me though, so unless someone volunteer to help, it will probably just remain as a known issue.

@ghost ghost removed the Stale label May 11, 2020
@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 14, 2021
@gasche
Copy link
Member

gasche commented May 14, 2021

@hackwaly is it something that you would know how to fix, and would be interested in fixing?

@gasche gasche removed the Stale label May 14, 2021
@hackwaly
Copy link

@gasche I have no clues about this.

@hackwaly
Copy link

I would like to work on this. But I have a few time @gasche

@xavierleroy
Copy link
Contributor

I can guess what's happening. The lazy value is marshaled (from debuggee to debugger) before being passed to the custom printer. There's a special case in this marshaling that causes all code pointers to be replaced with an impossible code pointer instead of causing marshaling to fail. When the custom printer forces the lazy value, the impossible code pointer is called, and something wrong happens. (I would expect it to raise an exception "cannot evaluate".)

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 16, 2022
@xavierleroy
Copy link
Contributor

I think this is fixed in 4.14 via commit cc9ae80 . See #10709 for more info. The repro case for this issue now results in

(ocd) print n
n: int lazy_t =  <printer P.f raised an exception: Failure("custom printer tried to invoke a function from the debuggee")>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants