odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Loop on `include` of shadowing module type substitution

Open lukemaurer opened this issue 1 year ago • 2 comments

This .mli makes odoc (either Jane Street's modified trunk or stock 2.4.3) loop:

(* can also be := *)
module type Fail = sig end

(* must be := *)
module type Monad := sig
  (* must be := and the same name *)
  module type Fail := Fail

  include Fail
end

include Monad

The precise behavior is slightly different between trunk and 2.4.3: on trunk, we get an immediate segfault that gdb shows happens tens of thousands of frames deep:

#0  camlOdoc_model__Paths__compare_10_10 () at paths.ml:181
#1  0x000000000103cfed in camlStdlib__Map__find_7_78_code () at map.ml:148
#2  0x00000000004d009b in camlOdoc_xref2__Tools__resolve_module_type_66_66 () at env.ml:154
#3  0x00000000004d9fd1 in camlOdoc_xref2__Tools__signature_of_u_module_type_expr_91_91 () at tools.ml:1646
#4  0x00000000004da669 in camlOdoc_xref2__Tools__expansion_of_module_type_expr_93_93 () at tools.ml:1687
#5  0x00000000004da06c in camlOdoc_xref2__Tools__signature_of_u_module_type_expr_91_91 () at tools.ml:1647
#6  0x00000000004da669 in camlOdoc_xref2__Tools__expansion_of_module_type_expr_93_93 () at tools.ml:1687
...

(with the last two frames repeating ad infinitum)

On 2.4.3, instead odoc hangs, and if I ask gdb for a backtrace I get something that at least looks different:

#0  0x000000000060468c in camlOdoc_xref2__Tools.process_module_type_2624 () at src/xref2/tools.ml:554
#1  0x000000000060a8e9 in camlOdoc_xref2__Tools.fun_7266 () at src/xref2/tools.ml:1170
#2  0x0000000000604460 in camlOdoc_xref2__Tools.get_module_type_path_modifiers_2623 () at src/xref2/tools.ml:526
#3  0x0000000000604604 in camlOdoc_xref2__Tools.process_module_type_2624 () at src/xref2/tools.ml:550
#4  0x000000000060a8e9 in camlOdoc_xref2__Tools.fun_7266 () at src/xref2/tools.ml:1170
#5  0x0000000000604460 in camlOdoc_xref2__Tools.get_module_type_path_modifiers_2623 () at src/xref2/tools.ml:526
#6  0x0000000000604604 in camlOdoc_xref2__Tools.process_module_type_2624 () at src/xref2/tools.ml:550
...

(again, it repeats for thousands of frames)

lukemaurer avatar Oct 24 '24 14:10 lukemaurer

I can't reproduce this issue either on 2.4.3 or on the master branch. What commands did you use exactly?

gpetiot avatar Oct 30 '24 13:10 gpetiot

Just to say I can reproduce this - no further details yet though.

jonludlam avatar Feb 07 '25 08:02 jonludlam