Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoping issue with "no autodie" and the "system" sub #69

Closed
nthykier opened this issue Dec 21, 2015 · 5 comments
Closed

Scoping issue with "no autodie" and the "system" sub #69

nthykier opened this issue Dec 21, 2015 · 5 comments

Comments

@nthykier
Copy link
Contributor

Hi,

We saw a report in Debian (https://bugs.debian.org/798096), where autodie broke valid code.

The code can basically be reduced to:

#!/usr/bin/perl

use autodie;

use_system();

sub break_system {
    no autodie qw(system);
}

sub use_system {
    system('/bin/true');
}

A couple items to note:

  • The order of break_system and use_system is significant (reorder them and the problem disappears)
  • It appears to affect system() but not chdir() [have not tested other functions yet]
  • It also appears if you replace "no autodie qw(${sub})" with a plain "no autodie".
@nthykier
Copy link
Contributor Author

The error received is:

 $ ./test.pl 
Undefined subroutine called at ./test.pl line 12.

ntyni added a commit to ntyni/autodie that referenced this issue Dec 21, 2015
Skip uninstalling subs that we never installed. This makes
sure we don't try to reinstall nonexisting subs later when
exiting the 'no autodie' scope.

Bug: Dual-Life#69
Bug-Debian: https://bugs.debian.org/798096
@ntyni
Copy link
Contributor

ntyni commented Dec 21, 2015

Hi, please see the pull request I just linked. I'm not quite sure if it's correct but it seems to work.

@ntyni
Copy link
Contributor

ntyni commented Dec 21, 2015

Taking that back: the change only works on the 'main' package so it still needs some more work :)

ntyni added a commit to ntyni/autodie that referenced this issue Dec 21, 2015
Don't queue nonexisting subs for reinstalling later when
exiting the 'no autodie' scope.

FIXME: if the original sub 'can be undef for "CORE::" subs', does this
break for those? Is that the case when $symbol =~ /::/, as guarded for
on L566?

Bug: Dual-Life#69
Bug-Debian: https://bugs.debian.org/798096
@ntyni
Copy link
Contributor

ntyni commented Dec 23, 2015

Hi, ntyni@c1b4fc4 is my next try and passes all tests, but I'm not sure about this:

FIXME: if the original sub 'can be undef for "CORE::" subs', does this break for those? Is that the case when $symbol =~ /::/, as guarded on L566?

Help/comments would be welcome.

@nthykier
Copy link
Contributor Author

Fixed by the merge of c1b4fc4

ntyni added a commit to ntyni/perl5 that referenced this issue Oct 14, 2017
Don't queue nonexisting subs for reinstalling later when
exiting the 'no autodie' scope.

FIXME: if the original sub 'can be undef for "CORE::" subs', does this
break for those? Is that the case when $symbol =~ /::/, as guarded for
on L566?

Bug: Dual-Life/autodie#69
Bug-Debian: https://bugs.debian.org/798096
Origin: upstream, Dual-Life/autodie@c1b4fc4
Patch-Name: fixes/autodie-scope.diff
metux pushed a commit to oss-qm/perl5 that referenced this issue Apr 26, 2018
Don't queue nonexisting subs for reinstalling later when
exiting the 'no autodie' scope.

FIXME: if the original sub 'can be undef for "CORE::" subs', does this
break for those? Is that the case when $symbol =~ /::/, as guarded for
on L566?

Bug: Dual-Life/autodie#69
Bug-Debian: https://bugs.debian.org/798096
Origin: upstream, Dual-Life/autodie@c1b4fc4
Patch-Name: fixes/autodie-scope.diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants