On Czw. 16 Mar. 2006, 06:24:00, ingy@ttul.org wrote:
Show quoted text> Any chance you could divide and conquer that file at least a bit.
>
> I'm pretty sure that's not the smallest the file could be.
>
> Thanks, Ingy
Ingy, this is bug in Perl, not in YAML. See perl-porters bug #39167.
The problem is in YAML.pm:1271 line:
if ($o->{inline} =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) {
Try to run:
#! /usr/bin/perl
$_ = '"' . ( "a" x 50_000) . '"';
/^"((?:\\"|[^"])*)"\s*(.*)$/
See this regexp? It segfaults the perl interpreter (and mod_perl,
and httpd and ayayayay!)
According to Dominic Dunlop, this will be fixed in perl 5.10.x,
meanwhile I think making things more iterative, like puting
chunks in @list and join("",)-ing it together would help.
Cheers
Krzysio Leszczynski
PS. Here's a patch I made to YAML.pm, that make a silly work-around.
diff -u o/YAML.pm YAML.pm
--- o/YAML.pm 2006-05-20 08:49:43.000000000 +0200
+++ YAML.pm 2006-05-20 10:02:44.000000000 +0200
@@ -1266,9 +1266,24 @@
return $node;
}
+# Work around /regexp/ bug in perl < 5.10
+sub _parse_inline_double_quoted_perl_bug_work_around {
+ my @list;
+ local $_=$o->{inline};
+ s{^"}{} or croak YAML_PARSE_ERR_BAD_DOUBLE();
+ push @list, $1
+ while s{^((?:\\.|[^\"\\]+){1,1000})}{};
+ s/\\"/"/g for @list;
+ s{^"}{} or croak YAML_PARSE_ERR_BAD_DOUBLE();
+ $o->{inline} = $_;
+ return join("",@list);
+}
+
# Parse the inline double quoted string.
sub _parse_inline_double_quoted {
my $node;
+ return _parse_inline_double_quoted_perl_bug_work_around(@_)
+ if $]<5.009 && length($o->{inline}) > 10_000;
if ($o->{inline} =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) {
$node = $1;
$o->{inline} = $2;