summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-05-15 16:07:12 +1200
committerGitHub <noreply@github.com>2022-05-15 16:07:12 +1200
commit32de6097b2b5d8394b3a1399e13d309444697954 (patch)
treebfcad8e159c733e0ed6ae0b6e72743cd2eb0e3c7 /thread.c
parent48002ff1877e2fedb5d3893eec4ea633b87ea22f (diff)
downloadruby-32de6097b2b5d8394b3a1399e13d309444697954.tar.gz
Fix various autoload race conditions. (#5898)
* Add RUBY_VM_CRITICAL_SECTION for detecting unexpected context switch. * Prevent race between GC mark and autoload setup. * Protect race on autoload state. * Avoid potential race condition when allocating `autoload_featuremap`. * Add NEWS entry for autoload fixes.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index aeb1a6308d..7582849767 100644
--- a/thread.c
+++ b/thread.c
@@ -1562,6 +1562,10 @@ static inline int
blocking_region_begin(rb_thread_t *th, struct rb_blocking_region_buffer *region,
rb_unblock_function_t *ubf, void *arg, int fail_if_interrupted)
{
+#ifdef RUBY_VM_CRITICAL_SECTION
+ VM_ASSERT(rb_vm_critical_section_entered == 0);
+#endif
+
region->prev_status = th->status;
if (unblock_function_set(th, ubf, arg, fail_if_interrupted)) {
th->blocking_region_buffer = region;