You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Gregory Burmistrov <gr...@dataart.com> on 2004/05/18 16:35:44 UTC

Bug: mod_perl and mod_xslt as output filter

Hello!

I've had a challenge with mod_perl and mod_xslt under Apache2, the
problem is:

mod_xslt collects buckets from mod_perl for further processing. When
mod_xslt got EOS bucket processing occurs, but some data in buckets
appear to be corrupted.

After few hours with various server configurations, gdb and other fun
stuff, I've found a clue. At least it works for me.

--- patch ---
*** modperl_filter.c.orig       Tue May 18 17:37:34 2004
--- modperl_filter.c    Tue May 18 17:38:06 2004
*************** MP_INLINE apr_status_t modperl_wbucket_p
*** 127,132 ****
--- 127,133 ----
      apr_bucket_alloc_t *ba = (*wb->filters)->c->bucket_alloc;
      apr_bucket_brigade *bb;
      apr_bucket *bucket;
+     char *copy;

      /* reset the counter to 0 as early as possible and in one place,
       * since this function will always either pass the data out (and
*************** MP_INLINE apr_status_t modperl_wbucket_p
*** 165,171 ****
      }

      bb = apr_brigade_create(wb->pool, ba);
!     bucket = apr_bucket_transient_create(buf, len, ba);
      APR_BRIGADE_INSERT_TAIL(bb, bucket);

      if (add_flush_bucket) {
--- 166,173 ----
      }

      bb = apr_brigade_create(wb->pool, ba);
!     copy = apr_pmemdup(wb->pool, buf, len);
!     bucket = apr_bucket_transient_create(copy, len, ba);
      APR_BRIGADE_INSERT_TAIL(bb, bucket);

      if (add_flush_bucket) {
------------------------------------------------------------------------
------------

Best regards,
/grig

P.S. mod_xslt-2.0.4 mod_perl-1.99.13 apache-2.0.49

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Bug: mod_perl and mod_xslt as output filter

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Gregory Burmistrov wrote:
> 
>> Hello!
>>
>> I've had a challenge with mod_perl and mod_xslt under Apache2, the
>> problem is:
>>
>> mod_xslt collects buckets from mod_perl for further processing. When
>> mod_xslt got EOS bucket processing occurs, but some data in buckets
>> appear to be corrupted.
>>
>> After few hours with various server configurations, gdb and other fun
>> stuff, I've found a clue. At least it works for me.
> 
> 
> I see what you mean Gregory. But that solution doesn't make me happy. 
> Most of the time you won't need to do that, and forcing a double copy of 
> data on each print call is not an efficient thing to do. Let me ask 
> httpd-dev whether there is a way to mark buckets as something that has 
> to be copied on if set-aside.

This time the answer came back quicky, quoting Bill:

   It's a bug in mod_xslt, if that module trys to set aside a transient bucket.

http://marc.theaimsgroup.com/?t=108494355000002&r=1&w=2

So please tell the author of mod_xslt that it needs to check whether the 
bucket type is transient and if so it has to do the copying on itself. 
Unfortunately I can't point you to the httpd filter docs, since I'm not aware 
of their existence. Though apr_bucket.h has this:

/**
  * The TRANSIENT bucket type.  This bucket represents a data allocated off
  * the stack.  When the setaside function is called, this data is copied on
  * to the heap
  */
APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient;

So if mod_xslt uses a proper function like: apr_bucket_setaside to keep the 
buckets, supposedly it should handle the copying on itself, transparently to 
the filter writer.

I'll document that in our source code and have a note for modperl filter writers.

-- 
__________________________________________________________________
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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Bug: mod_perl and mod_xslt as output filter

Posted by Stas Bekman <st...@stason.org>.
Gregory Burmistrov wrote:
> Hello!
> 
> I've had a challenge with mod_perl and mod_xslt under Apache2, the
> problem is:
> 
> mod_xslt collects buckets from mod_perl for further processing. When
> mod_xslt got EOS bucket processing occurs, but some data in buckets
> appear to be corrupted.
> 
> After few hours with various server configurations, gdb and other fun
> stuff, I've found a clue. At least it works for me.

I see what you mean Gregory. But that solution doesn't make me happy. Most of 
the time you won't need to do that, and forcing a double copy of data on each 
print call is not an efficient thing to do. Let me ask httpd-dev whether there 
is a way to mark buckets as something that has to be copied on if set-aside.

> !     copy = apr_pmemdup(wb->pool, buf, len);
> !     bucket = apr_bucket_transient_create(copy, len, ba);

Also in the future please post unified diffs 'cvs diff -u'. Thanks.



__________________________________________________________________
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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html