When running the following PHP code, I get a "Segmentation fault: 11" :
$pattern = '#^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$#';
$horas = "2012-05-15 11:23:56";
echo filter_var($horas, FILTER_VALIDATE_REGEXP, array("options" => array('regexp' => $pattern))) ? "1" : "2";
If I use a shorter regular expression, I don't get any segmentation fault:
$pattern = '#^([\+-]?\d*)$#';
$horas = "2012-05-15 11:23:56";
echo filter_var($horas, FILTER_VALIDATE_REGEXP, array("options" => array('regexp' => $pattern))) ? "1" : "2";
In this case, the value is "2".
I decided to use strace (or dtruss, since I'm using OSX) and compare the output for the different regular expressions. Although I didn't know where to go from here, I realized that the first scripts stops here :
open("/opt/local/lib/libmemcached.9.dylib\0", 0x0, 0x0) = 3 0
pread(0x3, "\317\372\355\376\a\0", 0x1000, 0x0) = 4096 0
mmap(0x103532000, 0x24000, 0x5, 0x12, 0x3, 0x100001F) = 0x3532000 0
mmap(0x103556000, 0x1000, 0x3, 0x12, 0x3, 0x100001F) = 0x3556000 0
mmap(0x103557000, 0x15098, 0x1, 0x12, 0x3, 0x100001F) = 0x3557000 0
close(0x3) = 0 0
stat64("/opt/local/lib/libsasl2.2.dylib\0", 0x7FFF61CDD430, 0x7FFF61CDE2B0) = 0 0
open("/opt/local/lib/libsasl2.2.dylib\0", 0x0, 0x0) = 3 0
pread(0x3, "\317\372\355\376\a\0", 0x1000, 0x0) = 4096 0
mmap(0x10356D000, 0x14000, 0x5, 0x12, 0x3, 0x100001F) = 0x356D000 0
mmap(0x103581000, 0x1000, 0x3, 0x12, 0x3, 0x100001F) = 0x3581000 0
mmap(0x103582000, 0x3848, 0x1, 0x12, 0x3, 0x100001F) = 0x3582000 0
close(0x3) = 0 0
__sysctl(0x7FFF61CDE14C, 0x2, 0x7FFF61CDE138) = 0 0
I'm not sure it this helps at all or if it has anything to do with libsasl. I recently upgraded php5, apache2 and some other packages using macports. This code used to work before the upgrade. This is the output for php -version :
PHP 5.3.12 (cli) (built: May 11 2012 14:31:01) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH
Thank you in advance.