Skip Menu |

This queue is for tickets about the Text-Reflow CPAN distribution.

Report information
The Basics
Id: 7640
Status: resolved
Priority: 0/
Queue: Text-Reflow

People
Owner: martin [...] gkc.org.uk
Requestors: mat [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: Problem with 5.8.5
I've been using Text::Reflow for a while and last week, I upgraded my 5.8.2 to 5.8.5 and, kaboom : $ cat foo.pl use Text::Reflow 'reflow_string'; print reflow_string(q#Votre $_->{contrat} arrive à échéance le $_->{date}. Afin d'assurer la continuité du service merci de répondre $_->{urgent} à cet email afin de confirmer que vous souhaitez bien renouveler ce domaine au prix annuel de $_->{montant} Euro HT (soit $_->{montant_ttc} Euro TTC).#); $ perl foo.pl Out of memory during "large" request for 134221824 bytes, total sbrk() is 413452288 bytes at /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm line 610. Bad free() ignored (PERL_CORE). Bad free() ignored (PERL_CORE). Bad free() ignored (PERL_CORE). Bad free() ignored (PERL_CORE). $ perl -d:Trace foo.pl [..] Show quoted text
>> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:609: for ($j = 0; $terminus >= 0; $j++) { >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:610: $output[$j] = join(' ', @words[$lastbreak+1..$terminus])."\n"; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:612: $terminus = $lastbreak; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:613: $lastbreak = $linkbreak[$lastbreak]; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:610: $output[$j] = join(' ', @words[$lastbreak+1..$terminus])."\n"; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:612: $terminus = $lastbreak; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:613: $lastbreak = $linkbreak[$lastbreak]; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:610: $output[$j] = join(' ', @words[$lastbreak+1..$terminus])."\n"; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:612: $terminus = $lastbreak; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:613: $lastbreak = $linkbreak[$lastbreak]; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:610: $output[$j] = join(' ', @words[$lastbreak+1..$terminus])."\n"; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:612: $terminus = $lastbreak; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:613: $lastbreak = $linkbreak[$lastbreak]; >> /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm:610: $output[$j] = join(' ', @words[$lastbreak+1..$terminus])."\n";
Bad realloc() ignored at /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm line 610. Segmentation fault (core dumped) make test produces the same kind of things.
From: Martin.Ward [...] durham.ac.uk
I just installed perl 5.8.5 on my system (i686-linux: Mandrake 9.0 running linux 2.4.27 on a Dell PC) and it works fine: % ./bin/perl foo.pl Votre $_->{contrat} arrive ` ichiance le $_->{date}. Afin d'assurer la continuiti du service merci de ripondre $_->{urgent} ` cet email afin de confirmer que vous souhaitez bien renouveler ce domaine au prix annuel de $_->{montant} Euro HT (soit $_->{montant_ttc} Euro TTC). Did you re-install Text::Reflow after installing the new perl?
From: gruber [...] cpan.org
[MAT - Tue Sep 14 07:06:47 2004]: Show quoted text
> I've been using Text::Reflow for a while and last week, I upgraded my > 5.8.2 to 5.8.5 and, kaboom : > > $ cat foo.pl > use Text::Reflow 'reflow_string'; > print reflow_string(q#Votre $_->{contrat} arrive à échéance le $_-
> >{date}. Afin d'assurer la continuité du service merci de répondre
> $_->{urgent} à cet email afin de confirmer que vous souhaitez bien > renouveler ce domaine au prix annuel de $_->{montant} Euro HT (soit > $_->{montant_ttc} Euro TTC).#); > > $ perl foo.pl > Out of memory during "large" request for 134221824 bytes, total sbrk() > is 413452288 bytes at > /usr/local/lib/perl5/site_perl/5.8.5/mach/Text/Reflow.pm line 610.
Right. As we debugged this with Mat on IRC yesterday, the culprit is the fact that Text::Reflow uses pack/unpack "N" type internally, and then proceeds treating the results as signed values. It appears to work with 32-bit perl integers (don't ask me why, probably because an IV never gets a chance to be promoted to NV), but fails miserably when use64bitint is in effect, as is the case with FreeBSD's perl 5.8.5. Alhtough Text::Reflow is at fault (it's XS portion uses native ints all over, so the code would probably not work at all on a "real" 64-bit platform - mind, I am not sure of it, it just seems likely), the problem at hand is not easy to cure since there is no _signed_ counterpart to "N" in perl 5.8. This problem might be a good case for backporting 5.9's "signed 32-bit network order" and friends to 5.8. That said, Text::Reflow should probably be re-written to account for different integer sizes in some way. Hope this was not too dense. :-) Cheers, \Anton.
Fixed in version Text-Reflow-1.06 The problem seems to be with these lines: @linkbreak = unpack("N*", pack("H*", $result)); @linkbreak = map { $_ + 0 } @linkbreak; which convert the unsigned value to signed on a 32 bit machine, but not on a 64 bit machine. I changed it to: @linkbreak = unpack("N*", pack("H*", $result)); # Convert @linkbreak from unsigned to signed: @linkbreak = map { $_ > 0xF0000000 ? -((0xFFFFFFFF - $_) + 1) : $_ + 0 } @linkbreak; which seems to work on both 32 bit and 64 bit machines.