php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cschneid at cschneid dot com
New email:
PHP Version: OS:

 

 [2018-09-07 15:42 UTC] cschneid at cschneid dot com
Description:
------------
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:
---------------
<?php

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

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


Expected result:
----------------
Return code 0

Actual result:
--------------
Return code 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-08 11:29 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: ab
 [2018-09-08 11:29 UTC] cmb@php.net
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] <http://git.php.net/?p=php-src.git;a=commit;h=684ce24eecc5afe7ba767e721c29ef3bb191c43c>
[2] <https://github.com/php/php-src/blob/php-7.3.0beta3/ext/pcre/php_pcre.c#L840>
 [2018-09-08 19:40 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c6ddd45650c295bdf800c600e89a15c0af9a1e09
Log: Fixed bug #76850 Exit code mangled by set locale/preg_match
 [2018-09-08 19:40 UTC] ab@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC