[geos-devel] Segmentation fault when using intersect with multithreading

Tanguy Fardet fardet.tanguy at laposte.net
Thu Nov 23 07:20:58 PST 2017


Hi,
thank you for your answer.

I am using the C API, and your macro allowed me to find a few places 
where I was using non-reentrant functions.
After recompiling, the code still fails if I remove the critical 
section, though.
Unfortunately, the code of the simulator is quite complex so I cannot 
really provide a MWE, the best I can give is what is on the SO post and 
the backtrace.

The new backtrace reads:

    Thread 22 "python" received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7fffa126e700 (LWP 6548)]
    0x00007fffa220fb35 in
    geos::noding::MCIndexSegmentSetMutualIntersector::intersectChains()
    () from /usr/lib/libgeos-3.6.2.so
    (gdb) bt
    #0  0x00007fffa220fb35 in
    geos::noding::MCIndexSegmentSetMutualIntersector::intersectChains()
    () from /usr/lib/libgeos-3.6.2.so
    #1  0x00007fffa220d661 in
    geos::noding::FastSegmentSetIntersectionFinder::intersects(std::vector<geos::noding::SegmentString
    const*, std::allocator<geos::noding::SegmentString const*> >*,
    geos::noding::SegmentIntersectionDetector*) ()
        from /usr/lib/libgeos-3.6.2.so
    #2  0x00007fffa220d6d5 in
    geos::noding::FastSegmentSetIntersectionFinder::intersects(std::vector<geos::noding::SegmentString
    const*, std::allocator<geos::noding::SegmentString const*> >*) ()
    from /usr/lib/libgeos-3.6.2.so
    #3  0x00007fffa21d55ca in
    geos::geom::prep::PreparedLineStringIntersects::intersects(geos::geom::Geometry
    const*) const () from /usr/lib/libgeos-3.6.2.so
    #4  0x00007fffa21d4f96 in
    geos::geom::prep::PreparedLineString::intersects(geos::geom::Geometry
    const*) const () from /usr/lib/libgeos-3.6.2.so
    #5  0x00007fffa24df380 in GEOSPreparedIntersects_r ()
        from /usr/lib/libgeos_c.so.1
    #6  0x00007fffa27e391b in growth::SpaceManager::env_intersect (
         this=0x555555f68918, line=std::shared_ptr (count 1, weak 0)
    0x7fff8c001430)
         at
    /home/tfardet/Documents/GitLabo/Growth/src/kernel/space_manager.cpp:122

L122 is in the code on the SO post 
<https://stackoverflow.com/questions/47182166/segfault-when-testing-the-intersection-with-geos-in-parallel>. 
Hope this helps.

In the meantime, I will try generating one PreparedGeometry object per 
thread to see if this helps.

Best,
Tanguy


Le 23/11/2017 à 15:50, Sandro Santilli a écrit :
> Are you using the C or C++ API ?
> When using the C API you can define
> the GEOS_USE_ONLY_R_API macro to be
> sure to be only using thread-safe methods.
>
> If you find a non-reentrant path by using that
> API then please file a bug report including
> the smallest testcase.
>
> --strk;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20171123/b44637bb/attachment.html>


More information about the geos-devel mailing list