Question

I have a web app that allows the user to upload a pdf and it will then email it to us via swiftmailer. With some pdfs, the process fails.

I can verify that it crashes the php script, yet returns no php error. There's a 500 error from the server, but normally if there's a 500 error, php has a log of what the error was.

I have also verified that it crashes at the $mailer->send($message); line

Oddly, only some pdfs crash it, and those same pdfs work fine on the development server with identical code.

What could be causing php to crash without an error message?

Was it helpful?

Solution

After running several tests, I found that error logging was happening some of the time, but not others. I didn't figure out why that was so, however, I tried renaming the php-errors.log file so php would start with a new, fresh log file, and now errors are getting logged properly. I don't know why that worked, but I'll take it.

OTHER TIPS

FYI, I've run into two things that can cause a PHP crash without an error message:

  1. Script timeouts - A timeout may prevent an error message from being returned; in my particular case the script was waiting for an SMTP response when the timeout happened, which may have been why I didn't get a timeout message. Try changing your max_execution_time value in php.ini to 300 (5 minutes) and see if you can get an actual error message.
  2. Folder permissions - I've encountered a case where insufficient folder permissions resulted in the script just halting without providing an error.

In the case of 2, I wrapped a try/catch clause around the line that was causing the halt, and I finally got an Exception to show up explaining about the permissions problem. That may be worth trying as a general response to silent crashes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top