<div dir="ltr"><div>I tried statically linking liblwgeom by changing SHLIB_LINK from "-L/usr/local/lib -llwgeom" to "/usr/local/lib/liblwgeom.a" but the segfault in pfree occurred just as before.</div>
<div><br></div><div>There are no compile-time warnings when compiling the module:</div><div><br></div><div><div>$ make clean && make</div><div>rm -f test2.so   libtest2.a </div><div>rm -f test2.o</div>
<div>gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -g -O0 -I. -I. -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include/internal -D_GNU_SOURCE   -c -o test2.o test2.c</div>

<div>gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -shared -o test2.so test2.o -L/usr/local/pgsql/lib -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  /usr/local/lib/liblwgeom.a</div>

</div><div><br></div><div>I am not sure how to verify that there is no mismatch between postgresql-server headers at build time and postgresql  libraries at run time. `pg_config --includedir-server` returns "/usr/local/pgsql/include/server" which seems correct. According to ldd, neither my test2.so nor /usr/local/pgsql/lib/<a href="http://postgis-2.0.so" target="_blank">postgis-2.0.so</a> link to postgresql libraries:</div>

<div><br></div><div>test2.so dynamically linked to liblwgeom.so:</div><div><div>$ ldd test2.so</div><div><span style="white-space:pre-wrap">      </span>linux-vdso.so.1 =>  (0x00007fffad914000)</div><div>
<span style="white-space:pre-wrap">     </span><a href="http://liblwgeom-2.0.2.so" target="_blank">liblwgeom-2.0.2.so</a> => /usr/local/lib/<a href="http://liblwgeom-2.0.2.so" target="_blank">liblwgeom-2.0.2.so</a> (0x00007f5cfd2df000)</div>
<div><span style="white-space:pre-wrap">  </span>libc.so.6 => /lib64/libc.so.6 (0x00007f5cfcf4b000)</div>
<div><span style="white-space:pre-wrap">  </span>libgeos_c.so.1 => /usr/local/lib/libgeos_c.so.1 (0x00007f5cfcd27000)</div><div><span style="white-space:pre-wrap">  </span>libproj.so.0 => /usr/lib64/libproj.so.0 (0x00007f5cfcae4000)</div>

<div><span style="white-space:pre-wrap">  </span>/lib64/ld-linux-x86-64.so.2 (0x00007f5cfd764000)</div><div><span style="white-space:pre-wrap"> </span><a href="http://libgeos-3.3.6.so" target="_blank">libgeos-3.3.6.so</a> => /usr/local/lib/<a href="http://libgeos-3.3.6.so" target="_blank">libgeos-3.3.6.so</a> (0x00007f5cfc759000)</div>

<div><span style="white-space:pre-wrap">  </span>libstdc++.so.6 => /usr/local/lib/../lib64/libstdc++.so.6 (0x00007f5cfc452000)</div><div><span style="white-space:pre-wrap"> </span>libm.so.6 => /lib64/libm.so.6 (0x00007f5cfc1ce000)</div>

<div><span style="white-space:pre-wrap">  </span>libgcc_s.so.1 => /usr/local/lib/../lib64/libgcc_s.so.1 (0x00007f5cfbfb8000)</div></div><div><br></div><div>test2.so statically linked to liblwgeom.a:</div><div><div>$ ldd test2.so</div>
<div><span class="" style="white-space:pre">    </span>linux-vdso.so.1 =>  (0x00007fff27bff000)</div><div><span class="" style="white-space:pre">        </span>libc.so.6 => /lib64/libc.so.6 (0x00007f1476360000)</div><div><span class="" style="white-space:pre">      </span>/lib64/ld-linux-x86-64.so.2 (0x00007f1476951000)</div>
</div><div><div><br></div><div>$ ldd /usr/local/pgsql/lib/<a href="http://postgis-2.0.so">postgis-2.0.so</a> <br></div><div><span class="" style="white-space:pre">       </span>linux-vdso.so.1 =>  (0x00007fff11bff000)</div><div>
<span class="" style="white-space:pre">       </span>libgeos_c.so.1 => /usr/local/lib/libgeos_c.so.1 (0x00007f0077428000)</div><div><span class="" style="white-space:pre">    </span>libproj.so.0 => /usr/lib64/libproj.so.0 (0x00007f00771e4000)</div>
<div><span class="" style="white-space:pre">    </span>libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f0076e92000)</div><div><span class="" style="white-space:pre">    </span>libm.so.6 => /lib64/libm.so.6 (0x00007f0076c0e000)</div>
<div><span class="" style="white-space:pre">    </span>libc.so.6 => /lib64/libc.so.6 (0x00007f007687a000)</div><div><span class="" style="white-space:pre">      </span><a href="http://libgeos-3.3.6.so">libgeos-3.3.6.so</a> => /usr/local/lib/<a href="http://libgeos-3.3.6.so">libgeos-3.3.6.so</a> (0x00007f00764f0000)</div>
<div><span class="" style="white-space:pre">    </span>libstdc++.so.6 => /usr/local/lib/../lib64/libstdc++.so.6 (0x00007f00761e9000)</div><div><span class="" style="white-space:pre">   </span>libgcc_s.so.1 => /usr/local/lib/../lib64/libgcc_s.so.1 (0x00007f0075fd3000)</div>
<div><span class="" style="white-space:pre">    </span>libdl.so.2 => /lib64/libdl.so.2 (0x00007f0075dcf000)</div><div><span class="" style="white-space:pre">    </span>libz.so.1 => /lib64/libz.so.1 (0x00007f0075bb9000)</div>
<div><span class="" style="white-space:pre">    </span>/lib64/ld-linux-x86-64.so.2 (0x00007f0077926000)</div></div><div><br></div><div style>-Dave</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Jan 11, 2013 at 3:53 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 Thu, Jan 10, 2013 at 02:29:31PM -0500, David Fuhry wrote:<br>
<br>
> I built the latest stable versions of PostgreSQL (9.2.2) and PostGIS<br>
> (2.0.2), both built with --enable-debug, on a different machine (RHEL 6)<br>
> and following Paul's instructions, got the following backtrace showing the<br>
> segfault occurring in pfree:<br>
<br>
</div>[...]<br>
<div class="im"><br>
> Program received signal SIGSEGV, Segmentation fault.<br>
> 0x000000000072488b in pfree (pointer=0xc63e40) at mcxt.c:659<br>
> 659 (*header->context->methods->free_p) (header->context, pointer);<br>
<br>
</div>[...]<br>
<div class="im"><br>
> I noticed that header->context->methods points (as do ->parent and ->name)<br>
> to an invalid address:<br>
><br>
> (gdb) f 0<br>
> #0  0x000000000072488b in pfree (pointer=0xc63e40) at mcxt.c:659<br>
> 659 (*header->context->methods->free_p) (header->context, pointer);<br>
> (gdb) p *header->context<br>
> $8 = {type = 1237353800, methods = 0x7e01be000003c484, parent =<br>
> 0x9a00e8c789480087, firstchild = 0xfa840fc08548ffd4, nextchild =<br>
> 0x1c3883d0ff000002,<br>
>   name = 0x279840fc58948 <Address 0x279840fc58948 out of bounds>, isReset =<br>
> 0 '\000'}<br>
> (gdb) p *header->context->methods<br>
> Cannot access memory at address 0x7e01be000003c484<br>
><br>
> Suggestions?<br>
<br>
</div>Can it be a mismatch between postgresql-server headers at build time<br>
and postgresql libraries at run time ? Any compile-time warning ?<br>
Also try statically linking liblwgeom<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>