Skip site navigation (1) Skip section navigation (2)

PG_RETURN_TEXT_P crash server process

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: PG_RETURN_TEXT_P crash server process
Date: 2002-11-12 08:06:59
Message-ID: Pine.LNX.4.44.0211120842330.10119-200000@kix.fsv.cvut.cz (view raw or flat)
Thread:
Lists: pgsql-bugs
Hi 

I found some problem with PG_RETURN_TEXT_P. I have function for creating 
html list from table column (I use SPI). With small lists function works 
fine, but when items is more then 300 (returned text is great then 8K) 
For items < 200 is all ok. Increasing of page size helps.

Source code is in attachement. Function is registered 

create or replace function html_list (cstring, cstring, int, int) returns 
text as 'html_list.so', 'html_list' language 'C';

parameters is
1. SQL query
2. column's name
3. max items (0 - all)
4. page size

SELECT html_list('select jmeno from jmena','jmeno',100,2000); -- ok
SELECT length(html_list('select jmeno from jmena','jmeno',200,2000)); ok
NOTICE:  before alloc 4000
NOTICE:  after alloc
NOTICE:  Alokovan 137108256
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  before alloc 6000
NOTICE:  after alloc
NOTICE:  Alokovan 137114320
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  before alloc 8000
NOTICE:  after alloc
NOTICE:  Alokovan 137124648
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  BEFORE finish
NOTICE:  AFTER FINISH
 length
--------
   6674
(1 øádka)

SELECT html_list('select jmeno from jmena','jmeno',0,2000);   -- crash

NOTICE:  before alloc 4000
NOTICE:  after alloc
NOTICE:  Alokovan 137067288
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  before alloc 6000
NOTICE:  after alloc
NOTICE:  Alokovan 137073352
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  before alloc 8000
NOTICE:  after alloc
NOTICE:  Alokovan 137083680
NOTICE:  after memcpy
NOTICE:  befor pfree
NOTICE:  after pfree
NOTICE:  BEFORE finish
NOTICE:  AFTER FINISH
LOG:  server process (pid 6955) was terminated by signal 11
LOG:  terminating any other active server processes
WARNING:  Message from PostgreSQL backend:
        The Postmaster has informed me that some other backend
        died abnormally and possibly corrupted shared memory.
        I have rolled back the current transaction and am
        going to terminate your database system connection and exit.
        Please reconnect to the database system and repeat your query.

SELECT html_list('select jmeno from jmena','jmeno',0,8000); --ok

Why? What is wrong in my code. Page size has importatnt only for speed, 
not for functionality (I think).

I have RedHat 7.2, PostgreSQL 7.3b3 (in 7.3b1 is this problem too)

Pavel Stehule

Attachment: html_list.c
Description: text/plain (2.7 KB)

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-11-12 13:11:45
Subject: Re: PG_RETURN_TEXT_P crash server process
Previous:From: RPDate: 2002-11-12 03:56:12
Subject: Install problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group