smol-rs/concurrent-queue

Bounded queue does not work correctly with sizes not power of 2

link2xt opened this issue · 2 comments

Here is a report of a queue of size 1000 crashing trying to access index 1020 during dequeueing: https://github.com/deltachat/deltachat-core-rust/issues/2442

Edit: I posted a "testcase" here previously, but actually it does not reproduce the problem

After checking all the code paths, I don't see the way index inside of head can become 1020 for a queue of size 1000. :/

Maybe it is a hardware problem, feel free to close this if you are sure that index inside of head can't exceed bounded queue size.

I have made a small fix as a result of reading the code, but it is unlikely to affect 64-bit systems, especially fix a cause of crashes in apps early after startup: #12