artem-ogre/CDT

VertexInsertionOrder::Randomized is not thread safe

proc-sim opened this issue · 2 comments

Sorry for the rapid-fire issue reporting...I'm testing CDT in a high performance geometry fracturing library that's using CDT for slice cap triangulation...so I'm putting CDT through the wringer against hundreds of thousands of test cases on complex polygons.

Anyways, VertexInsertionOrder::Randomized is not thread safe (multiple CDT operations cannot be run simultaneously) because your random_shuffle function relies on a static instance of an mt19937 generator that may be unsafely accessed by multiple concurrent threads.

A solution might be to allow users to provide their own pointer to a generator as an argument in the CDT constructor. That way local generators can be constructed in each thread running CDT operations...

This is a known issue: #97
The fix for it is in the new-insertion-sequence branch:
23f3dcf

Which I did not find time to merge yet, unfortunately. There is one complex data-set that produces different result on this branch and needs time for investigation. Maybe I should cherry-pick random fix separately.

Fixed.