Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP FPM exit with signal 8 (SIGFPE - core dumped) #141

Closed
oxycoder opened this issue Aug 26, 2016 · 6 comments
Closed

PHP FPM exit with signal 8 (SIGFPE - core dumped) #141

oxycoder opened this issue Aug 26, 2016 · 6 comments

Comments

@oxycoder
Copy link

OS: Ubuntu 16.04 with Nginx
Driver: 4.0.3
Tested on PHP-FPM 7.0.8 and 7.0.10 give same result

unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/frost/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

/var/log/php7.0-fpm.log

[26-Aug-2016 00:55:17] WARNING: [pool www] child 72407 exited on signal 8 (SIGFPE - core dumped) after 1064.849232 seconds from start
[26-Aug-2016 00:55:17] NOTICE: [pool www] child 72657 started

/var/log/syslog
Aug 26 00:55:13 api kernel: [ 5691.115511] traps: php-fpm7.0[72407] trap divide error ip:7f2fb56b6cec sp:7ffeaa469b10 error:0 in php_pdo_sqlsrv_7_nts.so[7f2fb565a000+8d000]

This error will return 502 Bad Gateway on nginx because PHP process crash. It happen with Update query.

@oxycoder oxycoder changed the title PHP FPM exit with signal 8 (SIGFPE - core dumped)) PHP FPM exit with signal 8 (SIGFPE - core dumped) Aug 26, 2016
@savvior
Copy link

savvior commented Aug 26, 2016

Similar issue with Apache2 on Ubuntu 16.04 using the 4.0.3 drivers. Definitely broken with parameterized update queries.

[Fri Aug 26 11:10:27.531094 2016] [core:notice] [pid 21449] AH00051: child pid 23078 exit signal Floating point exception (8), possible coredump in /etc/apache2
[Fri Aug 26 11:10:56.557670 2016] [core:notice] [pid 21449] AH00051: child pid 21615 exit signal Segmentation fault (11), possible coredump in /etc/apache2

@meet-bhagdev
Copy link
Contributor

@oxycoder @savvior We will look into this.

@meet-bhagdev
Copy link
Contributor

@oxycoder @savvior Can you share a repro script and a schema that we can use to reproduce this in our test lab?

@oxycoder
Copy link
Author

oxycoder commented Sep 1, 2016

I just start wrote a small script to reproduce this problem on my vmware, I realize that I have a mistake on my code (As driver 4.0.2 and before, the code still work)

<?php
$user = 'sa';
$pass = '123';
$out1 = '';
$out2 = '';
try {
    $db = new PDO("sqlsrv:Server=10.0.1.50,1433;Database=TestDB", $user, $pass);
    $sth = $db->prepare("EXEC [dbo].Create_Account ?, ?, ?");
    $sth->bindValue(1, 'tester00001');
    $sth->bindValue(2, '123456');
    $sth->bindValue(3, '[email protected]');
    $sth->bindValue(4, $out1);
    $sth->bindValue(5, $out2);
    $sth->execute();
    echo $out1 . '\n';
    echo $out2 . '\n';
} catch(Exception $e) {
    var_dump($e);
}
?>
ALTER PROC [dbo].[Create_Account]
    @username   nvarchar(50),
    @password nvarchar(50),
    @email nvarchar(255),
    @order_idx      int OUTPUT,
    @v_error        tinyint OUTPUT
AS
SET NOCOUNT ON
BEGIN TRAN
    INSERT users (username, password, email) VALUES (@username, @password, @email)
    SET @order_idx = 1
    SET @v_error = 1
COMMIT TRAN

From the stored procedure above, the output return has type int, but in my php code, I define it as ''.
After change the value to int, the error gone away and php process stop crash.

$out1 = 0;
$out2 = 0;

@oxycoder
Copy link
Author

oxycoder commented Sep 2, 2016

Another problem about empty string can make php-fpm process crash too, the log from system also about "trap divide error"

ALTER PROC [dbo].[Update_Account]
    @username   nvarchar(50),
    @password nvarchar(50),
    @email nvarchar(255),
    @last_login datetime,
    @order_idx      int output,
    @v_error        tinyint OUTPUT
AS
SET NOCOUNT ON
BEGIN TRAN
UPDATE users SET password = @password, email = @email, last_login = @last_login WHERE username = @username
SET @order_idx = 1
SET @v_error = 1
COMMIT TRAN

PHP code

<?php
$user = 'sa';
$pass = '123';
$out1 = 0;
$out2 = 0;
try {

    $db = new PDO("sqlsrv:Server=10.0.1.50,1433;Database=TestDB", $user, $pass);
    $sth = $db->prepare("EXEC [dbo].Update_Account ?, ?, ?, ?");
    $sth->bindValue(1, 'tester00001');
    $sth->bindValue(2, ''); // PHP-FPM crash
    $sth->bindValue(3, '[email protected]');
    $sth->bindValue(4, '2022-01-01 00:00:00.000');
    $sth->bindValue(5, $out1);
    $sth->bindValue(6, $out2);
    $sth->execute();
    echo $out1 . '\n';
    echo $out2 . '\n';

} catch(Exception $e) {
    var_dump($e);
}
?>

Workaround this problem:

$sth->bindValue(2, "''"); // wrap single quote with double quote

@meet-bhagdev
Copy link
Contributor

@oxycoder both the issues referenced above are fixed by our latest release: https://github.com/Microsoft/msphpsql/releases/tag/4.0.4-Linux. Can you help us verify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants