title: segmentation fault while running executable android ndk module
body: <p>I have java application, where I use C++ code. All c++ code is compiled to .so file.
  I have to write unit tests for native part of the project. 
  I wrote such unit test:</p>
  
  <pre><code>#include &lt;gtest/gtest.h&gt;
  #include &lt;gtest-all.cc&gt;
  #include &lt;myTestedFile.h&gt;
  #include &lt;jni.h&gt;
  #include &lt;iostream&gt;    
  
  int main(int argc, char** argv)
  {
    ::testing::InitGoogleTest(&amp;argc, argv);
      RUN_ALL_TESTS();
      return 0;
  }
  
  TEST(MyTest, Test1)
  {
      jclass jc;
      int k = jni_return_five((JNIEnv*)0, jc);
      ASSERT_EQ(k,5);
  }
  </code></pre>
  
  <p>there is file myTestedFile.cpp</p>
  
  <pre><code>#include "myTestedFile.h"
  
  JNIEXPORT jint JNICALL jni_return_five(JNIEnv *env, jclass cls)
  {
          jclass commonClass = env-&gt;FindClass(
  "com/android/appportal/common/Myclass");
      return 5;
  }
  </code></pre>
  
  <p>I start this test with such way</p>
  
  <pre><code>adb push libs/armeabi-v7a/myTest /data/local/tmp
  adb push libs/armeabi-v7a/myLibrary.so /data/local/tmp
  adb shel "LD_LIBRARY_PATH=/data/local/tmp data/local/tmp/myTest"
  </code></pre>
  
  <p>After this I have output</p>
  
  <pre><code>[==========] Running 1 test from 1 test case.
  [----------] Global test environment set-up.
  [----------] 1 test from MyTest
  [ RUN      ] MyTest.Test1
  Segmentation fault 
  </code></pre>
  
  <p>Test is passed succesfully, if I dont get references to java classes in the jni code. Can anyone help me with this error?</p>
  
  <p>There is logcat of the crash</p>
  
  <pre><code>F/libc    (10105): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 10105 (myLibrary)
  I/DEBUG   (  113): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  I/DEBUG   (  113): Build fingerprint: 'samsung/espresso10rfxx/espresso10rf:4.0.3/IML74K/P5100XWALE2:user/release-keys'
  I/DEBUG   (  113): Revision: '10'
  I/DEBUG   (  113): pid: 10105, tid: 10105, name: myLibrary  &gt;&gt;&gt; /data/local/tmp/myTest &lt;&lt;&lt;
  I/DEBUG   (  113): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
  W/NativeCrashListener(  399): Couldn't find ProcessRecord for pid 10105
  
  I/DEBUG   (  113):          be8268c8  004e1de8  [heap]
  I/DEBUG   (  113):          be8268cc  be826a6c  [stack]
  I/DEBUG   (  113):          be8268d0  00000001  
  I/DEBUG   (  113):          be8268d4  4021fdb4  /data/local/tmp/libgnustl_shared.so (operator new[](unsigned int)+8)
  I/DEBUG   (  113):          be8268d8  004e2610  [heap]
  I/DEBUG   (  113):          be8268dc  0000bc70  /data/local/tmp/myTest
  I/DEBUG   (  113):          be8268e0  402a22f0  /system/lib/libc.so
  I/DEBUG   (  113):          be8268e4  004e1e44  [heap]
  I/DEBUG   (  113):          be8268e8  00039df8  /data/local/tmp/myTest
  I/DEBUG   (  113):          be8268ec  be826918  [stack]
  I/DEBUG   (  113):          be8268f0  00000000  
  I/DEBUG   (  113):          be8268f4  be82690c  [stack]
  I/DEBUG   (  113):          be8268f8  e3a070ad  
  I/DEBUG   (  113):          be8268fc  ef9000ad  
  I/DEBUG   (  113):     #00  be826900  000384c4  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826904  00000000  
  I/DEBUG   (  113):          be826908  be826924  [stack]
  I/DEBUG   (  113):          be82690c  0002d9b4  /data/local/tmp/myTest
  I/DEBUG   (  113):     #01  be826910  004e1ee0  [heap]
  I/DEBUG   (  113):          be826914  00000000  
  I/DEBUG   (  113):          be826918  00000000  
  I/DEBUG   (  113):          be82691c  00000000  
  I/DEBUG   (  113):          be826920  be82695c  [stack]
  I/DEBUG   (  113):          be826924  0001df80  /data/local/tmp/myTest
  I/DEBUG   (  113):     #02  be826928  be826944  [stack]
  I/DEBUG   (  113):          be82692c  0001f040  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826930  000105cc  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826934  004e2548  [heap]
  I/DEBUG   (  113):          be826938  004e1ee0  [heap]
  I/DEBUG   (  113):          be82693c  00039df8  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826940  be826954  [stack]
  I/DEBUG   (  113):          be826944  00010620  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826948  be826954  [stack]
  I/DEBUG   (  113):          be82694c  004e1ee0  [heap]
  I/DEBUG   (  113):          be826950  be82695c  [stack]
  I/DEBUG   (  113):          be826954  004e2568  [heap]
  I/DEBUG   (  113):          be826958  be826974  [stack]
  I/DEBUG   (  113):          be82695c  00010e30  /data/local/tmp/myTest
  I/DEBUG   (  113):          be826960  be82696c  [stack]
  I/DEBUG   (  113):          be826964  004e2548  [heap]
  </code></pre>