pthread
やられた。
pthread_create(&mThread, NULL, sThreadHandler, this); pthread_detach(mThread);
sThreadHandler が即行でリターンする場合、pthread_detach に来るまでにスレッドが既に終わっている場合もあるんだねぇ。
pthread_cleanup ハンドラを登録していて、そこで mThread をクリアしてたんで落ちたっぽい。
こんな感じで回避。
pthread_create(&mThread, NULL, sThreadHandler, this); if (mThread != 0) { pthread_detach(mThread); }
pthread API のラッパをつくって、pthread_t の NULL チェックとかした方が良いのかねぇ。