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

LibIndex.get hangs in UTop #136

Open
kandu opened this issue Aug 6, 2019 · 4 comments
Open

LibIndex.get hangs in UTop #136

kandu opened this issue Aug 6, 2019 · 4 comments

Comments

@kandu
Copy link

kandu commented Aug 6, 2019

Hi, dear ocp-index developers. I recently encountered an issue working with ocp-index.lib, here is the step-to-reproduce:

#require "ocp-index.lib";;

let cmd_input_line cmd =
  try
    let ic = Unix.open_process_in (cmd ^ " 2>/dev/null") in
    let r = input_line ic in
    let r =
      let len = String.length r in
      if len>0 && r.[len - 1] = '\r' then String.sub r 0 (len-1) else r
    in
    match Unix.close_process_in ic with
    | Unix.WEXITED 0 -> r
    | _ -> failwith "cmd_input_line"
  with
  | End_of_file | Unix.Unix_error _ | Sys_error _ -> failwith "cmd_input_line"

let index=
  let ocaml_lib= try (cmd_input_line) "ocamlc -where" with _-> "" in
  let opam_lib= try (cmd_input_line) "opam config var lib" with _-> "" in
  LibIndex.load @@ LibIndex.Misc.unique_subdirs [ocaml_lib; opam_lib]
;;

LibIndex.Print.info (LibIndex.get index "String.concat");;

#require "core_kernel";;

LibIndex.Print.info (LibIndex.get index "Core_kernel.String.concat");;

Paste the code above to utop, LibIndex.get hangs at the last statement.

Buf if I replace the last three statements with only the last one, or just delete the #require "core_kernel";; statement, LibIndex.get will work.

There could be some conflicts between #require and LibIndex's internal implementation.

and here is the backtrace info

^CInterrupted.
Raised by primitive operation at file "typing/env.ml", line 1039, characters 6-43
Re-raised at file "typing/env.ml", line 1012, characters 2-164
Called from file "typing/printtyp.ml", line 289, characters 7-36
Called from file "typing/printtyp.ml", line 278, characters 13-46
Re-raised at file "typing/printtyp.ml", line 303, characters 20-256
Called from file "typing/printtyp.ml", line 330, characters 25-63
Called from file "utils/tbl.ml", line 105, characters 16-21
Called from file "typing/env.ml", line 1452, characters 10-120
Called from file "list.ml", line 100, characters 12-15
Called from file "typing/env.ml", line 1475, characters 2-29
Called from file "typing/printtyp.ml", line 391, characters 36-70
Called from file "typing/printtyp.ml", line 515, characters 23-39
Called from file "typing/printtyp.ml", line 767, characters 29-52
Called from file "typing/printtyp.ml", line 996, characters 11-44
Called from file "typing/printtyp.ml", line 1260, characters 7-40
Called from file "typing/printtyp.ml", line 1254, characters 18-39
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1256, characters 14-58
Called from file "typing/printtyp.ml", line 1184, characters 13-22
Called from file "typing/printtyp.ml", line 1226, characters 27-47
Called from file "typing/printtyp.ml", line 1289, characters 30-59
Called from file "libs/indexBuild.ml", line 552, characters 16-41
Called from file "libs/indexBuild.ml", line 628, characters 17-137
Called from file "libs/indexMisc.ml", line 36, characters 38-58
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "libs/indexBuild.ml", line 628, characters 17-137
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "libs/indexBuild.ml", line 628, characters 17-137
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "libs/indexBuild.ml", line 1077, characters 24-164
Called from file "libs/indexMisc.ml", line 36, characters 38-58
Called from file "libs/indexBuild.ml", line 1073, characters 17-514
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "libs/indexBuild.ml", line 746, characters 16-51
Called from file "list.ml", line 111, characters 24-34
Called from file "libs/indexBuild.ml", line 1094, characters 11-89
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 149, characters 42-53
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 42, characters 8-25
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 42, characters 8-25
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 42, characters 8-25
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 141, characters 8-25
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 60, characters 8-22
Called from file "list.ml", line 111, characters 24-34
Called from file "libs/indexBuild.ml", line 1094, characters 11-89
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 149, characters 42-53
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "libs/trie.ml", line 83, characters 35-52
Called from file "libs/trie.ml", line 86, characters 6-19
Called from file "libs/trie.ml", line 89, characters 8-26
Called from file "//toplevel//", line 2, characters 20-81
Called from file "toplevel/toploop.ml", line 180, characters 17-56
@AltGr
Copy link
Member

AltGr commented Aug 8, 2019

Interesting... thanks for the very helpful report.
I couldn't reproduce with rlwrap ocaml; do you know if utop is doing specific stuff that could interfere ?
I am not familiar with utop, and couldn't get past the first #require:

utop # #require "ocp-index.lib";;
Error: Reference to undefined global `Location'

what does it require that plain ocaml doesn't ??

@kandu
Copy link
Author

kandu commented Aug 8, 2019

Sorry. you can invoke utop-full and then #require "ocp-index.lib"

do you know if utop is doing specific stuff that could interfere ?

The backtrace tells that it struggled in typing/env.ml and typing/printtyp.ml, https://github.com/ocaml-community/utop/blob/master/src/lib/uTop_main.mli is suspicious.

compiler-libs, lazy-evalution, global variables, what a wonderful integration to debug with ;)

@Drup
Copy link
Collaborator

Drup commented Aug 15, 2019

The interaction is when you link utop and libindex together. utop non-full is expunged, which avoids the issue. @kandu It would probably be easier with a compiled examples, not one that requires to run stuff in utop-full, as expunging is going to muddy the waters.

@pmetzger
Copy link

pmetzger commented Sep 8, 2022

What should we do to get this resolved?

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

No branches or pull requests

4 participants