[Ecls-list] ECL 10.3.1 GC finalization bug and patch
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Sat Mar 20 14:49:09 UTC 2010
I have done some further investigation and your code works with ECL as of
git/CVS.
First of all I removed the finalization queue in ECL, as it seems that newer
versions of the collector invoke the finalizers in a safe environment.
Second, I executed your code with the following result
;;; Loading "/Users/jjgarcia/build/ecl/foo.fas"
;; allocated foreign object #<foreign :VOID 00500580>
;;; Larger 10 object case
;; allocated foreign object #<foreign :VOID 00500590>
;; allocated foreign object #<foreign :VOID 005005b0>
;; allocated foreign object #<foreign :VOID 005005d0>
;; allocated foreign object #<foreign :VOID 005005f0>
;; allocated foreign object #<foreign :VOID 00500610>
;; allocated foreign object #<foreign :VOID 00500630>
;; allocated foreign object #<foreign :VOID 00500650>
;; allocated foreign object #<foreign :VOID 00500670>
;; allocated foreign object #<foreign :VOID 00500690>
;; allocated foreign object #<foreign :VOID 005006b0>
;; freeing foreign object #<foreign VOID 00500580>
#P"/Users/jjgarcia/build/ecl/foo.fas"
NIL
NIL
> (si::gc t)
;; freeing foreign object #<foreign VOID 00500690>
;; freeing foreign object #<foreign VOID 005006b0>
;; freeing foreign object #<foreign VOID 00500590>
;; freeing foreign object #<foreign VOID 005005b0>
;; freeing foreign object #<foreign VOID 005005d0>
;; freeing foreign object #<foreign VOID 005005f0>
;; freeing foreign object #<foreign VOID 00500610>
;; freeing foreign object #<foreign VOID 00500630>
;; freeing foreign object #<foreign VOID 00500650>
;; freeing foreign object #<foreign VOID 00500670>
Note that I replaced your printf() with a FORMAT. No problem here. Second,
finalization is not guaranteed to happen when you call SI:GC because the
garbage collector may still have references to the objects. In this case
even though the functions and code that create the variables have exited,
there may be dangling references in the stack and it is only when I type
(SI:GC T) at the prompt, once the compiled code has finished, that the
collector feels free to reclaim and finalize the objects.
This is not a bug. Finalization is not a safe thing and it is not reliable
in the sense that you can predict when it is going to happen. It has to be
used only as a last resort to prevent resource leakage and is no substitute
for clever, well thought handling of those resources.
Juanjo
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100320/736088cf/attachment.html>
More information about the ecl-devel
mailing list