Control: tag -1 patch

On Sat, Feb 28, 2015 at 08:01:58PM +0200, Niko Tyni wrote:
> forwarded 779357 https://rt.perl.org/Public/Bug/Display.html?id=120170
> thanks
> 
> On Fri, Feb 27, 2015 at 05:15:57PM -0500, James McCoy wrote:
> 
> > As an FYI, upstream commit cde405a6b is what caused "perl -dt" to be
> > required.  Re-adding the lock prototype to the current perl5db.pl allows
> > "perl -d" to at least start, but then the debugger errors out with
> > "Modification of a read-only value attempted at .../perl5db.pl line
> > 4129." which is this:
> > 
> >     # Save current single-step setting.
> >     $stack[-1] = $single;
> 
> Thanks. I got that far too, and I also bisected the 'Modification of a
> read-only value' thing to ce0d59fdd1c7d145efdf6bf8da56a259fed483e4
> but that doesn't help much.

The attached patches are what I submitted upstream (Perl RT#124127).
They get the debugger back to the pre-5.18 state (“perl -d” works
again).

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <james...@debian.org>
From c3cc714b2096b20613323b4187bbc9a02a5c9314 Mon Sep 17 00:00:00 2001
From: James McCoy <vega.ja...@gmail.com>
Date: Thu, 19 Mar 2015 22:55:18 -0400
Subject: [PATCH 1/2] lib/perl5db.pl: Restore noop lock prototype

cde405a6b9b86bd8110f63531b42d89590a4c56e removed the lock prototype
"because it's already a do-nothing weak keyword without threads".
However, that causes "perl -d threaded-script.pl" to complain

    lock can only be used on shared values at /usr/share/perl/5.20/perl5db.pl line 4101.
    BEGIN failed--compilation aborted at threaded-script.pl line 2.
    lock can only be used on shared values at /usr/share/perl/5.20/perl5db.pl line 2514.
    END failed--call queue aborted at threaded-script.pl line 2.
    Unbalanced scopes: 3 more ENTERs than LEAVEs

because threaded-script.pl's importing of threads::shared enable's
lock()'s non-noop behavior.  Restoring the lock() prototype fixes the
inconsistency between lock() and share() usage.

Signed-off-by: James McCoy <vega.ja...@gmail.com>
---
 lib/perl5db.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 8babb45..4194428 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -871,6 +871,7 @@ BEGIN {
         lock($DBGR);
         print "Threads support enabled\n";
     } else {
+        *lock = sub(*) {};
         *share = sub(\[$@%]) {};
     }
 }
-- 
2.1.4

From 05bc4308e4b82982cebdf08c970cba7bbb599356 Mon Sep 17 00:00:00 2001
From: James McCoy <vega.ja...@gmail.com>
Date: Thu, 19 Mar 2015 23:05:35 -0400
Subject: [PATCH 2/2] lib/perl5db.pl: Fix "read-only value" modification

ce0d59fdd1c7d145efdf6bf8da56a259fed483e4 changed handling of
non-existent array elements.  This causes "perl -d threaded-script.pl"
to error out with the "Modification of a read-only value attempted"
error.

Pushing/popping @stack rather than resizing by changing the max index
avoids this error.

Signed-off-by: James McCoy <vega.ja...@gmail.com>
---
 lib/perl5db.pl | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 4194428..f531f03 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -4138,7 +4138,13 @@ sub DB::sub {
     local $stack_depth = $stack_depth + 1;    # Protect from non-local exits
 
     # Expand @stack.
-    $#stack = $stack_depth;
+    my $stack_change = $stack_depth - $#stack;
+    if ($stack_change > 0) {
+        push @stack, (undef) x $stack_change;
+    }
+    else {
+        pop @stack while $stack_change++;
+    }
 
     # Save current single-step setting.
     $stack[-1] = $single;
@@ -4279,7 +4285,13 @@ sub lsub : lvalue {
     local $stack_depth = $stack_depth + 1;    # Protect from non-local exits
 
     # Expand @stack.
-    $#stack = $stack_depth;
+    my $stack_change = $stack_depth - $#stack;
+    if ($stack_change > 0) {
+        push @stack, (undef) x $stack_change;
+    }
+    else {
+        pop @stack while $stack_change++;
+    }
 
     # Save current single-step setting.
     $stack[-1] = $single;
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

Reply via email to