php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74114 undefined symbol: Z_STRVAL_PP
Submitted: 2017-02-16 21:56 UTC Modified: 2017-03-08 21:27 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: neyman dot neil dot e at dol dot gov Assigned:
Status: Open Package: PDO_IBM (PECL)
PHP Version: 7.0.16 OS: RHEL 6.8
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: neyman dot neil dot e at dol dot gov
New email:
PHP Version: OS:

 

 [2017-02-16 21:56 UTC] neyman dot neil dot e at dol dot gov
Description:
------------
In ibm_driver.c, around line 985:


+#if PHP_MAJOR_VERSION >= 7
+                        if (Z_TYPE(data) == IS_STRING) {
+#else  
                        if (Z_TYPE_PP(data) == IS_STRING) {
+#endif
                                option_str = Z_STRVAL_PP(data);
                        } else {


The opt_str = Z_STR_PP(data) after the endif fails on php 7.  The module compiles, but when I include the module in php.ini, there is an error when running php 7:  "undefined symbol: Z_STRVAL_PP" and the pdo_ibm module will not load.



Test script:
---------------
I tried replacing with:  

#if PHP_MAJOR_VERSION >= 7
                        if (Z_TYPE(data) == IS_STRING) {
                              option_str = Z_STRVAL_P(*data);

#else
                        if (Z_TYPE_PP(data) == IS_STRING) {
                               option_str = Z_STRVAL_PP(data);

#endif
                        } else {


And in this case the module loads without that error, but not sure if it is correct.  It seems definitely must not have the Z_STRVAL_PP after the endif or it will still load in php version >= 7.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-21 12:49 UTC] fred dot demarcy dot ml at gmail dot com
Experiencing same problem.
I can get the code to compile using:

#if PHP_MAJOR_VERSION >= 7
                        if (Z_TYPE(data) == IS_STRING) {
                              option_str = Z_STRVAL_P(*data);

#else
                        if (Z_TYPE_PP(data) == IS_STRING) {
                               option_str = Z_STRVAL_PP(data);

#endif
                        } else {

but then this causes segmentation fault... executing on the cli or in Apache

Script:
<?php
try
{
    $db= new PDO("ibm:DATABASE=GEN1;HOSTNAME=10.78.10.16;PORT=50000;", "admin", "bluebird456", array(PDO::ATTR_CASE=> PDO::CASE_NATURAL));
}
catch(PDOException $e)
{
	die("Connection error: ".$e->getMessage());
}

$attributes = array(
    "AUTOCOMMIT", "ERRMODE", "CASE", "CLIENT_VERSION", "CONNECTION_STATUS",
    "ORACLE_NULLS", "PERSISTENT", "PREFETCH", "SERVER_INFO", "SERVER_VERSION",
    "TIMEOUT"
);

foreach ($attributes as $val) {
    echo "PDO::ATTR_$val: ";
    echo $db->getAttribute(constant("PDO::ATTR_$val")) . "\n";
}

?>


# strace php <script>.php
...
access("/home/db2inst1/sqllib/cfg/db2dsdriver.cfg", F_OK) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/db2inst1/sqllib/cfg/db2cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
semget(0x52dfa674, 1, 0)                = -1 ENOENT (No such file or directory)
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f779d086000
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f779d046000
semget(0x52dfa674, 1, 0)                = -1 ENOENT (No such file or directory)
semget(0x52dfa674, 1, 0)                = -1 ENOENT (No such file or directory)
semget(0x52dfa674, 1, 0)                = -1 ENOENT (No such file or directory)
semget(0x52dfa674, 1, 0)                = -1 ENOENT (No such file or directory)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

In Apache I get:
[Tue Feb 21 12:35:56.815597 2017] [core:notice] [pid 4737] AH00052: child pid 11607 exit signal Segmentation fault (11)
 [2017-02-22 19:26 UTC] neyman dot neil dot e at dol dot gov
Possibly the segfault is related to Bug #72424...

I was able to successfully connect using "fred's" test script if I removed the options parameter from the connection string

$db= new PDO("ibm:DATABASE=$database;HOSTNAME=$hostname;PORT=$port;", $user, $password);

But also get the segfault when I add options to end of the PDO array.
 [2017-02-23 15:53 UTC] fred dot demarcy dot ml at gmail dot com
Indeed without the options parameter from the connection string I can connect as well! Good catch :-)


$ php DB2-Fred-Test.php
PDO::ATTR_AUTOCOMMIT: 1
PDO::ATTR_ERRMODE: 0
PDO::ATTR_CASE: 1
PDO::ATTR_CLIENT_VERSION: 1.3.4
PDO::ATTR_CONNECTION_STATUS: PHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30
PHP Stack trace:
PHP   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
PHP   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30

Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30

Call Stack:
    0.0005     353728   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
    1.5188     357416   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30


PDO::ATTR_ORACLE_NULLS: 0
PDO::ATTR_PERSISTENT:
PDO::ATTR_PREFETCH: PHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30
PHP Stack trace:
PHP   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
PHP   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30

Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30

Call Stack:
    0.0005     353728   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
    1.5199     357416   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30


PDO::ATTR_SERVER_INFO: DB2/NT64
PDO::ATTR_SERVER_VERSION: PHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30
PHP Stack trace:
PHP   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
PHP   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30

Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30

Call Stack:
    0.0005     353728   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
    1.5209     357416   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30


PDO::ATTR_TIMEOUT: PHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30
PHP Stack trace:
PHP   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
PHP   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30

Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /home/freds/Downloads/DB2-Fred-Test.php on line 30

Call Stack:
    0.0005     353728   1. {main}() /home/freds/Downloads/DB2-Fred-Test.php:0
    1.5210     357416   2. PDO->getAttribute() /home/freds/Downloads/DB2-Fred-Test.php:30

The question is when will this get fixed?
 [2017-03-08 21:27 UTC] pollita@php.net
Unfortunately, this is far from the only bug in PDO_IBM's PHP7 implementation.  While I could apply your patch, there's no way the extension will actually function in PHP 7 or later as is.

As such I'd recommend contacting the package maintainer which is opendev@us.ibm.com according to https://pecl.php.net/package/PDO_IBM
 [2018-06-07 14:30 UTC] ronyan at outlook dot com
See a workaround: ( pdo_ibm 1.3.5 ) ibm_driver.c:



980 #if PHP_MAJOR_VERSION >= 7
981                         if (Z_TYPE_P(data) == IS_STRING) {
982 #else	
983 			if (Z_TYPE_PP(data) == IS_STRING) {
984 #endif
985 				option_str = Z_STRVAL_PP(data); // <--- this line
986 			} else {
987 #if PHP_MAJOR_VERSION >= 7
988 				option_num = Z_LVAL_P(data);
989 #else
990 				option_num = Z_LVAL_PP(data);
991 #endif
992 			}

FIX:

981 #if PHP_MAJOR_VERSION >= 7
982                         if (Z_TYPE_P(data) == IS_STRING) {
983 #else	
984 			if (Z_TYPE_PP(data) == IS_STRING) {
985 #endif
986 //------------- fix ---------------
987 #if PHP_MAJOR_VERSION >= 7
988 				option_str = Z_STRVAL_P(data);
989 #else
990 				option_str = Z_STRVAL_PP(data);
991 #endif
    //------------- end fix ---------------
992 			} else {
993 #if PHP_MAJOR_VERSION >= 7
994 				option_num = Z_LVAL_P(data);
995 #else
996 				option_num = Z_LVAL_PP(data);
997 #endif
998 			}
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri May 24 13:01:27 2019 UTC