Re: SEGV support for run-tests
| From: | Ferenc Kovacs | Date: | Thu, 03 Jul 2014 11:06:13 +0000 |
| Subject: | Re: SEGV support for run-tests | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75213@lists.php.net to get a copy of this message | ||
hm, how does that work?
I can comfirm that we indeed end up with 128+signum exit code, I just fail
to see why.
On Thu, Jul 3, 2014 at 12:19 PM, Michael Wallner <mike@php.net> wrote:
> Now I see; run-tests does several "unset foo;" before the actual command,
> we end up with the signo(+128) as exitcode of the shell.
>
>
> On 3 July 2014 12:05, Michael Wallner <mike@php.net> wrote:
>
>> Your case is actually already be handled by run-tests:
>> Termsig=11 sould be appended to the test's output.
>>
>> if ($stat['signaled']) {
>> $data .= "\nTermsig=" . $stat['stopsig'];
>> }
>>
>>
>> On 3 July 2014 11:57, Michael Wallner <mike@php.net> wrote:
>>
>>> Seems about true. I wonder why that's not the case in the run-tests
>>> environment...
>>>
>>>
>>> On 3 July 2014 11:40, Ferenc Kovacs <tyrael@php.net> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Thu, Jul 3, 2014 at 11:23 AM, Michael Wallner <mike@php.net> wrote:
>>>>
>>>>> On 3 July 2014 11:18, Ferenc Kovacs <tyrael@php.net> wrote:
>>>>>
>>>>>> hi,
>>>>>>
>>>>>> I think the patch is wrong.
>>>>>> from my experience, when a proc_opened process is killed via a signal
>>>>>> (before you had a chance to proc_close() it) then the exitcode reported by
>>>>>> proc_close() and proc_get_status() will be -1, but
>>>>>> proc_get_status()["signaled"] will be true and
>>>>>> proc_get_status()["termsig"]
>>>>>> will have the signalcode of the signal which terminated the process(11 for
>>>>>> sigsegv).
>>>>>>
>>>>>
>>>>> This worked:
>>>>>
>>>>> --TEST--
>>>>> segfault
>>>>> --SKIPIF--
>>>>> <?php extension_loaded("posix") or die("skip need
>>>>> posix\n");
>>>>> --FILE--
>>>>> <?php
>>>>> echo "before\n";
>>>>> posix_kill(posix_getpid(),11);
>>>>> echo "after\n";
>>>>> ?>
>>>>> ===DONE===
>>>>> --EXPECTF--
>>>>> before
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Mike
>>>>>
>>>>
>>>> [tyrael@Ferencs-MacBook-Pro-135 php-src.git (PHP-5.4 ✗)]$ cat test.php
>>>> <?php
>>>> $descriptorspec = array(
>>>> 0 => array("pipe", "r"), // stdin is a pipe that the
>>>> child will
>>>> read from
>>>> 1 => array("pipe", "w"), // stdout is a pipe that the
>>>> child will
>>>> write to
>>>> 2 => array("file", "/tmp/error-output.txt",
>>>> "a") // stderr is a file
>>>> to write to
>>>> );
>>>>
>>>> $cwd = '/tmp';
>>>> $env = array();
>>>>
>>>> $process = proc_open(PHP_BINARY.' '.__DIR__.'/test2.php',
>>>> $descriptorspec, $pipes, $cwd, $env);
>>>> sleep(1);
>>>> $status = proc_get_status($process);
>>>> $exitCode = proc_close($process);
>>>> var_dump($exitCode);
>>>> var_dump($status);
>>>> [tyrael@Ferencs-MacBook-Pro-135 php-src.git (PHP-5.4 ✗)]$ cat test2.php
>>>> <?php
>>>> echo "before\n";
>>>> posix_kill(posix_getpid(),11);
>>>> echo "after\n";
>>>> ?>
>>>> [tyrael@Ferencs-MacBook-Pro-135 php-src.git (PHP-5.4 ✗)]$
>>>> ./sapi/cli/php test.php
>>>> int(-1)
>>>> array(8) {
>>>> ["command"]=>
>>>> string(94) "/Users/tyrael/checkouts/php-src.git/sapi/cli/php
>>>> /Users/tyrael/checkouts/php-src.git/test2.php"
>>>> ["pid"]=>
>>>> int(9158)
>>>> ["running"]=>
>>>> bool(false)
>>>> ["signaled"]=>
>>>> bool(true)
>>>> ["stopped"]=>
>>>> bool(false)
>>>> ["exitcode"]=>
>>>> int(-1)
>>>> ["termsig"]=>
>>>> int(11)
>>>> ["stopsig"]=>
>>>> int(0)
>>>> }
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Mike
>>>
>>
>>
>>
>> --
>> Regards,
>> Mike
>>
>
>
>
> --
> Regards,
> Mike
>