browsermt / mts

Marian Translation Service
Apache License 2.0
18 stars 4 forks source link

Race condition in barrier #15

Closed kpu closed 3 years ago

kpu commented 3 years ago

Think about this code more:

https://github.com/browsermt/mts/blob/41978b4c225138432883a8c1abc98e7a86a31c2c/src/bergamot/request.cpp#L38-L40

Two threads could decrease the counter atomically then advance to see the counter is zero. Both threads would execute the code.

jerinphilip commented 3 years ago

Using pre-increment operator which should be atomic. Closing.

https://github.com/browsermt/mts/blob/e79286cbc590847c03a285a4a001fb99d444c514/src/bergamot/request.cpp#L34-L44