Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 130950
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: FANY [...] cpan.org
Cc: IT-1286 [...] jira.mensa.de
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
On Sat Nov 09 11:12:25 2019, FANY wrote: Show quoted text
> $ 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
If you have a __DIE__ handler that you don't want to be called in eval blocks, why aren't you checking $^S?
Show quoted text
> If you have a __DIE__ handler that you don't want to be called in eval > blocks, why aren't you checking $^S?
Because I wasn't aware of this possibility. Thanks a lot for the hint! Regards Martin