jimjag opened a new pull request, #79: URL: https://github.com/apache/apr/pull/79
`get_b_rand()` keeps its state in two function statics, so threads inserting into different skiplists, each under its own lock, race on them. httpd's MotorZ MPM does this, with one skiplist per poller thread, and ThreadSanitizer reports the race. The state now lives in the skiplist. It is an xorshift32 instead of `rand()`, which POSIX does not require to be thread-safe either. The old code also took 32 bits from each `rand()` call, so where `RAND_MAX` is 0x7fff (Windows) 17 of every 32 bits were zero and node heights came out lower than intended. There is no regression test, as the race does not fail deterministically. With four threads each inserting into and removing from its own list, ThreadSanitizer reports 5–6 races in `get_b_rand()` before this change and none after; `testskiplist` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
