xgettext: Perl: Add unit test for bug.

* gettext-tools/tests/xgettext-perl-11: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
This commit is contained in:
Bruno Haible 2025-07-07 09:16:01 +02:00
parent 80d0903beb
commit 673ca474f5
2 changed files with 18 additions and 1 deletions

View File

@ -148,7 +148,7 @@ TESTS = gettext-1 gettext-2 \
xgettext-objc-1 xgettext-objc-2 \
xgettext-perl-1 xgettext-perl-2 xgettext-perl-3 xgettext-perl-4 \
xgettext-perl-5 xgettext-perl-6 xgettext-perl-7 xgettext-perl-8 \
xgettext-perl-9 xgettext-perl-10 \
xgettext-perl-9 xgettext-perl-10 xgettext-perl-11 \
xgettext-perl-stackovfl-1 xgettext-perl-stackovfl-2 \
xgettext-perl-stackovfl-3 xgettext-perl-stackovfl-4 \
xgettext-perl-stackovfl-5 \

View File

@ -0,0 +1,17 @@
#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
# Test Perl support: long comments.
cat <<\EOF > xg-pl-11.pl
#!/usr/bin/perl
# This is a comment line that is longer than 1024 bytes, which is the size of the stack-allocated space in a 'struct string_buffer'. For shorter comment lines, a different code path is used than for longer comment lines. In the commit that started to use 'struct string_buffer', namely commit 63709a20897369ca8d2cebf8a7d1f9f51ae9e359, there was a mistake. The effect was a bug with two visible effects: 1) When executed with valgrind, this unit test produced "Invalid read of size 1" errors. 2) Building the po4a package as a Nix package on Alpine Linux produced a crash of xgettext (because Nix adds a very long list of -I options to the first line of many perl scripts). For the other xgettext backends, there is no problem. I checked this by running "make check" with valgrind enabled (through the CHECKER variable in the Makefile) after temporarily changing the stack-allocated size from 1024 bytes to 10 bytes. _______________________________________________________________________________________________________________
=cut
package Locale::Po4a::Dia;
EOF
: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments --omit-header --no-location --keyword=_ \
-d xg-pl-11.tmp xg-pl-11.pl || Exit 1