title: art_sigsegv_fault crash in Android Studio while debugging native code
body: <p><strong>The problem</strong><br>
  I'm trying to <em>debug native (c++) code</em> that is called from Java code (MainActivity.OnCreate) in simple android application. I'm using <em>lldb</em> for debugging and build the native code using <em>cmake</em>.<br>
  The debug works as expected until I try to step into native language function, then one of these happens:<br>
   1. The debugger steps into the function and allows making further steps, but there is no cursor, no normal stack trace, and no variable watches. The only thing in stack trace is the name of the cpp file and memory adress (instruction pointer maybe?) that increases with every step that I take. It looks to me as no debug symbols were loaded.<br>
   2. The step suceeds as it should and for a brief moment I can catch a glimpse of correct stack trace. But then the lldb crashes, the stack changes and the cursor is at <code>art_sigsegv_fault</code>. When I continue, I simply get a message that debugger was disconnected. The app continues to run as it should.</p>
  
  <p>Additionally, I've noticed that at the moment of crash the debugger attempts to collect data from variables and never actually suceeds. The variables that are successfully resolved are a <em>JNI pointer</em> and <em>jobject</em>, while the others are <em>jstring</em>.<br>
  <strong>Miliseconds before the crash:</strong><br>
  <a href="https://i.stack.imgur.com/2Sb0z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2Sb0z.png" alt="Milisecond before the crash"></a><br>
  <strong>After the crash:</strong><br>
  <a href="https://i.stack.imgur.com/AZi4E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AZi4E.png" alt="After the crash"></a><br>
  <strong>What I've tried</strong>  </p>
  
  <ul>
  <li>Made sure that symbols are not stripped from <em>.so</em> files, by adding  </li>
  </ul>
  
  <pre><code>packagingOptions{
      doNotStrip "**/*.so"
      }  
  </code></pre>
  
  <ul>
  <li>Made sure that CMAKE_CXX_FLAGS have <code>-O0 -ggdb</code> in them (no code optimization, debug compile)  </li>
  <li>Made sure that in Project Structure there is <em>debug</em> build, with properties <em>Debuggable, Jni Debuggable, and Renderscript Debuggable</em> set to true.<br>
  <a href="https://i.stack.imgur.com/4yEF9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4yEF9.png" alt="Project Structure"></a><br>
  <a href="https://i.stack.imgur.com/5uj8o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5uj8o.png" alt="Build types"></a><br>
  I believe that I've tried all the possible options that I've found here, hence a new question that may seem repetitive at first.</li>
  </ul>