Bug#1014730: liburi-perl: Breaks apt-cacher with "Can't locate Regexp/IPv6.pm" error
Mark Hindley
mark at hindley.org.uk
Tue Jul 12 07:31:48 BST 2022
Niko,
On Mon, Jul 11, 2022 at 09:26:12PM +0300, Niko Tyni wrote:
> [apt-cacher maintainers: the context here is that URI.pm introduced an
> optional dependency on Regexp::IPv6 by requiring it in an eval block,
> but the apt-cacher __DIE__ handler exits when the require fails.]
Thanks for including me.
> On Mon, Jul 11, 2022 at 05:35:17PM +0200, gregor herrmann wrote:
>
> > So we have:
> > - do nothing
> > - patch URI to restart the default signal handler in the eval
> > - (reassign? and) do something in apt-cacher
>
> I'm not really sure if there's a consensus on best practices around
> $SIG{__DIE__}.
I agree, although perlvar suggests it should be avoided completely:
Having to even think about the $^S variable in your exception handlers
is simply wrong. $SIG{__DIE__} as currently implemented invites
grievous and difficult to track down errors. Avoid it and use an
"END{}" or CORE::GLOBAL::die override instead.
I don't know when that was added. I don't remember reading it before.
> IMO apt-cacher is the one that should be fixed, rather
> than demanding that all the modules it uses need to reset and restore
> $SIG{__DIE__} before catching exceptions.
>
> >From 'perldoc -f die' :
>
> You can arrange for a callback to be run just before the "die"
> does its deed, by setting the $SIG{__DIE__} hook. The associated
> handler is called with the exception as an argument, and can
> change the exception, if it sees fit, by calling "die" again.
> See "%SIG" in perlvar for details on setting %SIG entries, and
> "eval" for some examples. Although this feature was to be run only
> right before your program was to exit, this is not currently so:
> the $SIG{__DIE__} hook is currently called even inside "eval"ed
> blocks/strings! If one wants the hook to do nothing in such
> situations, put
>
> die @_ if $^S;
>
> as the first line of the handler (see "$^S" in perlvar). Because
> this promotes strange action at a distance, this counterintuitive
> behavior may be fixed in a future release.
>
> Corresponding untested patch against apt-cacher attached.
The problem with this approach is that errors from apt-cacher's own evals will
be skipped as well.
Mark
More information about the pkg-perl-maintainers
mailing list