You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by le...@netcourrier.com on 2013/11/21 14:25:25 UTC

[users@httpd] Strange apache behaviour when lauching an external binary called by a perl script

Hello list,
I am currently setting up a web service running on CentOS 6.4. This service uses perl scripts (cgi-bin) launching an external homemade fortran compiled binary.
This last is triggered through a web form when the user ask for it. It is not a system service but an 'on demand' execution.

Here is the issue: when I boot my server, everything goes well except that this binary crashes systematically (with a kernel segfault) when called by my perl scripts.
If I restart manually the httpd service at the command line (service httpd restart) the issue is totally fixed. I examined apache/system logs and nothing suspicious can be found.

It appears that the problem occurs only when httpd is launched by /etc/rc[0-6].d startup directives. I tried to change the launch order of http (S85httpd by default) to any other position without success.
Even with a httpd restart scheduled several minutes after the last rc script by the 'at' command, the issue is still there.

To summarize, my web service is only functional (with no external binary crash) when httpd is (re)launched at the command line once the server has fully booted up.
All insights will be very appreciated.


Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script

Posted by le...@netcourrier.com.
This issue is now resolved: my fortran binary handles very large arrays and complex functions requiring an unlimited stack size. 

Despite that the stack size limit was defined on a system-wide basis (in /etc/security/limits.conf), for any reason it appears that the "apache/perl/fortran binary" ensemble was not aware of that (causing my binary to crash each time it was called). At the contrary, when I manually restarted apache at the shell prompt, the stacksize limit was correctly passed (.bashrc with 'ulimit -S -s unlimited').

As a workaround, I used BSD::Resource module (http://search.cpan.org/~jhi/BSD-Resource-1.2907/Resource.pm) to define stacksize directly in my perl script by using e.g. setrlimit(RLIMIT_STACK, $softlimit, $hardlimit); Thus, these new stack size limits are now directly passed from my perl script to my binary. 

Thanks for your time and providing me with insights to fix this issue! Cheers.  


---- Message d'origine ----
De : ledoc@netcourrier.com
À : "Pete Houston" <ph...@openstrike.co.uk>;
   users@httpd.apache.org
Objet : Re: Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script
Date : 21/11/2013 16:53:10 CET

Nice suggestion. But unfortunately both environments are the same (and my binary is compiled with static library option).

---- Message d'origine ----
De : "Pete Houston" <ph...@openstrike.co.uk>
À : users@httpd.apache.org
Objet : Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script
Date : 21/11/2013 14:40:33 CET

Possibly a difference in environment would cause this (perhaps
LD_LIBRARY_PATH or similar?).

Compare the environment in your failing at job with the environment in
your successful shell command and determine if there are any
differences.

HTH,

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlKODVEACgkQdzfnYmsKt524FACgncbrG/UwTOKTXPMp5Zs26FoA
HI4AoKIpwfFsqkJHQSuOdolX0lXnCHWh
=6+wF
-----END PGP SIGNATURE-----



Re: Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script

Posted by le...@netcourrier.com.
Nice suggestion. But unfortunately both environments are the same (and my binary is compiled with static library option).

---- Message d'origine ----
De : "Pete Houston" <ph...@openstrike.co.uk>
À : users@httpd.apache.org
Objet : Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script
Date : 21/11/2013 14:40:33 CET

Possibly a difference in environment would cause this (perhaps
LD_LIBRARY_PATH or similar?).

Compare the environment in your failing at job with the environment in
your successful shell command and determine if there are any
differences.

HTH,

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlKODVEACgkQdzfnYmsKt524FACgncbrG/UwTOKTXPMp5Zs26FoA
HI4AoKIpwfFsqkJHQSuOdolX0lXnCHWh
=6+wF
-----END PGP SIGNATURE-----



Re: [users@httpd] Strange apache behaviour when lauching an external binary called by a perl script

Posted by Pete Houston <ph...@openstrike.co.uk>.
Possibly a difference in environment would cause this (perhaps
LD_LIBRARY_PATH or similar?).

Compare the environment in your failing at job with the environment in
your successful shell command and determine if there are any
differences.

HTH,

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script

Posted by le...@netcourrier.com.
Fastidious but undeniably efficient. I'll try that. Thanks!

---- Message d'origine ----
De : "smaug ix" <sm...@gmail.com>
À : users@httpd.apache.org
Objet : Re: [users@httpd] Strange apache behaviour when lauching an externalbinary called by a perl script
Date : 21/11/2013 19:52:49 CET

On 11/21/2013 08:25 AM, ledoc@netcourrier.com wrote:
> crashes systematically (with a kernel segfault)

configure core dumps and use gdb to see the stack trace at the time of 
the crash.
see if you can figure it out from that.

additionally, you can wrap your binary in a script that runs strace
letting you see what the program was doing up to the crash.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



Re: [users@httpd] Strange apache behaviour when lauching an external binary called by a perl script

Posted by smaug ix <sm...@gmail.com>.
On 11/21/2013 08:25 AM, ledoc@netcourrier.com wrote:
> crashes systematically (with a kernel segfault)

configure core dumps and use gdb to see the stack trace at the time of 
the crash.
see if you can figure it out from that.

additionally, you can wrap your binary in a script that runs strace
letting you see what the program was doing up to the crash.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org