Bug 62180 - mod_xml2enc destroys error buckets
Summary: mod_xml2enc destroys error buckets
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_xml2enc (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2018-03-14 15:29 UTC by Mihaly Petrenyi
Modified: 2018-08-04 10:24 UTC (History)
2 users (show)



Attachments
mod_xml2enc.c (xml2enc_ffunc): do not remove error buckets (969 bytes, patch)
2018-03-15 10:22 UTC, Micha Lenk
Details | Diff
mod_xml2enc.c: pass all meta buckets down the chain (1.86 KB, patch)
2018-03-15 10:54 UTC, Yann Ylavic
Details | Diff
mod_xml2enc: pass all meta buckets down the chain (v2) (27.24 KB, patch)
2018-04-12 22:34 UTC, Yann Ylavic
Details | Diff
mod_xml2enc: pass all meta buckets down the chain (v3) (27.44 KB, patch)
2018-04-12 22:42 UTC, Yann Ylavic
Details | Diff
mod_xml2enc: pass all meta buckets down the chain (v4) (2.42 KB, patch)
2018-04-12 22:49 UTC, Yann Ylavic
Details | Diff
mod_xml2enc: pass all meta buckets down the chain (v5) (2.47 KB, patch)
2018-04-13 07:50 UTC, Yann Ylavic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mihaly Petrenyi 2018-03-14 15:29:06 UTC
Error bucket is a special kind of meta bucket that is not part of apr but added in httpd and can be created via the ap_bucket_error_create() call. This type of bucket is simply destroyed by mod_xml2enc.
I have created a pull request with a fix that resolves this issue:
https://github.com/apache/httpd/pull/48
Comment 1 Micha Lenk 2018-03-15 10:22:07 UTC
Created attachment 35769 [details]
mod_xml2enc.c (xml2enc_ffunc): do not remove error buckets

I worked with Mihaly on this issue, and he found the fix. The impact of the error bucket getting dropped is that any failure raised by another filter earlier in the output filter chain will get dropped. This means an entirely broken page is delivered instead of blocking the request with a proper error message.
Comment 2 Yann Ylavic 2018-03-15 10:54:41 UTC
Created attachment 35770 [details]
mod_xml2enc.c: pass all meta buckets down the chain

How about passing *all* metadata buckets down the chain (and, btw, bail out on EOS)?
Comment 3 Micha Lenk 2018-03-15 13:19:45 UTC
I've just tested your patch, and it fixes our issue with the dropped error bucket too.

We didn't dare to do a bigger clean-up like you did, because we were not sure what else could break by doing so. For that reason I've just run our internal charset conversion and HTML rewriting regression test suite against a httpd with your patch applied which flagged no issues.

From our perspective your patch is good to go.
Comment 4 Eric Covener 2018-03-30 13:11:32 UTC
Hi Yann, if you commit this please add "this closes #48" to the commit to close out the github PR.
Comment 5 Micha Lenk 2018-04-12 15:07:14 UTC
Yann, is there any additional information needed from our side?
Comment 6 Yann Ylavic 2018-04-12 22:01:09 UTC
I'd like the patch to aggregate meta buckets (besides FLUSH which can't be retained), and then send them together either before further real data or before leaving.
I didn't start working on this though, will try soon if you don't beat me at it ;)
Comment 7 Yann Ylavic 2018-04-12 22:34:47 UTC
Created attachment 35869 [details]
mod_xml2enc: pass all meta buckets down the chain (v2)

Something like this maybe, does it work for you?
Comment 8 Yann Ylavic 2018-04-12 22:42:15 UTC
Created attachment 35870 [details]
mod_xml2enc: pass all meta buckets down the chain (v3)

Well, better if it compiles...
Comment 9 Yann Ylavic 2018-04-12 22:49:41 UTC
Created attachment 35871 [details]
mod_xml2enc: pass all meta buckets down the chain (v4)

... and yet better without other work (or not) in progress.
Sorry, I need a pause :)
Comment 10 Yann Ylavic 2018-04-13 07:50:21 UTC
Created attachment 35872 [details]
mod_xml2enc: pass all meta buckets down the chain (v5)

An APR_BRIGADE_CONCAT() added for safety (unlikely case where EOS is not the latest bucket).
Comment 11 Yann Ylavic 2018-04-13 08:00:12 UTC
v5 committed in r1829038, will let it linger a bit for review before proposing a backport to 2.4.x.
Comment 12 Yann Ylavic 2018-04-13 08:05:30 UTC
+ r1829039.
Comment 13 Micha Lenk 2018-04-13 08:24:10 UTC
Yann, thanks for jumping on this so fast. I got something to test... :)

One comment about the current code in trunk (SVN r1829039), file modules/filters/mod_xml2enc.c line 550. Shouldn't pending_metadata get reset to zero within the if block?
Comment 14 Yann Ylavic 2018-04-13 08:32:50 UTC
(In reply to Micha Lenk from comment #13)
> Yann, thanks for jumping on this so fast. I got something to test... :)
You're welcome. Fortunately you didn't test the series one by one :)

> 
> One comment about the current code in trunk (SVN r1829039), file
> modules/filters/mod_xml2enc.c line 550. Shouldn't pending_metadata get reset
> to zero within the if block?
It's a local variable and the filter is leaving at this point.
Comment 15 Micha Lenk 2018-04-13 09:10:46 UTC
>> Shouldn't pending_metadata get reset to zero within the if block?
>
> It's a local variable and the filter is leaving at this point.

Right. Thanks for the explanation.
Comment 16 Micha Lenk 2018-04-27 14:56:26 UTC
I've just tested the cherry-picked SVN revisions r1829038 and r1829039 applied to a httpd-2.4.25 build and can confirm that this variant of the patch also fixes our issue.

Thanks for considering to backport this.
Comment 17 Yann Ylavic 2018-04-29 22:20:45 UTC
Thanks for testing, backport proposed in r1830524.
Comment 18 Micha Lenk 2018-05-02 15:16:06 UTC
> Thanks for testing, backport proposed in r1830524.

The above mentioned change of the STATUS document lists another SVN revision (r1830523). So I re-run our tests with that one applied on top. The issue remains fixed. Thanks!
Comment 19 Yann Ylavic 2018-05-02 15:27:12 UTC
Thanks Mika, it was more or less a cosmetic change which allowed me to close the corresponding pull request on github (with the commit message, I missed that on the first commits) :p
Comment 20 Christophe JAILLET 2018-08-04 10:24:07 UTC
backported in 2.4.x in r1834104

This is part of 2.4.34