[postgis-devel] C-Library function returning PostGIS point crashing backend

Sandro Santilli strk at keybit.net
Thu Jan 10 08:53:23 PST 2013


On Thu, Jan 10, 2013 at 10:57:08AM -0500, David Fuhry wrote:

>    I'm trying to write a C-Library function to return a PostGIS point. It's
> crashing the backend when called:
> 
> => select test2();
> The connection to the server was lost. Attempting reset: Failed.

[...]

> #include "liblwgeom.h"
> 
> PG_MODULE_MAGIC;
> 
> /* This is needed by liblwgeom */
> void lwgeom_init_allocators(void)
> {
>   lwgeom_install_default_allocators();
> }

David, if you're using current trunk you'll need and explicit
call to lwgeom_set_handlers() for registering allocators for liblwgeom.
Simply defining lwgeom_init_allocators is not enough anymore.

Note that failing to register the handlers will result in lwerror
simply printing an error on stderr but not interrupting the control
flow in your function body. I noticed there's no PG_RETURN_NULL() 
on error, it's a good practice to not assume lwerror throws an
exception.

--strk;




More information about the postgis-devel mailing list