CC: | IT-1286 [...] jira.mensa.de |
Subject: | Net::DNS::Resolver calls my $SIG{__DIE__} handler upon loading |
$ perl -E '$SIG{__DIE__} = sub { say "Handler called:\n@_" }; require Net::DNS::Resolver'
Handler called:
Can't locate Net/DNS/Resolver/linux.pm in @INC (you may need to install the Net::DNS::Resolver::linux module) (@INC contains: lib /usr/local/lib/perl5/site_perl/5.30.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.30.0 /usr/local/lib/perl5/5.30.0/x86_64-linux /usr/local/lib/perl5/5.30.0 /etc/perl) at (eval 1) line 1.
----
IMHO you should do a "local $SIG{__DIE__}" in every eval, as suggested in "perldoc -f eval":
| Using the "eval {}" form as an exception trap in libraries
| does have some issues. Due to the current arguably broken
| state of "__DIE__" hooks, you may wish not to trigger any
| "__DIE__" hooks that user code may have installed. You can
| use the "local $SIG{__DIE__}" construct for this purpose, as
| this example shows:
|
| # a private exception trap for divide-by-zero
| eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
| warn $@ if $@;
(Net::DNS already does this before requiring Net::DNS::Resolver, but unfortunately other modules like Mail::SPF use Net::DNS::Resolver directly, thus my handler gets called when I "require Mail::SPF".)
Please let me know if you are interested in a patch for this issue (or a pull request if there already is a public git repository available somewhere).
Regards
Martin