I'm running Perl 5.20.2 on a Gentoo virtual machine. We've had some code in place that uses a mod_perl handler to send complex hashref based structures between two servers using nfreeze / thaw; the code needed to be high performance therefore we used nfreeze/thaw rather than XML or similar. This has been working correctly on a variety of architectures since July 2014.

The mod_perl server does:

print nfreeze( $message_hash )

The client connects to the server use LWP::UserAgent and does:

my $message = thaw( $response->decoded_content() );

The message from client to server is similarly encoded with nfreeze / thaw in a cgi parameter in multi-part-form-data.

This has all worked perfectly up until I upgraded to Apache 2.4 / mod_perl 2.0.10 - I've even downgraded just those two packages to mod_perl 2.0.8 / Apache 2.2.31 and it starts working again. The message from the client gets to the server correctly and the server logs and processes the message correctly, but it then fails with an 'Out of memory!' error from the client when the response is received (due to this bug in Storable.pm) - however, regardless of that bug, something is corrupting the data in transit...

I've picked apart what's going on and found there are an additional two bytes being inserted somehow. I've recorded the data in a /tmp/ file before the print statement in the mod_perl handler and I've used perl -d to inspect what's received:

  DB<3> say "0x$_" for unpack "(H2)*", $response->content()
0x05
0x0a
0x03
0x00
0x00
0x00
0x01
0x08
0xc2
0x81
0x00
0x00
0x00
0x02
0x6f
0x6b

However, the server sent:

0x05
0x0a
0x03
0x00
0x00
0x00
0x01
0x08
0x00
0x00
0x00
0x02
0x6f
0x6b

So somehow 2 bytes have appeared in the middle of the message 0x08 and 0xc2.

So, what's going on here - is this a mod_perl bug, an Apache bug or correct behaviour and I need to work around it?


In reply to Strange issue with mod_perl 2.0.10 / Apache 2.4 corrupting nfreeze data by amasidlover

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.