Skip to content

LibIndex.get hangs in UTop #136

@kandu

Description

@kandu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions