Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_byte method returns overflowed data when parsing very large XML files [rt.cpan.org #50781] #48

Open
toddr opened this issue Sep 24, 2019 · 1 comment
Labels

Comments

@toddr
Copy link
Member

toddr commented Sep 24, 2019

Migrated from rt.cpan.org#50781 (status was 'new')

Requestors:

Attachments:

From [email protected] on 2009-10-23 18:17:28
:

When parsing a very large XML file, somewhere over 2 gigabytes, the value returned from the 
current_byte method of XML::Parser::Expat will return negative values. Attached to this ticket 
is a simple program to parse an XML file and print the current byte value every second. The 
output when this bug shows its head looks like this:

2134412390
2137250345
2140088951
2142891080
2145707930
-2146463171
-2143671866
-2140868846
-2138058386
-2135266961
-2132475521

This is a particular problem because the Wikipedia dump files are extremely large.

From [email protected] on 2009-11-14 21:56:11
:

I've confirmed this is not an issue when using a 64 bit version of perl. 
@toddr
Copy link
Member Author

toddr commented Sep 24, 2019

#!/usr/bin/env perl

use strict;
use warnings;

use XML::Parser;

our $LAST_BYTE = 0;

$SIG{ALRM} = \&print_byte;

my $xml = XML::Parser->new(
	Handlers => {
		Char => \&char
	}
);

alarm(1);

$xml->parsefile(shift(@ARGV));


sub char {
	my ($e) = @_;

	$LAST_BYTE = $e->current_byte;
}

sub print_byte {
	print "$LAST_BYTE\n";

	alarm(1);
}

@toddr toddr added the Has Test label Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant