[geos-devel] [GEOS] #1052: Thread safety: C API contexts use shared GeometryFactory without any refCount synchronization

GEOS geos-trac at osgeo.org
Mon Sep 28 13:03:56 PDT 2020


#1052: Thread safety: C API contexts use shared GeometryFactory without any
refCount synchronization
------------------------+--------------------------
 Reporter:  macdrevx    |      Owner:  geos-devel@…
     Type:  defect      |     Status:  new
 Priority:  major       |  Milestone:
Component:  Default     |    Version:  3.6.2
 Severity:  Unassigned  |   Keywords:
------------------------+--------------------------
 The C API's `GEOSContextHandle_HS` initializes its `geomFactory` fields
 via

 {{{
 geomFactory = GeometryFactory::getDefaultInstance();
 }}}

 Various operations subsequently utilize the reference counting features of
 `GeometryFactory` without synchronization.

 We have
 [https://github.com/GEOSwift/GEOSwift/issues/190#issuecomment-699502839
 observed] that this can lead to data races.

 It appears as though a corruption of the value in `_refCount` could
 possibly be harmless so long as `GeometryFactory::destroy()` is never
 invoked, thus setting `_autoDestroy` to `true`. As far as I can tell,
 `destroy()` is never invoked on `GeometryFactory` returned from
 `getDefaultInstance()`, so perhaps we're getting lucky so long as we're
 only using the C API.

-- 
Ticket URL: <https://trac.osgeo.org/geos/ticket/1052>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).


More information about the geos-devel mailing list