perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: t/perl/ithreads.t revisited
Date Mon, 13 Dec 2004 15:21:36 GMT
Steve Hay wrote:
> Steve Hay wrote:
> 
> 
>>Anyway, I've made an interesting new discovery:  the ithreads.t test 
>>crashes the server because ithreads.pm contains "use warnings FATAL => 
>>'all'".  Simply commenting-out that line, the skeleton test now succeeds!
>>
> 
> Furthermore, the full svn (rev 111694) test suite, with 
> t/perl/ithreads.t re-enabled, also works! 

Again, /me says, it's just a coincidence, and adding new code elsewhere 
will break it again.

> The warnings now appear in 
> the console window:
> 
> t\perl\ithreads.........................Attempt to free temp 
> prematurely: SV 0x8437b04, Perl interpreter: 0x470e764 at 
> C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 44.
> Attempt to free temp prematurely: SV 0x84378dc, Perl interpreter: 
> 0x470e764 at C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 44.
> Attempt to free temp prematurely: SV 0x476b4a0, Perl interpreter: 
> 0x470e764 at C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 44.
> Scalars leaked: 3
> Attempt to free temp prematurely: SV 0x83d06e4, Perl interpreter: 
> 0x7b522a4 at C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 61.
> Attempt to free temp prematurely: SV 0x83d04bc, Perl interpreter: 
> 0x7b522a4 at C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 61.
> Attempt to free temp prematurely: SV 0x4763bd4, Perl interpreter: 
> 0x7b522a4 at C:\Temp\mod_perl-2.0\t\response/TestPerl/ithreads.pm line 61.
> Scalars leaked: 3
> 
> Lines 44 & 61 are respectively the last lines of these two chunks:
> 
>         my $thr = threads->new(sub {
>             my $tid = threads->self->tid;
>             debug "2nd TID is $tid" if defined $tid;
>             return 2;
>         });
> 
>         my $thr = threads->new(sub {
>             my $tid = threads->self->tid;
>             debug "2nd TID is $tid" if defined $tid;
>             $counter_priv += $counter_priv for 1..10;
>             {
>                 lock $counter_shar;
>                 $counter_shar += $counter_shar for 1..10;
>             }
>         });
> 
> Regarding that warning, perldiag says:
> 
> "Mortalized values are supposed to be freed by the free_tmps() routine. 
> This indicates that something else is freeing the SV before the 
> free_tmps() routine gets a chance, which means that the free_tmps() 
> routine will be freeing an unreferenced scalar when it does try to free it."
> 
> Presumably the "something else" that is trying to free the SV's here is 
> simply the wrong interpreter?

Quite possible, since ithreads doesn't set the global context. how about:

--- ext/threads/threads.xs.orig 2004-12-13 10:19:10.985754535 -0500
+++ ext/threads/threads.xs      2004-12-13 10:20:04.044543828 -0500
@@ -432,7 +432,8 @@
          */
         {
             dTHXa(thread->interp);
-
+            PERL_SET_CONTEXT(thread->interp);
+
              /* Here we remove END blocks since they should only run
                in the thread they are created
              */

you will have to apply it manually because of the tab.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message