Bug #5323 Updated: Accessing the array returned by sybase_fetch_array() crashes php.
| From: | joey@php.net | Date: | Mon, 14 May 2001 16:02:40 +0000 |
| Subject: | Bug #5323 Updated: Accessing the array returned by sybase_fetch_array() crashes php. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-55184@lists.php.net to get a copy of this message | ||
ID: 5323
Updated by: joey
Reported By: miguel222@mindless.com
Old-Status: Analyzed
Status: Duplicate
Bug Type: Sybase (dblib) related
Operating system:
PHP Version: 4.0.1pl2
Assigned To:
Comments:
This has now become #5684
Previous Comments:
---------------------------------------------------------------------------
[2000-07-27 22:22:23] miguel222@mindless.com
I've switched to CT-Lib; data corruption is gone, BUT... the call to ct_con_alloc() fails
frequently... in ext/php_sybase_ct.c, the line that reads:
if(ct_con_alloc(...) != CS_SUCCEED) {
phperror(E_WARNING, "Unable to allocate connection record...");
}
~(not a verbatim description)~
Is getting executed. I can't get php, sybase, or linux to give me any more information...
Perhaps CT-Lib has verbose error reporting that I could build in right here?
---------------------------------------------------------------------------
[2000-07-27 20:19:02] waldschrott@php.net
awaiting feedback since 07-04
---------------------------------------------------------------------------
[2000-07-04 22:04:30] joey@cvs.php.net
There have been some changes to the DB-Lib in recent CVS.
DB-Lib has been very unreliable since 4.0 beta 1, but Zeev
is trying to fix it. Can you try the CVS and see if it works?
Reason(s) to use CT-Lib instead of DB-Lib:
1) DB-Lib is no longer supported by Sybase and will eventually
go away.
2) DB-Lib does not have, for example, sybase_num_rows(). You
have to do a second query ("select count(*)") to get this information.
3) The error messages in CT-Lib are more configurable. You can turn
down the min_severity_level with sybase.min_message_severity and
friends in your php.ini. This will make the warnings go away, while still
letting you see the stuff that you need to.
---------------------------------------------------------------------------
[2000-07-02 01:20:14] miguel222@mindless.com
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...
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=5323&edit=2