Jonathan Field wrote:
> Hi all,
> 
> This is my first mod_perl bug report, so I'd like to start by thanking you
> all for your great work over the years.
> 
> The problem I am experiencing involves passing a scalar reference (instead
> of a scalar) to $r->print().  It usually works as documented.  However I
> have come across a situation where instead of printing the contents, it
> prints the string version of the ref itself:  "SCALAR(0x8ca70e4)".
> 
> After some research, it seems that I can trigger this behavior by doing a
> certain type of regex on the scalar reference, specifically: a successful
> regex that includes a backreference.

>       my $data = "hello\n";
>       my $dataref = \$data;

>       $$dataref =~ s/(h)/$1/;

interesting.

I think the issue is that after your manipulations $dataref is no longer a
plain PV.  I used Devel::Peek to look at $dataref before and after and it
changes from a PV to PVMG.  where this trips up mod_perl is in
Apache::write_client:

        SV *sv = SvROK(ST(i)) && (SvTYPE(SvRV(ST(i))) == SVt_PV) ?
                 (SV*)SvRV(ST(i)) : ST(i);

so, if the scalar reference to be printed isn't of type SVt_PV it does not
get dereferenced.

I suppose we could change that to a SvPOK check instead, but I'm really not
inclined to change anything here - doug has said several times that the
magical dereferencing in $r->print() was a bad idea and should be considered
deprecated.  it's not in 2.0 either, so you'll need to dereference yourself
in order to port your code (someday :)

but thanks for the report - it's fun to track this kind of stuff down, even
if we end up not changing anything :)

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to