From time to time I get the infamous
Fatal error: Exception thrown without a stack frame in Unknown on line 0
but googling about it yesterday I found this article that describes a method for seeing through it and discover the real error. It’s very simple and yet powerful (and it works).
The key trick is
- find the line N where your script is misbehaving. This is tedious but easily done with a binary search on the execution line. At the beginning, the execution line can be that of the whole script.
- find an approximate middle point in the current execution line
- put an exit instruction there and execute the script again
- do you get the same error?
- YES: make the executed half the next execution line
- NO: make the non executed half the next execution line
- remove the exit
- repeat all until the exit on line N is clean and on line N+1 is dirty
- look at what you have on line N and try to figure out how to force your script to willfully do right there the same operations that are automatically done on shut down
- in my case yesterday, like the author of the article, I had a session_start on line N, so that I added a session_write_close() on line N+1 and an exit on line N+2. Magically the real error message got displayed!!