I'm having a hard time with this problem, but I've narrowed it down to using XML::LibXML after I've done a fork in Perl. I'm running Strawberry Perl 5.12.0 on Windows XP, and XML::LibXML 1.70.
I'm have a script where I need to run several processes concurrently, take the XML output and process the results. If I run this on a Solaris machine, it runs just fine and I have no issues. However, if I run this on Windows, I get a crash window stating that 'perl.exe has encountered a problem and needs to close.'
Here is a sample program that will generate the error:
use strict;
use warnings;
use XML::LibXML;
use Try::Tiny;
my $cmds = ['cmd1', 'cmd2'];
my @pids = ();
foreach my $cmd (@{$cmds}) {
my $pid = fork();
if ($pid) {
# parent
push (@pids, $pid);
} elsif ($pid == 0) {
XML::LibXML->load_xml(string=>'<root />'); # <-- this will crash it
exit 0;
}
}
foreach my $ch_pid (@pids) {
try {
waitpid($ch_pid, 0);
} catch {
carp("Error on waitpid: $!");
};
}
exit 0;
If I only have one process, or if I don't fork, then it will work successfully. If I remove the load_xml call (and have nothing in the child), then it will work successfully.
Does anyone know what may be causing this and how to fix it?