diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-02-28 23:58:33 -0800 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2020-03-15 19:35:24 +0900 |
commit | a36ead3f4fe801ddaebe6d1ed905e9e3276dbac7 (patch) | |
tree | 53de69643c057929db9305329fa16989b96c9ded /cont.c | |
parent | 17e925b9917f4877f2da8c64316feb3ce1ca2932 (diff) | |
download | ruby-a36ead3f4fe801ddaebe6d1ed905e9e3276dbac7.tar.gz |
Prevent unloading methods used in root_fiber while calling another Fiber (#2939)
Fixing SEGVs like:
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400
[Bug #16664]
(cherry picked from commit adcf0316d1ecedae2a9157ad941550e0c0fb510b)
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -1097,6 +1097,15 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th) } static void +cont_init_mjit_cont(rb_context_t *cont) +{ + VM_ASSERT(cont->mjit_cont == NULL); + if (mjit_enabled) { + cont->mjit_cont = mjit_cont_new(&(cont->saved_ec)); + } +} + +static void cont_init(rb_context_t *cont, rb_thread_t *th) { /* save thread context */ @@ -1105,9 +1114,7 @@ cont_init(rb_context_t *cont, rb_thread_t *th) cont->saved_ec.local_storage = NULL; cont->saved_ec.local_storage_recursive_hash = Qnil; cont->saved_ec.local_storage_recursive_hash_for_trace = Qnil; - if (mjit_enabled) { - cont->mjit_cont = mjit_cont_new(&cont->saved_ec); - } + cont_init_mjit_cont(cont); } static rb_context_t * @@ -1124,6 +1131,14 @@ cont_new(VALUE klass) return cont; } +void +rb_fiber_init_mjit_cont(struct rb_fiber_struct *fiber) +{ + // Currently this function is meant for root_fiber. Others go through cont_new. + // XXX: Is this mjit_cont `mjit_cont_free`d? + cont_init_mjit_cont(&fiber->cont); +} + #if 0 void show_vm_stack(const rb_execution_context_t *ec) |