Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Problem serializing Net::Patricia object

by Anonymous Monk
on Aug 31, 2012 at 17:36 UTC ( #991053=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,

I've been using Net::IPTtrie for handling IP address spaces. I am now trying to move to Net::Patricia because it's much faster, but there's something that I can't figure out. I need to store the tree structure so that I don't have to constantly rebuild it. But using Storable's nfreeze/thaw gives me a seg fault:

use Net::Patricia; use Storable qw(nfreeze thaw); my $pt = new Net::Patricia(AF_INET6); $pt->add_string(...) ... etc and then: my $frozen = nfreeze($pt); undef $pt; $pt = thaw($frozen);

(Boom! segfault here)

Why is this happening, and what other options do I have to store the tree structure?

Thanks in advance for your help.


Replies are listed 'Best First'.
Re: Problem serializing Net::Patricia object
by philiprbrenan (Monk) on Aug 31, 2012 at 21:32 UTC
    p>Please do three things. First: add

    use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp);

    Second: eliminate the undef $pt line, try restoring to a different variable using my $pt2 for example. Third: could you supply an example of a minimal set of input data that causes a SEGV on your system? The easiest way would be via dump(). Thanks

Re: Problem serializing Net::Patricia object
by cvicente (Initiate) on Aug 31, 2012 at 18:44 UTC

    I guess you can't:

    Any other options?

Re: Problem serializing Net::Patricia object
by mbethke (Hermit) on Sep 01, 2012 at 20:51 UTC

    A couple of years ago I created Net::CIDR::Lookup that does pretty much the same thing. Either it predated the other modules or I was too thick to find them at this time. While as a pure-Perl module it certainly can't compete with Net::Patricia's XS code, a quick look at Net::IPTrie tells me it would likely be a tad faster than the latter and certainly use less memory. Maybe that will do for now, at least for IPv4. The v6 version uses Bit::Vector which is XS itself though I seem to remember it had some serialization hook support.

    I just uploaded V0.5 to CPAN that should be some 10-20% faster than the previous version on searches, BTW.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991053]
Front-paged by Corion
[SuicideJunkie]: That's a dumb comparison. If you want to compare equivalent things, you should ask about battery+motors vs fuel tank+engine+ transmission.
[pryrt]: Are you sure?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2017-08-22 18:54 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (339 votes). Check out past polls.