title: How do I debug Segfaults occurring in the JVM when it runs my code?
body: <p>My Java application has started to crash regularly with a SIGSEGV and a dump of stack data and a load of information in a text file.</p>
  
  <p>I have debugged C programs in gdb and I have debugged Java code from my IDE. I'm not sure how to approach C-like crashes in a running Java program.</p>
  
  <p>I'm assuming I'm not looking at a JVM bug here. Other Java programs run just fine, and the JVM from Sun is probably more stable than my code. However, I have no idea how I could even cause segfaults with Java code. There definitely is enough memory available, and when I last checked in the profiler, heap usage was around 50% with occasional spikes around 80%. Are there any startup parameters I could investigate? What is a good checklist when approaching a bug like this?</p>
  
  <p>Though I'm not so far able to reliably reproduce the event, it does not seem to occur entirely at random either, so testing is not completely impossible.</p>
  
  <p><strong>ETA: Some of the gory details</strong></p>
  
  <p><em>(I'm looking for a general approach, since the actual problem might be very specific. Still, there's some info I already collected and  that may be of some value.)</em></p>
  
  <p>A while ago, I had similar-looking trouble after upgrading my CI server (see <a href="http://youtrack.jetbrains.net/issue/TW-17664?projectKey=TW" rel="noreferrer">here</a> for more details), but that fix (setting <code>-XX:MaxPermSize</code>) did not help this time.</p>
  
  <p>Further investigation revealed that in the crash log files the thread marked as "current thread" is never one of mine, but either one called "VMThread" or one called "GCTaskThread"- I f it's the latter, it is additionally marked with the comment "(exited)", if it's the former, the GCTaskThread is not in the list. This makes me suppose that the problem might be around the end of a GC operation.</p>