While testing “Project: Sippy-Cup [1],” one of the components I was using for testing asserted [2]:
>
```
tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' failed.
```
This is not good. This wasn't our code that called assert(), but pthreads [3].
Sigh.
The hardest part of debugging this was getting it to happen consistently (yes, it's one of those bugs [4]) to test out various hypotheses.
It wasn't neglecting to initialize a variable [5]. It wasn't a compiler bug (It's never lupus!) [6]. It turned out to be a abuse of the mutex API (Application Program Interface) [7], where one thread locks a mutex, and some other thread attempts to unlock the mutex.
[2] http://pubs.opengroup.org/onlinepubs/009695399/functions/assert.html
[3] https://en.wikipedia.org/wiki/POSIX_Threads
[4] https://en.wikipedia.org/wiki/Race_condition
[5] http://stackoverflow.com/questions/21825291/threading-issues
[6] https://gcc.gnu.org/ml/gcc-bugs/2006-10/msg00805.html
[7] http://stackoverflow.com/questions/1105745/pthread-mutex-assertion-error