perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Förtsch <torsten.foert...@gmx.net>
Subject Re: [mp2] make test fails with a debugging perl
Date Tue, 13 Apr 2010 10:00:05 GMT
On Tuesday 13 April 2010 11:29:49 Jan Schmidt wrote:
> From the test logs it seems to me that mod_perl is doing something nasty
> (but systematically) with the perl API concerning Perl_sv_catpvn().
> 
Fixed in trunk.

You may try this patch:

Index: src/modules/perl/modperl_filter.c                              
===================================================================   
--- src/modules/perl/modperl_filter.c   (revision 931502)             
+++ src/modules/perl/modperl_filter.c   (revision 931503)             
@@ -654,9 +654,14 @@                                                  
     apr_size_t len = 0;                                              
                                                                      
     (void)SvUPGRADE(buffer, SVt_PV);                                 
-    SvPOK_only(buffer);                                              
     SvCUR(buffer) = 0;                                               
                                                                      
+    /* calling SvPOK_only here may leave buffer an invalid state since
+     * SvPVX may be NULL. But it's very likely that something is copied.
+     * So, we turn the POK flag on here. Later we check if SvPVX is NULL
+     * and turn the flag off again if so. */                            
+    SvPOK_only(buffer);                                                 
+                                                                        
     /* sometimes the EOS bucket arrives in the same brigade with other  
      * buckets, so that particular read() will not return 0 and will    
      * be called again if called in the while ($filter->read(...))      
@@ -682,6 +687,7 @@                                                      
                        wanted,                                          
                        MP_TRACE_STR_TRUNC(filter->pool, filter->leftover, 
wanted),
                        filter->remaining);                                        
+            SvGROW(buffer, wanted+1);                                             
             sv_catpvn(buffer, filter->leftover, wanted);                          
             filter->leftover += wanted;                                           
             filter->remaining -= wanted;                                          
@@ -692,6 +698,7 @@                                                                
                        "eating remaining %db",                                    
                        MP_FILTER_NAME(filter->f),                                 
                        filter->remaining);                                        
+            SvGROW(buffer, filter->remaining+1);                                  
             sv_catpvn(buffer, filter->leftover, filter->remaining);               
             len = filter->remaining;                                              
             filter->remaining = 0;                                                
@@ -728,6 +735,7 @@                                                                
         if (buf_len) {                                                            
             if ((SvCUR(buffer) + buf_len) >= wanted) {                            
                 int nibble = wanted - SvCUR(buffer);
+                SvGROW(buffer, SvCUR(buffer)+nibble+1);
                 sv_catpvn(buffer, buf, nibble);
                 filter->leftover = (char *)buf+nibble;
                 filter->remaining = buf_len - nibble;
@@ -736,11 +744,16 @@
             }
             else {
                 len += buf_len;
+                SvGROW(buffer, SvCUR(buffer)+buf_len+1);
                 sv_catpvn(buffer, buf, buf_len);
             }
         }
     }

+    if (!SvPVX(buffer)) {
+        SvPOK_off(buffer);
+    }
+
     MP_TRACE_f(MP_FUNC,
                MP_FILTER_NAME_FORMAT
                "return: %db from %d bucket%s [%s]\n\t(%db leftover)",

Or use trunk:

svn checkout https://svn.apache.org/repos/asf/perl/modperl/trunk/ mod_perl-2.0

or

svn checkout \
  https://svn.apache.org/repos/asf/perl/modperl/branches/threading \
  mod_perl-2.0

I'd recommend the latter.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

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


Mime
View raw message