[Openmcl-devel] cl-ppcre crash in openmcl

Gary Byers gb at clozure.com
Thu Dec 9 00:33:23 PST 2004



On Wed, 8 Dec 2004, Alan Ruttenberg wrote:

> This kills my lisp.
> (ppcre::scan "\\(.*\\)$" "")
>
> Yours?
>
> -Alan

OpenMCL dies doing the moral equivalent of:

(defun foo (s i)
  (declare (optimize (speed 3) (safety 0)))
  (schar s i))

(foo "" -1)

If I do:

? (let* ((policy
           ;; Be conservative about generating unsafe code,
           ;; regardless of OPTIMIZE declaration settings
           (new-compiler-policy
             :trust-declarations #'(lambda (env)
                                     (declare (ignore env)) nil)
             :inhibit-safety-checking #'(lambda (env)
                                          (declare (ignore env)) nil)
             :open-code-inline #'(lambda (env) (declare (ignore env)) nil))))
    (set-current-compiler-policy policy)
    (set-current-file-compiler-policy policy))

and recompile cl-ppcre with those settings in effect, I get

? (ppcre::scan "\\(.*\\)$" "")
> Error in process listener(1): Array index -1 out of bounds for "" .
> While executing: #<Anonymous Function #x648DD4E>

(The empty string that's being referenced is the value of
CL-PPCRE::*STRING*, and -1 is the value of a local variable named
CL-PPCRE::START-POS.)

Why this code was trying to call SCHAR on an empty string (with -1 for
an index) isn't clear; it certainly -could- be a compiler bug or
something similar, but it's also plausible to me that an unsafe
(SCHAR "" -1) is a quieter error in other implementations.

Wherever the bug is, it might be easier to isolate if the compiler's
operating under a policy that discourages generation of unsafe code.



More information about the Openmcl-devel mailing list