Christopher H. Laco wrote:
Christopher H. Laco wrote:No love. This block segfaults my apache2/mp2:if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {require Apache2::RequestRec; require Apache2::RequestUtil; require Apache2::RequestIO; require Apache2::ServerUtil;my $c = eval {Apache2::RequestUtil->request} || Apache2::ServerUtil->server;if ($c) { $value = $c->dir_config($key) || $ENV{$key} || $default; }; } elsif ($ENV{MOD_PERL}) {Commenting out the eval line lets the server run fine and dandy. :-( -=ChrisOh geez. I think I found the most obscure bug ever. :-/I'm working on narrowing down the code to a test case. In a nutshell of seudo code, it looks like this:$ rm -rf /var/tmp/.* use Data::UUID; use Apache2::RequestRec; use Apache2::RequestUtil; use Apache2::RequestIO; use Apache2::ServerRec; use Apache2::ServerUtil; my $ug = Data::UUID->new; my $uuid = $ug->create; print $ug->to_string($uuid);There is some variance in there.If I simply 'require' instead of 'use' all of the Apache2 modules, all works fine, unless I call ->dir_config, then it goes boom.It only happens on the first call to Data::UUID, where it creates two state files in /var/tmp. Every request after that initial segfault works just dandy. On the segfaulted run, it creates the first file, and dies on creating the second. If I run the code again, it creates the second and goes just dandy.... only if I use the Apache modules, or 'require' them and call dir_config.If I take the apache2 modules out of the picture and clean /var/tmp, the first call to Data::UUID succeeds , it creates both files in temp, and there are no segfaults.Like I said, the strangest damn thing I've ever seen. More to come when I get a specific narrowed test case and a ktrace for it. -=Chris
Just as a followup to this. I found a workaround, but that doesn't really make any sense either. If I moved the require block outside of the sub, the segfault never happens on the first Data::UUID->new with the Apache2: modules loaded...
require Apache2::RequestRec; require Apache2::RequestUtil; require Apache2::RequestIO; require Apache2::ServerUtil; if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) { my $c = eval {Apache2::RequestUtil->request} || Apache2::ServerUtil->server; if ($c) { $value = $c->dir_config($key) || $ENV{$key} || $default;};} elsif ($ENV{MOD_PERL}) {
That doesn't make a bit of sense to me, but after 5 days of headaches, I'll take it.
-=Chris
smime.p7s
Description: S/MIME Cryptographic Signature