title: Understanding Android Native code crash report
body: <p>Okay, my NDK app crashes with info like that:</p>
  
  <pre><code>signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
  r0 00000000 r1 0009a830 r2 698a2efc r3 2a63f4da
  r4 66db37ac r5 698a2efc r6 6b843b14 r7 66d89ed4
  r8 6b6e0ff5 r9 6b746000 sl 697e0680 fp 401912ec
  ip 00000003 sp 6b843a90 lr 66d9d7dd pc 6b69ac36 cpsr 000d0030
  d0 4c555345525f4c53 d1 4e4f434552505f54
  d2 5f534e4f49544944 d3 444554414c4f4956
  d4 0000000000000000 d5 000000003f800000
  d6 000084c03f800000 d7 3f8000003f800000
  d8 0000000000000000 d9 0000000000000000
  d10 0000000000000000 d11 0000000000000000
  d12 0000000000000000 d13 0000000000000000
  d14 0000000000000000 d15 0000000000000000
  d16 00000a3dcc4f35c1 d17 ffff000000010000
  d18 3ff8099d80000000 d19 0000000000000000
  d20 3ff0000000000000 d21 0000000000000000
  d22 c040000000000000 d23 0000000000000000
  d24 3ff8099d80000000 d25 0000000000000000
  d26 3ff0000000000000 d27 0000000000000000
  d28 3ff8099d80000000 d29 c040000000000000
  d30 0000000000000000 d31 0000000000000000
  scr 20000010
  
  backtrace:
  #00 pc 000dec36 /mnt/asec/com.myapp/lib/myapp.so     (HWLayer::SoundManagerImpl::MyChannel::start(SLEngineItf_ const* const*, SLObjectItf_ const* const*, HWLayer::SndChannelData const&amp;)+249)
  #01 pc 000decb1 /mnt/asec/com.myapp/lib/myapp.so (HWLayer::SoundManagerImpl::startChannel(HWLayer::SndChannelData const&amp;)+20)
  #02 pc 000cb2f3 /mnt/asec/com.myapp/lib/myapp.so (ChannelController::start(GPSoundObjectImpl*, bool)+242)
  </code></pre>
  
  <p>How I want to locate this crash in my C++ code.</p>
  
  <p>What does <code>+249</code> or <code>+20</code> mean in backtrace above? I guess it's some offset from start of the routine to the call of subroutine. But in what units is it measured?</p>
  
  <p>How can <code>ip 00000003</code> help me? I guess it's an instruction pointer... and what?</p>
  
  <p>My C++ code looks like</p>
  
  <pre><code>void SoundManagerImpl::startChannel( const SndChannelData&amp; data )
  {
      int const nChannel = data.nChannel;
      dbgAssert(nChannel &gt;= 0 &amp;&amp; nChannel &lt; m_maxNumChannels);
      m_channels[nChannel].start(m_engineEngine, m_outputMix, data);
  }
  
  void SoundManagerImpl::MyChannel::start(SLEngineItf engine, SLObjectItf outputMix, SndChannelData const &amp;data)
  {
      stop();
  
      dbgAssertEq(16, data.bps);
      m_numPlayedPages = 0;
      m_pBuffer1 = data.pBuffer1;
      m_pBuffer2 = data.pBuffer2;
  
      SLresult status;
      SLDataLocator_BufferQueue bufferQueue;
      SLDataFormat_PCM pcm;
      SLDataSource audioSource;
      audioSource.pFormat = &amp;pcm;
      audioSource.pLocator = &amp;bufferQueue;
  
      /* Setup the data source structure for the buffer queue */
      bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
      bufferQueue.numBuffers = data.nTotalPages;
      /* Setup the format of the content in the buffer queue */
      pcm.formatType = SL_DATAFORMAT_PCM;
      pcm.numChannels = (m_pBuffer2 != 0) ? 2 : 1;
      pcm.samplesPerSec = /*SL_SAMPLINGRATE_44_1*/data.sampleRate * 1000;
      pcm.bitsPerSample = /*SL_PCMSAMPLEFORMAT_FIXED_16*/data.bps;
      pcm.containerSize = pcm.bitsPerSample;
      pcm.channelMask = 1 == pcm.numChannels ? SL_SPEAKER_FRONT_CENTER : (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT);
      pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
  
      SLDataSink audioSink;
      SLDataLocator_OutputMix locator_outputmix;
      locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
      locator_outputmix.outputMix = outputMix;
      audioSink.pLocator = &amp;locator_outputmix;
      audioSink.pFormat = 0;
  
      static SLboolean const s_required[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
      static SLInterfaceID const s_iidArray[] = {SL_IID_BUFFERQUEUE, SL_IID_VOLUME};
      dbgCompileAssert(GP_PLAIN_ARRAY_LEN(s_required) == GP_PLAIN_ARRAY_LEN(s_iidArray));
  
      status = (*engine)-&gt;CreateAudioPlayer(engine, &amp;m_player, &amp;audioSource, &amp;audioSink,
      GP_PLAIN_ARRAY_LEN(s_required), s_iidArray, s_required);
      dbgAssertEq(SL_RESULT_SUCCESS, status);
  
      // ... and so on
  }
  </code></pre>
  
  <p>Can anybody help me to find corellation between those magic numbers from the crash report and this C++ code?</p>