Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007810OCamlruntime system and C interfacepublic2018-06-21 21:402018-06-29 14:55
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007810: Ephemerons do not correctly handle Infix_tag
DescriptionThis function creates an ephemeron, fills it in, causes a GC and finally inspects the ephemeron. The ephemeron should not be cleared because the key is still live, since it is part of the return value.

    let ephe x =
      let open Ephemeron.K1 in
      let e = create () in
      set_key e x;
      set_data e 42;
      Gc.full_major ();
      (x, get_data e)

The second component of this pair should never be None, e.g.:

    # ephe (ref 1000);;
    - : int ref * int option = ({contents = 1000}, Some 42)

However, it is None if the argument has Infix_tag (i.e. is a member of a set of mutually recursive functions other than the first):

    # ephe (let rec f x = () and g x = () in g);;
    Warning 26: unused variable f.
    - : ('_a -> unit) * int option = (<fun>, None)

The bug is this check in minor_gc.c (which appears a couple of times):

    if (Hd_val (*key) == 0){ /* Value copied to major heap */

If *key has Infix_tag, Hd_val (*key) can be nonzero even though it is copied to the major heap.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
bobot (reporter)
2018-06-22 10:33

Why in `caml_oldify_one` the test is `if (hd == 0){ /* If already forwarded */`? Are `Infix_tag` forwarded multiple times?
bobot (reporter)
2018-06-22 10:42

For multicore, I remember that infix_tag handling could have changed? Is it true?
doligez (administrator)
2018-06-22 13:55

In `caml_oldify_one`, if the tag is `Infix_tag` we call `caml_oldify_one` recursively on the real block (which can be forwarded only once) then patch up the returned pointer.
kayceesrk (reporter)
2018-06-29 14:55

`Infix_tag` handling remains the same in multicore.

- Issue History
Date Modified Username Field Change
2018-06-21 21:40 stedolan New Issue
2018-06-22 10:33 bobot Note Added: 0019203
2018-06-22 10:42 bobot Note Added: 0019204
2018-06-22 13:55 doligez Note Added: 0019205
2018-06-29 14:55 kayceesrk Note Added: 0019218

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker