Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007210OCamlruntime system and C interfacepublic2016-04-04 11:442016-12-08 08:41
Reporterbobot 
Assigned Toshinwell 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.04.0 
Summary0007210: Finaliser that are really called when a value will be freed.
DescriptionSince the values finalized are given as argument of their finalizers, they are kept alive. So you can't be sure that nobody will ever use this value again.

Before 4.03 the finalizer where called after cleaning weak pointers, thus possibly breaking invariant of weakset, hashconsing. In 4.03 they are called before cleaning weak pointers (which is done when we are sure to sweep the value).

It could be interesting to give the possibility to register finalizers that would not take the value as argument but instead `unit` and would be called when we are sure to sweep the value.

The question is not really how to add this feature (straightforward), more if ocaml needs it.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0015783)
lpw25 (developer)
2016-04-18 15:00

This would be very useful in combination with weak pointers.

As of 4.03, it is difficult to "clean up" a data structure containing a weak pointer when the weak pointer is cleared (e.g. removing an entry from a weak hash table once its weak pointer is empty). Previously this could be done with ordinary finalisers, but that is no longer possible since finalisers are now run before weak pointers are cleared.

Ordinary finalisers are now run before clearing weak pointers to make sure that weak pointers are only cleared once the object is genuinely dead -- a useful invariant for things like hash-consing. Since the proposed alternative finalisers do not receive their argument and cannot bring it back to life, they can safely be run after weak pointers have been cleared without breaking the desired invariant on weak pointers.
(0015877)
bobot (reporter)
2016-04-27 14:25

GPR at https://github.com/ocaml/ocaml/pull/562 [^]
(0016813)
shinwell (developer)
2016-12-08 08:40

Fixed in 4.04

- Issue History
Date Modified Username Field Change
2016-04-04 11:44 bobot New Issue
2016-04-18 15:00 lpw25 Note Added: 0015783
2016-04-27 14:25 bobot Note Added: 0015877
2016-05-02 15:30 doligez Status new => acknowledged
2016-12-08 08:40 shinwell Note Added: 0016813
2016-12-08 08:41 shinwell Status acknowledged => resolved
2016-12-08 08:41 shinwell Fixed in Version => 4.04.0
2016-12-08 08:41 shinwell Resolution open => fixed
2016-12-08 08:41 shinwell Assigned To => shinwell
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