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

Re: PG_RETURN_TEXT_P crash server process (solved)

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PG_RETURN_TEXT_P crash server process (solved)
Date: 2002-11-13 08:09:44
Message-ID: Pine.LNX.4.44.0211130905210.17441-100000@kix.fsv.cvut.cz (view raw or flat)
Thread:
Lists: pgsql-bugs
Hi

PG_RETURN_TEXT_P works well. I made beginer error. I allocated memory by 
palloc and before PG_RETURN_TEXT_P deallocated by SPI_finish. After change 
SPI_palloc between palloc my function works.

Thank you
Pavel

On Tue, 12 Nov 2002, Pavel Stehule wrote:

> You have true. When I modify code on 
> 
>  long ma = ((*saved_chars + l + VARHDRSZ) / page_size + 1) * page_size;
>  *allocated_free = ma - *saved_chars - VARHDRSZ;
> 
> my function works well. Thank you wery much. One night I lost with this 
> :->
> 
> On Tue, 12 Nov 2002, Tom Lane wrote:
> 
> > Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> writes:
> > > I found some problem with PG_RETURN_TEXT_P.
> > 
> > Fix your code to not scribble on memory that doesn't belong to it,
> > and all will be well.  I can see at least two buffer-overrun bugs,
> > and there may be more:
> > 
> >       txtn = (text *) palloc (ma);	-- forgot to add VARHDRSZ
> > 
> >   strcpy (*str_pointer, str);		-- copies one byte too many
> > 
> > 			regards, tom lane
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
> > 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
> 


In response to

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2002-11-13 09:44:59
Subject: Bug #816: Bad time conversion from type abstime to datetime
Previous:From: pgsql-bugsDate: 2002-11-13 06:11:42
Subject: Bug #815: after trigger not working in begin-commit block (no bug)

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