|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48002 pcnt_exec() called on php binary with parameters crashes
Submitted: 2009-04-17 07:03 UTC Modified: 2009-04-19 22:54 UTC
From: smeves at gmail dot com Assigned:
Status: Closed Package: PCNTL related
PHP Version: 5.2.9 OS: Mac OS 10.5.6
Private report: No CVE-ID: None
 [2009-04-17 07:03 UTC] smeves at gmail dot com
A call to pcntl_exec($path, $args) where $path is the path to the php 
binary (ie '/usr/bin/php') causes a segmentation fault if $args contains 
more than one element (the first element in $args is the full path to 
the a php source file).

Calling pcntl_exec() directly on a php file with the #!/usr/bin/php 
header causes the same problem, and in this case the the only way to 
avoid a segmentation fault is if $args is an empty array (in other 
words, if *no* parameters are passed to the php script).

A workaround is to call pcntl_exec($path, $args) where $path is 
'/bin/sh', and $args is array('-c', 'executablePhp.php param1 
param2'). However, if more than 3 params are passed into the 
executablePhp file, a segmentation fault occurs.

Reproduce code:
  echo "Starting inside of ".__FILE__."\n";
  $args = array(
  pcntl_exec('/usr/local/bin/php', $args);
  echo "Back inside of ".__FILE__."\n"; // should never execute

  echo "Now inside of ".__FILE__."\n";

Expected result:
Starting inside of /path/to/parentProcess.php
Now inside of /path/to/childProcess.php
    [0] => /path/to/childProcess.php
    [1] => myParam

Actual result:
Starting inside of /path/to/parentProcess.php
Segmentation fault

// inside my crash log:
Process:         php [9209]
Path:            /usr/local/bin/php
Identifier:      php
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  bash [3413]

Date/Time:       2009-04-17 02:48:06.303 -0400
OS Version:      Mac OS X 10.5.6 (9G55)
Report Version:  6

Exception Codes: 0x000000000000000d, 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   ???                           	0x0000000100adf1c1 0 + 
1   ???                           	0x0000000100ae076f 0 + 
2   ???                           	0x0000000100ae0a1c 0 + 
3   ???                           	0x0000000100adf04d 0 + 

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000041  rbx: 0x00007fff5fbfff10  rcx: 
0x0000000000000000  rdx: 0x0000000000000014
  rdi: 0x0000000100ae2708  rsi: 0x636f6c2f7273752f  rbp: 
0x00007fff5fbffe50  rsp: 0x00007fff5fbffe50
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 
0x0000000000000000  r11: 0x0000000000000000
  r12: 0x0000000000000014  r13: 0x0000000100ae2708  r14: 
0x0000000000000015  r15: 0x0000000000000000
  rip: 0x0000000100adf1c1  rfl: 0x0000000000010293  cr2: 

Binary Images:
    0x7fff5fc00000 -     0x7fff5fc2e643  dyld 97.1 (???) 
<b40847f1ce1ba2ed13837aeccbf19284> /usr/lib/dyld



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-18 18:18 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read for *NIX and for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

Thanks for your report. Could you please send a backtrace with debug symbols ?
 [2009-04-19 22:54 UTC] smeves at gmail dot com
I ran the same source with sudo and the segmentation fault went away, so 
I assume this error is due to incorrect permissions in the php 
installation and not a bug with PHP itself. I am sorry to waste your 
time with this. The mystery remains what library had incorrect 
permissions, but that is my problem, not yours!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 06:01:31 2024 UTC