[php-src] Issue #9298: PHP segfaults if pcntl is built as shared module

From: Date: Thu, 11 Aug 2022 15:02:08 +0000
Subject: [php-src] Issue #9298: PHP segfaults if pcntl is built as shared module
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242179@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9298 Author: hasso ### Description The following code: ```php <?php declare(strict_types = 1); function sigalrm() { } while (true) { pcntl_signal(SIGALRM, "sigalrm", false); $pid = pcntl_fork(); if ($pid < 0) { printf("pcntl_fork() failed\n"); exit(-1); } if ($pid == 0) { exit(0); } else { while (true) { posix_kill($pid, SIGALRM); $pid = pcntl_wait($st, WNOHANG); if ($pid > 0) { break; } } if (pcntl_wifsignaled($st)) { $signo = pcntl_wtermsig($st); if ($signo != SIGALRM) { printf("##### Worker killed by signal %d ####\n", $signo); exit(0); } } printf("Worker exited normally\n"); } } ``` Resulted in this output: ``` ##### Worker killed by signal 11 #### ``` But I expected this output instead: ``` Worker exited normally Worker exited normally Worker exited normally Worker exited normally ... ``` The problem only appears if pcntl is built as shared module (--enable-pcntl=shared). There is no problem if pcntl support is built in (--enable-pcntl). ### PHP Version PHP 8.1.9 ### Operating System Debian GNU/Linux 11 (bullseye)

« previous php.bugs (#242179) next »