Segfault in PHP without php error log. How to debug?

1

I have a script using com_dotnet, that makes PHP segfault (not sure if segfault is the technical correct term) under certain circumstances.

Using PHP 7.4.2 NTS 32bit on Windows 2019 64bit. The same error happens when using FCGI or CLI. The same script worked will with PHP 7.0.30. In case of FCGI, only this error is in the Apache log:

[...] [fcgid:warn] [pid ...] (OS 109)The pipe has been ended.  : [client ...] mod_fcgid: get overlap result error
[...] [fcgid:warn] [pid ...] (OS 109)The pipe has been ended.  : [client ...] mod_fcgid: ap_pass_brigade failed in handle_request_ipc function

In the event log, Application log, there is an Application Error event with id 1000:

Faulting application name: php-cgi.exe, version: 7.4.2.0, time stamp: 0x5e273bd1
Faulting module name: php7.dll, version: 7.4.2.0, time stamp: 0x5e274c52
Exception code: 0xc0000005
Fault offset: 0x004a1554
Faulting process id: 0x1d3c
Faulting application start time: 0x01d5e7035b9ba103
Faulting application path: F:\wamp\bin\php\php7.4.2nts86\php-cgi.exe
Faulting module path: F:\wamp\bin\php\php7.4.2nts86\php7.dll
Report Id: 83f813df-1bda-48f9-89f6-2374f9b04af5
Faulting package full name: 
Faulting package-relative application ID:

And event 1001 Windows Error Reporting

Fault bucket 1785407568804712926, type 1
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: php-cgi.exe
P2: 7.4.2.0
P3: 5e273bd1
P4: php7.dll
P5: 7.4.2.0
P6: 5e274c52
P7: c0000005
P8: 004a1554
P9: 
P10: 

Attached files:
[Temp files no longer on disk]

These files may be available here:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_php-cgi.exe_db93fdd1eb9fce3ac32a6e96e418914fb9fca_32a55e52_0a30ae4b

Analysis symbol: 
Rechecking for solution: 0
Report Id: 83f813df-1bda-48f9-89f6-2374f9b04af5
Report Status: 268435456
Hashed bucket: 85fc32c6322e070cd8c70ab96de611de
Cab Guid: 0

The WER\ReportArchive-file does not seem to contain interesting data.

I was not able to locate the exact place in the code where the fault is happening. It happens while reading data using the com_dotnet module.

if($this->statement->State == 1){
    $result = [];
    while(!$this->statement->EOF) {
        $row = [];
        for( $x = 0; $x < $this->statement->Fields->Count; $x++) {
            $name = $this->statement->Fields[$x]->Name;
            $value = $this->statement->Fields[$x]->Value;
            $row[$name] = $value;
        }
        $this->statement->MoveNext();
        $result[] = $row;
    }
    return $result;
}

The fault appears all tested data sources as soon as I read more than 9000 to 9500 rows. It does not seem to be related to the data itself.

The minimum code that leads to a fault is:

if($this->statement->State == 1){
    $result = [];
    while(!$this->statement->EOF) {
        $row = [];
        $row[] = '';                   // <==
        $this->statement->MoveNext();
        $result[] = $row;              // <==
    }
    return $result;
}

There is no fault when I remove either of the two lines marked with an arrow. Here the content of $result and the com-object are completely unrelated, and even so, PHP faults if there are more than 9000 loops. The number of lines leading to the fault does not seem to change neither with the data source, neither between the two code snippets above.

This here interestingly does not fault, even though $row = ['']; is functionally equivalent to $row = []; $row[] = ''; (above).

if($this->statement->State == 1){
    $result = [];
    while(!$this->statement->EOF) {
        $row = [''];
        $this->statement->MoveNext();
        $result[] = $row;
    }
    return $result;
}

Here I'm at the end of my knowledge. Things do not seem to behave logically anymore. How could I narrow down the problem ? Any advice ?

Edit: PHP 7.3.15 is not affected, only PHP 7.4.2.

php
segmentation-fault
php-extension
asked on Stack Overflow Feb 20, 2020 by Lorenz Meyer • edited Feb 20, 2020 by Lorenz Meyer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0