[geos-devel] [GEOS] #1012: Thread Sanitizer warns of data race in geos::util::Interrupt::cancel()

GEOS geos-trac at osgeo.org
Sat Oct 10 11:48:38 PDT 2020


#1012: Thread Sanitizer warns of data race in geos::util::Interrupt::cancel()
------------------------+---------------------------
 Reporter:  macdrevx    |       Owner:  geos-devel@…
     Type:  defect      |      Status:  new
 Priority:  major       |   Milestone:
Component:  Default     |     Version:  master
 Severity:  Unassigned  |  Resolution:
 Keywords:              |
------------------------+---------------------------

Comment (by macdrevx):

 I've spent some time considering what would be gained by making
 `requested` atomic. While it would avoid the data race on that particular
 memory, it would not result in a thread-safe system overall.

 Consider this example: there are long-running operations on 2 threads. A
 3rd thread requests an interrupt. The result could be either:

 A. 1 thread is interrupted (passes the check at Interrupt.cpp:66 and
 executes line 67 to lock out the other thread), or
 B. Both threads are interrupted. (Both threads pass the check at
 Interrupt.cpp:66 before either one executes line 67).

 Which scenario occurs (and within scenario A, which thread is interrupted)
 depends on the timing.

 A better solution would provide an interface that allows the consumer to
 be specific about their intent. My current thought is that for the thread
 safe CAPI we could design a new interface that would allow requesting an
 interrupt only on a specific context. Ideally, any such interface would
 avoid requiring the CAPI consumer to implement synchronization mechanisms
 around the context. Optionally, we could maintain the existing
 `GEOS_interruptRequest` interface to allow requesting interruption on
 '''all''' contexts.

 I have some implementation ideas, but I'll wait to share them until after
 getting some feedback about whether this general direction is desirable.

-- 
Ticket URL: <https://trac.osgeo.org/geos/ticket/1012#comment:4>
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