Thread: BUG #3653: Database crash

BUG #3653: Database crash

From
"Marc Munro"
Date:
The following bug has been logged online:

Bug reference:      3653
Logged by:          Marc Munro
Email address:      marc@bloodnok.com
PostgreSQL version: 8.2.5
Operating system:   Linux 2.6.15.6 #4 SMP PREEMPT i686
Description:        Database crash
Details:

Also occurs on 8.2.3 and 8.1.4

The following script causes a db server crash:
psql -d postgres <<'CLUSTEREOF'


create database "skittest" with
 encoding 'UTF8'
 connection limit = -1;

CLUSTEREOF


psql -d skittest <<'DBEOF'

create or replace function "public"."mycharin"(
    in "pg_catalog"."cstring")
  returns "public"."mychar"
as 'charin'
language internal immutable strict;


create or replace function "public"."mycharout"(
    in "public"."mychar")
  returns "pg_catalog"."cstring"
as 'charout'
language internal immutable strict;


create type "public"."mychar"(
  input = "public"."mycharin",
  output = "public"."mycharout",
  internallength = -1,
  alignment = char,
  storage = plain,
  delimiter = ',');


create domain "public"."postal3"
  as "public"."mychar"
  default 'xxx' not null;

comment on domain "public"."postal3" is
'wibble';

DBEOF


The following is from the log file:

2007-10-04 11:05:40 PDT NOTICE:  type "public.mychar" is not yet defined
2007-10-04 11:05:40 PDT DETAIL:  Creating a shell type definition.
2007-10-04 11:05:40 PDT NOTICE:  argument type public.mychar is only a
shell
2007-10-04 11:05:40 PDT LOG:  server process (PID 13775) was terminated by
signa
l 11
2007-10-04 11:05:40 PDT LOG:  terminating any other active server processes
2007-10-04 11:05:40 PDT LOG:  all server processes terminated;
reinitializing
2007-10-04 11:05:40 PDT LOG:  database system was interrupted at 2007-10-04
11:0
5:34 PDT

Re: BUG #3653: Database crash

From
Tom Lane
Date:
"Marc Munro" <marc@bloodnok.com> writes:
> The following script causes a db server crash:

You are using the I/O routines for the builtin "char" type, but you
have not duplicated the storage parameters for that type.  The length
must be 1 not -1, and it's pass by value.

            regards, tom lane