This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix failure of C<&locked_sub;> under -Dusethreads
authorGurusamy Sarathy <gsar@cpan.org>
Wed, 24 Mar 1999 06:34:56 +0000 (06:34 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Wed, 24 Mar 1999 06:34:56 +0000 (06:34 +0000)
p4raw-id: //depot/perl@3140

pp_hot.c
t/lib/thread.t

index 4c699ca..0785f5f 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2155,8 +2155,13 @@ PP(pp_entersub)
            if (SP > PL_stack_base + TOPMARK)
                sv = *(PL_stack_base + TOPMARK + 1);
            else {
-               MUTEX_UNLOCK(CvMUTEXP(cv));
-               croak("no argument for locked method call");
+               AV *av = (AV*)PL_curpad[0];
+               if (hasargs || !av || AvFILLp(av) < 0
+                   || !(sv = AvARRAY(av)[0]))
+               {
+                   MUTEX_UNLOCK(CvMUTEXP(cv));
+                   croak("no argument for locked method call");
+               }
            }
            if (SvROK(sv))
                sv = SvRV(sv);
index 8d38523..61997cf 100755 (executable)
@@ -13,7 +13,7 @@ BEGIN {
     $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
 }
 $| = 1;
-print "1..14\n";
+print "1..18\n";
 use Thread;
 print "ok 1\n";
 
@@ -71,3 +71,17 @@ sub islocked
 $t = Thread->new(\&islocked, "ok 13\n", "ok 14\n");
 $t->join->join;
 
+{
+    package Loch::Ness;
+    sub new { bless [], shift }
+    sub monster {
+       use attrs qw(locked method);
+       my($s, $m) = @_;
+       print "ok $m\n";
+    }
+    sub gollum { &monster }
+}
+Loch::Ness->monster(15);
+Loch::Ness->new->monster(16);
+Loch::Ness->gollum(17);
+Loch::Ness->new->gollum(18);