Skip to content

Commit

Permalink
lib: Fix assert in thread_add_unuse if thread_execute was used
Browse files Browse the repository at this point in the history
* thread.c: (thread_call) thread_execute passes in a dummy thread, on its
  stack, with a NULL thread master. Those shouldn't be added to the unuse
  list or thread_add_unuse rightly asserts.

  Fix this very dumb bug.

  See https://bugzilla.quagga.net/show_bug.cgi?id=975

  With thanks to Sergey Popov, admin@pinkbyte.ru, and Andreas Nilsson,
  andrnils@resilans.se, for help with diagnosis and testing.
  • Loading branch information
pjakma committed Feb 19, 2018
1 parent fed5021 commit 9d7a49f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,12 @@ struct thread *thread_current = NULL;

/* We check thread consumed time. If the system has getrusage, we'll
use that to get in-depth stats on the performance of the thread in addition
to wall clock time stats from gettimeofday. */
to wall clock time stats from gettimeofday.
'Dummy' threads (e.g. see funcname_thread_execute) must have
thread->master == NULL.
*/

static void
thread_call (struct thread *thread)
{
Expand Down Expand Up @@ -1336,8 +1341,10 @@ thread_call (struct thread *thread)
realtime/1000, cputime/1000);
}
#endif /* CONSUMED_TIME_CHECK */


thread_add_unuse (thread);
if (thread->master)
thread_add_unuse (thread);
}

/* Execute thread */
Expand Down

0 comments on commit 9d7a49f

Please sign in to comment.