Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006664OCamlruntime system and C interfacepublic2014-11-18 22:282015-03-04 20:59
Reporterdoligez 
Assigned Todoligez 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformallOSallOS Versionall
Product Version4.03.0+dev / +beta1 
Target Version4.03.0+dev / +beta1Fixed in Version4.03.0+dev / +beta1 
Summary0006664: Crash when finalising lazy values of the wrong type.
DescriptionWhen 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 ReproduceWith 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;
  Gc.full_major ();
;;
f 3;;
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0012574)
doligez (administrator)
2014-11-24 22:39

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.
(0013379)
doligez (administrator)
2015-03-04 20:59

fixed in trunk (commit 15876)

- Issue History
Date Modified Username Field Change
2014-11-18 22:28 doligez New Issue
2014-11-18 22:28 doligez Status new => assigned
2014-11-18 22:28 doligez Assigned To => doligez
2014-11-24 22:39 doligez Note Added: 0012574
2015-01-13 22:10 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-03-04 20:59 doligez Note Added: 0013379
2015-03-04 20:59 doligez Status assigned => closed
2015-03-04 20:59 doligez Resolution open => fixed
2015-03-04 20:59 doligez Fixed in Version => 4.03.0+dev / +beta1
2015-03-04 20:59 doligez Target Version 4.02.2+dev / +rc1 => 4.03.0+dev / +beta1
2017-02-23 16:43 doligez Category OCaml runtime system => runtime system
2017-03-03 17:45 doligez Category runtime system => runtime system and C interface


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker