Skip Menu |

This queue is for tickets about the Want CPAN distribution.

Report information
The Basics
Id: 21180
Status: resolved
Priority: 0/
Queue: Want

People
Owner: robin [...] cpan.org
Requestors: jdhedden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.10
  • 0.01
  • 0.02
  • 0.03
  • 0.04
  • 0.05
  • 0.06
  • 0.07
  • 0.08
  • 0.09
Fixed in: (no value)



Subject: [PATCH] Calling 'lnoreturn' with 'use threads' causes error
The attached script (bug.pl) produces the following error: Can't undef active subroutine during global destruction. This results from the need to decrement the 'subroutine depth' in 'lnoreturn'. The attached patch fixes this bug, and includes tests that verify the fix.
Subject: want.patch
diff -urN Want-0.10/Changes Want-0.11/Changes --- Want-0.10/Changes 2006-03-26 15:08:08.000000000 -0500 +++ Want-0.11/Changes 2006-08-25 14:14:16.000000000 -0400 @@ -66,3 +66,6 @@ - Fix bug whereby want('LVALUE') sometimes gave false positives (see test 58 in t/all.t) - Fix bug whereby want_boolean often gave false positives + +0.11 + - Fix bug whereby 'lnoreturn' + 'use threads' resulted in error diff -urN Want-0.10/MANIFEST Want-0.11/MANIFEST --- Want-0.10/MANIFEST 2006-08-25 14:15:14.000000000 -0400 +++ Want-0.11/MANIFEST 2006-08-25 14:14:56.000000000 -0400 @@ -11,3 +11,5 @@ t/damian.t t/err.t t/object.t +t/threads.t +t/threads.p diff -urN Want-0.10/README Want-0.11/README --- Want-0.10/README 2006-03-29 08:49:30.000000000 -0500 +++ Want-0.11/README 2006-08-25 14:14:22.000000000 -0400 @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- -| Want v0.10 - Robin Houston, 2006-03-25 +| Want v0.11 - Robin Houston, 2006-03-25 ----------------------------------------------------------------------------- For full documentation, see the POD included with the module. diff -urN Want-0.10/Want.pm Want-0.11/Want.pm --- Want-0.10/Want.pm 2006-03-26 14:52:22.000000000 -0500 +++ Want-0.11/Want.pm 2006-08-25 14:14:30.000000000 -0400 @@ -12,7 +12,7 @@ our @EXPORT = qw(want rreturn lnoreturn); our @EXPORT_OK = qw(howmany wantref); -our $VERSION = '0.10'; +our $VERSION = '0.11'; bootstrap Want $VERSION; diff -urN Want-0.10/Want.xs Want-0.11/Want.xs --- Want-0.10/Want.xs 2006-03-26 09:08:56.000000000 -0500 +++ Want-0.11/Want.xs 2006-08-25 14:13:00.000000000 -0400 @@ -651,6 +651,7 @@ Perl_croak(aTHX_ "Can't return outside a subroutine"); ourcx->cx_type = CXt_NULL; + CvDEPTH(ourcx->blk_sub.cv)--; #if HAS_RETSTACK if (PL_retstack_ix > 0) --PL_retstack_ix; diff -urN Want-0.10/t/threads.p Want-0.11/t/threads.p --- Want-0.10/t/threads.p 1969-12-31 19:00:00.000000000 -0500 +++ Want-0.11/t/threads.p 2006-08-25 14:11:40.000000000 -0400 @@ -0,0 +1,26 @@ +use strict; +use warnings; + +{ + package Foo; + use Want; + + sub new { return (bless({}, shift)); } + + my $foo; + + sub foo :lvalue + { + my (@args) = Want::want('ASSIGN'); + $foo = $args[0]; + Want::lnoreturn; + return; + } + +} + +use threads; +my $obj = Foo->new(); +$obj->foo() = 'bar'; + +# EOF diff -urN Want-0.10/t/threads.t Want-0.11/t/threads.t --- Want-0.10/t/threads.t 1969-12-31 19:00:00.000000000 -0500 +++ Want-0.11/t/threads.t 2006-08-25 14:12:50.000000000 -0400 @@ -0,0 +1,10 @@ +use strict; +use warnings; + +use Test::More 'tests' => 1; + +my $out = `perl -Mblib t/threads.p 2>&1`; + +is($out, '' => 'No destruct error'); + +# EOF
Subject: bug.pl
#!/usr/bin/perl use strict; use warnings; { package Foo; use Want; sub new { return (bless({}, shift)); } my $foo; sub foo :lvalue { my (@args) = Want::want('ASSIGN'); $foo = $args[0]; Want::lnoreturn; return; } } use threads; my $obj = Foo->new(); $obj->foo() = 'bar';
I had to change the test, because it failed on non-threaded builds of perl, but other than that the patch looks good. Version 0.11 is on its way to CPAN now.
On Sun Aug 27 05:14:16 2006, ROBIN wrote: Show quoted text
> I had to change the test, because it failed on non-threaded builds of > perl
Unfortunately, you tested for 'usethreads'. You need to test for 'useithreads'. Patch attached. Perl 5.6 can be built with 'usethreads' for use with the old 'Threads' module. Right now, Want fails testing on Perl 5.6 built with 'usethreads'.
diff -urN Want-0.11/Changes Want-0.12/Changes --- Want-0.11/Changes 2006-08-27 05:08:28.000000000 -0400 +++ Want-0.12/Changes 2006-08-29 14:52:52.000000000 -0400 @@ -70,3 +70,6 @@ 0.11 Sat Aug 26 22:36:27 BST 2006 - (Jerry D. Hedden) Fix bug whereby 'lnoreturn' failed to decrement the CvDEPTH, which causes an error with 'use threads' + +0.12 + - Fix 'skip' on threads test diff -urN Want-0.11/README Want-0.12/README --- Want-0.11/README 2006-08-26 17:36:52.000000000 -0400 +++ Want-0.12/README 2006-08-29 14:53:18.000000000 -0400 @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- -| Want v0.11 - Robin Houston, 2006-08-26 +| Want v0.12 - Robin Houston, 2006-08-29 ----------------------------------------------------------------------------- For full documentation, see the POD included with the module. diff -urN Want-0.11/Want.pm Want-0.12/Want.pm --- Want-0.11/Want.pm 2006-08-26 17:30:46.000000000 -0400 +++ Want-0.12/Want.pm 2006-08-29 14:53:48.000000000 -0400 @@ -12,7 +12,7 @@ our @EXPORT = qw(want rreturn lnoreturn); our @EXPORT_OK = qw(howmany wantref); -our $VERSION = '0.11'; +our $VERSION = '0.12'; bootstrap Want $VERSION; diff -urN Want-0.11/t/threads.t Want-0.12/t/threads.t --- Want-0.11/t/threads.t 2006-08-27 04:58:18.000000000 -0400 +++ Want-0.12/t/threads.t 2006-08-29 14:54:02.000000000 -0400 @@ -5,7 +5,7 @@ use Config; SKIP: { - skip "Threads not available", 1 unless $Config{usethreads}; + skip "Threads not available", 1 unless $Config{useithreads}; my $out = `$^X -Mblib t/threads.p 2>&1`; is($out, '' => 'No destruct error'); }
Argh, I'd forgotten about that. (Surely nobody uses it any more?) Many thanks for the patch. The new version is PAUSEing as I type. Robin