title: Segmentation fault in PHP?
body: <p>Why does the following code cause a segmentation fault?</p>
  
  <pre><code>&lt;?php
  
  $CNX = new mysqli('localhost','dbuser', 'dbpass', 'dbtest');
  
  class DAO
  {
          var $stmt;
  
          function DAO()
          {
                  $this-&gt;stmt = $GLOBALS['CNX']-&gt;stmt_init();
          }
  
          function listing()
          {
                  $this-&gt;stmt-&gt;prepare('SELECT * FROM any_table');
          }
  }
  
  class Page
  {
          function go()
          {
                  $d1 = new DAO();
                  $d2 = new DAO();
                  $d1-&gt;listing();
                  exit;
          }
  }
  
  $tpl = new Page();
  $tpl-&gt;go();
  ?&gt;
  </code></pre>
  
  <p><strong>Additional Notes</strong></p>
  
  <p>1) I ran this code on two different LAMP servers and they both generate errors like <code>child pid somenumber exit signal Segmentation fault (11)</code> in my error.log files.  On one server, I am running Ubuntu 10.04, Apache 2, Mysql 5 and PHP 5.3.2-1ubuntu4.9, and on another server I'm running Ubuntu 11.10, Apache 2, mysql 5 and PHP 5.3.6-13ubuntu3.3.  </p>
  
  <p>2) It's weird, but when I comment out the line <code>$d2 = new DAO();</code> or the line <code>exit;</code>, the segmentation fault goes away. </p>
  
  <p>3) The segmentation fault occurs no matter which db table I select from in the prepared statement</p>
  
  <p>What is going on?  I am so frustrated. I have lost an entire day's worth of time because of this segmentation fault.  Please...if anyone knows what's going on, let me know</p>
  
  <p>Thanks</p>