Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl being what
it is, things aren't quite working right. After a little bit of probing, I've found the source of the problem.

Under mod_perl, we are managing the PL_endav/PL_initav ourselves, as we need to
somewhat alter their behaviour, and they can be temporarly null, so following
patch avoids a possible segfault.

The other issue is that CHECK/INIT blocks are not being called proprely under
mod_perl 1.x, so moving the CHECK/INIT code in a sub of its own, allows the
mod_perl user to do this in his/her startup script:

 use Devel::Cover;
 Devel::Cover::check;
 Devel::Cover::set_first_init_and_end;

With these 2 simple modifications, all Devel-Cover tests still passing, mod_perl
can now benefit from the coolness of Devel::Cover.

Hope this is helpfull and I hope you'll be able to integrate this in your next
scheduled release of Devel::Cover

diff -p -ru Devel-Cover-0.43/Cover.xs Devel-Cover/Cover.xs
--- Devel-Cover-0.43/Cover.xs   2004-05-01 15:27:00.000000000 -0700
+++ Devel-Cover/Cover.xs        2004-05-18 10:58:27.277892570 -0700
@@ -176,7 +176,7 @@ static void set_firsts_if_neeed()
     SV *init = (SV *)get_cv("Devel::Cover::first_init", 0);
     SV *end  = (SV *)get_cv("Devel::Cover::first_end",  0);
     NDEB(svdump(end));
-    if (av_len(PL_initav) >= 0)
+    if (PL_initav && (av_len(PL_initav) >= 0))
     {
         SV **cv = av_fetch(PL_initav, 0, 0);
         if (*cv != init)
@@ -185,7 +185,7 @@ static void set_firsts_if_neeed()
             av_store(PL_initav, 0, init);
         }
     }
-    if (av_len(PL_endav) >= 0)
+    if (PL_endav && (av_len(PL_endav) >= 0))
     {
         SV **cv = av_fetch(PL_endav, 0, 0);
         if (*cv != end)
diff -p -ru Devel-Cover-0.43/lib/Devel/Cover.pm Devel-Cover/lib/Devel/Cover.pm
--- Devel-Cover-0.43/lib/Devel/Cover.pm 2004-05-01 15:27:00.000000000 -0700
+++ Devel-Cover/lib/Devel/Cover.pm      2004-05-18 10:56:28.185024129 -0700
@@ -84,7 +84,7 @@ BEGIN { $^P = 0x004 | 0x100 | 0x200 }

 no warnings "void";  # Avoid "Too late to run CHECK block" warning.

-CHECK
+sub check
 {
     return unless $Initialised;

@@ -124,6 +124,8 @@ EOM
     $Run{start} = get_elapsed();
 }

+CHECK { check() }
+
 }

 {



--
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to