develooper Front page | perl.perl5.porters | Postings from October 1999

Re: croak in a tied method doesn't like eval

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
October 14, 1999 11:06
Subject:
Re: croak in a tied method doesn't like eval
Message ID:
199910141812.LAA16662@activestate.com
On Thu, 30 Sep 1999 21:06:20 BST, paul.marquess@bt.com wrote:
>When I run the script below with 5.005_58 or greater I get this 
>
>    panic: POPSTACK
>
>Older versions of Perl work fine and changing the croak to a die fixes the
>problem.
>
>Paul
>
>
>package TiedHash ;
>use Carp ;
>
>sub TIEHASH  { bless {}, $_[0] }
>sub STORE    { croak "abcd" }
>
>package main ;
>
>tie %h, TiedHash ;
>eval { $h{1} = 2 } ;

Here's a fix for this problem.


Sarathy
gsar@activestate.com
-----------------------------------8<-----------------------------------
NOTE: parts that backed out change#3988 have been elided.

Change 4376 by gsar@auger on 1999/10/14 17:47:35

	fix POPSTACK panics that ensued from bad interaction between
	runlevels and stack of stacks (change#3988 done right);
	basically, we pop the runlevel if the stacklevel is not the
	same one we started the runlevel with

Affected files ...

... //depot/perl/cop.h#34 edit
... //depot/perl/perl.c#174 edit
... //depot/perl/pp_ctl.c#155 edit
... //depot/perl/t/op/runlevel.t#12 edit
... //depot/perl/util.c#154 edit

Differences ...

==== //depot/perl/cop.h#34 (text) ====
[revert change#3988]
==== //depot/perl/perl.c#174 (text) ====
[revert change#3988]
==== //depot/perl/pp_ctl.c#155 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c.~1~	Thu Oct 14 10:47:39 1999
+++ perl/pp_ctl.c	Thu Oct 14 10:47:39 1999
@@ -2436,6 +2436,7 @@
     dTHR;
     int ret;
     OP *oldop = PL_op;
+    volatile PERL_SI *cursi = PL_curstackinfo;
     dJMPENV;
 
 #ifdef DEBUGGING
@@ -2448,7 +2449,7 @@
     case 0:
 	break;
     case 3:
-	if (PL_restartop) {
+	if (PL_restartop && cursi == PL_curstackinfo) {
 	    PL_op = PL_restartop;
 	    PL_restartop = 0;
 	    goto redo_body;

==== //depot/perl/t/op/runlevel.t#12 (xtext) ====
Index: perl/t/op/runlevel.t
--- perl/t/op/runlevel.t.~1~	Thu Oct 14 10:47:39 1999
+++ perl/t/op/runlevel.t	Thu Oct 14 10:47:39 1999
@@ -335,3 +335,17 @@
 print join('|', @bar[0..3]), "\n"; 
 EXPECT
 foo|fee|fie|foe
+########
+package TH;
+sub TIEHASH { bless {}, TH }
+sub STORE { eval { print "@_[1,2]\n" }; die "bar\n" }
+tie %h, TH;
+eval { $h{A} = 1; print "never\n"; };
+print $@;
+eval { $h{B} = 2; };
+print $@;
+EXPECT
+A 1
+bar
+B 2
+bar

==== //depot/perl/util.c#154 (text) ====
[revert change#3988]
End of Patch.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About