Memory fault with SEARCH-ROOTS
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
SBCL 2.0.10 on Linux amd64.
* (flet ((root (thing) (search-roots (make-weak-pointer thing) :print nil)))
(sb-ext:gc :full t)
(dotimes (i 10) (make-instance 'standard-class))
(let ((thing (root (slot-value (make-instance 'standard-class)
(sb-ext:gc :full t)
(root thing)))
CORRUPTION WARNING in SBCL pid 606045 tid 606045:
Memory fault at 0xf8 (pc=0x525279bc [code 0x52527760+0x25C ID 0x7767], fp=0x7ff8995ff8a8, sp=0x7ff8995ff830) tid 606045
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
debugger invoked on a SB-SYS:
#<THREAD "main thread" RUNNING {1001570103}>:
Unhandled memory fault at #xF8.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-
0: [ABORT] Exit debugger, returning to top level.
(SB-IMPL:
0] backtrace
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001570103}>
0: (SB-IMPL:
1: (SEARCH-ROOTS #<weak pointer: ((#<SB-
2: (SB-INT:
3: (EVAL (LABELS ((ANCESTOR (THING) (FIRST (THIRD #))) (ROOT (THING) (SEARCH-ROOTS (MAKE-WEAK-POINTER THING) :PRINT NIL)) (FROB (THING) (ANCESTOR (ROOT THING)))) (GC :FULL T) (DOTIMES (I 10) (MAKE-INSTANCE (QUOTE STANDARD-CLASS))) (LET ((THING (ROOT #))) (GC :FULL T) (ROOT THING))))
4: (INTERACTIVE-EVAL (LABELS ((ANCESTOR (THING) (FIRST (THIRD #))) (ROOT (THING) (SEARCH-ROOTS (MAKE-WEAK-POINTER THING) :PRINT NIL)) (FROB (THING) (ANCESTOR (ROOT THING)))) (GC :FULL T) (DOTIMES (I 10) (MAKE-INSTANCE (QUOTE STANDARD-CLASS))) (LET ((THING (ROOT #))) (GC :FULL T) (ROOT THING))) :EVAL NIL)
5: (SB-IMPL::REPL-FUN NIL)
6: ((LAMBDA NIL :IN SB-IMPL:
7: (SB-IMPL:
8: (SB-IMPL:
9: (SB-IMPL:
10: ((FLET SB-UNIX::BODY :IN SB-IMPL:
11: ((FLET "WITHOUT-
12: (SB-IMPL:
description: | updated |
description: | updated |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
Yes search-roots shouldn't crash, but your test case seems to be misusing it.
The return value is not "a root", it is a path, which is effectively random cons cells.
Your second query asks for a patch to the first cons cell of the path that formed the previous answer. That path was a pinned object in the just-prior GC, but it's actually not going to find a path to that. So it was trying to return no answer, and did that wrong. and the lisp side crashed.
I've fixed that. But I'm not sure if the point of this example was that you're trying to actually use traceroot in a meaningful way or whether you're pointing out a strange edge case.