summaryrefslogtreecommitdiff
path: root/load.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-28 17:50:25 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-28 19:39:43 +0900
commit7cfabe1acc55b24fc2c479a87efa71cf74e9e8fc (patch)
tree6ff14d14f7a545c0efd5728d1d79173f450bf8e6 /load.c
parent6391132c03ac08da0483adb986ff9a54e41f9e14 (diff)
Preserve `ec` argument across `longjmp`
Fix segfault on icc 2023.2. An optimizer may allocate this argument to a register, and it may be clobbered by `longjmp`, e.g. exceptions.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8135
Diffstat (limited to 'load.c')
-rw-r--r--load.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/load.c b/load.c
index 499d5af6f2..0d4fbae5a6 100644
--- a/load.c
+++ b/load.c
@@ -1184,8 +1184,10 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
rb_thread_t *th = rb_ec_thread_ptr(ec);
volatile const struct {
VALUE wrapper, self, errinfo;
+ rb_execution_context_t *ec;
} saved = {
th->top_wrapper, th->top_self, ec->errinfo,
+ ec,
};
enum ruby_tag_type state;
char *volatile ftptr = 0;
@@ -1248,6 +1250,7 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
}
EC_POP_TAG();
+ ec = saved.ec;
rb_thread_t *th2 = rb_ec_thread_ptr(ec);
th2->top_self = saved.self;
th2->top_wrapper = saved.wrapper;