commit: d9a3e8ab7afe3ed85e840849ea925064d836f37a
Author: Z. Liu <zhixu.liu <AT> gmail <DOT> com>
AuthorDate: Thu Nov 20 02:53:06 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 4 08:59:03 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d9a3e8ab
dev-perl/Text-WrapI18N: fix build hang of app-text/po4a
Text::WrapI18N has a bug that causes an infinite loop. The following
program demonstrates the issue:
> use Text::WrapI18N qw($columns);
> use Text::WrapI18N qw(wrap);
> $columns = 78;
>
> my $a="po/pod.cfg:1: ";
> my $b=" ";
> my $c="No PO files found in
> '/var/tmp/portage/app-text/po4a-0.74-r1/work/po4a-0.74'/'po/pod'.";
>
> print wrap($a, $b, $c);
This program will hang indefinitely until OOM. However, if change $columns to
any value greater than 78, it finishes quickly.
In po4a, $columns is set from $ENV{COLUMNS} ( see
https://github.com/mquinson/po4a/blob/master/lib/Locale/Po4a/Common.pm#L68),
so if your terminal width is <= 78, emerge will hang.
This is a very old bug that Debian found and fixed in 2008. See
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470250
and upstream issue:
https://rt.cpan.org/Public/Bug/Display.html?id=42102
Closes: https://bugs.gentoo.org/959830
Signed-off-by: Z. Liu <zhixu.liu <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44680
Closes: https://github.com/gentoo/gentoo/pull/44680
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../Text-WrapI18N/Text-WrapI18N-0.60.0-r3.ebuild | 18 +++++++++++++++
.../files/Text-WrapI18N-fix-endless-loop.patch | 26 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/dev-perl/Text-WrapI18N/Text-WrapI18N-0.60.0-r3.ebuild
b/dev-perl/Text-WrapI18N/Text-WrapI18N-0.60.0-r3.ebuild
new file mode 100644
index 000000000000..0d0af734929d
--- /dev/null
+++ b/dev-perl/Text-WrapI18N/Text-WrapI18N-0.60.0-r3.ebuild
@@ -0,0 +1,18 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DIST_AUTHOR=KUBOTA
+DIST_VERSION=0.06
+inherit perl-module
+
+DESCRIPTION="Internationalized substitute of Text::Wrap"
+
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos
~x64-macos ~x64-solaris"
+
+RDEPEND="dev-perl/Text-CharWidth"
+BDEPEND="${RDEPEND}"
+
+PATCHES=( "${FILESDIR}"/${PN}-fix-endless-loop.patch )
diff --git a/dev-perl/Text-WrapI18N/files/Text-WrapI18N-fix-endless-loop.patch
b/dev-perl/Text-WrapI18N/files/Text-WrapI18N-fix-endless-loop.patch
new file mode 100644
index 000000000000..ab51380b7d16
--- /dev/null
+++ b/dev-perl/Text-WrapI18N/files/Text-WrapI18N-fix-endless-loop.patch
@@ -0,0 +1,26 @@
+patch is extracted from debian:
+https://deb.debian.org/debian/pool/main/libt/libtext-wrapi18n-perl/libtext-wrapi18n-perl_0.06-10.debian.tar.xz
+
+Description: The infinite loop occurs in Text::WrapI18N when po4a tries to
report an error in the PO files.
+ I could reproduce the problem in WrapI18N::wrap() and I propose the
+ attached patch to WrapI18N::wrap(). (A word should be placed on the
+ next line if it fits on this line, but the leading header must be taken
+ into account, thus $columns -> $columns - length $header)
+Origin: vendor
+Bug-Debian: https://bugs.debian.org/470250
+Forwarded: unknown
+Author: Nicolas François <[email protected]>
+Reviewed-by: gregor herrmann <[email protected]>
+Last-Update: 2019-03-21
+
+--- a/WrapI18N.pm 2003-06-25 11:14:25.000000000 +0200
++++ b/WrapI18N.pm 2008-03-13 02:04:02.628000837 +0100
+@@ -88,7 +88,7 @@ sub wrap {
+ $len = 0;
+ $text = $top2 . $text;
+ $word = ''; $wlen = 0;
+- } elsif ($wlen + $w <= $columns) {
++ } elsif ($wlen + $w <= $columns - length ($top2)) {
+ # the current word is sent to next line
+ $out .= $separator;
+ $len = 0;