[PHP-DEV] PHP 4.0 Bug #5323: Accessing the array returned by sybase_fetch_array() crashes php. From: miguel222 <email protected>
Date: 07/01/00

From: miguel222 <email protected>
Operating system: Redhat Linux 6.2
PHP version: 4.0.1pl2
PHP Bug Type: Sybase (dblib) related
Bug description: Accessing the array returned by sybase_fetch_array() crashes php.

The following code snippet is used in an abstract db class in an application I am writing:

~~~~~
$query=sybase_query("<SQL QUERY HERE>");
while($row=sybase_fetch_array($query)) {
   while(list($key,$val)=each($row))
      if(is_int($key)) unset($row[$key]);

   $result[]=$row;
}
return $result;
~~~~~

The code is used to get rid of [via unset()] the numeric keys in the array that syabse_fetch_array() returns. When executed, the Apache server dies from a seg fault.

gdb reports different error messages spuriously:
segfault - 0x40082501 in __kill () from /lib/libc.so.6
segfault - 0x???????? in ?????? () from /opt/sybase-11.9.2/libsybc.so

If the line containing "unset()" is removed, the crash does not occur (sometimes there is no crash, only garbled data).

If PHP is compiled with the Sybase-CT library instead, then the code works fine (unchanged), but this is unoptimal since then warnings are generated by selecting the database with sybase_connect() or sybase_select_db().

Please e-mail me if there is a solution to that problem. Also, I couldn't find any documentation on the advantages or disadvantages of DB vs CT...

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>