bug: core dump in pl/perl (cvs head).

Started by Hans-Jürgen Schönigalmost 21 years ago16 messagesbugs
Jump to latest
#1Hans-Jürgen Schönig
postgres@cybertec.at

we have found a bug in CVS head using PL/Perl:

[hs@hp hs]$ psql test < /tmp/core.sql
DROP FUNCTION
CREATE FUNCTION
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL
AND pid = pg_backend_pid()
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

DROP FUNCTION func();
CREATE OR REPLACE FUNCTION func() RETURNS int4 AS '
$sql = "SELECT 10, 10 FROM pg_locks "
. "WHERE transaction IS NOT NULL AND pid =
pg_backend_pid() ";
elog(NOTICE, "sql: $sql");
my $rv = spi_exec_query($sql);
return 0;
' LANGUAGE 'plperlu';

SELECT func();

somehow Perl does not seem to like the SPI.
only the development code seems to be affected.

thanks a lot,

hans

#2Michael Fuhr
mike@fuhr.org
In reply to: Hans-Jürgen Schönig (#1)
Re: bug: core dump in pl/perl (cvs head).

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

test=> SELECT func();
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL AND pid = pg_backend_pid()
func
------
0
(1 row)

Have you run "make distclean" and then done a fresh build?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#3Hans-Jürgen Schönig
postgres@cybertec.at
In reply to: Michael Fuhr (#2)
Re: bug: core dump in pl/perl (cvs head).

Michael Fuhr wrote:

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

test=> SELECT func();
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL AND pid = pg_backend_pid()
func
------
0
(1 row)

Have you run "make distclean" and then done a fresh build?

Yes, this was my first concern ... - everything has been build cleanly ...
I think this is yesterday's CVS ...

hans

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Fuhr (#2)
Re: bug: core dump in pl/perl (cvs head).

Michael Fuhr <mike@fuhr.org> writes:

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

None for me either (trying on a Fedora Core 3 x86 box; don't currently
have plperl built on my other machine). Platform-specific issue maybe?

regards, tom lane

#5Michael Fuhr
mike@fuhr.org
In reply to: Tom Lane (#4)
Re: bug: core dump in pl/perl (cvs head).

On Tue, Jul 05, 2005 at 04:37:05PM -0400, Tom Lane wrote:

Michael Fuhr <mike@fuhr.org> writes:

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

None for me either (trying on a Fedora Core 3 x86 box; don't currently
have plperl built on my other machine). Platform-specific issue maybe?

My platform that works is Solaris 9/sparc with Perl 5.8.7; compiler
is gcc 3.4.2.

Did you get a core dump? If so, can you do a stack trace on it?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#6Hans-Jürgen Schönig
postgres@cybertec.at
In reply to: Michael Fuhr (#5)
Re: bug: core dump in pl/perl (cvs head).

Michael Fuhr wrote:

On Tue, Jul 05, 2005 at 04:37:05PM -0400, Tom Lane wrote:

Michael Fuhr <mike@fuhr.org> writes:

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

None for me either (trying on a Fedora Core 3 x86 box; don't currently
have plperl built on my other machine). Platform-specific issue maybe?

My platform that works is Solaris 9/sparc with Perl 5.8.7; compiler
is gcc 3.4.2.

Did you get a core dump? If so, can you do a stack trace on it?

I am running FC4 on x86. There is no core dump.
I have compiled it all over again cleanly.
The last elog is never reached so something seems to go wrong inside the
SQL call ...

CREATE OR REPLACE FUNCTION trig_func() RETURNS trigger AS '
# select the current transaction id
elog(NOTICE, "trigger starting ...");
$sql = "SELECT transaction, pid FROM pg_locks "
. "WHERE transaction IS NOT NULL AND pid =
pg_backend_pid() ";
elog(NOTICE, "sql: $sql");
my $rv = spi_exec_query($sql);
elog(NOTICE, "looking for transactions ...");

I don't know what it is yet as it seemed to work with 8.0.3.
Interesting to see that nodody else has similar problems ...

regards,

hans

#7Hans-Jürgen Schönig
postgres@cybertec.at
In reply to: Hans-Jürgen Schönig (#6)
Re: bug: core dump in pl/perl (cvs head).

i have never seen this before ...
after rebooting the box (for some other reason) it worked.
somehow there has been something else going terribly wrong ...
sorry for the confusion ...

best regards,

hans

Hans-J�rgen Sch�nig wrote:

Show quoted text

Michael Fuhr wrote:

On Tue, Jul 05, 2005 at 04:37:05PM -0400, Tom Lane wrote:

Michael Fuhr <mike@fuhr.org> writes:

On Tue, Jul 05, 2005 at 09:54:52PM +0200, Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

How current is your checkout? Mine's from this morning and I don't
get a crash with the example you posted:

None for me either (trying on a Fedora Core 3 x86 box; don't currently
have plperl built on my other machine). Platform-specific issue maybe?

My platform that works is Solaris 9/sparc with Perl 5.8.7; compiler
is gcc 3.4.2.

Did you get a core dump? If so, can you do a stack trace on it?

I am running FC4 on x86. There is no core dump.
I have compiled it all over again cleanly.
The last elog is never reached so something seems to go wrong inside the
SQL call ...

CREATE OR REPLACE FUNCTION trig_func() RETURNS trigger AS '
# select the current transaction id
elog(NOTICE, "trigger starting ...");
$sql = "SELECT transaction, pid FROM pg_locks "
. "WHERE transaction IS NOT NULL AND pid =
pg_backend_pid() ";
elog(NOTICE, "sql: $sql");
my $rv = spi_exec_query($sql);
elog(NOTICE, "looking for transactions ...");

I don't know what it is yet as it seemed to work with 8.0.3.
Interesting to see that nodody else has similar problems ...

regards,

hans

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

#8Michael Fuhr
mike@fuhr.org
In reply to: Hans-Jürgen Schönig (#6)
Re: bug: core dump in pl/perl (cvs head).

On Tue, Jul 05, 2005 at 10:49:54PM +0200, Hans-J�rgen Sch�nig wrote:

I am running FC4 on x86. There is no core dump.

Just to be sure: where are you looking? I don't know if it's
configurable on your platform, but I usually find core dumps under
$PGDATA/base/<databaseoid>/. Do you have a resource limit or other
setting that would prevent core dumps from happening? Tom Lane can
probably help out on that platform.

I have compiled it all over again cleanly.
The last elog is never reached so something seems to go wrong inside the
SQL call ...

Can you run the query in psql? What about in a PL/pgSQL function?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Fuhr (#8)
Re: bug: core dump in pl/perl (cvs head).

Michael Fuhr <mike@fuhr.org> writes:

On Tue, Jul 05, 2005 at 10:49:54PM +0200, Hans-J�rgen Sch�nig wrote:

I am running FC4 on x86. There is no core dump.

Just to be sure: where are you looking? I don't know if it's
configurable on your platform, but I usually find core dumps under
$PGDATA/base/<databaseoid>/.

CVS tip of the last forty-eight hours or so would dump into $PGDATA
instead. It's a good bet though that "ulimit -c" is set to 0 (no dumps)
by default on that platform. I tend to put
ulimit -c unlimited
into the postmaster startup script on Linux machines, so that I can get
core dumps.

regards, tom lane

#10Bruce Momjian
bruce@momjian.us
In reply to: Hans-Jürgen Schönig (#1)
Re: bug: core dump in pl/perl (cvs head).

Has this been fixed?

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

Hans-J���rgen Sch���nig wrote:

we have found a bug in CVS head using PL/Perl:

[hs@hp hs]$ psql test < /tmp/core.sql
DROP FUNCTION
CREATE FUNCTION
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL
AND pid = pg_backend_pid()
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

DROP FUNCTION func();
CREATE OR REPLACE FUNCTION func() RETURNS int4 AS '
$sql = "SELECT 10, 10 FROM pg_locks "
. "WHERE transaction IS NOT NULL AND pid =
pg_backend_pid() ";
elog(NOTICE, "sql: $sql");
my $rv = spi_exec_query($sql);
return 0;
' LANGUAGE 'plperlu';

SELECT func();

somehow Perl does not seem to like the SPI.
only the development code seems to be affected.

thanks a lot,

hans

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#11Michael Fuhr
mike@fuhr.org
In reply to: Bruce Momjian (#10)
Re: bug: core dump in pl/perl (cvs head).

On Fri, Jul 29, 2005 at 10:46:35PM -0400, Bruce Momjian wrote:

Has this been fixed?

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

Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

[hs@hp hs]$ psql test < /tmp/core.sql
DROP FUNCTION
CREATE FUNCTION
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL
AND pid = pg_backend_pid()
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

I don't think anybody was able to reproduce the problem, and
Hans-J�rgen said that it started working after he rebooted
the box:

http://archives.postgresql.org/pgsql-bugs/2005-07/msg00062.php

There was reportedly no core dump and apparently the reboot destroyed
whatever conditions were causing the problem, so it might be difficult
to find out what was happening :-(

Hans-J�rgen, did this problem ever reappear?

Somebody else recently reported a backend crash when calling PL/Perl
in 8.0.3, but again we've been given no core dump info and thus far
nobody has been able to duplicate the problem:

http://archives.postgresql.org/pgsql-novice/2005-07/msg00181.php

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#12Hans-Jürgen Schönig
postgres@cybertec.at
In reply to: Michael Fuhr (#11)
Re: bug: core dump in pl/perl (cvs head).

no, this one seems to be fine now.
i have no idea what went wrong.
the code cored at some very "unlikely" place.

somehow rebooting helped ... - this was very strange.
fortunately it works nicely now ...

many thanks a best regards,

hans

Michael Fuhr wrote:

Show quoted text

On Fri, Jul 29, 2005 at 10:46:35PM -0400, Bruce Momjian wrote:

Has this been fixed?

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

Hans-J�rgen Sch�nig wrote:

we have found a bug in CVS head using PL/Perl:

[hs@hp hs]$ psql test < /tmp/core.sql
DROP FUNCTION
CREATE FUNCTION
NOTICE: sql: SELECT 10, 10 FROM pg_locks WHERE transaction IS NOT NULL
AND pid = pg_backend_pid()
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

I don't think anybody was able to reproduce the problem, and
Hans-J�rgen said that it started working after he rebooted
the box:

http://archives.postgresql.org/pgsql-bugs/2005-07/msg00062.php

There was reportedly no core dump and apparently the reboot destroyed
whatever conditions were causing the problem, so it might be difficult
to find out what was happening :-(

Hans-J�rgen, did this problem ever reappear?

Somebody else recently reported a backend crash when calling PL/Perl
in 8.0.3, but again we've been given no core dump info and thus far
nobody has been able to duplicate the problem:

http://archives.postgresql.org/pgsql-novice/2005-07/msg00181.php

#13Michael Fuhr
mike@fuhr.org
In reply to: Hans-Jürgen Schönig (#12)
Re: bug: core dump in pl/perl (cvs head).

On Sat, Jul 30, 2005 at 02:43:23PM +0200, Hans-J�rgen Sch�nig wrote:

no, this one seems to be fine now.
i have no idea what went wrong.
the code cored at some very "unlikely" place.

Are you saying that it *did* dump core, or that it *didn't*? It's
possible that your coredumpsize resource limit prevented a core
dump from happening at all. If you're playing with the development
code than it would be a good idea to set that limit so that you do
get core dumps. Configuring with --enable-debug and --enable-cassert
would also be useful, if you aren't doing so already.

somehow rebooting helped ... - this was very strange.
fortunately it works nicely now ...

...but unfortunate for finding out what was happening :-(

Had you stopped and restarted the postmaster before the reboot?
That is, was the reboot really necessary to "fix" the problem?
Had you run "make install" while the postmaster was still running?
I haven't tested whether that could cause a problem, but I wonder
if that's possible.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#14Hans-Jürgen Schönig
postgres@cybertec.at
In reply to: Michael Fuhr (#13)
Re: bug: core dump in pl/perl (cvs head).

Michael Fuhr wrote:

On Sat, Jul 30, 2005 at 02:43:23PM +0200, Hans-J�rgen Sch�nig wrote:

no, this one seems to be fine now.
i have no idea what went wrong.
the code cored at some very "unlikely" place.

Are you saying that it *did* dump core, or that it *didn't*? It's
possible that your coredumpsize resource limit prevented a core
dump from happening at all. If you're playing with the development
code than it would be a good idea to set that limit so that you do
get core dumps. Configuring with --enable-debug and --enable-cassert
would also be useful, if you aren't doing so already.

it cored; my core-size settings are ok ...

somehow rebooting helped ... - this was very strange.
fortunately it works nicely now ...

...but unfortunate for finding out what was happening :-(

absolutely. however, it is a bit hard to find a bug which cannot be
reproduced ...
to me it seems as if something else was doing some sort of crap on this box.

Had you stopped and restarted the postmaster before the reboot?

yes - I even did a make distclean and a recompile ...

That is, was the reboot really necessary to "fix" the problem?

I rebooted for some other reasons ...

Had you run "make install" while the postmaster was still running?
I haven't tested whether that could cause a problem, but I wonder
if that's possible.

To be honest; I don't have the slightest idea; I have never seen this
before and I have been able to reproduce that.
I don't have the slightest idea what happened. This seems like higher
power ...

Best regards,

Hans

#15Michael Fuhr
mike@fuhr.org
In reply to: Hans-Jürgen Schönig (#14)
Re: bug: core dump in pl/perl (cvs head).

On Sat, Jul 30, 2005 at 03:46:46PM +0200, Hans-J�rgen Sch�nig wrote:

Michael Fuhr wrote:

Are you saying that it *did* dump core, or that it *didn't*?

it cored; my core-size settings are ok ...

So were you able to get a stack trace from the core dump?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#16Michael Fuhr
mike@fuhr.org
In reply to: Hans-Jürgen Schönig (#1)
Re: bug: core dump in pl/perl (cvs head).

[Please copy the mailing list on replies.]

On Sat, Jul 30, 2005 at 05:20:07PM +0200, Hans-J�rgen Sch�nig wrote:

Michael Fuhr wrote:

So were you able to get a stack trace from the core dump?

yes, but i did not keep the backtrace.
i did not expect the db to work after the reboot.

you shouldn't worry to much about that. i don't believe it is a
postgresql related problem ...

Maybe not, but if it happens again then please post the stack trace
so somebody can take a look. Even if it isn't a PostgreSQL problem,
it's worth finding out the cause so you can prevent it in the future.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/