Skip Menu |

This queue is for tickets about the Contextual-Return CPAN distribution.

Report information
The Basics
Id: 121009
Status: resolved
Priority: 0/
Queue: Contextual-Return

People
Owner: Nobody in particular
Requestors: jkahrman [...] mathworks.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.003001
  • 0.003002
  • 0.004000
  • 0.004001
  • 0.004002
  • 0.004003
  • 0.004004
  • 0.004005
  • 0.004006
  • 0.004007
  • 0.004008
  • 0.004009
  • 0.004010
Fixed in: (no value)



Subject: leaked references of the caller's arguments
Contextual::Return is leaking references to the arguments it is passed. @DB::args is holding onto the references. I believe this started with Perl 5.15.2 when the handling of reference counting of @DB::args changed (https://perl5.git.perl.org/perl.git/commit/af80dd863acea8450a9f41ae03645f4d69dad091).
Subject: db_args_leak
Download db_args_leak
application/octet-stream 580b

Message body not shown because it is not plain text.

From: jkahrman [...] mathworks.com
On Fri Apr 07 12:23:07 2017, jkahrman@mathworks.com wrote: Show quoted text
> Contextual::Return is leaking references to the arguments it is > passed. @DB::args is holding onto the references. > > I believe this started with Perl 5.15.2 when the handling of reference > counting of @DB::args changed > https://perl5.git.perl.org/perl.git/commit/af80dd863acea8450a9f41ae03645f4d69dad091
An additional call to 'caller' in a 'DB' package context appears to clear the leaked references. I've attached a patch with this workaround.
Subject: db_args_leak.patch.refactor
Download db_args_leak.patch.refactor
application/octet-stream 2.5k

Message body not shown because it is not plain text.

Subject: db_args_leak.patch
--- Contextual-Return-0.004007/lib/Contextual/Return.pm 2016-11-03 00:16:14.000000000 -0400 +++ Contextual-Return-0.004007.patch/lib/Contextual/Return.pm 2016-11-03 00:16:14.000000000 -0400 @@ -248,7 +248,7 @@ # Determine call context and arg list... my $context; - my $args = do { package DB; $context=(CORE::caller 1)[5]; \@DB::args }; + my $args = do { package DB; $context=(CORE::caller 1)[5]; my $args = \@DB::args; ()=CORE::caller(1); $args }; # No args -> return appropriate value... if (!@_) { @@ -287,7 +287,7 @@ *{$subname} = sub(&;@) :lvalue { # (handler, return_lvalue); my $handler = shift; my $impl; - my $args = do{ package DB; ()=CORE::caller(1); \@DB::args }; + my $args = do{ package DB; ()=CORE::caller(1); my $args = \@DB::args; ()=CORE::caller(1); $args }; if (@_==0) { $impl = tie $_[0], 'Contextual::Return::Lvalue', $subname => $handler, args=>$args; @@ -442,7 +442,7 @@ # Ensure we have an object... my $attrs; if (!refaddr $crv) { - my $args = do{ package DB; ()=CORE::caller(1); \@DB::args }; + my $args = do{ package DB; ()=CORE::caller(1); my $args = \@DB::args; ()=CORE::caller(1); $args }; my $subname = (CORE::caller(1))[3]; if (!defined $subname) { $subname = 'bare LIST {...}'; @@ -531,7 +531,7 @@ # Ensure we have an object... my $attrs; if (!refaddr $crv) { - my $args = do{ package DB; ()=CORE::caller(1); \@DB::args }; + my $args = do{ package DB; ()=CORE::caller(1); my $args = \@DB::args; ()=CORE::caller(1); $args }; my $subname = (CORE::caller(1))[3]; if (!defined $subname) { $subname = 'bare VOID {...}'; @@ -650,7 +650,7 @@ # Ensure we have an object... my $attrs; if (!refaddr $crv) { - my $args = do{ package DB; ()=CORE::caller(1); \@DB::args }; + my $args = do{ package DB; ()=CORE::caller(1); my $args = \@DB::args; ()=CORE::caller(1); $args }; my $subname = (CORE::caller(1))[3]; if (!defined $subname) { $subname = "bare $context {...}"; @@ -781,7 +781,7 @@ # Ensure we have an object... my $attrs; if (!refaddr $crv) { - my $args = do{ package DB; ()=CORE::caller(1); \@DB::args }; + my $args = do{ package DB; ()=CORE::caller(1); my $args = \@DB::args; ()=CORE::caller(1); $args }; my $subname = (CORE::caller(1))[3]; if (!defined $subname) { $subname = "bare $context_name {...}";
Subject: Re: [rt.cpan.org #121009] leaked references of the caller's arguments
Date: Sat, 8 Apr 2017 15:26:17 +1000
To: bug-Contextual-Return [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Jay, Thank-you for investigating and resolving this annoying issue. I am particularly grateful for the patch, which I have now applied and uploaded a new release. Much appreciated! Damian