Opened 13 years ago
Closed 12 years ago
#723 closed defect (fixed)
using set-finalizer in this loop triggers a OOM panic / segfault
Reported by: | Christian Kellermann | Owned by: | felix winkelmann |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | unknown | Version: | 4.7.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
This innocent looking program crashes:
(use lolevel) (define (make-stuff) (let ((mem (allocate 100))) (set-finalizer! mem free) mem)) (let lp ((i 0)) (make-stuff) (lp (add1 i)))
This has been confirmed by Peter on NetBSD, I have the situation that it works for me if I add a (print i) before (make-stuff). Peter cannot see the same behaviour on his machine.
I have tried 4.5.0 4.7.0 and master from last week. All show the same strange thing.
Am I misusing this? I stumbled upon it during some allocation in an egg for a FFI buffer...
Change History (12)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Does this happen with the current HEAD? I can't reproduce this right now (only tried on Windows). What is shown when the code is compiled and run with "-:d" ?
comment:3 Changed 13 years ago by
gah, this is weird...
(use lolevel) (define (make-stuff) (let ((mem (allocate 1000))) (set-finalizer! mem free) mem)) (let lp ((i 0)) (print i) (make-stuff) (lp (add1 i)))
either one of these version crashes for me now on OpenBSD 32 bit 4.7.0 (sorry I don't have a more recent version there)
The above program does crash with current master on 64 bit linux when adding -O3. With the print output sent to /dev/null I get this:
./bla -:d >/dev/null [debug] application startup... [debug] heap resized to 500000 bytes [debug] stack bottom is 0x7ffff803d090. [debug] entering toplevel toplevel... [debug] stack resized to 262144 bytes [debug] entering toplevel library_toplevel... [debug] entering toplevel build_2dversion_toplevel... [debug] resizing heap dynamically from 500k to 1032k ... [debug] entering toplevel eval_toplevel... [debug] entering toplevel expand_toplevel... [debug] entering toplevel modules_toplevel... [debug] entering toplevel lolevel_toplevel... [debug] entering toplevel srfi_2d69_toplevel... [debug] resizing heap dynamically from 1032k to 2196k ... [panic] out of memory - heap full while resizing - execution terminated ...more... bla.scm:6: set-finalizer! bla.scm:12: lp bla.scm:10: print bla.scm:11: make-stuff bla.scm:5: allocate bla.scm:6: set-finalizer! bla.scm:12: lp bla.scm:10: print bla.scm:11: make-stuff bla.scm:5: allocate bla.scm:6: set-finalizer! bla.scm:12: lp bla.scm:10: print bla.scm:11: make-stuff bla.scm:5: allocate bla.scm:6: set-finalizer! <--
comment:4 Changed 13 years ago by
Note that it only crashes when compiled! (the OP forgot to mention this)
comment:7 Changed 13 years ago by
I suggest to postpone investigating this to after the 4.8.0 release.
comment:8 Changed 13 years ago by
Milestone: | 4.8.0 |
---|
comment:11 Changed 12 years ago by
No longer crashes when the patch from here http://lists.nongnu.org/archive/html/chicken-hackers/2012-06/msg00080.html is applied
comment:12 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Yep, seems to do the right thing now. Thanks!
I managed to get a stacktrace from gdb: