php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5323 Accessing the array returned by sybase_fetch_array() crashes php.
Submitted: 2000-07-02 01:20 UTC Modified: 2001-06-12 17:37 UTC
From: miguel222 at mindless dot com Assigned:
Status: Closed Package: Sybase (dblib) related
PHP Version: 4.0.1pl2 OS: Redhat Linux 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 - 36 = ?
Subscribe to this entry?

 
 [2000-07-02 01:20 UTC] miguel222 at mindless dot 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...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-04 22:04 UTC] joey at cvs dot php dot 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-27 20:19 UTC] waldschrott@php.net
awaiting feedback since 07-04
 [2000-07-27 22:22 UTC] miguel222 at mindless dot 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?
 [2001-05-14 12:02 UTC] joey@php.net
This has now become #5684
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC