Original bug ID: 6664 Reporter:@damiendoligez Assigned to:@damiendoligez Status: closed (set by @damiendoligez on 2015-03-04T19:59:26Z) Resolution: fixed Priority: normal Severity: minor Platform: all OS: all OS Version: all Version: 4.03.0+dev / +beta1 Target version: 4.03.0+dev / +beta1 Fixed in version: 4.03.0+dev / +beta1 Category: runtime system and C interface
When you finalise a value of type [int lazy], you get a crash.
The problem is in caml_final_update, at finalise.c:94, short-circuiting the pointer makes a finalised int, which violates the invariants.
I'm not sure what the behavior should be in that case.
Steps to reproduce
With ocamlc, ocamlopt, or the toplevel:
let f x =
let r = ref (lazy (1+x)) in
let fin x = Printf.eprintf "finalisation %d\n%!" (Lazy.force x) in
Gc.finalise fin !r;
ignore (Lazy.force !r);
r := lazy 0;
The text was updated successfully, but these errors were encountered:
After thinking about it and discussing with some users, it seems clear that Gc.finalise should raise Invalid_argument when called on a lazy or a float, because these types are not (always) represented by heap blocks.
Unfortunately, the run-time test for lazy is not exact: some lazy values (the ones that are already forwarded) cannot be detected as such. This will have to be documented.