guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

regexp-exec critcial section errors


From: Kevin Ryde
Subject: regexp-exec critcial section errors
Date: Sun, 14 Jan 2007 09:24:12 +1100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

In regexp-exec in 1.8, a nul in the input string, or a bad flags arg,
results in a throw from a critical section, which calls abort().  Eg.

        (regexp-exec (make-regexp "x") "\0")
        => abort

        (regexp-exec (make-regexp "x") "hello" 0 'badflags)
        => abort

What's the reason for the critical section?  Do we think regexec() is
not reentrant?  It looks like a conversion from SCM_DEFER_INTS in past
versions, if that suggests anything about it.

I struck this when running a regexp search on some file data that
slightly unexpectedly had nuls in it.  I think I was using 1.6 last
time I did the same thing.  I guess that version silently ignores past
the nul.  Maybe that should get a check, though there's probably a
zillion libc calls that would really ought to have the same.


--- regex-posix.c.~1.78.2.1.~   2006-02-14 08:59:02.000000000 +1100
+++ regex-posix.c       2007-01-13 12:53:32.000000000 +1100
@@ -245,7 +245,6 @@
      whole regexp, so add 1 to nmatches. */
 
   nmatches = SCM_RGX(rx)->re_nsub + 1;
-  SCM_CRITICAL_SECTION_START;
   matches = scm_malloc (sizeof (regmatch_t) * nmatches);
   c_str = scm_to_locale_string (substr);
   status = regexec (SCM_RGX (rx), c_str, nmatches, matches,
@@ -269,7 +268,6 @@
                                   scm_from_long (matches[i].rm_eo + offset)));
     }
   free (matches);
-  SCM_CRITICAL_SECTION_END;
 
   if (status != 0 && status != REG_NOMATCH)
     scm_error_scm (scm_regexp_error_key,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]