rovf has asked for the wisdom of the Perl Monks concerning the following question:

I'm using in my program in my program the function dircopy from File::Copy::Recursive. This worked fine so fast, but recently (and, no, I am not aware that I have changed something in the call to this function), I get error message like

Attempt to free unreferenced scalar: SV 0x3f7b6d8, Perl interpreter: 0 +x15d4884 at e:/Tools/Perl587/lib/File/Copy.pm line 91.
when calling it. Note that the error is triggered in File::Copy, which is a standard module. Looking at the source of my version of Copy.pm, I see that the offending line in File/Copy.pm is the line containing the if expression
if (!$from_a_handle && !$to_a_handle && -d $to && ! -d $from) { $to = _catname($from, $to); }
which looks pretty innocent to me. I googled for this error message, and though I found other people also observing this error in Copy.pm, I didn't find any solution to this. Any ideas what I could do here?

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re: Attempt to free unreferenced scalar in Copy.pm
by mr_mischief (Monsignor) on Oct 28, 2008 at 16:40 UTC
    I notice you're using Perl 5.8.7 there. Any idea what version of File::Copy you're using? The perl588delta doc says that File::Copy was upgraded to 2.09 in the core distribution. If you can't upgrade Perl perhaps you could upgrade File::Copy from CPAN.

    If you have an example that triggers this error, I'd be happy to run it against 5.8.8 and 5.10.0 on Mandriva, against 5.8.6 on Cygwin, against 5.8.8 and 5.10.0 on Windows XP (both Strawberry and ActiveState) and/or 5.8.8 on Puppy Linux to verify whether or not it still happens.

      The perl588delta doc says that File::Copy was upgraded to 2.09

      I'm still using File::Copy 2.08. As I plan to upgrade to Perl 5.10 in the near future anyway, I will wait whether the problem disappears and report back if it doesn't.

      -- 
      Ronald Fischer <ynnor@mm.st>
Re: Attempt to free unreferenced scalar in Copy.pm
by JadeNB (Chaplain) on Oct 29, 2008 at 00:02 UTC
    Notice that an error will be reported from the line containing an if statement if it occurs anywhere in the controlled block. Accordingly, it's probably _catname, not the if itself, that's giving the trouble.

    UPDATE: I thought that this was true, but

    perl -e 'if ( 1 ) {' -e '1/0' -e '}'
    reports "Illegal division by zero at -e line 2", so I guess not. (Also, having looked at the code for _catname, it looks almost as innocuous as the if test itself.)

      Runtime errors and warning that occur in the elsif condition were reported as being on the line of the "if".

      >perl580\bin\perl -we"if ( $foo ) {}" -e "elsif ( length($bar) ) {}" Name "main::bar" used only once: possible typo at -e line 2. Name "main::foo" used only once: possible typo at -e line 1. Use of uninitialized value in length at -e line 1.

      I don't know about 5.8.7, but it's was fixed by 5.8.8.

      >perl588\bin\perl -we"if ( $foo ) {}" -e "elsif ( length($bar) ) {}" Name "main::bar" used only once: possible typo at -e line 2. Name "main::foo" used only once: possible typo at -e line 1. Use of uninitialized value in length at -e line 2.

      In any case, that's not the problem here since the if in question doesn't have an elsif clause.