BUG #5835: PL/Python crashes

From: "Julien Demoor" <jdemoor(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5835: PL/Python crashes
Date: 2011-01-13 13:57:29
Message-ID: 201101131357.p0DDvT8E039516@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5835
Logged by: Julien Demoor
Email address: jdemoor(at)gmail(dot)com
PostgreSQL version: 9.0.2
Operating system: Ubuntu Linux
Description: PL/Python crashes
Details:

Description of the system on which the problem occurs:
======================================================

$ psql --version
psql (PostgreSQL) 9.0.2

$ uname -a
Linux <hostname> 2.6.32-27-generic #49-Ubuntu SMP Wed Dec 1 23:52:12 UTC
2010 i686 GNU/Linux

PostgreSQL packages obtained through
https://launchpad.net/~pitti/+archive/postgresql and installed with Ubuntu's
package manager.

Reproduced on two machines, both running the same OS and Postgres version.
One of the two runs the stock postgresql.conf.

Steps to reproduce the problem:
===============================

In psql, create a database and install PL/Python:
CREATE DATABASE test2;
\c test2
CREATE LANGUAGE plpython2u;

Run the following in psql:

BEGIN;
CREATE OR REPLACE FUNCTION test_none_3(a numeric[]) RETURNS numeric(12,4) AS
$$
return 1;
$$ LANGUAGE plpython2u;
SELECT test_none_3('{NULL, NULL, NULL}'::numeric[]) FROM
generate_series(1,244) ORDER BY generate_series DESC LIMIT 1;
ROLLBACK;

Transcript of what happens:
===========================
Full transcript:

$ psql -d test2
psql (9.0.2)
Type "help" for help.

test2=# BEGIN;
BEGIN
test2=# CREATE OR REPLACE FUNCTION test_none_3(a numeric[]) RETURNS
numeric(12,4) AS $$
test2$# return 1;
test2$# $$ LANGUAGE plpython2u;
SELCREATE FUNCTION
test2=# SELECT test_none_3('{NULL, NULL, NULL}'::numeric[]) FROM
generate_series(1,244) ORDER BY generate_series DESC LIMIT 1;
BACK;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> ROLLBACK;
You are currently not connected to a database.
!> ^D\q

In the server logs:
===================
Fatal Python error: deallocating None
2011-01-13 14:20:10 CET LOG: server process (PID 27747) was terminated by
signal 6: Aborted
2011-01-13 14:20:10 CET LOG: terminating any other active server processes
2011-01-13 14:20:10 CET WARNING: terminating connection because of crash of
another server process
2011-01-13 14:20:10 CET DETAIL: The postmaster has commanded this server
process to roll back the current transaction and exit, because another
server process exited abnormally and possibly corrupted shared memory.
2011-01-13 14:20:10 CET HINT: In a moment you should be able to reconnect
to the database and repeat your command.
2011-01-13 14:20:10 CET FATAL: the database system is in recovery mode

More tests to reproduce:
========================
Changing the constant array and the second parameter given to
generate_series() we get:

-- {NULL, NULL, NULL}: Crashes at 244 and more, but not less
-- {NULL, 12, NULL}: Crashes 366 and more, but not less
-- {NULL, NULL}: Crashes 366 and more, but not less
-- {NULL, 12}: Crashes at 730 and more, but not less
-- {NULL}: Crashes at 730 and more, but not less
-- {}: Doesn't crash even at 1'000'000
-- {12}: Doesn't crash even at 1'000'000

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Pinheiro 2011-01-13 17:33:11 BUG #5836: Enum Support Functions don't work on empty tables
Previous Message Pasman 2011-01-13 09:07:47 BUG #5834: Planner - cost for hash scan too small