Another boring Internal Server error…


It looks like half the times I put my web application online, it fails with an internal server error; that’s discouraging.
I just uploaded all the files and set their permissions. I get the Internal Server error again.
Usually, I’d either look at the Apache log file or try in SSH. The Apache logs, this time, don’t tell me anything useful:
[Sun Dec 09 16:13:16.395255 2018] [cgi:error] [pid 356] [client <client’s IP>:59458] AH01215: Can’t use an undefined value as a symbol reference at /var/www/html/mywebsite.cgi line 118.: /var/www/html/mywebsite.cgi, referer: http:///mywebsite.cgi
[Sun Dec 09 16:13:16.396169 2018] [cgi:error] [pid 356] [client <client’s IP>:59458] End of script output before headers: mywebsite.cgi, referer: http:///mywebsite.cgi

As for the SSH, it tells me the exact same thing:
perl /var/www/html/mywebsite.cgi
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “fr_CH.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
Use of uninitialized value $ENV{“REQUEST_METHOD”} in string eq at mywebsite.cgi line 110.
Can’t use an undefined value as a symbol reference at mywebsite.cgi line 118.
(please disregard the “locale” thing: the other times, the application would work even with this error appearing)

If it was, say, a permission issue, it would be reported in these 2 places (I just tested). Instead, I just get these lines above, which appear as soon as there’s a problem anyway.

The web app works fine on my Mac, while debugging. Also, the UnhandledException method of the app class is returning true, so I don’t think the app crashes on launch.

Do I have overlooked something?

All you’re doing by returning true is ignoring exceptions in your app and while they could cause a crash, they are preventable. It’s more likely that your app is crashing for some other non-preventable reason.

That said, the fact that you get an error when calling the cgi file from the command line is not unexpected. When Apache calls it, it first sets a bunch of environment variables to tell the script how it had been called and to pass along any request data there may have been. The command line doesn’t do that, so you get errors.

This usually means that the app closed before it got a chance to respond, but in the case of a xojo app, it can also mean that the app itself didn’t even launch. If you changed xojo versions lately, make sure the server has all of the dependencies. You should also make sure you are not running out of RAM. They usually appear in the system log as a segfault.

What I meant is, when the app worked (i.e., until last week), I could use the command line to check the cgi file (it wouldn’t run the app, but I could see more than I get now).

The Xojo version hasn’t changed. What changed is I have reinstalled (reformatted) the server last week. However, after installing the one library that was missing, my web app ran 2 or 3 days on the fresh server. Then I recompiled it because of a bug I found, and, after re-sending it to my server, it ceased to work.

I tested a plain application, and this one works.

The server error logs don’t seem to mention anything either.

Thank you.

That’s fine, but what I’m saying is that running it from the command line is not a good test. There’s lots of reasons you would or wouldn’t get errors doing that.

Launch the binary itself using ldd. It will tell you if anything it relies on to launch is missing.

Guess what? I found the problem. My web app was actually not truly ended. In fact, I eventually tried ps -A in the command line and found that the process (certainly the old one) was still alive. This would explain why the new process wouldn’t launch, if the old one was somehow “stuck”. I now have to figure out why it wasn’t quitting properly…

Anyway, I’m “glad” to have all these problems with web apps: I’m making a dictionary of troubleshooting steps in this forum :wink:

Thanks Greg, your help is appreciated.

Glad you found the error. I’ve been bitten by this more than once.