ID: 33167
User updated by: jsnell at networkninja dot com
Reported By: jsnell at networkninja dot com
Status: Open
Bug Type: PostgreSQL related
Operating System: Debian (dotdeb), gentoo
PHP Version: 5.0.4
New Comment:
While the snapshot solved my original case, I'm still having problems
with similar code. I haven't quite narrowed it down yet as even
changing the position of an echo seems to affect the outcome.
PHP 5.1.0-dev (cli) (built: May 28 2005 13:09:48)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies
[Switching to Thread -1213082528 (LWP 16161)]
0xb7d4f0a1 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7d4f0a1 in mallopt () from /lib/tls/libc.so.6
#1 0xb7d4ef6e in mallopt () from /lib/tls/libc.so.6
#2 0xb7d4ddcb in free () from /lib/tls/libc.so.6
#3 0x081da1e6 in shutdown_memory_manager (silent=1, full_shutdown=0)
at /usr/src/php5-src/php5-200505280230/Zend/zend_alloc.c:511
#4 0x081b677d in php_request_shutdown (dummy=0x0)
at /usr/src/php5-src/php5-200505280230/main/main.c:1248
#5 0x0825e8f0 in main (argc=2, argv=0xbfffe824)
at /usr/src/php5-src/php5-200505280230/sapi/cli/php_cli.c:1134
Previous Comments:
------------------------------------------------------------------------
[2005-05-28 20:21:11] jsnell at networkninja dot com
works fine with PHP Version 5.1.0-dev in both cgi and mod forms.
------------------------------------------------------------------------
[2005-05-28 04:47:26] jsnell at networkninja dot com
No segfault with the --enable-debug
Instead I get:
/usr/src/php5-src/php5-5.0.4/ext/pgsql/pgsql.c(1440) : Freeing
0x0856003C (16 bytes), script=breaker.php
=== Total 1 memory leaks detected ===
which is:
/usr/src/php5-src/php5-5.0.4/ext/pgsql/pgsql.c
Also, if the value is manipulated or copied in any way such as casting
to int and then recasting to float, the problem seems to go away.
------------------------------------------------------------------------
[2005-05-28 01:07:20] [EMAIL PROTECTED]
Also, try it with the latest snapshot available at http://snaps.php.net
------------------------------------------------------------------------
[2005-05-28 01:05:42] [EMAIL PROTECTED]
Please compile PHP with --enable-debug and generate GDB backtrace once
more.
------------------------------------------------------------------------
[2005-05-28 00:59:29] jsnell at networkninja dot com
Description:
------------
Calling pg_fetch_array() with the results of a division followed by
calling it with a constant causes a segfault. I have confirmed it in
both cgi and mod php 5.0.4 and also in cgi php 5.0.3.
Reproduce code:
---------------
// need a valid database to connect to
// contents don't matter
$query = 'select 1 as one';
$db_user = "your_user";
$db_password = "your_pass";
$db_name = "your_db";
$db_port = 5432;
$connect_string = "user=$db_user " .
"password=$db_password " .
"port=$db_port ".
"dbname=$db_name";
$db_link = pg_connect($connect_string);
$result = pg_exec($db_link, $query);
$i = floor(4/5);
$data = pg_fetch_array($result, $i);
$i = 0;
$data = pg_fetch_array($result, $i);
echo("No segfault");
Expected result:
----------------
No segfault
Actual result:
--------------
gdb backtrace:
#0 0x0820cf3b in _zend_hash_index_update_or_next_insert ()
#1 0x08209c53 in add_index_stringl ()
#2 0x406bee43 in zif_pg_fetch_result () from
/usr/lib/php5/20041030/pgsql.so
#3 0x406bf10f in zif_pg_fetch_array () from
/usr/lib/php5/20041030/pgsql.so
#4 0x0823c4da in zend_do_fcall_common_helper ()
#5 0x0823cb11 in zend_do_fcall_handler ()
#6 0x08224cb5 in execute ()
#7 0x08207e28 in zend_execute_scripts ()
#8 0x081d8bca in php_execute_script ()
#9 0x0824c3f4 in main ()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33167&edit=1