Skip to content

tests/slice-concurrent.c: avoid using rand() from multiple threads

Alexander Richardson requested to merge arichardson/glib:concurrent-rand into main

The rand() function is not thread safe, and calling it from multiple threads can result in data corruption (especially with weaker memory models such as Arm). I encountered this data corruption as a buffer overflow while running the tests on an Arm Morello system. It appears that this does not cause issues in most configurations since GLibc uses a global lock and most of the time these tests are run on architectures with stronger memory ordering.

See https://github.com/CTSRD-CHERI/cheribsd/issues/1584 for more details. Split out from !3135 (closed) (not CHERI specific, general fix)

Merge request reports

Loading