|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-02-15 15:43 UTC] khleung at isfactory dot com
Description:
------------
Having installed
php 7.4.2 on CentOS 7 1804 64-bit (3.10.0-1062.12.1.el7.x86_64) on a VMware host :
2 GB ram, 250G HardDisk and 1 CPU Core.
PHP and necessary modules are installed via yum install php and also by compiling using source from php-7.4.2.tar.gz
With SAP SDK for ASE binary file SDKASE160003P_7-21012007.TGZ installed
A testing script was prepared to check the connecting
It works fine to query a simple varchar(3) with
"SELECT name FROM sysusers ORDER BY uid ASC"
but it crashed :
SELECT name, environ FROM sysusers ORDER BY uid ASC
or even
SELECT top 1 name, environ FROM sysusers ORDER BY uid ASC
with following message:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967320 bytes) in /home/sybase/sybconnect1.php on line 16
sysusers table layout as follow
Column_name Type Length Prec Scale Nulls
----------- -------- ------ ---- ----- -----
suid int 4 NULL NULL 0
uid int 4 NULL NULL 0
gid int 4 NULL NULL 0
name char 30 NULL NULL 0
environ varchar 255 NULL NULL 1
user_status smallint 2 NULL NULL 0
via UnixODBC Client tool : isql
/bin/isql SB007H sa [sapassword]
all of the above query works perfectly without any error
Test script:
---------------
[sybase@nagioshost lib]$ vi sybconnect.php
<?php
//PDO Driver Connect to Sybase
try {
//$pdo = new PDO("odbc:Driver={Adaptive Server Enterprise};NA=lx007hsyb,5000;Uid=sa;Pwd=[sapassword];");
$pdo = new PDO("odbc:SB007H", "sa", "[sapassword]");
$pdo_status = "dsn: odbc:SB007H Connected to ASE 16\n";
echo $pdo_status;
$getUsers = $pdo->prepare('SELECT name FROM sysusers ORDER BY uid ASC');
while ($row = $stmt->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
$data = $row[0] . "\t" . $row[1] . "\t" . $row[2] . "\n";
print $data;
}
$stmt = null;
$getUsers->execute();
$users = $getUsers->fetchAll();
if ($users) {
foreach ($users as $user) {
echo $user['name']."\n";
}
} else {
trigger_error('No users.');
}
} catch(PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
:wq
Expected result:
----------------
sysusers contains only 20 rows and so it was expected
All query result set can shown
Actual result:
--------------
pdo_odnc FetchAll queries with column of varchar(255) crashed
with following message:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967320 bytes) in /home/sybase/sybconnect1.php on line 16
Patchesinit-displaysize (last revision 2020-02-23 12:04 UTC by cmb@php.net)odbc_tracelog_revised (last revision 2020-02-16 06:19 UTC by khleung at isfactory dot com) odbc_tracelog (last revision 2020-02-16 06:08 UTC by khleung at isfactory dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 11:00:01 2025 UTC |
[root@localhost ext]# cd /usr/local/src/php-7.4.2/ext/pdo_odbc/ [root@localhost pdo_odbc]# ls config.m4 CREDITS odbc_driver.lo odbc_stmt.c odbc_stmt.o pdo_odbc.lo php_pdo_odbc.h tests config.w32 odbc_driver.c odbc_driver.o odbc_stmt.lo pdo_odbc.c pdo_odbc.o php_pdo_odbc_int.h [root@localhost pdo_odbc]# vi odbc_stmt.c static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno) { pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; struct pdo_column_data *col = &stmt->columns[colno]; RETCODE rc; SWORD colnamelen; SQLULEN colsize; SQLLEN displaysize = 0; ... :wq [root@localhost pdo_odbc]# cd /usr/local/src/php-7.4.2/ [root@localhost php-7.4.2]# make /bin/sh /usr/local/src/php-7.4.2/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /usr/local/src/php-7.4.2/modules /bin/sh /usr/local/src/php-7.4.2/libtool --silent --preserve-dup-deps --mode=compile cc -I/usr/local/src/php-7.4.2/ext -I/usr/include -DPDO_ODBC_TYPE=\"unixODBC\" -Iext/pdo_odbc/ -I/usr/local/src/php-7.4.2/ext/pdo_odbc/ -DPHP_ATOM_INC -I/usr/local/src/php-7.4.2/include -I/usr/local/src/php-7.4.2/main -I/usr/local/src/php-7.4.2 -I/usr/local/src/php-7.4.2/ext/date/lib -I/usr/include/libxml2 -I/usr/local/src/php-7.4.2/TSRM -I/usr/local/src/php-7.4.2/Zend -I/usr/include -g -O2 -fvisibility=hidden -Wall -Wno-strict-aliasing -DZEND_SIGNALS -c /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c -o ext/pdo_odbc/odbc_stmt.lo /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c: In function ‘odbc_stmt_describe’: /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c:573:4: warning: pointer targets in passing argument 3 of ‘SQLDescribeCol’ differ in signedness [-Wpointer-sign] &S->cols[colno].coltype, &colsize, NULL, NULL); ^ In file included from /usr/include/sqlext.h:43:0, from /usr/include/sqlucode.h:784, from /usr/local/src/php-7.4.2/ext/pdo_odbc/php_pdo_odbc_int.h:53, from /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c:29: /usr/include/sql.h:644:24: note: expected ‘SQLCHAR *’ but argument is of type ‘char *’ SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT StatementHandle, ^ /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c: In function ‘odbc_stmt_set_param’: /usr/local/src/php-7.4.2/ext/pdo_odbc/odbc_stmt.c:781:4: warning: pointer targets in passing argument 2 of ‘SQLSetCursorName’ differ in signedness [-Wpointer-sign] rc = SQLSetCursorName(S->stmt, Z_STRVAL_P(val), Z_STRLEN_P(val)); ^ In file included from /usr/include/sqlext.h:43:0, .... Build complete. Don't forget to run 'make test'. [root@localhost php-7.4.2]# make install Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20190902/ Installing PHP CLI binary: /usr/bin/ Installing PHP CLI man page: /usr/php/man/man1/ Installing phpdbg binary: /usr/bin/ Installing phpdbg man page: /usr/php/man/man1/ Installing PHP CGI binary: /usr/bin/ Installing PHP CGI man page: /usr/php/man/man1/ Installing build environment: /usr/lib/php/build/ Installing header files: /usr/include/php/ Installing helper programs: /usr/bin/ program: phpize program: php-config Installing man pages: /usr/php/man/man1/ page: phpize.1 page: php-config.1 /usr/local/src/php-7.4.2/build/shtool install -c ext/phar/phar.phar /usr/bin ln -s -f phar.phar /usr/bin/phar Installing PDO headers: /usr/include/php/ext/pdo/ [root@localhost php-7.4.2]# exit [sybase@localhost ~]$ cd ~ [sybase@localhost ~]$ php sybconnect.php dsn: odbc:SB007H Connected to ASE 16 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967320 bytes) in /home/sybase/sybconnect.php on line 14 [sybase@localhost ~]$ which php /usr/bin/php [sybase@localhost ~]$ ls -l /usr/bin/php -rwxr-xr-x. 1 root root 32209632 Mar 8 23:34 /usr/bin/php