title: Random signal 11 (SIGSEGV)
body: <p>For few days now i got SIGSEGV errors at random points in my app. It crashed when i do nothing.</p>
  
  <p>I started taking apart code to see which line was causing this segmentation, and was most shocked when i found out that it was: ( drum roll, please )</p>
  
  <p><code>Activity.setResult(Activity.OK,intent)</code></p>
  
  <p>WHAT? This still doesn't make ANY sense to me at all! In the line below i will show you my code before and after and can anyone tell me WHY the SIGSEGV was happening?</p>
  
  <p><strong>Before</strong></p>
  
  <p>CommentActivity:</p>
  
  <pre><code>val comments = ArrayList&lt;Comment&gt;()
  comments.add(comment)
  /*Set the results*/
  val intent = Intent()
  intent.putExtra("comment_result", Utils.General.serializeToJson(comments))
  this.setResult(Activity.RESULT_OK, intent)
  this.finish()
  </code></pre>
  
  <p>MainActivity:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
      switch (requestCode) {
          //catch data from CommentActivity
          case (INTENT_COMMENT): {
              if (resultCode == RESULT_OK) {
                  String comments = intent.getExtras().getString("comment_result");
                  if (comments != null &amp;&amp; !comments.isEmpty()) {
                      /*Save the instance to the database and expect the database observable to call the upload thread*/
                      Type type = new TypeToken&lt;ArrayList&lt;Comment&gt;&gt;() {}.getType();
                      ArrayList&lt;Comment&gt; list = Utils.General.Companion.deserializeFromJson(comments, type);
                      /*Save the instance to the database and expect the database observable to call the upload thread*/
                      DataSource.INSTANCE.saveComments(list);
                  } else {
                      showToast(getResources().getString(R.string.picture_lost), Toast.LENGTH_SHORT);
                  }
              }
              break;
          }
  </code></pre>
  
  <p>==== This crashed in MainActivity after between 10secs and 1 minute =====</p>
  
  <p><strong>After - No Crash</strong></p>
  
  <p>CommentActivity:</p>
  
  <pre><code>/*Set the results*/
  DataSource.saveComments(comments)
  this.finish()
  </code></pre>