:save-runtime-options t fails when running an executable core

Bug #411925 reported by Faré on 2009-08-11
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

# Works (application in control of the argv):
sbcl --eval '(sb-ext:save-lisp-and-die "foo" :executable t :save-runtime-options t)'
./foo --version --eval '(sb-ext:quit)'
* sb-ext:*posix-argv*
("./foo" "--version" "--eval" "(sb-ext:quit)")
* <Ctrl-D>

# Doesn't work (sbcl runtime interprets argv):
sbcl --eval '(sb-ext:save-lisp-and-die "bar" :executable t)'
./bar --eval '(sb-ext:save-lisp-and-die "baz" :executable t :save-runtime-options t)'
./baz --version --eval '(sb-ext:quit)'
SBCL 1.0.30.4

(And yes, if this happened without the developer suspecting it, it could indeed open a security backdoor.)

Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
Zach Beane (xach) wrote :

This happens because the runtime options in bar are initialized from the command line but clobbered to NULL by an attempt to load them from the core. Attached is a patch that keeps the current runtime options unchanged if no runtime options are saved in the core.

$ sbcl --no-userinit --eval '(sb-ext:save-lisp-and-die "bar" :executable t)'
This is SBCL 1.0.30.54, 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.
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into bar:
writing 5200 bytes from the read-only space at 0x20000000
writing 3088 bytes from the static space at 0x20100000
writing 42819584 bytes from the dynamic space at 0x1000000000
done]

$ ./bar --no-userinit --eval '(sb-ext:save-lisp-and-die "baz" :executable t :save-runtime-options t)'
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into baz:
writing 5200 bytes from the read-only space at 0x20000000
writing 3088 bytes from the static space at 0x20100000
writing 42844160 bytes from the dynamic space at 0x1000000000
done]

$ ./baz --no-userinit --version --eval '(sb-ext:quit)'
* sb-ext:*posix-argv*

("./baz" "--version" "--eval" "(sb-ext:quit)")
*

Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers