Bug #78272 [NEW]: calling preg_match() before pcntl_fork() will freeze child process

From: Date: Wed, 10 Jul 2019 15:32:54 +0000
Subject: Bug #78272 [NEW]: calling preg_match() before pcntl_fork() will freeze child process
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221690@lists.php.net to get a copy of this message
From:             dams
Operating system: OSX
PHP version:      7.3.7
Package:          PCRE related
Bug Type:         Bug
Bug description:calling preg_match() before pcntl_fork() will freeze child process

Description:
------------
When preg_match (or another preg_*function) has been called before
pcntl_fork(), and then, called again in the child process, the child
process stops at the preg_match, and just hangs. 

No error, no crash. 

This was tested on OSX, and it couldn't be replicated on Debian. This
may be specific to OSX.


It is reproductible with PHP 7.3.7. It works on 7.2, 7.1.

It may be related to https://bugs.php.net/bug.php?id=77260 

Test script:
---------------
<?php
// Uncomment the following to freeze child process
//        preg_match('/abc/', 'abcde', $r);

        $pid = pcntl_fork();
        if ($pid === 0) {
            print "Child start\n";
            preg_match('/abc/', 'abcde', $r);
            print_r($r);
            print "End child\n";
            exit(0);
        } else {
            print "Main start\n";
            sleep(3);
            print "End Main\n";
            exit(0);
        }
?>

Expected result:
----------------
Main start
Child start
Array
(
    [0] => abc
)
End child
End Main

Actual result:
--------------
Main start
Child start
End Main

-- 
Edit bug report at https://bugs.php.net/bug.php?id=78272&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=78272&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=78272&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=78272&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=78272&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=78272&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=78272&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=78272&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=78272&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=78272&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=78272&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=78272&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=78272&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=78272&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78272&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=78272&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=78272&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=78272&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78272&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=78272&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=78272&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#221690) next »