Re: plpgsql functions crash cvs - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: plpgsql functions crash cvs
Date
Msg-id 20060302012224.GA11359@surnet.cl
Whole thread Raw
In response to plpgsql functions crash cvs  (Kris Jurka <books@ejurka.com>)
List pgsql-bugs
Kris Jurka wrote:
>
> eKol in #postgresql reported a problem with a plpgsql function crashing
> the server.  I tested the attached against 8.2cvs as of this morning
> and got this stacktrace:

Interesting.  8.1 also crashes.  8.0 instead gives this output:

psql:/home/alvherre/funcs.sql:86: ERROR:  control reached end of function without RETURN
CONTEXT:  PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT  admin.fn_revoke_all_functions_from( $1 ,  $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:88: ERROR:  control reached end of function without RETURN
CONTEXT:  PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT  admin.fn_revoke_all_functions_from( $1 ,  $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:89: ERROR:  control reached end of function without RETURN
CONTEXT:  PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT  admin.fn_revoke_all_functions_from( $1 ,  $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform
psql:/home/alvherre/funcs.sql:90: ERROR:  control reached end of function without RETURN
CONTEXT:  PL/pgSQL function "fn_revoke_all_functions_from"
SQL statement "SELECT  admin.fn_revoke_all_functions_from( $1 ,  $2 )"
PL/pgSQL function "fn_revoke_all" line 11 at perform



In 8.1, the backtrace reads thus:

(gdb) bt
#0  plpgsql_xact_cb (event=XACT_EVENT_COMMIT, arg=0x0)
    at /pgsql/source/81_rel/src/pl/plpgsql/src/pl_exec.c:4525
#1  0x080b37ed in CallXactCallbacks (event=XACT_EVENT_COMMIT)
    at /pgsql/source/81_rel/src/backend/access/transam/xact.c:2618
#2  0x080b5923 in CommitTransaction ()
    at /pgsql/source/81_rel/src/backend/access/transam/xact.c:1534
#3  0x080b73d9 in CommitTransactionCommand ()
    at /pgsql/source/81_rel/src/backend/access/transam/xact.c:2184
#4  0x081e2d8d in finish_xact_command ()
    at /pgsql/source/81_rel/src/backend/tcop/postgres.c:2006
#5  0x081e40c5 in exec_simple_query (
    query_string=0x83d011c "SELECT admin.fn_revoke_all('public');")
    at /pgsql/source/81_rel/src/backend/tcop/postgres.c:1032
#6  0x081e593d in PostgresMain (argc=4, argv=0x8372898,
    username=0x8372860 "alvherre")
    at /pgsql/source/81_rel/src/backend/tcop/postgres.c:3217
#7  0x081b771a in ServerLoop ()
    at /pgsql/source/81_rel/src/backend/postmaster/postmaster.c:2853
#8  0x081b88d4 in PostmasterMain (argc=1, argv=0x8371860)
    at /pgsql/source/81_rel/src/backend/postmaster/postmaster.c:941
#9  0x081753c9 in main (argc=1, argv=0x8371860)
    at /pgsql/source/81_rel/src/backend/main/main.c:265
(gdb) info locals
expr = (PLpgSQL_expr *) 0x7f7f7f7f
enext = <value optimized out>


So the problem seems to be that the context containing the PLpgSQL_expr
was reset too early.  I'll investigate more after dinner, if somebody
doesn't beat me to it.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: Kris Jurka
Date:
Subject: plpgsql functions crash cvs
Next
From: Tom Lane
Date:
Subject: Re: plpgsql functions crash cvs