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
A combination eval, DESTROY method and $@ - dangerous - bug #8257
Comments
From root@localhost.localdomainCreated by root@localhost.localdomainBrief: To see example below // Perlover (perlover@perlover.com) eval { my print "error = $error\n"; { sub new sub DESTROY sub alex Perl Info
|
From @smpeters
But what if the scenario you show above is exactly what I want? It may |
The RT System itself - Status changed from 'new' to 'open' |
From @ysthOn Mon, Jan 02, 2006 at 07:43:32AM -0800, Steve Peters via RT wrote:
You can prevent DESTROY methods from affecting $@ by starting them with |
@smpeters - Status changed from 'open' to 'resolved' |
From mjtg@cam.ac.ukYitzchak Scott-Thoennes <sthoenna@efn.org> wrote
This fact is notoriously underdocumented; I suggest the attached. Mike Guy Inline Patch--- ./pod/perlobj.pod.orig 2003-07-10 07:12:41.000000000 +0100
+++ ./pod/perlobj.pod 2006-01-03 18:48:55.479193000 +0000
@@ -433,6 +433,11 @@
the thingy the reference points to, namely C<${$_[0]}>, C<@{$_[0]}>,
C<%{$_[0]}> etc.) is not similarly constrained.
+Since DESTROY methods can be called at unpredictable times, it is
+important that you localise any global variables that the method may
+update. In particular, localise C<$@> if you use C<exec {} and
+localise C<$?> if you use C<system> or backticks.
+
If you arrange to re-bless the reference before the destructor returns,
perl will again call the DESTROY method for the re-blessed object after
the current one returns. This can be used for clean delegation of
End of patch |
From mjtg@cam.ac.ukOoops - typo. Try again. Mike Guy Inline Patch--- ./pod/perlobj.pod.orig 2003-07-10 07:12:41.000000000 +0100
+++ ./pod/perlobj.pod 2006-01-03 18:48:55.479193000 +0000
@@ -433,6 +433,11 @@
the thingy the reference points to, namely C<${$_[0]}>, C<@{$_[0]}>,
C<%{$_[0]}> etc.) is not similarly constrained.
+Since DESTROY methods can be called at unpredictable times, it is
+important that you localise any global variables that the method may
+update. In particular, localise C<$@> if you use C<exec {}> and
+localise C<$?> if you use C<system> or backticks.
+
If you arrange to re-bless the reference before the destructor returns,
perl will again call the DESTROY method for the re-blessed object after
the current one returns. This can be used for clean delegation of
End of patch |
From mjtg@cam.ac.ukJoshua ben Jore <twists@gmail.com> wrote
Bah! Haven't recovered from New Year's Eve yet. Try 3: Mike Guy Inline Patch--- ./pod/perlobj.pod.orig 2003-07-10 07:12:41.000000000 +0100
+++ ./pod/perlobj.pod 2006-01-03 18:48:55.479193000 +0000
@@ -433,6 +433,11 @@
the thingy the reference points to, namely C<${$_[0]}>, C<@{$_[0]}>,
C<%{$_[0]}> etc.) is not similarly constrained.
+Since DESTROY methods can be called at unpredictable times, it is
+important that you localise any global variables that the method may
+update. In particular, localise C<$@> if you use C<eval {}> and
+localise C<$?> if you use C<system> or backticks.
+
If you arrange to re-bless the reference before the destructor returns,
perl will again call the DESTROY method for the re-blessed object after
the current one returns. This can be used for clean delegation of
End of patch |
From @smpetersOn Tue, Jan 03, 2006 at 07:18:41PM +0000, Mike Guy wrote:
Try 3 added as change #26625. Thanks! Steve Peters |
From nick@ing-simmons.netMike Guy <mjtg@cam.ac.uk> writes:
Did you mean C<eval> there?
|
Migrated from rt.perl.org#38034 (status was 'resolved')
Searchable as RT38034$
The text was updated successfully, but these errors were encountered: