PHP 4.0 Bug #7632: Segmentation fault upon call to sybase_connect()
| From: | serge at panix dot com | Date: | Fri, 03 Nov 2000 23:50:20 +0000 |
| Subject: | PHP 4.0 Bug #7632: Segmentation fault upon call to sybase_connect() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37044@lists.php.net to get a copy of this message | ||
From: serge@panix.com
Operating system: Solaris 8
PHP version: 4.0.3pl1
PHP Bug Type: Sybase (dblib) related
Bug description: Segmentation fault upon call to sybase_connect()
Setup:
Host: Sun SparcServer 20 w/128Mb RAM, one CPU
O/S: Solaris 8
GCC: 2.95.2
GDB: 5.0
PHP: 4.0.3pl1
PHP Config Args: now lost after a few changes (sorry), but definetely had these:
--with-sybase=<path to sybase> --with-xml --enable-track-vars
Problem:
The following PHP script:
<?php
global $s_connection;
$s_connection = sybase_connect ( "SYBSRV", "user", "password"
)
or die("Could not make SYBASE connection");
echo "<b>Connected</b>";
sybase_close($s_connection);
?>
invoked as
/usr/local/bin/php <path to script>/test.php
always resulted in a "Segmentation fault (core dumped)." GDB stack trace showed the
following:
(gdb) bt
#0 0xef132b9c in strlen () from /usr/lib/libc.so.1
#1 0xef547ae8 in dbsetlname () from /usr/local/app/sybase/lib/libsybdb.so
#2 0x8838c in php_sybase_do_connect (ht=3, return_value=0x145d58,
this_ptr=0x0, return_value_used=1, persistent=0) at php_sybase_db.c:354
#3 0x888c8 in php_if_sybase_connect (ht=3, return_value=0x145d58,
this_ptr=0x0, return_value_used=1) at php_sybase_db.c:512
#4 0xd3038 in execute ()
#5 0xa1fe4 in zend_execute_scripts (type=8, file_count=3) at zend.c:717
#6 0x26f70 in php_execute_script (primary_file=0xeffffb88) at main.c:1200
#7 0x24ebc in main (argc=2, argv=0xeffffc14) at cgi_main.c:715
(gdb)
Stepping through ext/sybase/php_sybase_db.c:php_sybase_do_connect() with gdb showed that the
segmentation fault occured at line 354
353: if (charset) {
354: DBSETLCHARSET(sybase.login,charset);
355: }
and was caused by the uninitialized `charset' which contained an out-of-range address.
Changing the declaration of charset at line 257 from
char *user,*passwd,*host,*charset;
to
char *user,*passwd,*host,*charset=(char *)0;
and recompililng php seemed to alleviate the problem.
Thanks for looking into this,
Sergey
P.S. php_sybase_db.c's ident was
/* $Id: php_sybase_db.c,v 1.4 2000/09/03 17:43:09 derick Exp $ */
--
Edit Bug report at: http://bugs.php.net/?id=7632&edit=1