Skip Menu |

This queue is for tickets about the Net-IP-XS CPAN distribution.

Report information
The Basics
Id: 102155
Status: resolved
Priority: 0/
Queue: Net-IP-XS

People
Owner: Nobody in particular
Requestors: calle [...] init.se
Cc:
AdminCc:

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



Subject: Crash when using in threaded Perl
Necronomicon-II:~% perl -Mthreads -MNet::IP::XS -E 'my $i = Net::IP::XS->new("::1"); async{}; $_->join for threads->list;' perl(52317,0x7fff7318f300) malloc: *** error for object 0x7fdf206afff0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug zsh: abort perl -Mthreads -MNet::IP::XS -E I haven't tried to figure out exactly what is happening. I just distilled this down from a crash in a larger application to the smallest example I could that still displays the problem. It does seem to only happen with IPv6 addresses.
The problem is that when a thread is started, Perl clones all existing Net::IP::XS::N128 objcts. That includes copying their pointer to malloc:ed memory. Eventually, all objects get passed to DESTROY, which frees the malloced memory. Which is a problem since the pointer to that memory is no longer unique to each object. One possible solution would be to instead of malloc:ing memory ask Perl for an SvPV holding a sixteen-byte string, and use that space to hold the data. Then Perl would take care of all the copying itself. It seems like a fairly large change to the code, though.
Subject: Re: [rt.cpan.org #102155] Crash when using in threaded Perl
Date: Tue, 17 Feb 2015 21:54:52 +1000
To: bug-Net-IP-XS [...] rt.cpan.org
From: Tom Harrison <tomh5908 [...] gmail.com>
Thanks for this. The problem is fixed in 0.14, though it could do with some tidying. Cheers -Tom On Tue, Feb 17, 2015 at 8:36 PM, Calle Dybedahl via RT < bug-Net-IP-XS@rt.cpan.org> wrote: Show quoted text
> Queue: Net-IP-XS > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=102155 > > > The problem is that when a thread is started, Perl clones all existing > Net::IP::XS::N128 objcts. That includes copying their pointer to malloc:ed > memory. Eventually, all objects get passed to DESTROY, which frees the > malloced memory. Which is a problem since the pointer to that memory is no > longer unique to each object. > > One possible solution would be to instead of malloc:ing memory ask Perl > for an SvPV holding a sixteen-byte string, and use that space to hold the > data. Then Perl would take care of all the copying itself. It seems like a > fairly large change to the code, though. >
The problem has been fixed properly in 0.15, though 0.14 will work too. Cheers -Tom