On Thu, Apr 22, 2010 at 3:57 PM, Howard Butler <[email protected]> wrote: > > On Apr 22, 2010, at 3:28 AM, Sean Gillies wrote: > >> On Tue, Apr 20, 2010 at 3:48 PM, Jean-Baptiste Quenot <[email protected]> >> wrote: >>> Hi there, >>> >>> First, thanks for the great piece of software! >>> >>> I am a happy user of Shapely since a few years, but since I upgraded >>> my server to Ubuntu 9.10 I notice the following message everytime I my >>> Python application ends: >>> >>> *** glibc detected *** python: double free or corruption (!prev): >>> 0x00000000018839b0 *** >>> >>> Also, the process hangs and never completes. This problem is >>> particularly painful when Python is run as a CGI within Apache, as >>> HTTP requests will never complete. Otherwise on the command-line, I >>> just issue a CTRL-C to stop it. >>> >>> Software that has changed during the Ubuntu upgrade includes: >>> >>> * Python, from 2.6.2 to 2.6.4 >>> * Libgeos, from 3.0.0 to 3.1.0 >>> >>> I tried to upgrade shapely from 1.0.11 to 1.0.14 with no luck. >>> >>> Note that I also use python-mapscript, the package that comes with >>> mapserver, also using libgeos. I verified that only one version of >>> libgeos is installed and used. >>> >>> Here is the gdb backtrace during the hang: >>> >>> #0 __lll_lock_wait_private () at >>> ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97 >>> #1 0x00007f238c6c7b11 in _L_lock_9274 () from /lib/libc.so.6 >>> #2 0x00007f238c6c5741 in *__GI___libc_free (mem=0x7f238c9b5e40) at >>> malloc.c:3714 >>> #3 0x00007f238d48ab32 in _dl_scope_free (old=0xf6e5b0) at dl-open.c:175 >>> #4 0x00007f238d485035 in _dl_map_object_deps (map=0x7f238d697530, >>> preloads=<value optimized out>, npreloads=<value optimized out>, >>> trace_mode=<value optimized out>, open_mode=<value optimized out>) at >>> dl-deps.c:668 >>> #5 0x00007f238d48ada3 in dl_open_worker (a=<value optimized out>) at >>> dl-open.c:326 >>> #6 0x00007f238d486386 in _dl_catch_error (objname=<value optimized >>> out>, errstring=<value optimized out>, mallocedp=<value optimized >>> out>, operate=<value optimized out>, args=<value optimized out>) at >>> dl-error.c:178 >>> #7 0x00007f238d48a6c7 in _dl_open (file=0x7f238c77e2ae >>> "libgcc_s.so.1", mode=-2147483647, caller_dlopen=0x0, nsid=-2, argc=1, >>> argv=0x18, env=0xafed90) at dl-open.c:615 >>> #8 0x00007f238c767c00 in do_dlopen (ptr=0x7ffff3913b10) at dl-libc.c:86 >>> #9 0x00007f238d486386 in _dl_catch_error (objname=<value optimized >>> out>, errstring=<value optimized out>, mallocedp=<value optimized >>> out>, operate=<value optimized out>, args=<value optimized out>) at >>> dl-error.c:178 >>> #10 0x00007f238c767d57 in dlerror_run (name=<value optimized out>, >>> mode=<value optimized out>) at dl-libc.c:47 >>> #11 *__GI___libc_dlopen_mode (name=<value optimized out>, mode=<value >>> optimized out>) at dl-libc.c:160 >>> #12 0x00007f238c7426e5 in init () at >>> ../sysdeps/x86_64/../ia64/backtrace.c:41 >>> #13 0x00007f238d2687a3 in pthread_once () at >>> ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S:94 >>> #14 0x00007f238c7427e4 in *__GI___backtrace (array=<value optimized >>> out>, size=64) at ../sysdeps/x86_64/../ia64/backtrace.c:79 >>> #15 0x00007f238c6b6cab in __libc_message (do_abort=<value optimized >>> out>, fmt=<value optimized out>) at >>> ../sysdeps/unix/sysv/linux/libc_fatal.c:168 >>> #16 0x00007f238c6c0dd6 in malloc_printerr (action=3, >>> str=0x7f238c7827b0 "double free or corruption (!prev)", ptr=<value >>> optimized out>) at malloc.c:6217 >>> #17 0x00007f238c6c574c in *__GI___libc_free (mem=<value optimized >>> out>) at malloc.c:3716 >>> #18 0x00007f2384a5130b in msGEOSCleanup () from >>> /usr/lib/python2.6/dist-packages/_mapscript.so >>> #19 0x00007f2384969fda in msCleanup () from >>> /usr/lib/python2.6/dist-packages/_mapscript.so >>> #20 0x00000000004c2cc2 in call_ll_exitfuncs () at ../Python/pythonrun.c:1705 >>> #21 Py_Finalize () at ../Python/pythonrun.c:534 >>> #22 0x00000000004185c2 in Py_Main (argc=<value optimized out>, >>> argv=<value optimized out>) at ../Modules/main.c:625 >>> #23 0x00007f238c669abd in __libc_start_main (main=<value optimized >>> out>, argc=<value optimized out>, ubp_av=<value optimized out>, >>> init=<value optimized out>, fini=<value optimized out>, >>> rtld_fini=<value optimized out>, stack_end=0x7ffff3914738) at >>> libc-start.c:220 >>> #24 0x0000000000417ca9 in _start () at ../sysdeps/x86_64/elf/start.S:113 >>> >>> I have no clue where the problem comes from, however, when I edit the >>> installed python2.6/shapely/geos.py module and comment the cleanup >>> code, Python does not crash anymore: >>> >>> def cleanup(): >>> if lgeos is not None: >>> pass >>> #lgeos.finishGEOS() >>> >>> Any idea? Your help will be much appreciated. >> >> Hi Jean-Baptiste, >> >> I suspect at-exit cleanup collision: mapscript's msCleanup is freeing >> some memory allocated by libgeos and when Shapely exits, cleanup() >> attempts to free that same memory. I've created a ticket in the >> tracker: >> >> http://trac.gispython.org/lab/ticket/217 >> >> If you've anything to add, please register and do so. In the >> meanwhile, do not use Shapely with mapscript. Mapscript provides most >> of the functionality if not such a handy API. >> > > I fixed this problem in a newer version of GEOS > (http://trac.osgeo.org/geos/ticket/256) so it will not double free in > finishGEOS. Another thing to try.... >
That's good news. Shapely 1.2 has its own private GEOS handle and is safe to use with mapscript. -- Sean _______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
