#232 perl -d chokes on lvalue functions

core (120)

This works as expected
cat > perldl-lvalue.pl
#!/usr/bin/env perl
use strict;
use PDL;
print identity 1
perl perldl-lvalue.pl

But this does not:

perl -d perldl-lvalue.pl

Can't return a temporary from lvalue subroutine at /usr/lib/perl5/PDL/MatrixOps.pm line 169.
at /usr/lib/perl5/PDL/MatrixOps.pm line 169
PDL::MatrixOps::identity(1) called at /home/davis/tmp/perldl-lvalue.pl line 5

I.e. PDL lvalue functions, not just this one, seem to fail under the Perl debugger.

I tried this on the PDL (2.4.5) included in my Ubuntu 10.04 (i686) and also built 2.4.6 and 2.4.6_001 from CPAN.


1 2 > >> (Page 1 of 2)
  • Chris Marshall

    Chris Marshall - 2010-05-02

    See PDL/BUGS for the recommended minimum info for a bug report.

    That said, I seem to remember some discussion on a PDL mailing list
    about this problem being introduced in a newer version of perl. As is,
    for the perl I am running on cygwin, 5.10.0, I do not see the problem.
    For strawberry perl 5.10.1, I get the error.

    Thanks for reporting the problem. I'm not sure where we stand with
    the problem as far as a ticket to perl or a work-around.

  • Chris Marshall

    Chris Marshall - 2010-05-02

    Sorry, I did not see the attached perl -V output file.

    Thanks again for the report. -chm

  • Shlomi Fish

    Shlomi Fish - 2010-05-11

    I can reproduce this here on Mandriva Linux Cooker (on a 32-bit Pentium 4 machine) with
    perl-PDL-2.4.6-1mdv2010.1 and perl-5.10.1-8mdv2010.1 . It disrupts my work and I hope it will be fixed soon. Maybe I'll switch to an older (5.8.9) or newer perl to see if I can reproduce it or alternatively found a way to overcome it for perl -d sessions.

  • Chris Marshall

    Chris Marshall - 2010-05-17

    I've changed the priority for this to 9-Highest because it basically makes it impossible to debug PDL code in the perl debugger. It would be helpful if there were a work-around that could be used in the meantime.

  • Chris Marshall

    Chris Marshall - 2010-05-17
    • priority: 5 --> 9
    • milestone: --> critical
  • Chris Marshall

    Chris Marshall - 2010-05-28

    After reviewing the rt.perl.org ticket #71172 for this problem, it seems like something is understood about the problem. Is there a work around for the debugger so that it can be used on perl versions 5.10.1 through 5.12?

  • Chris Marshall

    Chris Marshall - 2010-05-29

    The work around for the problem is to use the pre-lvalue subroutine syntax for slicing operations (and other lvalue subs). The modification has been made so that the tests
    failing on win32 from the debugger "feature" now run with perl -d. E.g.:

    $piddle->diagonal(0,1) .= 10;


    my $tmp; # work around perl -d "feature"
    ($tmp = $piddle->diagonal(0,1)) .= 10;

    Also reducing the priority slightly because there
    is a workable work around---if ugly.

  • Chris Marshall

    Chris Marshall - 2010-05-29
    • priority: 9 --> 7
  • Chris Marshall

    Chris Marshall - 2010-07-24

    I had another thought---maybe we could use the PDL source
    filter to "fix" the problem code in case a user needs to use
    the debugger. I don't get the sense that a fix for the various
    perl versions is coming any time soon.

    TODO: figure out how to make a test that runs under the
    debugger for our test suite...

  • Chris Marshall

    Chris Marshall - 2010-07-24
    • priority: 7 --> 5
  • Chris Marshall

    Chris Marshall - 2010-08-01
    • priority: 5 --> 1
    • status: open --> open-remind
  • Chris Marshall

    Chris Marshall - 2010-08-01

    Reducing the priority of this problem and marking the ticket Remind
    as the PDL part of the issue has been resolved with the ugly
    work-around required for use under the debugger. Still no word
    from the perl folks on a fix on their side. In the meantime,
    further work on this will be deferred until post-PDL-2.4.7.

  • Chris Marshall

    Chris Marshall - 2011-05-31

    You can use @lvsubs = PDL::Lvalue->subs; to get the list of
    all the PDL lvalue subroutines. Then you could replace each
    instance (via a source filter) as follows:

    lvsub() -> { my $tmpyuck = lvsub() }

    I don't think we would even need to restrict the
    filter operation to only where an lvalue assignment
    is being made. However, it would be cleaner and
    easier to debug if we only did the special transform
    where it was needed.

  • Chad A. Davis

    Chad A. Davis - 2011-06-02

    Thanks for the update.
    I discovered that the original example no longer produces the original error.
    I am still using perl 5.10.1 (now Ubuntu 11.04 rather than 10.04), but am using the current PDL 2.4.9 (originally was 2.4.5)
    Was this fixed, intentionally or otherwise? Or does this require a different test to trigger?

  • Chris Marshall

    Chris Marshall - 2011-06-02

    The problem was not fixed (it is a "feature" in current perls)
    but I did apply the workaround to all the usages in the PDL
    source tree for the PDL-2.4.6_008 release around 30-May-2010.

    If you wish to verify that the issue still exists, try debugging
    your own lvalue subs code (like assigning with .= to a slice).

    I would like to see support for auto-workaround insertion
    via PDL::NiceSlice or some such eventually. In the
    meantime, the workaround is needed and documented
    in Known_problems.

  • Chris Marshall

    Chris Marshall - 2011-06-19

    I finally tracked down how to check for when a program is
    being compile for the debugger: Before the program
    compile starts, BEGIN { require 'perl5db.pl; } is added to
    the top.

    Hence, we can check for compiling under 'perl -d' by seeing
    if $DB::VERSION is defined. PDL::NiceSlice could check
    for this and add the workaround for the lvalue subs problem
    under 'perl -d'.

  • Chris Marshall

    Chris Marshall - 2011-06-20

    I notice that the rt.perl.org ticket at


    lists this as resolved. The error has been downgraded
    to a warning---presumably those could be quieted with
    some flavor of 'no warnings'.

    I'm not sure when this fix would be available in a perl
    release nor whether a PDL user has been able to
    verify the resolution. For older perl versions, I think
    the source filter fix may still be desirable.

  • Derek Lamb

    Derek Lamb - 2011-07-08

    The commit that supposedly fixed this http://perl5.git.perl.org/perl.git/commitdiff/b724cc1
    is not in Perl 5.12.4 or 5.14.1, but is in 5.15.0 according to the perl5 git repo. Maybe somebody who is adept at compiling Perl & sticking PDL on it can give it a test? I just did 5.12.3-->5.14.1, so I'm a little burned out on that. David's one-liner
    perl -d -MPDL -e'$a=sequence(9); $a->slice("1") .= -9; print $a, "\n"'
    still fails for me on Perl 5.14.1.

  • Chris Marshall

    Chris Marshall - 2013-01-02

    Bumping priority to medium as I think this could be resolved for the next PDL release.

  • Chris Marshall

    Chris Marshall - 2013-01-02
    • priority: 1 --> 5
  • Chris Marshall

    Chris Marshall - 2013-01-11

    The only solution that works for all perl versions is
    to use the idiom:

    ($tmp = $a->slice(...)) .= stuff

    which is ugly but functional. Switching
    to perl 5.16.x also resolves the problem.
    I'm lowering this priority since you can
    get things to work in the debugger. I would
    like to keep the ticket open as I think
    a perl source filter automatic work-around
    may be possible.

  • Chris Marshall

    Chris Marshall - 2013-01-11
    • priority: 5 --> 1
  • Chris Marshall

    Chris Marshall - 2015-02-22
    • assigned_to: Chris Marshall
    • Group: critical --> feature_request
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks