From c7ddf9d5165ff3fd739f1b3f54837899c185a0be Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 30 May 2015 00:14:34 +0000 Subject: [PATCH] cont.c: Check ruby_current_thread * cont.c (cont_free): check if ruby_current_thread is still valid. [Fix GH-914] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ cont.c | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8d45266f5..9a2ff24ffd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat May 30 09:14:28 2015 Scott Francis + + * cont.c (cont_free): check if ruby_current_thread is still valid. + [Fix GH-914] + Sat May 30 08:36:04 2015 Eric Wong * variable.c (static int special_generic_ivar): move diff --git a/cont.c b/cont.c index 22e0c5abe0..703007dc8b 100644 --- a/cont.c +++ b/cont.c @@ -236,17 +236,16 @@ cont_free(void *ptr) else { /* fiber */ rb_fiber_t *fib = (rb_fiber_t*)cont; + const rb_thread_t *const th = GET_THREAD(); #ifdef _WIN32 - if (GET_THREAD()->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) { + if (th && th->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) { /* don't delete root fiber handle */ - rb_fiber_t *fib = (rb_fiber_t*)cont; if (fib->fib_handle) { DeleteFiber(fib->fib_handle); } } #else /* not WIN32 */ - if (GET_THREAD()->fiber != fib) { - rb_fiber_t *fib = (rb_fiber_t*)cont; + if (th && th->fiber != fib) { if (fib->ss_sp) { if (cont->type == ROOT_FIBER_CONTEXT) { rb_bug("Illegal root fiber parameter");