Thread: PostgreSQL / PHP Overrun Error
I have just upgraded to the new PostgreSQL 7.1.3 (from 7.0.3) and have been experiencing a pretty serious problem: On one particular page, in what seems to be completely random instances, I get buffer overruns and either 0-rows or a crashed apache child. Turning on PHP's --enable-debug, I receive the following: [Wed Sep 26 06:21:12 2001] Script: '/path/to/script.php' --------------------------------------- pgsql.c(167) : Block 0x086A6DF8 status: Beginning: Overrun (magic=0x00000000, expected=0x7312F8DC) End: Unknown --------------------------------------- Sometimes it will actually crash mid-way (probably overwrote some valuable code): --------------------------------------- pgsql.c(167) : Block 0x08684290 status: Beginning: Overrun (magic=0x0000111A, expected=0x7312F8DC) [Wed Sep 26 09:22:46 2001] [notice] child pid 8710 exit signal Segmentation fault (11) This problem is of great concern to me and I have been working for days trying to debug it myself and find other reports, with little success. The line it claims to be failing on is PHP's ext/pgsql/pgsql.c on line 167 (by what this claims) which is the following function [the efree(PGG(last_notice)) line]. static void _notice_handler(void *arg, const char *message) { PGLS_FETCH(); if (! PGG(ignore_notices)) { php_log_err((char *) message); if (PGG(last_notice) != NULL) { efree(PGG(last_notice)); } PGG(last_notice) = estrdup(message); } } Can anyone provide further input as to why this is causing problems? The PHP code works sometimes and not others, and it seems to be only that one script, so I do not believe it to be a hardware issue. Any thoughts? I can provide any further system information if needed. I have tried recompiling pgsql, php and apache with different optimizations [including none at all and debug mode on as i have now] with little change in the result. Thanks in advance; -- Mike cc: pgsql-hackers; pgsql-php; pgsql_bugs
"Mike Rogers" <temp6453@hotmail.com> writes: > This problem is of great concern to me and I have been working for days > trying to debug it myself and find other reports, with little success. The > line it claims to be failing on is PHP's ext/pgsql/pgsql.c on line 167 (by > what this claims) which is the following function [the > efree(PGG(last_notice)) line]. This isn't our code, so you'd likely have better luck complaining on some PHP-related list. But it looks to me like this code is simply trying to free any previous notice message before it stores the new one into PGG(last_notice) (whatever the heck that is). I'm guessing that that pointer is uninitialized or has been clobbered somehow. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Well it really isn't your code (true), but the only thing that is changed is the 7.0-7.1- Was a data length changed on the return or something that could affect this? -- Mike ----- Original Message ----- From: "Tom Lane" <tgl@sss.pgh.pa.us> To: "Mike Rogers" <temp6453@hotmail.com> Cc: <pgsql-hackers@postgresql.org>; <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> Sent: Wednesday, September 26, 2001 1:23 PM Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > "Mike Rogers" <temp6453@hotmail.com> writes: > > This problem is of great concern to me and I have been working for days > > trying to debug it myself and find other reports, with little success. The > > line it claims to be failing on is PHP's ext/pgsql/pgsql.c on line 167 (by > > what this claims) which is the following function [the > > efree(PGG(last_notice)) line]. > > This isn't our code, so you'd likely have better luck complaining on > some PHP-related list. But it looks to me like this code is simply > trying to free any previous notice message before it stores the new > one into PGG(last_notice) (whatever the heck that is). I'm guessing > that that pointer is uninitialized or has been clobbered somehow. > > regards, tom lane >
Mike Rogers wrote: > Well it really isn't your code (true), but the only thing that is changed is > the 7.0-7.1- Was a data length changed on the return or something that > could affect this? What version of PHP are you using? ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Sorry: PHP 4.0.6 (with memory leak patch [download listed right below php-4.0.6.tar.gz download- It was a problem]) PostgreSQL 7.1.3 Apache 1.3.20 (with mod_ssl- but it does the same thing without mod_ssl) -- Mike ----- Original Message ----- From: "mlw" <markw@mohawksoft.com> To: "Mike Rogers" <temp6453@hotmail.com> Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> Sent: Wednesday, September 26, 2001 1:55 PM Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > Mike Rogers wrote: > > > Well it really isn't your code (true), but the only thing that is changed is > > the 7.0-7.1- Was a data length changed on the return or something that > > could affect this? > > What version of PHP are you using? > > >
Interesting. I am using that same configuration. We are using the same thing on our website as well. I have never seen this problem. Weird. My guess is that you are getting an error. The PHP code is some how mucking this up. But I would try executing the query in psql and see what comes up. The PHP code than handles the error may have a fixed langth buffer for speed, and it is to short for a longer 7.1 error message. Again, I am guessing. My bet is that the query is failing with an error, so you really have two problems. A problem in your SQL which is causing you to see a bug in PHP. Mike Rogers wrote: > Sorry: > PHP 4.0.6 (with memory leak patch [download listed right below > php-4.0.6.tar.gz download- It was a problem]) > PostgreSQL 7.1.3 > Apache 1.3.20 (with mod_ssl- but it does the same thing without mod_ssl) > -- > Mike > > ----- Original Message ----- > From: "mlw" <markw@mohawksoft.com> > To: "Mike Rogers" <temp6453@hotmail.com> > Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; > <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> > Sent: Wednesday, September 26, 2001 1:55 PM > Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > > > Mike Rogers wrote: > > > > > Well it really isn't your code (true), but the only thing that is > changed is > > > the 7.0-7.1- Was a data length changed on the return or something that > > > could affect this? > > > > What version of PHP are you using? > > > > > > ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Have you recompiled PHP to link against the new postgres libraries? Chris > -----Original Message----- > From: pgsql-hackers-owner@postgresql.org > [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Mike Rogers > Sent: Thursday, 27 September 2001 1:07 AM > To: mlw > Cc: pgsql-hackers@postgresql.org; pgsql-php@postgresql.org; > pgsql-bugs@postgresql.org > Subject: Re: [HACKERS] [BUGS] PostgreSQL / PHP Overrun Error > > > Sorry: > PHP 4.0.6 (with memory leak patch [download listed right below > php-4.0.6.tar.gz download- It was a problem]) > PostgreSQL 7.1.3 > Apache 1.3.20 (with mod_ssl- but it does the same thing > without mod_ssl) > -- > Mike > > ----- Original Message ----- > From: "mlw" <markw@mohawksoft.com> > To: "Mike Rogers" <temp6453@hotmail.com> > Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; > <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> > Sent: Wednesday, September 26, 2001 1:55 PM > Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > > > > Mike Rogers wrote: > > > > > Well it really isn't your code (true), but the only thing that is > changed is > > > the 7.0-7.1- Was a data length changed on the return or > something that > > > could affect this? > > > > What version of PHP are you using? > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
There is a problem in PHP-4.0.6. Please use PHP4.0.7 or 4.0.8 and the problem will be solved. This can be obtained from CVS -- Mike ----- Original Message ----- From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> To: "Mike Rogers" <temp6453@hotmail.com>; "mlw" <markw@mohawksoft.com> Cc: <pgsql-hackers@postgresql.org>; <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> Sent: Wednesday, September 26, 2001 10:31 PM Subject: RE: [HACKERS] [BUGS] PostgreSQL / PHP Overrun Error > Have you recompiled PHP to link against the new postgres libraries? > > Chris > > > -----Original Message----- > > From: pgsql-hackers-owner@postgresql.org > > [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Mike Rogers > > Sent: Thursday, 27 September 2001 1:07 AM > > To: mlw > > Cc: pgsql-hackers@postgresql.org; pgsql-php@postgresql.org; > > pgsql-bugs@postgresql.org > > Subject: Re: [HACKERS] [BUGS] PostgreSQL / PHP Overrun Error > > > > > > Sorry: > > PHP 4.0.6 (with memory leak patch [download listed right below > > php-4.0.6.tar.gz download- It was a problem]) > > PostgreSQL 7.1.3 > > Apache 1.3.20 (with mod_ssl- but it does the same thing > > without mod_ssl) > > -- > > Mike > > > > ----- Original Message ----- > > From: "mlw" <markw@mohawksoft.com> > > To: "Mike Rogers" <temp6453@hotmail.com> > > Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; > > <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> > > Sent: Wednesday, September 26, 2001 1:55 PM > > Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > > > > > > > Mike Rogers wrote: > > > > > > > Well it really isn't your code (true), but the only thing that is > > changed is > > > > the 7.0-7.1- Was a data length changed on the return or > > something that > > > > could affect this? > > > > > > What version of PHP are you using? > > > > > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > >
On Mié 26 Sep 2001 22:51, Mike Rogers wrote: > There is a problem in PHP-4.0.6. Please use PHP4.0.7 or 4.0.8 and the > problem will be solved. This can be obtained from CVS Sorry, but 4.0.6 is the last version out (there may be some RC of 4.0.7), but how can we get those, and how much can we trust a RC version? Saludos... :-) -- Porqué usar una base de datos relacional cualquiera, si podés usar PostgreSQL? ----------------------------------------------------------------- Martín Marqués | mmarques@unl.edu.ar Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral -----------------------------------------------------------------
I'm using the current CVS (4.0.8-dev)- It's spectacular. Lower memory usage, more descriptive debug, better control over it. Tons more options, smaller code, much much faster. Can you trust it- sure. It isn't a release candidate. It is the current development version. As they find problems, they get fixed. As long as you keep a bit on top you are fine. If anything it is _MORE_ secure than the current version, as any security problems were fixed earlier as soon as they get found, and new bugs aren't known yet. I'm seriously impressed with it and feel like I will be using the CVS code quite a bit more. Any bugs Zend memory manager cleans up anyway. Note: if you are not having the problem of 0 rows or buffer overruns, don't bother upgrading as it will not benefit you. Clearly I was and the new code fixed the flaws in the existing code for my usage. -- Mike ----- Original Message ----- From: "Martín Marqués" <martin@bugs.unl.edu.ar> To: "Mike Rogers" <temp6453@hotmail.com> Cc: <pgsql-hackers@postgresql.org>; <pgsql-php@postgresql.org> Sent: Thursday, September 27, 2001 5:55 PM Subject: Re: [PHP] [HACKERS] [BUGS] PostgreSQL / PHP Overrun Error > On Mié 26 Sep 2001 22:51, Mike Rogers wrote: > > There is a problem in PHP-4.0.6. Please use PHP4.0.7 or 4.0.8 and the > > problem will be solved. This can be obtained from CVS > > Sorry, but 4.0.6 is the last version out (there may be some RC of 4.0.7), but > how can we get those, and how much can we trust a RC version? > > Saludos... :-) > > -- > Porqué usar una base de datos relacional cualquiera, > si podés usar PostgreSQL? > ----------------------------------------------------------------- > Martín Marqués | mmarques@unl.edu.ar > Programador, Administrador, DBA | Centro de Telematica > Universidad Nacional > del Litoral > ----------------------------------------------------------------- >
> I'm using the current CVS (4.0.8-dev)- It's spectacular. Lower memory > usage, more descriptive debug, better control over it. Tons more options, > smaller code, much much faster. > > Can you trust it- sure. It isn't a release candidate. It is the > current development version. As they find problems, they get fixed. As > long as you keep a bit on top you are fine. If anything it is _MORE_ secure > than the current version, as any security problems were fixed earlier as > soon as they get found, and new bugs aren't known yet. I'm seriously > impressed with it and feel like I will be using the CVS code quite a bit > more. Any bugs Zend memory manager cleans up anyway. > > Note: if you are not having the problem of 0 rows or buffer overruns, > don't bother upgrading as it will not benefit you. Clearly I was and the > new code fixed the flaws in the existing code for my usage. Keep in mind we can change the on-disk structure or system tasbles anytime so you may have trouble moving between different CVS versions. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
On Fri, Sep 28, 2001 at 03:50:12PM -0400, Bruce Momjian wrote: > > I'm using the current CVS (4.0.8-dev)- It's spectacular. Lower memory > > usage, more descriptive debug, better control over it. Tons more options, > > smaller code, much much faster. <snip> > > Note: if you are not having the problem of 0 rows or buffer overruns, > > don't bother upgrading as it will not benefit you. Clearly I was and the > > new code fixed the flaws in the existing code for my usage. > > Keep in mind we can change the on-disk structure or system tasbles > anytime so you may have trouble moving between different CVS versions. Also note that Bruce is talking about using PostgreSQL CVS version, rather than the PHP CVS version (as one can tell from the version number 4.0.8) that everyone else is discussing. ;-) Ross
Mike Rogers wrote: > Well it really isn't your code (true), but the only thing that is changed is > the 7.0-7.1- Was a data length changed on the return or something that > could affect this? What version of PHP are you using? ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Interesting. I am using that same configuration. We are using the same thing on our website as well. I have never seen this problem. Weird. My guess is that you are getting an error. The PHP code is some how mucking this up. But I would try executing the query in psql and see what comes up. The PHP code than handles the error may have a fixed langth buffer for speed, and it is to short for a longer 7.1 error message. Again, I am guessing. My bet is that the query is failing with an error, so you really have two problems. A problem in your SQL which is causing you to see a bug in PHP. Mike Rogers wrote: > Sorry: > PHP 4.0.6 (with memory leak patch [download listed right below > php-4.0.6.tar.gz download- It was a problem]) > PostgreSQL 7.1.3 > Apache 1.3.20 (with mod_ssl- but it does the same thing without mod_ssl) > -- > Mike > > ----- Original Message ----- > From: "mlw" <markw@mohawksoft.com> > To: "Mike Rogers" <temp6453@hotmail.com> > Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; > <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> > Sent: Wednesday, September 26, 2001 1:55 PM > Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > > > Mike Rogers wrote: > > > > > Well it really isn't your code (true), but the only thing that is > changed is > > > the 7.0-7.1- Was a data length changed on the return or something that > > > could affect this? > > > > What version of PHP are you using? > > > > > > ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
"Mike Rogers" <temp6453@hotmail.com> writes: > This problem is of great concern to me and I have been working for days > trying to debug it myself and find other reports, with little success. The > line it claims to be failing on is PHP's ext/pgsql/pgsql.c on line 167 (by > what this claims) which is the following function [the > efree(PGG(last_notice)) line]. This isn't our code, so you'd likely have better luck complaining on some PHP-related list. But it looks to me like this code is simply trying to free any previous notice message before it stores the new one into PGG(last_notice) (whatever the heck that is). I'm guessing that that pointer is uninitialized or has been clobbered somehow. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
This is a known problem with PHP 4.0.6. You might want to upgrade to 4.1.0RC2, or try patches made by one of the PHP developers: ftp://ftp.sra.co.jp/pub/cmd/postgres/php/php-4.0.6-patches.tar.gz > Mike Rogers wrote: > > > Sorry: > > PHP 4.0.6 (with memory leak patch [download listed right below > > php-4.0.6.tar.gz download- It was a problem]) > > PostgreSQL 7.1.3 > > Apache 1.3.20 (with mod_ssl- but it does the same thing without mod_ssl) > > -- > > Mike > > > > ----- Original Message ----- > > From: "mlw" <markw@mohawksoft.com> > > To: "Mike Rogers" <temp6453@hotmail.com> > > Cc: "Tom Lane" <tgl@sss.pgh.pa.us>; <pgsql-hackers@postgresql.org>; > > <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> > > Sent: Wednesday, September 26, 2001 1:55 PM > > Subject: Re: [BUGS] PostgreSQL / PHP Overrun Error > > > > > Mike Rogers wrote: > > > > > > > Well it really isn't your code (true), but the only thing that is > > changed is > > > > the 7.0-7.1- Was a data length changed on the return or something that > > > > could affect this? > > > > > > What version of PHP are you using? > > > > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html >
Why did it just send out tons of mail since September of this year- every message? -- Mike
someone, either intentially or accidentally, sent out a load to the lists ... On Fri, 16 Nov 2001, Mike Rogers wrote: > Why did it just send out tons of mail since September of this year- every > message? > -- > Mike > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
if you look at the originating time for all of the messages that got sent out of when it was sent from the host machine (with HELO host). Clearly it was done on an admin side. -- Mike ----- Original Message ----- From: "Marc G. Fournier" <scrappy@hub.org> To: "Mike Rogers" <temp6453@hotmail.com> Cc: <pgsql-hackers@postgresql.org>; <pgsql-php@postgresql.org>; <pgsql-bugs@postgresql.org> Sent: Friday, November 16, 2001 3:26 PM Subject: Re: [BUGS] [HACKERS] [PG MAIL LISTS] SEND OUT ALL???? > > someone, either intentially or accidentally, sent out a load to the lists > ... > > > On Fri, 16 Nov 2001, Mike Rogers wrote: > > > Why did it just send out tons of mail since September of this year- every > > message? > > -- > > Mike > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >