Skip Menu |

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 78624
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: dmacks [...] netspace.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.017



Subject: "Attempt to free unreferenced scalar" for invalid macros
Date: Sat, 28 Jul 2012 02:12:57 -0400
To: bug-Socket [...] rt.cpan.org
From: "Daniel Macks" <dmacks [...] netspace.org>
Using Socket-2.002 (installed via fink) on OS X on my intel Mac, I get a diagnostic whenever I try to access a Socket::* macro that doesn't exist. For example, TCP_KEEPALIVE is defined but TCP_oops is not... % perl -MSocket -e 'print &Socket::TCP_KEEPALIVE, "\n"' 16 % perl -MSocket -e 'print &Socket::TCP_oops, "\n"' TCP_oops is not a valid Socket macro at -e line 1 Attempt to free unreferenced scalar: SV 0x804b10, Perl interpreter: 0x800000 at -e line 1. I see the same results for OS X 10.6 (perl 5.10.0) in either 32-bit or 64-bit mode and for OS X 10.7 (perl 5.12.3). The free... diagnostic does not appear for Socket-1.80 (as shipped in OS X 10.6 perl 5.10.0 itself) or Socket-1.87_01 (as shipped with OS X 10.7 perl 5.12.3 itself). dan -- Daniel Macks dmacks@netspace.org
On Sat Jul 28 02:13:18 2012, dmacks@netspace.org wrote: Show quoted text
> Using Socket-2.002 (installed via fink) on OS X on my intel Mac, I get > a diagnostic whenever I try to access a Socket::* macro that > doesn't exist. For example, TCP_KEEPALIVE is defined but TCP_oops > is not... > > % perl -MSocket -e 'print &Socket::TCP_KEEPALIVE, "\n"' > 16 > > % perl -MSocket -e 'print &Socket::TCP_oops, "\n"' > TCP_oops is not a valid Socket macro at -e line 1 > Attempt to free unreferenced scalar: SV 0x804b10, Perl interpreter: > 0x800000 at -e line 1. > > I see the same results for OS X 10.6 (perl 5.10.0) in either 32-bit or > 64-bit mode and for OS X 10.7 (perl 5.12.3). The free... diagnostic > does not appear for Socket-1.80 (as shipped in OS X 10.6 perl > 5.10.0 itself) or Socket-1.87_01 (as shipped with OS X 10.7 perl > 5.12.3 itself).
Ah; I've always thought I couldn't reproduce this one, turns out I can: leo@cel:~ $ perl5.10.1 -MSocket -E 'say Socket::TCP_oops()' TCP_oops is not a valid Socket macro at -e line 1 Attempt to free unreferenced scalar: SV 0x1f45448 at -e line 1. leo@cel:~ $ perl5.12.4 -MSocket -E 'say Socket::TCP_oops()' TCP_oops is not a valid Socket macro at -e line 1 Attempt to free unreferenced scalar: SV 0x2170430 at -e line 1. leo@cel:~ $ perl5.14.2 -MSocket -E 'say Socket::TCP_oops()' TCP_oops is not a valid Socket macro at -e line 1 At first thoughts, tempted to blame ExtUtils::Constant, as it generates that code. -- Paul Evans
On Sat Jul 28 02:13:18 2012, dmacks@netspace.org wrote: Show quoted text
> I see the same results for OS X 10.6 (perl 5.10.0) in either 32-bit or > 64-bit mode and for OS X 10.7 (perl 5.12.3). The free... diagnostic > does not appear for Socket-1.80 (as shipped in OS X 10.6 perl > 5.10.0 itself) or Socket-1.87_01 (as shipped with OS X 10.7 perl > 5.12.3 itself).
Also, the ones shipped by Perl itself are built by perl's in-core build process, and not by the external system used by the CPAN module. As such, it may not be using ExtUtils::Constant there, or if so, it may be differently configured. I'm not sure it can be directly compared this way. -- Paul Evans
Subject: Re: [rt.cpan.org #78624] "Attempt to free unreferenced scalar" for invalid macros
Date: Wed, 15 Aug 2012 15:40:05 +0100
To: Paul Evans via RT <bug-Socket [...] rt.cpan.org>
From: Nicholas Clark <nick [...] ccl4.org>
On Wed, Aug 15, 2012 at 09:10:47AM -0400, Paul Evans via RT wrote: Show quoted text
> Queue: Socket > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78624 > > > On Sat Jul 28 02:13:18 2012, dmacks@netspace.org wrote:
> > I see the same results for OS X 10.6 (perl 5.10.0) in either 32-bit or > > 64-bit mode and for OS X 10.7 (perl 5.12.3). The free... diagnostic > > does not appear for Socket-1.80 (as shipped in OS X 10.6 perl > > 5.10.0 itself) or Socket-1.87_01 (as shipped with OS X 10.7 perl > > 5.12.3 itself).
> > Also, the ones shipped by Perl itself are built by perl's in-core build > process, and not by the external system used by the CPAN module. As > such, it may not be using ExtUtils::Constant there, or if so, it may be > differently configured. I'm not sure it can be directly compared this > way.
Try this: $ diff -u Socket.xs.orig Socket.xs --- Socket.xs.orig 2012-08-15 16:35:35.000000000 +0200 +++ Socket.xs 2012-08-15 16:35:47.000000000 +0200 @@ -92,7 +92,7 @@ #endif /* !Newx */ #ifndef croak_sv -# define croak_sv(sv) croak(SvPV_nolen(sv)) +# define croak_sv(sv) croak(SvPVx_nolen(sv)) #endif #ifndef hv_stores (I managed to find that I could replicate it on dromedary with a build of maint-5.12) The problem is that SvPV_nolen() is a macro, and is evaluating its arguments twice. In this case, the argument is sv_2mortal(sv) so that is getting called twice, and *two* entries on the mortals stack made, hence requesting two reference count decrements. (I don't feel that this is the most ideal long term fix, but it seems the simplest for now. I think I should fix ExtUtils::Constant to not rely on croak_sv and avoid the need for that macro completely. But this is faster.) Nicholas Clark
On Wed Aug 15 10:40:24 2012, nick@ccl4.org wrote: Show quoted text
> Try this: > > $ diff -u Socket.xs.orig Socket.xs > --- Socket.xs.orig 2012-08-15 16:35:35.000000000 +0200 > +++ Socket.xs 2012-08-15 16:35:47.000000000 +0200 > @@ -92,7 +92,7 @@ > #endif /* !Newx */ > > #ifndef croak_sv > -# define croak_sv(sv) croak(SvPV_nolen(sv)) > +# define croak_sv(sv) croak(SvPVx_nolen(sv)) > #endif > > #ifndef hv_stores >
Patch applied; will see if this solves things. -- Paul Evans