Ocaml exception "Out of memory"; verbose mode says: "Stack overflow in structural comparison"

You need to install a very huge ocaml program from someone else's source. One of the problems is that the program crashes due to an innocent line:

Hashtbl.mem loc_to_no loc

with the exception of "Without memory." The fact is that there, of course, there is enough memory, and this line is executed just fine for other inputs, and even earlier when processing the problematic one.

Running it with OCAMLRUNPARAM="v=63", I see a line that prints just before the crash:

Stack overflow in structural comparison

The following structures are defined below. lochas 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 needs to be done to execute the code?

+3
1

, - "=" ( ), , , . .. . , - , . , , - , , , ; Hashtbl.Make - , / .

+6

Source: https://habr.com/ru/post/1717132/


All Articles