<div dir="ltr">Dropping the lwgeom_init_allocators function doesn't work because CREATE FUNCTION then fails with error:<div>ERROR:  could not load library "/usr/local/pgsql/lib/test2.so": /usr/local/pgsql/lib/test2.so: undefined symbol: lwgeom_init_allocators<br>
<div><br></div></div><div style>Declaring an empty lwgeom_init_allocators doesn't work because an infinite loop seems to occur where lwgeom_init_allocators is repeatedly called (I think).</div><div style><br></div><div style>
What did work was imitating libpgcommon/lwgeom_pg.c and defining my own pg_alloc etc., then having lwgeom_init_allocators assign lwalloc_var = pg_alloc; and likewise for the others. strk I think you were right about allocation using malloc and deallocation using pfree because the implementation of lwgeom_install_default_allocators (in lwutil.c) sets lwalloc_var = default_allocator; and default_allocator uses malloc.</div>
<div style><br></div><div style>Thanks for the help, all. Working code is attached.</div><div style><br></div><div style>-Dave</div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Jan 15, 2013 at 3:04 AM, Sandro Santilli <span dir="ltr"><<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Mon, Jan 14, 2013 at 10:19:52PM -0500, David Fuhry wrote:<br>
> Not sure if this reveals anything more, but here's the valgrind output.<br>
> Apparently the segfault is of reading 16 bytes before the memory location<br>
> malloced in lwgeom_to_wkb, I don't know if that's a coincidence or not.<br>
<br>
</div>16 bytes could the the amount of bytes used for postgresql memory<br>
management functions, so it could really be that postgis is allocating<br>
with malloc and deallocating with pfree, pointing back to liblwgeom<br>
memory initialization functions.<br>
Try to drop the memory management initialization function and see<br>
what happens. Or try to get liblwgeom initialized with your own<br>
management functions and see how/when they are called.<br>
<div class="HOEnZb"><div class="h5"><br>
--strk;<br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
</div></div></blockquote></div><br></div>