pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Syntax error in plpgsql crashes backend
7+ messages / 5 participants
[nested] [flat]

* Syntax error in plpgsql crashes backend
@ 2002-05-04 18:09  Joseph Barillari <jbarilla@princeton.edu>
  0 siblings, 1 reply; 7+ messages in thread

From: Joseph Barillari @ 2002-05-04 18:09 UTC (permalink / raw)
  To: pgsql-sql

I've found a pathological function input that crashes the backend.

Note the profusion of 'blah' text and the lack of an 'end;'
statement. Less text or an end statement stops this function from
provoking a crash.

CREATE OR REPLACE FUNCTION foo()
    RETURNS INTEGER
    AS '
DECLARE
	querystr TEXT;
BEGIN
querystr := ''
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 


'';
return 1;
'
language 'plpgsql';

When I load this function and try to execute it, I get a syntax error:

cal=> \i test
CREATE
cal=> select foo();
NOTICE:  plpgsql: ERROR during compile of foo near line 60
ERROR:  parse error at or near ""

If I try it again, the backend crashes:

cal=> select foo();
NOTICE:  plpgsql: ERROR during compile of foo near line 60
ERROR:  parse error at or near ""
pqReadData() -- backend closed the channel unexpectedly.
	This probably means the backend terminated abnormally
	before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 

I get the following output from the postmaster:

ERROR:  parse error at or near ""
NOTICE:  plpgsql: ERROR during compile of foo near line 60
DEBUG:  server process (pid 17990) was terminated by signal 11
DEBUG:  terminating any other active server processes
DEBUG:  all server processes terminated; reinitializing shared memory and semaphores
DEBUG:  database system was interrupted at 2002-05-04 14:03:46 EDT
DEBUG:  checkpoint record is at 0/41FFA70
DEBUG:  redo record is at 0/41FFA70; undo record is at 0/0; shutdown TRUE
DEBUG:  next transaction id: 41659; next oid: 147628
DEBUG:  database system was not properly shut down; automatic recovery in progress
DEBUG:  redo starts at 0/41FFAB0
DEBUG:  ReadRecord: record with zero length at 0/4205D4C
DEBUG:  redo done at 0/4205D28
FATAL 1:  The database system is starting up
DEBUG:  database system is ready


I anticipate that the correct response is `Don't do that then!' But I
assume someone would want to know about crashes like
this.

I'm using PostgreSQL 7.2, compiled with `gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)'

--Joe

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-05-04 18:19  Joseph Barillari <jbarilla@princeton.edu>
  parent: Joseph Barillari <jbarilla@princeton.edu>
  0 siblings, 2 replies; 7+ messages in thread

From: Joseph Barillari @ 2002-05-04 18:19 UTC (permalink / raw)
  To: pgsql-sql

More fun with the backend: I've found that I can incite a crash by
reloading a long, but syntactically correct function twice. Is this a
problem with my installation? --Joe

cal=> \i test
CREATE
cal=> select foo();
 foo 
-----
   1
(1 row)

cal=> \i test
CREATE
cal=> select foo();
pqReadData() -- backend closed the channel unexpectedly.
	This probably means the backend terminated abnormally
	before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 


On the console:

DEBUG:  server process (pid 18109) was terminated by signal 11
DEBUG:  terminating any other active server processes
DEBUG:  all server processes terminated; reinitializing shared memory and semaphores
DEBUG:  database system was interrupted at 2002-05-04 14:18:31 EDT
DEBUG:  checkpoint record is at 0/424D570
DEBUG:  redo record is at 0/424D570; undo record is at 0/0; shutdown TRUE
DEBUG:  next transaction id: 41770; next oid: 164012
DEBUG:  database system was not properly shut down; automatic recovery in progress
FATAL 1:  The database system is starting up
DEBUG:  redo starts at 0/424D5B0
DEBUG:  ReadRecord: record with zero length at 0/4253914
DEBUG:  redo done at 0/42538F0
DEBUG:  database system is ready


Function body:

CREATE OR REPLACE FUNCTION foo()
    RETURNS INTEGER
    AS '
DECLARE
	querystr TEXT;
BEGIN
querystr := ''
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 
             -- blah blah blah blah blah blah blah blah blah blah blah 


'';
return 1;
end;
'
language 'plpgsql';

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-05-04 18:35  dman <dman@dman.ddts.net>
  parent: Joseph Barillari <jbarilla@princeton.edu>
  1 sibling, 1 reply; 7+ messages in thread

From: dman @ 2002-05-04 18:35 UTC (permalink / raw)
  To: pgsql-sql

On Sat, May 04, 2002 at 02:19:35PM -0400, Joseph Barillari wrote:
| More fun with the backend: I've found that I can incite a crash by
| reloading a long, but syntactically correct function twice. Is this a
| problem with my installation? --Joe

Considering that you said postgres was built with gcc 2.96 I really
wouldn't be surprised.

http://gcc.gnu.org/gcc-2.96.html

Try using a real compiler and see if the problem still exists :-).

-D

-- 

Pleasant words are a honeycomb,
sweet to the soul and healing to the bones.
        Proverbs 16:24
 
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-05-04 18:44  Joseph Barillari <jbarilla@princeton.edu>
  parent: dman <dman@dman.ddts.net>
  0 siblings, 0 replies; 7+ messages in thread

From: Joseph Barillari @ 2002-05-04 18:44 UTC (permalink / raw)
  To: pgsql-sql

>>>>> "d" == dman  <dman@dman.ddts.net> writes:

    > On Sat, May 04, 2002 at 02:19:35PM -0400, Joseph Barillari
    > wrote: | More fun with the backend: I've found that I can incite
    > a crash by | reloading a long, but syntactically correct
    > function twice. Is this a | problem with my installation? --Joe

    > Considering that you said postgres was built with gcc 2.96 I
    > really wouldn't be surprised.

    > http://gcc.gnu.org/gcc-2.96.html

    > Try using a real compiler and see if the problem still exists
    > :-).

    > -D

I tried it on a Debian box with 2.95 (version 2.95.4 20011002 (Debian
prerelease)) and had the same problem.

--Joe

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-05-04 23:26  Roberto Mello <rmello@cc.usu.edu>
  parent: Joseph Barillari <jbarilla@princeton.edu>
  1 sibling, 1 reply; 7+ messages in thread

From: Roberto Mello @ 2002-05-04 23:26 UTC (permalink / raw)
  To: Joseph Barillari <jbarilla@princeton.edu>; +Cc: pgsql-sql

On Sat, May 04, 2002 at 02:19:35PM -0400, Joseph Barillari wrote:
> More fun with the backend: I've found that I can incite a crash by
> reloading a long, but syntactically correct function twice. Is this a
> problem with my installation? --Joe

<snip>

I created Joseph's function here and the my backend also crashes.

foobar=# select version();
                            version                            
---------------------------------------------------------------
 PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4

-Roberto

-- 
+----| http://fslc.usu.edu/ USU Free Software & GNU/Linux Club |------+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net/ 
       http://www.sdl.usu.edu/ - Space Dynamics Lab, Developer    
Homework time limit exceeded.  Auto logon in effect!



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-06-03 04:00  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Roberto Mello <rmello@cc.usu.edu>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruce Momjian @ 2002-06-03 04:00 UTC (permalink / raw)
  To: Roberto Mello <rmello@cc.usu.edu>; +Cc: Joseph Barillari <jbarilla@princeton.edu>; pgsql-sql


I just tried this on current sources and it was fine:

test=> select version();
                            version                             
----------------------------------------------------------------
 PostgreSQL 7.3devel on i386-pc-bsdi4.2, compiled by GCC 2.95.2
(1 row)


---------------------------------------------------------------------------

Roberto Mello wrote:
> On Sat, May 04, 2002 at 02:19:35PM -0400, Joseph Barillari wrote:
> > More fun with the backend: I've found that I can incite a crash by
> > reloading a long, but syntactically correct function twice. Is this a
> > problem with my installation? --Joe
> 
> <snip>
> 
> I created Joseph's function here and the my backend also crashes.
> 
> foobar=# select version();
>                             version                            
> ---------------------------------------------------------------
>  PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4
> 
> -Roberto
> 
> -- 
> +----| http://fslc.usu.edu/ USU Free Software & GNU/Linux Club |------+
>   Roberto Mello - Computer Science, USU - http://www.brasileiro.net/ 
>        http://www.sdl.usu.edu/ - Space Dynamics Lab, Developer    
> Homework time limit exceeded.  Auto logon in effect!
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Syntax error in plpgsql crashes backend
@ 2002-06-03 18:02  Joseph D. Barillari <jbarilla@Princeton.EDU>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Joseph D. Barillari @ 2002-06-03 18:02 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Roberto Mello <rmello@cc.usu.edu>; pgsql-sql

IIRC, a gentleman whose name escapes me fixed this in CVS -- the problem 
was that the PL/pgsql handler wasn't grabbing enough memory. The 
current devel sources should reflect the fix. --Joe


On Mon, 3 Jun 2002, Bruce Momjian wrote:

> 
> I just tried this on current sources and it was fine:
> 
> test=> select version();
>                             version                             
> ----------------------------------------------------------------
>  PostgreSQL 7.3devel on i386-pc-bsdi4.2, compiled by GCC 2.95.2
> (1 row)
> 
> 
> ---------------------------------------------------------------------------
> 
> Roberto Mello wrote:
> > On Sat, May 04, 2002 at 02:19:35PM -0400, Joseph Barillari wrote:
> > > More fun with the backend: I've found that I can incite a crash by
> > > reloading a long, but syntactically correct function twice. Is this a
> > > problem with my installation? --Joe
> > 
> > <snip>
> > 
> > I created Joseph's function here and the my backend also crashes.
> > 
> > foobar=# select version();
> >                             version                            
> > ---------------------------------------------------------------
> >  PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4
> > 
> > -Roberto
> > 
> > -- 
> > +----| http://fslc.usu.edu/ USU Free Software & GNU/Linux Club |------+
> >   Roberto Mello - Computer Science, USU - http://www.brasileiro.net/ 
> >        http://www.sdl.usu.edu/ - Space Dynamics Lab, Developer    
> > Homework time limit exceeded.  Auto logon in effect!
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> > 
> > http://www.postgresql.org/users-lounge/docs/faq.html
> > 
> 
> -- 
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2002-06-03 18:02 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-04 18:09 Syntax error in plpgsql crashes backend Joseph Barillari <jbarilla@princeton.edu>
2002-05-04 18:19 ` Joseph Barillari <jbarilla@princeton.edu>
2002-05-04 18:35   ` dman <dman@dman.ddts.net>
2002-05-04 18:44     ` Joseph Barillari <jbarilla@princeton.edu>
2002-05-04 23:26   ` Roberto Mello <rmello@cc.usu.edu>
2002-06-03 04:00     ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-06-03 18:02       ` Joseph D. Barillari <jbarilla@Princeton.EDU>

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