Skip to content

php_cli Segmentation fault #8950

Closed as not planned
Closed as not planned
@TheOneThingSpecial

Description

@TheOneThingSpecial

Description

The following code:
Sometimes when I run php script using php command,I get a Segmentation fault.
I don't know why.so I need some help!

<?php
require_once "/var/www/html/function.php";
require_once "/var/www/html/send_sms.php";
global $DB;
$path = '/var/www/html//times/';
$fileName = 'sendTimes.json';
$sql = "SELECT DeviceID,Tel,AdminID FROM  TSMSCode GROUP BY DeviceID,Tel,AdminID";
$res = $DB->getFetchAll($sql);
if (!file_exists($path . $fileName)) {
    cutil_php_debug("File not exist ,Quit!", 'SmsLimitReset');
    exit;
}
$sendSMS = AjaxSend_SMS::recordSMSTimes($sendSMS, 1);
if (is_array($res) && count($res) > 0) {
    foreach ($res as $index => $smsVal) {
        $id = 0;
        $SendType = $smsVal['AdminID'] > 0 ? 'admin' : 'user';
        if ($SendType === 'admin') {
            $id = $smsVal['AdminID'];
        } else {
            $id = $smsVal['DeviceID'];
        }

        if (isset($sendSMS[$SendType][$id][$smsVal['Tel']])
            && $sendSMS[$SendType][$id][$smsVal['Tel']]['expired'] < time()
            && $sendSMS[$SendType][$id][$smsVal['Tel']]['usedTimes'] >= AjaxSend_SMS::getSendTimes('times')) {
            $sendSMS[$SendType][$id][$smsVal['Tel']] = AjaxSend_SMS::defaultSmsLimit();
            // print_r($sendSMS);
            AjaxSend_SMS::recordSMSTimes($sendSMS);
            cutil_php_debug("Reset Device :" . $smsVal['DeviceID'] . " Tel:" . $smsVal['Tel'], 'SmsLimitReset');
        }
    }
}


Resulted in this output:
![image](https://user-images.githubusercontent.com/14242762/177926637-29e1c6d9-475f-4357-a6ef-dcf80d272b8a.png)

But I expected this output instead:
run success!

there is a core dump file:
[core.php.1498679.11.zip](https://github.com/php/php-src/files/9069261/core.php.1498679.11.zip)

I have tried using gdb command to analyze core dump file,but I still don't know why.
I hope the screenshots below are of some help to you:
![image](https://user-images.githubusercontent.com/14242762/177928126-937f3e56-d16c-4c72-b4e1-49ddb6005f7f.png)
![image](https://user-images.githubusercontent.com/14242762/177929064-917c0167-e9e5-4474-afea-fed24707b299.png)



### PHP Version

PHP 7.3.24

### Operating System

Centos 6.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions