ID:               20927
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         PostgreSQL related
 Operating System: Red Hat Linux 8.0 on Intel
 PHP Version:      4.3.0RC2
 New Comment:

It crashs with PHP 4.2.2 because it runs in Apache 2.

The PSQL lib ist most probably not thread safe.


Previous Comments:
------------------------------------------------------------------------

[2002-12-11 09:55:43] [EMAIL PROTECTED]

I disagree.  The bug *IS* in PHP, not libpq.  The reason I assert this
is as follows:

- I tried Apache 1.3.27, 2.0.40 and 2.0.43 with libraries from
PostgreSQL 7.2.2, 7.2.3 and 7.3, and PHP 4.2.2, 4.2.3 and PHP 4.3.0RC2.
 ALL combinations crashed reliably.

With PHP 4.1.2, I am *unable* to get a crash.  Something in PHP is
corrupting memory, and later on, malloc() is failing.  I use the same
libpq library with Perl and Tcl, and have never yet had a segfault.

For more info, here's a stack trace for Red Hat 8.0 with Red Hat's
version of Apache (2.0.40) and Red Hat's PHP (4.2.2).

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 3305)]
0x42073d65 in _int_malloc () from /lib/i686/libc.so.6
(gdb) bt
#0  0x42073d65 in _int_malloc () from /lib/i686/libc.so.6
#1  0x42073155 in malloc () from /lib/i686/libc.so.6
#2  0x4051881b in completed.1 () from /etc/httpd/modules/libphp4.so
#3  0x405c5cb1 in completed.1 () from /etc/httpd/modules/libphp4.so
#4  0x405c5fe1 in completed.1 () from /etc/httpd/modules/libphp4.so
#5  0x405c615e in completed.1 () from /etc/httpd/modules/libphp4.so
#6  0x40522efc in completed.1 () from /etc/httpd/modules/libphp4.so
#7  0x40522c6d in completed.1 () from /etc/httpd/modules/libphp4.so
#8  0x40522c6d in completed.1 () from /etc/httpd/modules/libphp4.so
#9  0x40522c6d in completed.1 () from /etc/httpd/modules/libphp4.so
#10 0x4052f6b6 in completed.1 () from /etc/httpd/modules/libphp4.so
#11 0x4053df7a in completed.1 () from /etc/httpd/modules/libphp4.so
#12 0x4053a7bd in completed.1 () from /etc/httpd/modules/libphp4.so
#13 0x0807169c in ap_pass_brigade ()
#14 0x08078e27 in default_handler ()
#15 0x08065bf5 in ap_run_handler ()
#16 0x0806620d in ap_invoke_handler ()
#17 0x080629c6 in ap_process_request ()
#18 0x0805e0ac in ap_process_http_connection ()
#19 0x0806f0d5 in ap_run_process_connection ()
#20 0x08064238 in child_main ()
#21 0x0806445a in make_child ()
#22 0x080644b6 in startup_children ()
#23 0x08064cdf in ap_mpm_run ()
#24 0x0806ac5f in main ()
#25 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6

------------------------------------------------------------------------

[2002-12-11 09:17:15] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

The crash is the fault of PostgreSQL and not that of PHP.

------------------------------------------------------------------------

[2002-12-11 06:50:18] [EMAIL PROTECTED]

Backtrace for Apache 1.3.27 and PHP 4.3.0RC2:

Program received signal SIGSEGV, Segmentation fault.
0x42073d65 in _int_malloc () from /lib/i686/libc.so.6
(gdb) where
#0  0x42073d65 in _int_malloc () from /lib/i686/libc.so.6
#1  0x42073155 in malloc () from /lib/i686/libc.so.6
#2  0x402bda44 in pqResultAlloc () from /usr/lib/libpq.so.2
#3  0x402be3d5 in getRowDescriptions () from /usr/lib/libpq.so.2
#4  0x402be2f1 in parseInput () from /usr/lib/libpq.so.2
#5  0x402be970 in PQgetResult () from /usr/lib/libpq.so.2
#6  0x402bea78 in PQexec () from /usr/lib/libpq.so.2
#7  0x40251626 in zif_pg_query (ht=135421720, return_value=0x812593c, 
    this_ptr=0x0, return_value_used=1)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/ext/pgsql/pgsql.c:931
#8  0x40201692 in execute (op_array=0x80f1e54)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend_execute.c:1596
#9  0x40201433 in execute (op_array=0x80f3a84)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend_execute.c:1640
#10 0x40201433 in execute (op_array=0x80b0d40)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend_execute.c:1640
#11 0x40201433 in execute (op_array=0x80a36a0)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend_execute.c:1640
#12 0x40201433 in execute (op_array=0x80a8a24)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend_execute.c:1640
#13 0x401f4fdd in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
    at /home/dfs/canit-3rdparty-builds/php-4.3.0RC2/Zend/zend.c:864
#14 0x401d09d4 in php_execute_script (primary_file=0xbffff530)
---Type <return> to continue, or q <return> to quit--- 
    at /home/dfs/canit-3rdparty-builds/php-4.3.0RC2/main/main.c:1549
#15 0x4020525e in apache_php_module_main (r=0x8099974,
display_source_mode=0)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/sapi/apache/sapi_apache.c:55
#16 0x40205c25 in send_php (r=0x8099974, display_source_mode=0,
filename=0x0)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/sapi/apache/mod_php4.c:556
#17 0x40205dba in send_parsed_php (r=0x8099974)
    at
/home/dfs/canit-3rdparty-builds/php-4.3.0RC2/sapi/apache/mod_php4.c:571
#18 0x40022174 in ap_invoke_handler (r=0x8099974) at http_config.c:518
#19 0x40038477 in hypot () at http_request.c:1308
#20 0x400384e9 in ap_process_request (r=0x8099974) at
http_request.c:1324
#21 0x4002ee39 in child_main (child_num_arg=0) at http_main.c:4603
#22 0x4002eff8 in make_child (s=0x804b7bc, slot=0, now=1039610873)
    at http_main.c:4718
#23 0x4002f182 in startup_children (number_to_start=5) at
http_main.c:4800
#24 0x4002f838 in standalone_main (argc=2, argv=0xbffff9b4) at
http_main.c:5108
#25 0x40030100 in ap_main (argc=2, argv=0xbffff9b4) at
http_main.c:5456
#26 0x080485b3 in ?? ()
#27 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6

------------------------------------------------------------------------

[2002-12-11 00:59:23] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

------------------------------------------------------------------------

[2002-12-10 19:42:59] [EMAIL PROTECTED]

This is difficult (impossible) to reproduce with a short script. 
Please download and unpack
http://www.roaringpenguin.com/segfault.tar.bz2

You need to have PostgreSQL and create a specific database with
specific data in it.  Here's the README file from the tarball:

SUMMARY: PHP segfaults for PHP versions > 4.1.2
-----------------------------------------------

THE SOURCE FILES IN THIS ARCHIVE ARE PROPRIETARY COMMERCIAL SOFTWARE.
PLEASE USE THEM ONLY TO DEBUG PHP PROBLEMS.

System: Red Hat Linux 8.0

PostgreSQL: 7.2.2, as supplied with Red Hat Linux 8.0

Apache: 1.3.27, configured as follows:
        ./configure --with-layout=Apache --enable-shared=max \
                    --enable-rule=SHARED_CORE

PHP: Tried 4.2.2, 4.2.3 and 4.3.0RC2, all configured as follows:

        ./configure  --with-pgsql=shared \
                     --with-gnu-ld \
                     --with-apxs=/usr/local/apache/bin/apxs



HOW TO REPRODUCE:
-----------------

1) Install Apache 1.3.27 and PHP 4.2.2, 4.2.3 or 4.3.0RC2 from source.
Configure PostgreSQL 7.2.2 to trust local connections.  That is, in
/var/lib/pgsql/data/pg_hba.conf, make the local line read thus:

                local   all     trust

2) Create and populate the database:

        createdb -U postgres spam
        psql -U postgres -d spam < spam-database-dump 

3) Copy the PHP files to your document root somewhere convenient.

4) Browse http://your_server/these_php_files/index.php

5) Log in as "admin", password "foo"

6) Click on "Pending Messages" - Apache will segfault.

However: Using PHP 4.1.2, configured as above, it works fine.

Extensive investigation shows that it's segfaulting inside libpq,
inside
PQexec, but the function which segfaults is "malloc" which leads me
to believe there's memory corruption going on.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=20927&edit=1

Reply via email to