Perl / perl5

šŸŖ The Perl programming language
https://dev.perl.org/perl5/
Other
1.89k stars 533 forks source link

exec and system call FETCH magic twice under -T #11759

Open p5pRT opened 12 years ago

p5pRT commented 12 years ago

Migrated from rt.perl.org#104084 (status was 'open')

Searchable as RT104084$

p5pRT commented 12 years ago

From @Hugmeir

perl -T -E 'delete $ENV{PATH}; package D { sub TIESCALAR { return bless {}\, shift } sub FETCH { say ++$y; } } tie $x\, "D"; system $x; say ""; exec $x'

Which calls FETCH 4 times\, not 2. Also\, I might be missing something/being particularly thick today\, but the output doesn't make sense to me​: 1 2

2 3

Shouldn't that be 1\, 2\, 3\, 4\, not 1\, 2\, 2\, 3?

p5pRT commented 12 years ago

From @cpansprout

On Sat Nov 19 16​:47​:51 2011\, Hugmeir wrote​:

perl -T -E 'delete $ENV{PATH}; package D { sub TIESCALAR { return bless {}\, shift } sub FETCH { say ++$y; } } tie $x\, "D"; system $x; say ""; exec $x'

Which calls FETCH 4 times\, not 2. Also\, I might be missing something/being particularly thick today\, but the output doesn't make sense to me​: 1 2

2 3

Shouldn't that be 1\, 2\, 3\, 4\, not 1\, 2\, 2\, 3?

That second part reminds me of #96332\, but I donā€™t think itā€™s related. system() seems to be clearing $y somehow\, even without threads.

--

Father Chrysostomos

p5pRT commented 12 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 12 years ago

From @cpansprout

On Sat Nov 19 22​:18​:02 2011\, sprout wrote​:

On Sat Nov 19 16​:47​:51 2011\, Hugmeir wrote​:

perl -T -E 'delete $ENV{PATH}; package D { sub TIESCALAR { return bless {}\, shift } sub FETCH { say ++$y; } } tie $x\, "D"; system $x; say ""; exec $x'

Which calls FETCH 4 times\, not 2. Also\, I might be missing something/being particularly thick today\, but the output doesn't make sense to me​: 1 2

2 3

Shouldn't that be 1\, 2\, 3\, 4\, not 1\, 2\, 2\, 3?

That second part reminds me of #96332\, but I donā€™t think itā€™s related. system() seems to be clearing $y somehow\, even without threads.

Er\, I meant even without taint.

--

Father Chrysostomos

p5pRT commented 12 years ago

From @tonycoz

On Sat\, Nov 19\, 2011 at 04​:47​:52PM -0800\, Brian Fraser wrote​:

perl -T -E 'delete $ENV{PATH}; package D { sub TIESCALAR { return bless {}\, shift } sub FETCH { say ++$y; } } tie $x\, "D"; system $x; say ""; exec $x'

Which calls FETCH 4 times\, not 2. Also\, I might be missing something/being particularly thick today\, but the output doesn't make sense to me​: 1 2

2 3

Shouldn't that be 1\, 2\, 3\, 4\, not 1\, 2\, 2\, 3?

The first "2" is inside a forked child\, so the change isn't visible in the parent.

Tony