php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77547 ibm_db2 test 147 fails on PHP 7.1 with ZTS enabled
Submitted: 2019-01-30 21:08 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kadler at us dot ibm dot com Assigned:
Status: Open Package: ibm_db2 (PECL)
PHP Version: 7.1.26 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kadler at us dot ibm dot com
New email:
PHP Version: OS:

 

 [2019-01-30 21:08 UTC] kadler at us dot ibm dot com
Description:
------------
It seems that on php 7.1 (and only on 7.1), with ZTS when you assign a literal value to a variable, you do not get a copy, but a reference. Thus, when we bind to that variable and change it, the *referenced literal itself* is changed! You can see this with the output:

Expected output:

date before 2002-10-20
date after 1982-01-24
date before 2002-10-20
date after 1982-01-24
date before 2002-10-20
date after 1982-01-24

Actual output:

date before 2002-10-20
date after 1982-01-24
date before 1982-01-24
date after 1982-01-24
date before 1982-01-24
date after 1982-01-24

After the first execution of the loop, the underlying literal value "2002-10-20" on line 28 has been changed to "1982-01-24".

Test script:
---------------
<?php
    require_once('connection.inc');
    $conn = db2_connect($database, $user, $password);

    @db2_exec( $conn , "DROP PROCEDURE test147proc" );
    db2_exec( $conn , "CREATE PROCEDURE test147proc ( OUT p5 DATE)
                           LANGUAGE SQL
                           BEGIN
                             SET p5 = '24.01.1982';
                           END" );

    db2_commit( $conn );

    $prep = db2_prepare($conn, "CALL test147proc (?)");
    for( $i=1 ; $i<=3; $i++ ){
        $p5 = "2002-10-20";
        assert($p5 == "2002-10-20");

        db2_bind_param($prep, 1, 'p5', DB2_PARAM_OUT, DB2_CHAR);

        $result = db2_execute($prep);
    }
    db2_close( $conn );
?>


Expected result:
----------------
Test should run without assertion warnings.

Actual result:
--------------
Assertion warnings are printed:

Warning: assert(): assert($p5 == '2002-10-20')

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-30 21:19 UTC] kadler at us dot ibm dot com
I believe that there are more bugs related to how refcounted variables are handled in PHP 7 in this module. For instance:

$p5 = "2002-10-20";
$p6 = $p5;

db2_bind_param($prep, 1, 'p5', DB2_PARAM_OUT, DB2_CHAR);
$result = db2_execute($prep);

assert($p6 == "2002-10-20");

This will fail on PHP 7.0 and 7.1 with ZTS enabled, though it seems to be fine on PHP 7.2. Without ZTS enabled, it succeeds on all releases.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 14:01:32 2024 UTC