jthread icon indicating copy to clipboard operation
jthread copied to clipboard

Stop token internal state double delete issue.

Open Grumpfy opened this issue 3 years ago • 2 comments

https://github.com/josuttis/jthread/blob/0fa8d394254886c555d6faccd0a3de819b7d47f8/source/stop_token.hpp#L56

Grumpfy avatar Jun 16 '21 07:06 Grumpfy

Hi everyone,

If you have two stop_token(s) alive and the originating source has already been destroyed, the first of the two remaining tokens that is destroyed will delete the internal state, and the second will double delete.

If my understanding of the code is correct, the test should be (in __remove_token_reference): if (__oldState < (__token_ref_increment + __token_ref_increment))

Grumpfy avatar Jun 16 '21 08:06 Grumpfy

Pull request: https://github.com/josuttis/jthread/pull/43

Grumpfy avatar Jun 16 '21 08:06 Grumpfy