BenV's notes

Archive for March, 2011

Xen, DRBD and live migration

by on Mar.10, 2011, under Software

Once again I have some new hardware that’s been labeled “Xen Server”.
This time I want to set it up in a way that brings some redudancy so we can actually have 1 server fail and still have our hosts up and running.
(or at least back up in a few minutes instead of several hours).
To achieve this goal I will install the latest version of Xen (which seems to be 4.01) and use DRBD with LVM for storage. (continue reading…)

1 Comment :, , , , more...

How to segfault perl

by on Mar.06, 2011, under Fun

Yesterday when I was messing around with our homebrew IRC bot (written from scratch in perl) it somehow managed to segfault.
Which surprised me, it doesn’t happen very often that I see perl segfault.
It was caused by the fairly new module that handles RSS feeds. Running it through gdb quickly pointed a finger at XML::LibXML, which probably surprises nobody 😉
(at least I suspected the moment it crashed)
It looked like LibXML tried to free up some resource that didn’t exist anymore.

Today I wrote a little test script to figure out the exact cause. Apparently, using Storable to store things that LibXML returned is a recipe for great fun 🙂
Actually, storing it works pretty good. It works so damn good that LibXML actually believes that the objects loaded through Storable are still valid.

Example.
First store a piece of XML::LibXML to disk:

#!/usr/bin/perl
use Data::Dumper;
use Storable qw/lock_nstore/;
use XML::LibXML;

die "Usage: $0 file.storable" unless(scalar(@ARGV));

my $rssfeed = 'Dummy RSS feed';
my $data = {};

my $xmlp = XML::LibXML->new();
my $xml = $xmlp->parse_string($rssfeed);
$data->{'xml'} = $xml->find('/rss/channel/title/text()');
my $s = lock_nstore($data, $ARGV[0]);
print "Stored.\n";


#!/usr/bin/perl
use Storable qw/retrieve/;
use XML::LibXML;

die "Usage: $0 file.storable" unless(scalar(@ARGV));
my $s = retrieve($ARGV[0]);
my $link = $s->{'xml'};
print "Segfault in progress! $link\n";

The execution looks like this:

benv@janeman:~:0>./test-store.pl asd
Stored.
benv@janeman:~:0>./test-load.pl asd
Segmentation fault (core dumped)

Fun!

Leave a Comment :, , , , more...

Archives

  • 2016 (1)
  • 2015 (7)
  • 2014 (4)
  • 2013 (11)
  • 2012 (27)
  • 2011 (26)
  • 2010 (25)
  • 2009 (68)