Crash in uri_canonical (version 6.2.5 of HTTP::Request)
tdlewis77 opened this issue · comments
The attached patch resolves a crash I have been experiencing in HTTP::Request.
Request.gz
Thanks @tdlewis77.
Patch looks like:
+++ Request.pm 2020-09-18 16:24:38.000000000 -0700
@@ -98,5 +98,5 @@
if (defined (my $canon = $self->{_uri_canonical})) {
# early bailout if these are the exact same string; try to use
# the cheapest comparison method possible
- return $canon if $$canon eq $$uri;
+ return $canon if $$canon eq $uri;
}
# otherwise we need to refresh the memoized value
Do you have some code to demonstrate how to trigger the error?
I can confirm the issue. In our code it looks like (for HTTP-Message 6.27):
Unhandled exception in OurNamespace::FetchHTML->process for message 15248240911: $VAR1 = 'Not a SCALAR reference at /lib/perl5/HTTP/Request.pm line 101. at /lib/perl5/LWP/UserAgent.pm line 1007.
';
This is really deep in the stack trace, trying to find a clean way to reproduce this
@andrew-grechkin does the patch fix it for you as well?
Nope I think this patch have no sense because it just hides issue IMHO.
I've nailed how this is happening in our code:
use v5.28;
use autodie;
use warnings;
use URI::URL ();
use HTTP::Request;
my $u = URI::URL->new('https://perl.org');
my $r = HTTP::Request->new(GET => $u);
say $r->uri_canonical;
say $r->uri_canonical;
result:
https://perl.org/
Not a SCALAR reference at /home/agrechkin/.local/share/perlbrew/libs/perl-5.30.2@default/lib/perl5/HTTP/Request.pm line 101.
Excellent. That makes it much easier to narrow down. Did you want to submit a PR to fix it?
Closed via #153. Thanks for reporting @tdlewis77.