php.net |  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
Description:
------------
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:
---------------
<?php
  //parentProcess.php
  echo "Starting inside of ".__FILE__."\n";
  $args = array(
    dirname(__FILE__).'/childProcess.php',
    'myParam'
  );
  pcntl_exec('/usr/local/bin/php', $args);
  echo "Back inside of ".__FILE__."\n"; // should never execute
?>

<?php
  //childProcess.php
  echo "Now inside of ".__FILE__."\n";
  print_r($argv);
?>

Expected result:
----------------
Starting inside of /path/to/parentProcess.php
Now inside of /path/to/childProcess.php
Array
(
    [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 Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: 0x000000000000000d, 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   ???                           	0x0000000100adf1c1 0 + 
4306366913
1   ???                           	0x0000000100ae076f 0 + 
4306372463
2   ???                           	0x0000000100ae0a1c 0 + 
4306373148
3   ???                           	0x0000000100adf04d 0 + 
4306366541

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: 
0x0000000100ae2708

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

 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-18 18:18 UTC] lbarnaud@php.net
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
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php 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-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 13:01:24 2020 UTC