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 quit with "Exception Not_found" when inspecting some variables #7830

Closed
vicuna opened this issue Jul 24, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Jul 24, 2018

Original bug ID: 7830
Reporter: jserot
Assigned to: @nojb
Status: resolved (set by @nojb on 2018-08-21T17:01:27Z)
Resolution: fixed
Priority: normal
Severity: crash
Platform: Mac
OS: Mac OS
OS Version: 10.9.5
Version: 4.06.0
Target version: 4.08.0+dev/beta1/beta2
Category: tools (ocaml{lex,yacc,dep,debug,...})
Monitored by: @nojb @gasche

Bug description

Ocamldebug sometimes quits launching an « Not_found » exception when trying to visualize some program variables. Here's a session example :

8<--------- START of EXAMPLE

$ ocamldebug -version
The OCaml debugger, version 4.06.0
$ ocamldebug rfsmc
OCaml Debugger version 4.06.0
Executing file .ocamldebug
Directories: _build lib lib/_build . /Users/jserot/.opam/4.06.0/lib/ocaml
(ocd) set arguments -dot -target_dir /tmp ../../examples/single/chrono/chrono.fsm
(ocd) break @ Fsm 308
Loading program... done.
Breakpoint 1 at 758316: file lib/fsm.ml, line 308, characters 5-3585
(ocd) run
Time: 10027 - pc: 758316 - module Fsm
Breakpoint: 1
308 <|b|>let bind_param vs (p,ty) =
(ocd) print tenv
Removed breakpoint 1 at 758316: file lib/fsm.ml, line 308, characters 5-3585
Uncaught exception: Not_found

8<--------- END of EXAMPLE

The problem is not systematic and seems to depend on the variable to be printed (or at least on the module where it is defined). For example, setting a breakpoint in the Main (top-level) module is ok.This makes isolating a minimum triggering program difficult.

I therefore give a pointer to a publicly available program on which it shows and a sequence of step to reproduce it.

Steps to reproduce

  1. Dowload the program :
  2. Build the executable (-g option is set by default)
    • cd rfsm
    • mkdir ../rfsm-install
    • ./configure --prefix ../rfsm-install --no-gui
    • make
  3. Go to the src/compiler directory and launch the debugger
    • cd src/compiler/
    • ocamldebug rfsmc
  4. Set argument and put a breakpoint somewhere in the code
    (ocd) set arguments -dot -target_dir /tmp ../../examples/single/chrono/chrono.fsm
    (ocd) break @ Fsm 308
  5. Run
    (ocd) run
  6. Try to print a variable (tenv, an argument of the function build_instance here)
    (ocd) print tenv

This gives :
*** Removed breakpoint 1 at 758316: file lib/fsm.ml, line 308, characters 5-3585
Uncaught exception: Not_found

Additional information

I did not try with 4.07.0 but since Ocamldebug is not mentioned in the Changelog i doubt this would make a difference (additionally, my program is bound to 4.06.0 because it must build under windows..)

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 24, 2018

Comment author: @nojb

TL;DR: seems to be a missing try ... with in ocamldebug's code when a .cmi cannot be found.

I run this on 4.07 and got the following backtrace for ocamldebug.

Raised at file "typing/env.ml", line 762, characters 18-27
Called from file "typing/env.ml", line 858, characters 13-47
Called from file "typing/env.ml", line 2044, characters 23-52
Called from file "typing/envaux.ml", line 66, characters 22-110
Called from file "typing/envaux.ml", line 64, characters 20-44
Called from file "typing/envaux.ml", line 45, characters 12-38
Called from file "typing/envaux.ml", line 43, characters 10-125

Called from file "typing/envaux.ml", line 41, characters 24-50
Called from file "typing/envaux.ml", line 40, characters 10-114
Called from file "command_line.ml", line 507, characters 7-76

Failure occurs when trying to open cmi of "Utils", which is a (packed) module of a library dependency (lascar).

Problem goes away adding the necessary include directory by hand, as in:

ocamldebug -I $(ocamlfind query lascar) rfsmc

@vicuna

This comment has been minimized.

Copy link
Author

commented Jul 24, 2018

Comment author: jserot

Thanks for the diagnosis and workaround !

@vicuna

This comment has been minimized.

Copy link
Author

commented Aug 11, 2018

Comment author: @nojb

Smaller reproduction:

empty.ml
(* empty *)

main.ml

open Empty
let f () = ()
let () = f ()

Compile with:

ocamlc -g empty.ml main.ml
rm empty.cmi

Debug with:

ocamldebug a.out
(ocd) break @ Main 1
(ocd) r
(ocd) print foo
Uncaught exception: Not_found

@vicuna

This comment has been minimized.

Copy link
Author

commented Aug 12, 2018

Comment author: @nojb

#1987

@vicuna

This comment has been minimized.

Copy link
Author

commented Aug 21, 2018

Comment author: @nojb

PR merged.

@vicuna vicuna closed this Aug 21, 2018

@vicuna vicuna added the tools label Mar 14, 2019

@vicuna vicuna added this to the 4.08.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

@nojb nojb modified the milestones: 4.08.0, 4.08 Mar 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.