Re: BUG #6379: SQL Function Causes Back-end Crash - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #6379: SQL Function Causes Back-end Crash
Date
Msg-id CAFj8pRB=x1-vx8=bsvDnxvh5JzhL0AFDp-DfGB=N_aLWnV_XmQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #6379: SQL Function Causes Back-end Crash  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-bugs
Hello

I can replicate it

postgres=3D# select kill_backend();
NOTICE:  table "foo" does not exist, skipping
CONTEXT:  SQL function "kill_backend" statement 1
The connection to the server was lost. Attempting reset: Failed.
!>

bash-4.2$ uname -a
Linux nemesis 2.6.41.4-1.fc15.x86_64 #1 SMP Tue Nov 29 11:53:48 UTC
2011 x86_64 x86_64 x86_64 GNU/Linux

Program terminated with signal 11, Segmentation fault.
#0  0x00000000005aaacd in postquel_end (es=3D0x2c77298) at functions.c:637
637        (*es->qd->dest->rDestroy) (es->qd->dest);

Missing separate debuginfos, use: debuginfo-install glibc-2.14-5.x86_64
(gdb) bt
#0  0x00000000005aaacd in postquel_end (es=3D0x2c77298) at functions.c:637
#1  0x00000000005abb3e in fmgr_sql (fcinfo=3D<optimized out>) at functions.=
c:902
#2  0x00000000005a44aa in ExecMakeFunctionResult (fcache=3D0x2c6acd0,
econtext=3D0x2c6aaa8, isNull=3D0x2c6b680 "", isDone=3D0x2c6b7c0)
    at execQual.c:1832
#3  0x00000000005a79e2 in ExecTargetList (isDone=3D0x7fff58a0fedc,
itemIsDone=3D0x2c6b7c0, isnull=3D0x2c6b680 "", values=3D0x2c6b660,
    econtext=3D0x2c6aaa8, targetlist=3D0x2c6b788) at execQual.c:5112
#4  ExecProject (projInfo=3D<optimized out>, isDone=3D0x7fff58a0fedc) at
execQual.c:5327
#5  0x00000000005ba73a in ExecResult (node=3D0x2c6a990) at nodeResult.c:155
#6  0x00000000005a0658 in ExecProcNode (node=3D0x2c6a990) at execProcnode.c=
:372
#7  0x000000000059d1f2 in ExecutePlan (dest=3D0x2c2d3c0,
direction=3D<optimized out>, numberTuples=3D0, sendTuples=3D1 '\001',
    operation=3DCMD_SELECT, planstate=3D0x2c6a990, estate=3D0x2c6a878) at
execMain.c:1449
#8  standard_ExecutorRun (queryDesc=3D0x2c6a468, direction=3D<optimized
out>, count=3D0) at execMain.c:323
#9  0x0000000000681487 in PortalRunSelect (portal=3D0x2c68458,
forward=3D<optimized out>, count=3D0, dest=3D0x2c2d3c0) at pquery.c:942
#10 0x0000000000682a90 in PortalRun (portal=3D0x2c68458,
count=3D9223372036854775807, isTopLevel=3D1 '\001', dest=3D0x2c2d3c0,
    altdest=3D0x2c2d3c0, completionTag=3D0x7fff58a102e0 "") at pquery.c:786
#11 0x000000000067eb99 in exec_simple_query (query_string=3D0x2c2ba38
"select kill_backend();") at postgres.c:1021
#12 PostgresMain (argc=3D<optimized out>, argv=3D<optimized out>,
username=3D<optimized out>) at postgres.c:3881
#13 0x0000000000636da9 in BackendRun (port=3D0x2baa940) at postmaster.c:3587
#14 BackendStartup (port=3D0x2baa940) at postmaster.c:3272
#15 ServerLoop () at postmaster.c:1350
#16 0x0000000000637798 in PostmasterMain (argc=3D<optimized out>,
argv=3D0x2b8a440) at postmaster.c:1110
#17 0x0000000000455f9a in main (argc=3D3, argv=3D0x2b8a440) at main.c:199

Regards

Pavel


2012/1/4 hubert depesz lubaczewski <depesz@depesz.com>:
> On Wed, Jan 04, 2012 at 07:17:17PM +0000, pramsey@cleverelephant.ca wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference: =C2=A0 =C2=A0 =C2=A06379
>> Logged by: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Paul Ramsey
>> Email address: =C2=A0 =C2=A0 =C2=A0pramsey@cleverelephant.ca
>> PostgreSQL version: 9.1.2
>> Operating system: =C2=A0 OSX 10.6.8
>> Description:
>>
>> CREATE OR REPLACE FUNCTION kill_backend()
>> RETURNS VOID
>> AS $$
>> =C2=A0 DROP TABLE if EXISTS foo;
>> =C2=A0 CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1;
>> $$ LANGUAGE 'SQL';
>
> Cannot replicate:
>
> (depesz@localhost:5910) 20:23:43 [depesz]
> $ CREATE OR REPLACE FUNCTION kill_backend()
>>> RETURNS VOID
>>> AS $$
>>> =C2=A0 DROP TABLE if EXISTS foo;
>>> =C2=A0 CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1;
>>> $$ LANGUAGE 'SQL';
> CREATE FUNCTION
> (depesz@localhost:5910) 20:23:49 [depesz]
> $ select kill_backend();
> NOTICE: =C2=A0table "foo" does not exist, skipping
> CONTEXT: =C2=A0SQL function "kill_backend" statement 1
> =C2=A0kill_backend
> --------------
> =C2=A0[null]
> (1 row)
>
> (depesz@localhost:5910) 20:23:55 [depesz]
> $ select kill_backend();
> =C2=A0kill_backend
> --------------
> =C2=A0[null]
> (1 row)
>
> (depesz@localhost:5910) 20:23:56 [depesz]
> $ select kill_backend();
> =C2=A0kill_backend
> --------------
> =C2=A0[null]
> (1 row)
>
> (depesz@localhost:5910) 20:23:58 [depesz]
> $ select version();
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0version
> -------------------------------------------------------------------------=
------------------------------
> =C2=A0PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.6.r=
eal (Debian 4.6.2-5) 4.6.2, 64-bit
> (1 row)
>
> Side note - definition as is, doesn't work on 9.2:
> $ CREATE OR REPLACE FUNCTION kill_backend()
>>> RETURNS VOID
>>> AS $$
>>> =C2=A0 DROP TABLE if EXISTS foo;
>>> =C2=A0 CREATE TABLE foo AS SELECT * FROM pg_class LIMIT 1;
>>> $$ LANGUAGE 'SQL';
> ERROR: =C2=A0language "SQL" does not exist
>
> changing it to proper sql (not uppercase) fixed this problem.
>
> Best regards,
>
> depesz
>
> --
> The best thing about modern society is how easy it is to avoid contact wi=
th it.
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://depes=
z.com/
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: BUG #6379: SQL Function Causes Back-end Crash
Next
From: Paul Ramsey
Date:
Subject: Re: BUG #6379: SQL Function Causes Back-end Crash