in reply to Re: read error in XML parsers, Windows XP Service only
in thread read error in XML parsers, Windows XP Service only

This is a very large program (5000 lines), but here are some snippets :
#!/usr/bin/perl # CVS version : $Id: MiraLoader.pl,v 2.13 2008-02-03 15:11:46 efs Exp +$ use strict "vars"; use warnings; use FindBin qw($Bin); use lib "$Bin/../lib"; use File::Basename; use File::Copy; use Getopt::Std; use Encode; use XML::Simple; #$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; #[...] log_msg(0,"Going to parse INI file."); $INITBL = parse_INI("$MYTOPDIR/$MYINI",$SVCNAME); # $INITBL = ref + to Parameter table # parse_INI dies in case of errors, so if we're here, it's ok log_msg(0,"INI file parsed."); #[...] sub parse_INI { ############# my $IniFile = shift; # INI file name my $MYTAG = shift; # tag of "my" section my $IniRef; # the returned ref. my ($MIRA,$MYSECT); my $SectRef; my ($Val,@SplitVals); my $Msg = "Required directory not found or insufficient permissions : +"; my $MsgSect = "Required section missing in INI file :"; my $MsgFil = "Required directory/file not found or insufficient permis +sions"; my $MsgParam = "Required parameter missing in INI file :"; my $MsgParam2 = "Parameter in INI file has invalid value :"; my $fh; log_msg(0,"==>parse_INI()") if $Debug>1; unless (open($fh,'<',$IniFile)) { die_msg(0,"** Cannot open INI file \"$IniFile\" **") if $Debug +; } # Create an XML::Simple object with default parameters, my $XMLOBJ = new XML::Simple( keeproot => 1, forcearray => 0, # keyattr => 'Id', forcecontent => 1, contentkey => 'Value', ); $IniRef = $XMLOBJ->XMLin($fh); # *** close $fh; #[...] }

As far as I can tell, it crashes with the error on the line marked "***" above. But I have 3 other programs, which do just about the same as above, and which do not experience this problem.

With the line
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
commented out as above, the message is :
read error at C:/Perl/lib/XML/Parser/Expat.pm line 469
With the same line set to :
$XML::Simple::PREFERRED_PARSER = 'XML::SAX::ExpatXS';
then the error message is :
read error at C:/Perl/site/lib/XML/SAX/ExpatXS.pm line 163

I thus assume it must be some cause common to both parsers, and external to the parser itself. But why then do other programs running on the same XP machine and using exactly the same logic and parser, parsing the same XML file, not crash, and why does this one crash only when run as a service, and not in a console (running under the same non LocalSystem user-id in both console and service mode?

Replies are listed 'Best First'.
Re^3: read error in XML parsers, Windows XP Service only
by BrowserUk (Patriarch) on Apr 20, 2008 at 21:58 UTC