From: Tom Lane <tgl@sss.pgh.pa.us>
To: rotten@windfish.net
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9202: C Functions crash database too easily
Date: Thu, 13 Feb 2014 11:04:37 -0500
Message-ID: <4289.1392307477@sss.pgh.pa.us> (raw)
In-Reply-To: <20140212205302.2708.53160@wrigleys.postgresql.org>
References: <20140212205302.2708.53160@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
rotten@windfish.net writes:
> While setting up a third party (commerical) provided C library functions
> I've observed PostgreSQL 9.3.2 to be very sensitive to simple typos.
Coding in C in general is very sensitive to simple typos. Perhaps you
should use some higher-level PL if you find C too uncooperative.
> 2) The same thing happens if you try to create the same function twice:
Hm, that seems odd, since merely creating the function doesn't call it.
But then again, stuff like this suggests that you're abusing something
rather badly:
> 2014-02-12 15:20:45.626 EST mydb [local] postgresWARNING: using index
> "pg_event_trigger_evtname_index" despite IgnoreSystemIndexes
How did IgnoreSystemIndexes come to be set?
> 2014-02-12 15:20:45.627 EST mydb [local] postgresPANIC: function
> "myfunction" already exists with same argument types
Interesting; that should only be an ERROR not a PANIC. I'm guessing
that something in your loadable module left the system thinking it
was in a critical section, which would cause errors to be promoted
to panics like that.
In general it looks like these issues arise from your C code having
tromped on some global variables it shouldn't have. Wild store through
a wrong pointer, perhaps?
> For case (1) I think you shouldn't be able to create a C function without
> the right number of arguments.
I know of no way that we could (portably) infer the number of arguments
a C function expects from looking at the loadable library. Even if we
could, that alone wouldn't be much of a safety improvement. There are
too many other ways to crash things with an incorrect C function.
IME wrong data types and failure to handle null arguments properly
(neither checking for them explicitly, nor marking the function STRICT)
are bigger hazards than wrong-number-of-arguments.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rotten@windfish.net
Subject: Re: BUG #9202: C Functions crash database too easily
In-Reply-To: <4289.1392307477@sss.pgh.pa.us>
References: <20140212205302.2708.53160@wrigleys.postgresql.org> <4289.1392307477@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox