"Can't use an undefined value as a symbol reference" in .cgi file

I’m currently testing a VPS configuration.
I installed Ubuntu 12.04 (32bits) and zPanel. Now I’m trying to run a simple web app but I’m getting this error in the log:

[error] Can't use an undefined value as a symbol reference at /var/zpanel/hostdata/zadmin/public_html/.../webtest/webtest.cgi line 118. [error] Premature end of script headers: webtest.cgi
I’m no Perl expert, but it seems that something went wrong in the .cgi script at line 118. Any Idea of what’s going on here?

I’ve tried with a simple script that display the environment variables::

print "Content-type: text/plain\ \ "; foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; $val =~ s|\ |\\\ |g; $val =~ s|"|\\\"|g; print "${var}=\"${val}\"\ "; }And it worked fine. I’ve checked the permissions of my web app’s files and the apache config, and everything seems OK. Still, all I got an error 500 whil trying to launch it…
Did anyone see this behavior before?

Eric.

I remember that I had that before. Deleting app and uploading again did help me.

Thanks for the tip Christian.
Unfortunately it didn’t work. I built the web app with 2014r1.1. I will try with other versions tomorrow morning.

Eric.

http://documentation.xojo.com/index.php/Deploying_Web_Apps_on_Linux
Web Logs :

If you get an “Internal Server Error” or any error, you need to check the web server log for specifics. A common source of problems is incorrect permissions.

Is yourapp’s config.cfg writeable, most of the time i forget that myself.

Actually, that’s where the error message come from.

Permissions were rwxrwxr-x for the test.

http://members.upc.nl/a.kuiper7/Pics/LinuxPermissions.jpg

Try setting the permission to 777 as in the picture and if that works try decrementing the permissions.
Also check if the owner of the Apache process is part of the group who has the write permission. The owner of the Apache process is most of the time ‘www-data’. If you have uploaded the files under your own account then probably you are the owner and only you have permission there and ofcourse the root user.
To easily check this you can issue the ‘ps -A’ command in a shell and search for apache-process.

Also, make sure you can run the app from the command line. To me it looks like it’s crashing.

Still no luck!

Here is the result of a ps -AF command:

[...] root 5021 1 0 12269 9944 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5026 5021 0 12308 5908 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5027 5021 0 12308 5912 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5028 5021 0 12308 5900 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5029 5021 0 12308 5912 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5030 5021 0 12686 10460 0 10:04 ? 00:00:00 /usr/sbin/apache2 -k start www-data 5038 5021 0 12308 5900 0 10:05 ? 00:00:00 /usr/sbin/apache2 -k start [...] www-data 5679 5021 0 12306 5884 0 10:44 ? 00:00:00 /usr/sbin/apache2 -k start [...]

The app is called ‘webtest’ so I tried the ./webtest when logged as root via ssh and in the app directory. It crashed and I got this message:

Segmentation Fault

I also tried ./webtest.cgi and got:

perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_GB.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 ./webtest.cgi line 110. Can't use an undefined value as a symbol reference at ./webtest.cgi line 118.
Can the locale setting issue be a problem?

At last, I built a simple “Hello World!” console app for Linux adn upload it and set the permissions. I ran it as root and get the following message:

[code]root@[…]/cgi-bin/test/testconsole# ./testconsole
Runtime Error
Please report what caused this error along with the information below.
Common/Loaders/LoaderLinux.cpp: 106
Failure Condition: 1 == itemsRead

Aborted[/code]
Does this message ring a bell?

I solved the locale settings issue and still the same result:

root@[...]/cgi-bin/webtest# ./webtest.cgi Use of uninitialized value $ENV{"REQUEST_METHOD"} in string eq at ./webtest.cgi line 110. Can't use an undefined value as a symbol reference at ./webtest.cgi line 118.

Seg fault? Make sure you built for the right platform and that you uploaded the libs folder. Something is very wrong with that app.

Also, you can’t just run the cgi file. It normally gets run by Perl, with a bunch of environment variables set by Apache, so it’ll be a false reading.

The test console application was built for Linux with 2014r1.1 and the Library folder is alongside the console app binary and run as a root.

That’s what I guessed since running the .cgi file show more errors.

Well, actually it was Filezilla’s settings that messed up the whole thing. It was set to transfer file in ASCII mode only… which can’t be good for application files. My test web app is now up and running !!! :slight_smile:

Hi all

I’ve the same issue.

Use of uninitialized value $ENV{“REQUEST_METHOD”} in string eq at ./leti.cgi line 110.
Use of uninitialized value $length in subtraction (-) at ./leti.cgi line 131.
Use of uninitialized value $length in numeric eq (==) at ./leti.cgi line 130.

Upload using binary mode.

Compiled with 2015 R3 FC1 64bits
Runing under Centos 7.0 64Bits

Any idea?

Regards

[quote=221438:@Franck Danard]Hi all

I’ve the same issue.

Use of uninitialized value $ENV{“REQUEST_METHOD”} in string eq at ./leti.cgi line 110.
Use of uninitialized value $length in subtraction (-) at ./leti.cgi line 131.
Use of uninitialized value $length in numeric eq (==) at ./leti.cgi line 130.

Upload using binary mode.

Compiled with 2015 R3 FC1 64bits
Runing under Centos 7.0 64Bits

Any idea?

Regards[/quote]
That would indicate that your web server is not sending a complete cgi request.

Hi Greg

Thanks for your reply but what can i do for that?
It’s a little short as answer :slight_smile:
If you could give me some clues and i could check some config.

For your informations, I’ve two projects on the same server.
Both compiled with 64b,
One works fine.
Second doesn’t work

Can you tell me more, why only one project is working and the other doesn’t want to work?
Weird doesn’t it?

Regards

Tsss… I’ve found the problem.

I use WinSCP and i launch my uploads using SSH access.
Even if i put binary method, it seems that some files are corrupted during upload.
When a problem appears, i launch the upload file by file or folder by folder and the project works again.

Thanks for your help and sorry sorry for the inconvenience :wink: