1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00

DEV: test_concurrent_access causing segfaults

In Ruby <=2.7, SecureRandom.hex lazily defined `gen_random'.
While the method definition itself was protected by a mutex,
another thread calling `gen_random' did not take the mutex so
it would attempt to call the method while another method was
still defining it.

Ruby 3.0+ has commit 475c8701d74ebebe (Make SecureRandom support
Ractor, 2020-09-04) which also made it thread-safe in addition
to being Ractor-safe.
This commit is contained in:
Sam Saffron 2021-12-10 15:28:37 +11:00
parent 81f30046d7
commit feb8dc4cbf
No known key found for this signature in database
GPG key ID: B9606168D2FFD9F5

View file

@ -583,6 +583,10 @@ raise FooError, "I like foos"
equals_after_sleep = {}
# workaround Rubies prior to commit 475c8701d74ebebe
# (Make SecureRandom support Ractor, 2020-09-04)
SecureRandom.hex
(1..10).map do |i|
Thread.new {
random = SecureRandom.hex