A very huge ocaml program from an alien source needs to be fixed. One of the problem is that the program crashes at seemingly innocent line:
Hashtbl.mem loc_to_no loc
with "Out of memory" exception. The thing is that there's surely enough memory out there and this line is executed just fine for other inputs and even earlier during the processing of the problem one.
Having run it with OCAMLRUNPARAM="v=63"
, I see a line that is printed right before crash:
Stack overflow in structural comparison
The structures involved are defined below. loc
is of type location
.
type ('a, 'b, 'c) automaton = {
aut_id : int ;
mutable start_location : (('a, 'b, 'c) location) option ;
mutable end_location : (('a, 'b, 'c) location) option ;
mutable aut_attributes : 'a ;
}
and ('a, 'b, 'c) location = {
loc_id : int ;
mutable succs : ('c * ('a, 'b, 'c) location) list ;
mutable preds : ('c * ('a, 'b, 'c) location) list ;
automaton : ('a, 'b, 'c) automaton ;
mutable loc_attributes : 'b ;
}
What should be done to make the code execute?