|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76850 Exit code mangled by set locale/preg_match
Submitted: 2018-09-07 15:42 UTC Modified: 2018-09-08 11:29 UTC
From: cschneid at cschneid dot com Assigned: ab (profile)
Status: Closed Package: PCRE related
PHP Version: 7.3Git-2018-09-07 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cschneid at cschneid dot com
New email:
PHP Version: OS:


 [2018-09-07 15:42 UTC] cschneid at cschneid dot com
PHP's shell return code is 1 where 0 is expected when running

php -n t.php; echo $?

I bisected the problem and it seems to work before commit 684ce24eecc5afe7ba767e721c29ef3bb191c43c which is pcre/locale related.

The locale returned by the first setlocale is de_CH.UTF-8 and I'm using openSUSE Tumbleweed 20180829.

Test script:

function foo()
        $oldlocale = setlocale(LC_CTYPE, 0);
        setlocale(LC_CTYPE, $oldlocale);

preg_match('/./', "a");

Expected result:
Return code 0

Actual result:
Return code 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-08 11:29 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: ab
 [2018-09-08 11:29 UTC]
Thanks for reporting!  I can confirm the issue, and also that the
regression has been introduced with commit 684ce24[1].  valgrind
reports a single memory leak regarding a zend_string[2], but it
also reports this leak for earlier commits.  However, running with
a debug build yields:

    [Sat Sep  8 13:26:03 2018]  Script:  '/mnt/c/Users/cmb/php-dev/76850.php'
    /mnt/c/Users/cmb/php-dev/php-src/Zend/zend_string.h(133) :  Freeing 0x00007f5b50c01730 (40 bytes), script=/mnt/c/Users/cmb/php-dev/76850.php
    === Total 1 memory leaks detected ===
    zend_mm_heap corrupted
    Segmentation fault (core dumped)

Anantol, could you please have a look at this?

[1] <;a=commit;h=684ce24eecc5afe7ba767e721c29ef3bb191c43c>
[2] <>
 [2018-09-08 19:40 UTC]
Automatic comment on behalf of ab
Log: Fixed bug #76850 Exit code mangled by set locale/preg_match
 [2018-09-08 19:40 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 23 01:03:36 2021 UTC