You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 104 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name:
Version: applies to all
OS: solaris, linux
Submission from: reichenau.gmd.de (129.26.12.135)
I attach an OCAML programm causing a core dump at laest in versions 2.01 -
3.00.
The program is non-sense, but the core-dump should not be the answer to that
:-)
(* of course, this program is non-sense. I know, that it's silly to use
structural equality for mutable data structures. It is an extract from
an ill-designed name-space-manager.It should compute non-sense,
BUT IT EFFECTS A CORE-DUMP.
for i = 1 to 100 do
try
let n = rm_node (rm_node v1).k1 in
n.k1 <- v2;
n.k2 <- n.k2+1;
print_string "got: "; print_int (Hashtbl.find ht v1);
print_newline ()
with e ->
print_string (Printexc.to_string e); print_newline ()
done
The text was updated successfully, but these errors were encountered:
I attach an OCAML programm causing a core dump at laest in
versions 2.01 - 3.00.
The program is non-sense, but the core-dump should not be the answer
to that :-)
On my machine, it says "stack overflow" just before "segmentation
fault".
It comes from the fact that the Hashtbl module uses polymorphic
equality to compare keys, and polymorphic equality doesn't handle
circular data structures (and your hash keys are circular data
structures).
There's no easy solution to this problem. Maybe someday we'll enhance
the equality primitive to handle all data, but don't hold your breath.
In the meantime, we'll add a note to the documentation of Hashtbl.
Original bug ID: 104
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name:
Version: applies to all
OS: solaris, linux
Submission from: reichenau.gmd.de (129.26.12.135)
I attach an OCAML programm causing a core dump at laest in versions 2.01 -
3.00.
The program is non-sense, but the core-dump should not be the answer to that
:-)
(* of course, this program is non-sense. I know, that it's silly to use
structural equality for mutable data structures. It is an extract from
an ill-designed name-space-manager.It should compute non-sense,
BUT IT EFFECTS A CORE-DUMP.
reinhard.budde@gmd.de
Run of this file "hbl.ml":
L/ml/Error 16> ocaml
Objective Caml version 2.01
#use "hbl.ml";;
type htlky = | Leaf of int | Node of htlsky
type htlsky = { mutable k1: htlky; mutable k2: int }
val rm_node : htlky -> htlsky =
val v1 : htlky = Node {k1=Node {k1=Leaf 0; k2=5}; k2=8}
val v2 : htlky =
Node {k1=Node {k1=Node {k1=Node {k1=Leaf 0; k2=5}; k2=8}; k2=5}; k2=9}
type htblt = (htlky, int) Hashtbl.t
val ht : htblt =
val tst : unit -> unit =
tst();;
give 2: 2
give 3: 3
got: Not_found
got: Not_found
Segmentation fault
L/ml/Error 17>
*)
type htlky =
| Leaf of int
| Node of htlsky
and htlsky =
{ mutable k1 : htlky;
mutable k2 : int
}
let rm_node = function
| Node n -> n
| _ -> raise (Failure "Leaf instead of Node!")
let v1 = Node { k1=Node {k1=Leaf 0;k2=5};k2=8 }
let v2 = Node { k1=Node {k1=v1;k2=5};k2=9 }
type htblt = (htlky, int) Hashtbl.t
let ht = ( Hashtbl.create 47 : htblt )
let tst () =
Hashtbl.add ht v1 2;
print_string "give 2: "; print_int (Hashtbl.find ht v1); print_newline ();
Hashtbl.add ht v2 3;
print_string "give 3: "; print_int (Hashtbl.find ht v2); print_newline ();
The text was updated successfully, but these errors were encountered: