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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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 Content-Type Size
html_list.c text/plain 2.7 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-11-12 13:11:45 Re: PG_RETURN_TEXT_P crash server process
Previous Message RP 2002-11-12 03:56:12 Install problem