Re: Server Programming in C: palloc() and pfree()

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Rodrigo Hjort <rodrigo(dot)hjort(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Server Programming in C: palloc() and pfree()
Date: 2006-02-09 21:28:14
Message-ID: 20060209212814.GF14852@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 09, 2006 at 04:16:51PM -0200, Rodrigo Hjort wrote:
> I'm having some problems when using "pfree()" on functions in C.
> Calling it on "psql" gives the exception below on both versions of function
> "insert()" [1,2] if "pfree()" is enabled:
>
> server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
> conexão com servidor foi perdida
> (connection to the server was lost)
>
> The strange is that it doesn't happen with the function "delstr()" [3],
> which has "pfree()".
> What could am I doing wrong?

You havn't said how you are calling the functions. For example, did you
declare them as cstring or text? text is not null terminated but a
varlena struct. So if you use text you'll end up with buffer overruns.

Could you provide a complete example with SQL?
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-02-09 21:47:13 Re: Upcoming re-releases
Previous Message Mark Woodward 2006-02-09 20:45:42 Re: PostgreSQL 8.0.6 crash