title: thread 'disappears' when blocking on read() how do i debug it?
body: <p>I have a multithreaded application, in c++ running under Linux (Fedora 27). One of the threads keep reading data from a file on the local disk using low-level IO (open, read, etc.) and supplies that data to a buffer that is rotated between other threads.</p>
  
  <p>Now, i suddenly ran into a strange problem where read() would start blocking infinitely for no apparent reason at arbitrary offset into the file. I added a monitor thread that would detect this block (by setting a timestamp before entering read() ) and attempt to shut down the program when it occurred.</p>
  
  <p>The weird thing now, is that at the end of the main thread, it waits for <code>pthread_join</code>, and on that read thread - it returns 0 (success).</p>
  
  <p>I tried again, but replaced the call to <code>read()</code> with a <code>while(1);</code> and now, <code>pthread_join</code> does not finish as expected.</p>
  
  <p>I then examined the program in gdb, and to my surprise when i reach the <code>pthread_join</code>, the read thread is GONE!</p>
  
  <p>Looking at <code>info thread</code> when the monitor thread detects a blocking <code>read()</code> the thread is still there, but at some point it disappears, and i can't catch it!</p>
  
  <p>I'm trying to catch this thread exiting and i'm looking for ideas on how to do so. I am using <code>pthread_cleanup_push/pop</code> but my function is not being invoked by the read thread (all other threads do).</p>
  
  <p>any ideas? i'm at my wits end!</p>
  
  <p>edit ----------------------------------------</p>
  
  <p>it appears to have something to do with <code>syslog</code> being called from a completely unrelated thread.</p>