[Gc] Patch resubmission: correct GC_oom_fn usage in finalize.c

Ivan Maidanski ivmai at mail.ru
Fri Sep 11 04:52:45 PDT 2009


This patch (ivmai128.diff), superseding diff62 and diff66 partly [Apr 11], fixes the following bug in GC_general_register_disappearing_link() and GC_register_finalizer_inner(): if GC_oom_fn() succeeds then (after gaining the lock again) the hash table index should be recalculated (since the table may grow) and the entry should be searched in the table again (to prevent adding a duplicate one).
Also, if GC_register_finalizer_inner() fails (because of lack of memory) then *ocd and *ofn shouldn't be modified.

The patch also changes (for convenience) error codes returned by GC_register_finalizer_inner() with public GC_SUCCESS, GC_DUPLICATE and GC_NO_MEMORY macros.

ChangeLog entries:

	* finalize.c (GC_general_register_disappearing_link): Return
	GC_SUCCESS, GC_DUPLICATE, GC_NO_MEMORY (instead of 0, 1 and 2,
	* include/gc.h (GC_NO_MEMORY): New macro (defined as 2).
	* include/gc.h (GC_register_disappearing_link,
	GC_general_register_disappearing_link): Update the comment.
	* typd_mlc.c (GC_calloc_explicitly_typed): Use GC_NO_MEMORY macro.
	* finalize.c (GC_general_register_disappearing_link,
	GC_register_finalizer_inner): Recalculate the hash table index
	after GC_oom_fn succeeded (since the table may grow while not
	holding the lock) and check again that the entry is still not in
	the table (free the unused entry otherwise unless DBG_HDRS_ALL).
	* finalize.c (GC_register_finalizer_inner): Initialize "hhdr"
	local variable (to prevent a compiler warning).
	* finalize.c (GC_register_finalizer_inner): Don't modify the data
	pointed by "ocd" and "ofn" in GC_register_finalizer_inner() failed
	(due to out of memory).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ivmai128.diff
Type: application/octet-stream
Size: 9450 bytes
Desc: not available
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090911/ab836505/ivmai128.obj

More information about the Gc mailing list