[Antik-devel] Memory corruption when loading an SBCL core containing antik (patch included)

James Wright james at chumsley.org
Sun Dec 11 22:01:31 UTC 2011


Hi Liam,

> Thanks James.  Indeed, *formatting-test-grid* is just a throwaway to test
> the formatting of grids.  While a patch is OK, I would rather just not load
> it.

Works for me; either solution will stop the corruption issue that I ran into. :)

> However, I've long been uneasy with saved images and foreign memory; I
> have no confidence that what's saved will come back.

I feel exactly the same way.  It has become an article of faith with
me that foreign pointers that get saved to a core will come back
essentially uninitialized.

> Indeed, if you are
> seeing rng variable problems, then there is a deeper problem that can't be
> fixed with turning a defparameter into a function.

Actually, my workaround (to saved rngs coming back uninitialized) kind
of does boil down to converting the defparameter to a function.
Fortunately it's possible to access the state of a GSL rng, so I've
been checkpointing that and then restoring it into a
freshly-constructed rng every time my program starts.

>  I would like to get
> ideas from SBCL experts.   I think the solution is likely to be
> implementation dependent, but that's the place to start.

I'll be interested to hear if there's any realistic solution; I've
mostly been assuming that it's up to me to make sure that I don't have
any "live" foreign pointers when I dump core.

>  Can you generate a small example of your rng problem?

Certainly; I've attached a small script along with its output on my machine.

      James
-------------- next part --------------
tanky:~/src/toys% sh ./run-bar.sh 
This is SBCL 1.0.48.19, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
WARNING: No definition for CFLAG-VDSUSP
WARNING: No definition for CFLAG-VSTATUS

; compiling file "/home/james/quicklisp/local-projects/antik/optimize/one-dim.lisp" (written 09 DEC 2011 10:55:38 AM):
; compiling (IN-PACKAGE :ANTIK)
; compiling (EXPORT (QUOTE #))
; compiling (DEFUN ROOT-1D ...)
; compiling (DEFUN MINIMIZE-1D ...)
; compiling (DEFUN MAXIMIZE-1D ...)

; /home/james/.cache/common-lisp/sbcl-1.0.48.19-linux-x86/home/james/quicklisp/local-projects/antik/optimize/ASDF-TMP-one-dim.fasl written
; compilation finished in 0:00:00.024
; compiling file "/home/james/quicklisp/local-projects/antik/linear-algebra/linear-algebra.lisp" (written 09 DEC 2011 10:55:38 AM):
; compiling (IN-PACKAGE :ANTIK)
; compiling (EXPORT (QUOTE #))
; compiling (DEFMETHOD *I ...)
; compiling (DEFMETHOD *I ...)
; compiling (DEFMETHOD *I ...)
; compiling (DEFMETHOD /I ...)
; compiling (DEFMETHOD +I ...)
; compiling (DEFMETHOD +I ...)
; compiling (DEFMETHOD +I ...)
; compiling (DEFMETHOD -I ...)
; compiling (DEFMETHOD -I ...)
; compiling (DEFMETHOD -I ...)
; compiling (DEFMETHOD EXPT ...)
; compiling (DEFUN INVERT-MATRIX ...)
; compiling (DEFUN DETERMINANT ...)
; compiling (DEFUN SOLVE-LINEAR ...)

; /home/james/.cache/common-lisp/sbcl-1.0.48.19-linux-x86/home/james/quicklisp/local-projects/antik/linear-algebra/ASDF-TMP-linear-algebra.fasl written
; compilation finished in 0:00:00.039
; compiling file "/home/james/quicklisp/local-projects/antik/sample/low-discrepancy-sequence.lisp" (written 09 DEC 2011 10:55:38 AM):
; compiling (IN-PACKAGE :ANTIK)
; compiling (EXPORT (QUOTE #))
; compiling (DEFUN VAL-FROM-RANGE ...)
; compiling (DEFUN QUASI-RANDOM-VALUES ...)
; compiling (DEFUN LOW-DISCREPANCY-SAMPLE ...)
; compiling (DEFUN APPLY-TO-ARGUMENTS ...)

; /home/james/.cache/common-lisp/sbcl-1.0.48.19-linux-x86/home/james/quicklisp/local-projects/antik/sample/ASDF-TMP-low-discrepancy-sequence.fasl written
; compilation finished in 0:00:00.017
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into bar.core:
writing 3512 bytes from the read-only space at 0x01000000
writing 7536 bytes from the static space at 0x01100000
writing 53903360 bytes from the dynamic space at 0x09000000
done]
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into bar:
writing 3512 bytes from the read-only space at 0x01000000
writing 7536 bytes from the static space at 0x01100000
writing 53936128 bytes from the dynamic space at 0x09000000
done]
CORRUPTION WARNING in SBCL pid 4155(tid 3085084352):
Memory fault at 8 (pc=0xb7498b3c, sp=0xb7984e7c)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
unhandled SB-SYS:MEMORY-FAULT-ERROR in thread #<SB-THREAD:THREAD
                                                "initial thread" RUNNING
                                                 {C370879}>:
  Unhandled memory fault at #x8.

0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA #) {C6570C5}> :START 0 :COUNT 128)
1: (BACKTRACE 128 #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDERR* {90BF8F9}>)
2: (SB-DEBUG::DEBUGGER-DISABLED-HOOK
    #<SB-SYS:MEMORY-FAULT-ERROR {C655AA1}>
    #<unavailable argument>)
3: (SB-DEBUG::RUN-HOOK
    *INVOKE-DEBUGGER-HOOK*
    #<SB-SYS:MEMORY-FAULT-ERROR {C655AA1}>)
4: (INVOKE-DEBUGGER #<SB-SYS:MEMORY-FAULT-ERROR {C655AA1}>)
5: (ERROR SB-SYS:MEMORY-FAULT-ERROR :ADDRESS 8)
6: (SB-SYS:MEMORY-FAULT-ERROR)
7: ("foreign function: call_into_lisp")
8: ("foreign function: post_signal_tramp")
9: ("foreign function: gsl_rng_uniform_int")
CORRUPTION WARNING in SBCL pid 4155(tid 3085084352):
Memory fault at 0 (pc=0xb7496b79, sp=0xb7984754)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
10: ((SB-PCL::FAST-METHOD GSLL:SAMPLE
      (GSLL:RANDOM-NUMBER-GENERATOR
       (EQL :UNIFORM-FIXNUM))) #<error printing object>)
11: (MAIN)
12: ((LABELS SB-IMPL::RESTART-LISP))

unhandled condition in --disable-debugger mode, quitting
tanky:~/src/toys% 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repro-rng-corruption.sh
Type: application/x-sh
Size: 831 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/antik-devel/attachments/20111211/7b0bf147/attachment.sh>


More information about the antik-devel mailing list