title: _XReply() terminates app with _XIOError()
body: <p>We're developing some complexed application which consists of linux binary integrated with java jni calls (from JVM created in linux binary) from our custom made .jar file. All gui work is implemented and done by java part. Each time some gui property has to be changed or gui has to be repainted, it is done by jni call to JVM.</p>
  
  <p>Complete display/gui is repainted (or refreshed) as fast as JVM/java can handle it. It is done iteratively and frequently, few hunderds or thousands iterations per second.</p>
  
  <p>After some exact time, application is terminated with <code>exit(1)</code> which I caught with gdb to be called from <code>_XIOError()</code>. This termination can be repeated after more or less exact time period, e.g. after some 15h on x86 dual core 2.5GHz. If I use some slower computer, it lasts longer, like it is proportional to cpu/gpu speed. Some conclusion would be that some part of xorg ran out of some resource or something like that.</p>
  
  <p>Here is my backtrace:</p>
  
  <pre><code>#0  0xb7fe1424 in __kernel_vsyscall ()
  #1  0xb7c50941 in raise () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
  #2  0xb7c53d72 in abort () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
  #3  0xb7fdc69d in exit () from /temp/bin/liboverrides.so
  #4  0xa0005c80 in _XIOError () from /usr/lib/i386-linux-gnu/libX11.so.6
  #5  0xa0003afe in _XReply () from /usr/lib/i386-linux-gnu/libX11.so.6
  #6  0x9fffee7b in XSync () from /usr/lib/i386-linux-gnu/libX11.so.6
  #7  0xa01232b8 in X11SD_GetSharedImage () from /usr/lib/jvm/jre1.8.0_20/lib/i386/libawt_xawt.so
  #8  0xa012529e in X11SD_GetRasInfo () from /usr/lib/jvm/jre1.8.0_20/lib/i386/libawt_xawt.so
  #9  0xa01aac3d in Java_sun_java2d_loops_ScaledBlit_Scale () from /usr/lib/jvm/jre1.8.0_20/lib/i386/libawt.so
  </code></pre>
  
  <p>I made my own <code>exit()</code> call in liboverrides.so and used it with LD_PRELOAD to capture <code>exit()</code> call in gdb with help of <code>abort()</code>/SIGABRT.
  After some debugging of libX11 and libxcb, I noticed that <code>_XReply()</code> got NULL reply (response from <code>xcb_wait_for_reply()</code>) that causes call to <code>_XIOError()</code> and <code>exit(1)</code>. Going more deeply in libxcb in <code>xcb_wait_for_reply()</code> function, I noticed that one of the reasons it can return NULL reply is when it detects broken or closed socket connection, which could be my situation.</p>
  
  <p>For test purposes, if I change xcb_io.c and ignore <code>_XIOError()</code>, application doesn't work any more. And if I repeat request inside <code>_XReply()</code>, it fails each time, i.e. gets NULL response on each <code>xcb_wait_for_reply()</code>.</p>
  
  <p>So, my questions would be why such uncontrolled app termination with exit(1) from <code>_XReply()</code> -> <code>XIOError()</code> -> <code>exit(1)</code> happened or how can I find out reason why and what happened, so I can fix it or do some workaround.</p>
  
  <p>For this problem to repeat, as I wrote above, I have to wait for some 15h, but currently I'm very short on time for debuging and can't find the cause of problem/termination.
  We also tried to reorganise java part which handles gui/display refresh, but the problem wasn't solved.</p>
  
  <p>Some SW facts:<br>
  - java jre 1.8.0_20, even with java 7 can repeat the problem<br>
  - libX11.so 1.5.0<br>
  - libxcb.so 1.8.1<br>
  - debian wheezy<br>
  - kernel 3.2.0  </p>