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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 18:01:28 2024 UTC