this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

workq_kernreturn: Assign to variables when terminating

We were accidentally using NULL by forgetting to assign to `dthread` and `thread_self` when resuming the thread to kill it.

+6 -7
+6 -7
src/kernel/emulation/linux/bsdthread/workq_kernreturn.c
··· 164 164 // resume the thread; it'll call `_pthread_wqthread_exit` and kill itself 165 165 goto resume_thread; 166 166 } 167 - wakeup: 168 - 169 - // reset stack and call entry point again with WQ_FLAG_THREAD_REUSE 170 - thread_self = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_MACH_THREAD_SELF); 171 - dthread = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_SELF); 172 167 168 + wakeup: // we actually want to go back into the thread to do work 173 169 // __simple_printf("Thread %d woken up, prio=%d\n", thread_self, me.flags & WQ_FLAG_THREAD_PRIOMASK); 174 170 175 171 if (me.event) 176 172 wq_event_pending = me.event; 177 173 178 - resume_thread: 174 + resume_thread: // we want the thread to resume, but it might be just to die 175 + // reset stack and call entry point again with WQ_FLAG_THREAD_REUSE 176 + thread_self = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_MACH_THREAD_SELF); 177 + dthread = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_SELF); 179 178 180 179 #ifdef __x86_64__ 181 180 // arguments are in rdi, rsi, rdx, rcx, r8, r9 ··· 197 196 "subl $32, %%esp\n" 198 197 "jmpl *%2\n" 199 198 :: "a" (dthread), "b" (thread_self), "S" (wqueue_entry_point), 200 - "D" (me.flags | WQ_FLAG_THREAD_REUSE), "d" (me.event ? me.event->events : NULL), 199 + "D" (me.flags | WQ_FLAG_THREAD_REUSE), "d" ((!terminating && me.event) ? me.event->events : NULL), 201 200 "S" (terminating ? WORKQ_EXIT_THREAD_NKEVENT : (me.event ? me.event->nevents : 0)), "c" (dthread->stackbottom) 202 201 ); 203 202 #else