[cl-ppcre-devel] Re: [Openmcl-devel] cl-ppcre crash in openmcl

Edi Weitz edi at agharta.de
Thu Dec 9 09:27:21 UTC 2004


On Thu, 9 Dec 2004 01:33:23 -0700 (MST), Gary Byers <gb at clozure.com> wrote:

> 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.

Good catch, thanks. This didn't occur to me because it doesn't seem to
happen with Lisps other than OpenMCL. I've just uploaded a new version
(0.9.3) of CL-PPCRE which hopefully fixes this. Maybe someone using
OpenMCL can try it.

  <http://weitz.de/files/cl-ppcre.tar.gz>

Thanks again,
Edi.




More information about the Cl-ppcre-devel mailing list