title: Baffled: PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0?
body: <p>I have found that one common reason for the error is <a href="http://www.wamped.org/post/2174829567/exception-thrown-without-a-stack-frame-in-unknown-on-lin" rel="noreferrer">an exception being thrown from within an exception handler</a>. I'm quite sure this doesn't happen in the application I'm trying to debug... But I've put all the initialization processing lines at the top of index.php in a try/catch.*</p>
  
  <p>It can apparently also happen because <a href="https://stackoverflow.com/questions/5440640/session-saving-problem-getting-php-fatal-error-exception-thrown-without-a-stac">some things cannot be serialized</a> <a href="https://stackoverflow.com/questions/4624223/object-in-session-fatal-error-exception-thrown-without-a-stack-frame-in-unknow">to be stored in a session</a>. At most this application stores arrays into the session (quite a bit), but I'm confident that it doesn't store anything too out of the ordinary in it.</p>
  
  <p>Someone commented that it happened to them because their primary key <a href="https://stackoverflow.com/a/6795527/425767">needed to be CHAR(32) instead of INT(11)</a>. The PK's in this app are all INTs.</p>
  
  <p>Other suggestions are that it could be a problem with <a href="https://stackoverflow.com/questions/5440640/session-saving-problem-getting-php-fatal-error-exception-thrown-without-a-stac">PHP 5.3.3</a> <a href="https://stackoverflow.com/questions/3662159/how-do-i-track-down-an-exception-thrown-without-a-stack-frame-in-unknown-on-lin">fixed in 5.3.6</a>, <a href="https://stackoverflow.com/a/7482211/425767">full disk</a>, and a <a href="http://www.php.net/manual/en/function.set-exception-handler.php#101502" rel="noreferrer">need to typecast a SimpleXML value</a>. We do happen to be running PHP 5.3.3, but upgrading would have to be a last resort in this case. It hasn't always been doing this.</p>
  
  <p>UPDATE/NOTE: I actually can't reproduce the error myself, only see it happening in the logs, see below paragraph for where I <em>believe</em> the error is happening...</p>
  
  <p>* From the error logs, it seems likely that at least one place it is happening is index.php. I am deducing this only because it is indicated in some entries by a referring URL. The try/catch code is currently only around the "top" initialization portion of the script, below that is mostly the HTML output. There is some PHP code in the output (pretty straightforward stuff though), so I may need to test that. Here is the catch part, which is not producing any output in the logs:</p>
  
  <pre><code>} catch (Exception $e) {
      error_log(get_class($e)." thrown. Message: ".$e-&gt;getMessage(). "  in " . $e-&gt;getFile() . " on line ".$e-&gt;getLine());
      error_log('Exception trace stack: ' . print_r($e-&gt;getTrace(),1));
  }
  </code></pre>
  
  <p>Would really appreciate any tips on this!</p>
  
  <p>EDIT: PHP is running as an Apache module (Server API: Apache 2.0 Handler). I don't think there are any PHP accelerators in use, but it could just be that I don't know how to tell. None of the ones <a href="http://en.wikipedia.org/wiki/List_of_PHP_accelerators" rel="noreferrer">listed on Wikipedia</a> are in phpinfo().</p>
  
  <p>As far as I can tell the MPM is prefork. This is the first I'd ever looked into the MPM:</p>
  
  <pre><code># ./httpd -l
  Compiled in modules:
    core.c
    prefork.c
    http_core.c
    mod_so.c
  </code></pre>