Subject: | validate clobbers $@ |
Date: | Thu, 11 Oct 2012 01:46:28 -0700 (PDT) |
To: | "bug-params-validate [...] rt.cpan.org" <bug-params-validate [...] rt.cpan.org> |
From: | Salvador Fandino <sfandino [...] yahoo.com> |
Hi Dave,
I have found that the validate function clears the value of $@. This can cause really nasty bugs, for instance, I found it when using Log::Log4perl (that uses Params::Validate under the hood) in the following manner:
eval { ... };
DEBUG "error: $@";
if ($@) {
# handle error
}
DEBUG calls validate that resets $@ and so the error handling code is never executed.
After looking at Params::Validate code I found that the root of the problem is that it uses eval_pv to find the caller module from get_options. The attached patch changes it to obtain it directly from the opcode calling validate.
I have also added a new test file that checks that $@ is not clobbered.
There is another usage of eval_pv on the code but it is not called from the non-failure code path, so I have left it unchanged. If you want I could also replace it by pure XS code.
Cheers,
- Salva
Message body is not shown because sender requested not to inline it.