Skip Menu |

This queue is for tickets about the Params-Validate CPAN distribution.

Report information
The Basics
Id: 127811
Status: stalled
Priority: 0/
Queue: Params-Validate

People
Owner: Nobody in particular
Requestors: PAWELKROL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.23
  • 1.29
Fixed in: (no value)



Subject: "validate" crashes on a closed IO::Scalar object
Hi! I would like to use Params::Validate's "validate" function to validate an IO::Scalar object. However when an IO::Scalar object is closed, "validate" will *always* crash regardless of whatever actual validation callbacks are defined. Here is a minimal code that demonstrates the bug and the results of its execution: $ cat test.pl #!/usr/bin/perl use Data::Dumper; use IO::Scalar; use Params::Validate qw(:all); sub test { print Dumper \@_; validate(@_, { arg => {} }); } my $var = new IO::Scalar; $var->close; test({ arg => $var }); $ ./test.pl $VAR1 = [ { 'arg' => bless( \*IO::Scalar::FH, 'IO::Scalar' ) } ]; Can't use an undefined value as a SCALAR reference at /usr/local/share/perl5/IO/Scalar.pm line 157. $ echo $? 255 I confirmed it to crash at least since version 1.23. I have got the latest version of IO::Scalar (2.111) installed as well. I would very much appreciate if this problem could be addressed in the next version of this excellent package. Many thanks! Best regards, Pawel Krol.
Hi Pawel, I'm not really using this module any more in any new code. Instead I'm using https://metacpan.org/release/Params-ValidationCompiler which ends up being quite a bit faster. You might want to take a look at it. Since I'm not really using it I'm not sure if I'll get a chance to investigate this bug myself. However, a PR against https://github.com/houseabsolute/Params-Validate would be welcome.
Hi! Thank you very much for your response. I was thinking how it could be fixed, and perhaps it makes more sense to address the issue at its root cause, i.e. in the "IO::Scalar" module, since this is where it actually blows up. I have opened a respective ticket to "IO-stringy" package: https://rt.cpan.org/Ticket/Display.html?id=127843 Since it is a low-level module, changing it would be more invasive. Thus I am not entirely sure if fixing a bug there is feasible. Let's wait and see what the maintainers say. If the change proves to be unacceptable, we could always "eval" + inspect "$@" to capture the error message from an underlying function, although I am not entirely sure how to account for a variety of possible errors thrown by different modules. If you have an idea what would be the most appropriate way to handle it, I would be happy to open a PR. Params::ValidationCompiler may seem like a reasonable alternative. Thanks for the suggestion, I was not aware of it. I will sure give it a try! Many thanks! Best regards, Pawel Krol.
Marking stalled since this needs to be fixed in IO::Scalar.