Commit f6a2fd84 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Threading fix: keep thread-start arguments alive

I think this ends up not affecting the interpreter because the interpreter
frame (that spawns the thread) ends up keeping the args alive for long enough?
parent 0cef6e28
......@@ -59,10 +59,14 @@ static size_t _pythread_stacksize = 0;
namespace pyston {
static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
static void* thread_start(STOLEN(Box*) target, STOLEN(Box*) varargs, STOLEN(Box*) kwargs) {
assert(target);
assert(varargs);
AUTO_DECREF(target);
AUTO_DECREF(varargs);
AUTO_XDECREF(kwargs);
#if STAT_TIMERS
// TODO: maybe we should just not log anything for threads...
static uint64_t* timer_counter = Stats::getStatCounter("us_timer_thread_start");
......@@ -90,7 +94,7 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
// TODO this should take kwargs, which defaults to empty
Box* startNewThread(Box* target, Box* args, Box* kw) {
intptr_t thread_id = start_thread(&thread_start, target, args, kw);
intptr_t thread_id = start_thread(&thread_start, incref(target), incref(args), xincref(kw));
return boxInt(thread_id);
}
......
# expected: reffail
from thread import start_new_thread
import time
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment