Non capturing parenthesis in regexp causes seg fault.

Arran Cudbard-Bell A.Cudbard-Bell at
Fri Feb 15 19:28:14 CET 2008

Arran Cudbard-Bell wrote:
> Alan DeKok wrote:
>> Arran Cudbard-Bell wrote:
>>> Hi,
>>> Got this on my 32bit intel box running Ubuntu Linux 6.10
>>> if("%{User-Name}" =~ /(?:.*)/){
>>   I'm not sure that's a valid regular expression... '?' is usually a
>> modifier...
> It is...
> It allows you to create backreferences but not capture the result 
> directly.
> Pretty sure it's supported with the PCRE library.
man pcre


       Subpatterns are delimited by parentheses (round brackets), which can be
       nested.  Turning part of a pattern into a subpattern does two things:

       1. It localizes a set of alternatives. For example, the pattern


       matches  one  of the words "cat", "cataract", or "caterpillar". Without
       the parentheses, it would match  "cataract",  "erpillar"  or  an  empty

       2.  It  sets  up  the  subpattern as a capturing subpattern. This means
       that, when the whole pattern  matches,  that  portion  of  the  subject
       string that matched the subpattern is passed back to the caller via the
       ovector argument of pcre_exec(). Opening parentheses are  counted  from
       left  to  right  (starting  from 1) to obtain numbers for the capturing

       For example, if the string "the red king" is matched against  the  pat-

         the ((red|white) (king|queen))

       the captured substrings are "red king", "red", and "king", and are num-
       bered 1, 2, and 3, respectively.

       The fact that plain parentheses fulfil  two  functions  is  not  always
       helpful.   There are often times when a grouping subpattern is required
       without a capturing requirement. If an opening parenthesis is  followed
       by  a question mark and a colon, the subpattern does not do any captur-
       ing, and is not counted when computing the  number  of  any  subsequent
       capturing  subpatterns. For example, if the string "the white queen" is
       matched against the pattern

         the ((?:red|white) (king|queen))

>>> Program received signal SIGSEGV, Segmentation fault.
>>> [Switching to Thread -1213196608 (LWP 6433)]
>>> 0xb7bc9492 in regexec () from /lib/tls/i686/cmov/
>>> (gdb) bt
>>> #0  0xb7bc9492 in regexec () from /lib/tls/i686/cmov/
>>   It might be a bug in the regular expression library...
>>> #1  0x0806d6a9 in ?? ()
>>   Ugh.  2.0.x *should* be built with debugging symbols, and should *not*
>> be stripped of those symbols before being installed.
> Yes, and this is from CVS. I'll rebuild with the debug flags...
Ok with --enable-developer , it's exactly the same. Grrr
>>   Alan DeKok.
>> -
>> List info/subscribe/unsubscribe? See 
Arran Cudbard-Bell (A.Cudbard-Bell at
Authentication, Authorisation and Accounting Officer
Infrastructure Services | ENG1 E1-1-08 
University Of Sussex, Brighton
EXT:01273 873900 | INT: 3900

More information about the Freeradius-Users mailing list