Skip to content

Commit b141c77

Browse files
committed
Block GC while creating Thread/Fiber structures.
1 parent 14e9e54 commit b141c77

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

machine/builtin/fiber.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ namespace rubinius {
236236
std::ostringstream name;
237237
name << "fiber." << fiber->fiber_id()->to_native();
238238

239-
fiber->vm(state->vm()->thread_nexus()->new_vm(&state->shared(), name.str().c_str()));
239+
{
240+
BlockPhase blocking(state);
241+
fiber->vm(state->vm()->thread_nexus()->new_vm(&state->shared(), name.str().c_str()));
242+
}
243+
240244
fiber->vm()->set_kind(memory::ManagedThread::eFiber);
241245
fiber->vm()->set_suspending();
242246

machine/builtin/thread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ namespace rubinius {
8787
}
8888

8989
Thread* Thread::create(STATE, Object* self, ThreadFunction function) {
90-
VM* vm = state->shared().thread_nexus()->new_vm(&state->shared());
90+
BlockPhase blocking(state);
9191

92-
return Thread::create(state, self, vm, function);
92+
return Thread::create(state, self,
93+
state->shared().thread_nexus()->new_vm(&state->shared()),
94+
function);
9395
}
9496

9597
Thread* Thread::create(STATE, Object* self, VM* vm, ThreadFunction function) {

0 commit comments

Comments
 (0)