Bug#1025880: libsyntax-keyword-multisub-perl: FTBFS on armhf et all due to wrong format string usage

Steve Langasek steve.langasek at canonical.com
Sun Dec 11 08:04:05 GMT 2022


Package: libsyntax-keyword-multisub-perl
Version: 0.02-2
Severity: serious
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu lunar ubuntu-patch

Hi Gregor,

libsyntax-keyword-multisub-perl fails to build from source on multiple
architectures because the build-time test suite successfully captures a bug
in the code for which there is a compiler warning during the build:

  lib/Syntax/Keyword/MultiSub.xs:52:11: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘IV’ {aka ‘long long int’} [-Wformat=]

(https://buildd.debian.org/status/fetch.php?pkg=libsyntax-keyword-multisub-perl&arch=armhf&ver=0.02-2&stamp=1658361396&raw=0)

The code uses a format string for an int, but passes nargs which is of type
IV which is almost never an int.  Therefore on some architectures the value
is being read from the wrong place in memory, resulting in a garbage value
instead of '3' as it should be in the test case:

[...]
#   Failed test 'f() complains with too many args'
#   at t/01multi.t line 22.
#                   'Unable to find a function body for a call to &main::f having 40571528 arguments at t/01multi.t line 21.
# '
#     doesn't match '(?^u:^Unable to find a function body for a call to &main::f having 3 arguments at )'
# Looks like you failed 1 test of 9.
[...]


The attached patch fixes the code by casting nargs to an int, which in
practice should always be sufficient.

Normally a build failure on architectures where the package has never built
before is an 'important' rather than 'serious' bug; because the new version
of libfuture-asyncawait-perl build-depends on
libsyntax-keyword-multisub-perl, it is also blocked by this bug so I am
marking it serious instead.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
diff -Nru libsyntax-keyword-multisub-perl-0.02/debian/patches/correct-format-string-arguments.patch libsyntax-keyword-multisub-perl-0.02/debian/patches/correct-format-string-arguments.patch
--- libsyntax-keyword-multisub-perl-0.02/debian/patches/correct-format-string-arguments.patch	1969-12-31 16:00:00.000000000 -0800
+++ libsyntax-keyword-multisub-perl-0.02/debian/patches/correct-format-string-arguments.patch	2022-12-10 20:41:55.000000000 -0800
@@ -0,0 +1,23 @@
+Description: Ensure format string arguments are of the matching type
+ The code treats 'nargs' as an int, but it is of type IV which may be of a
+ different size.  This results in the code reading the wrong area of memory
+ on some architectures, and rightly failing the build because the resulting
+ error message is wrong (printing a garbage value for the number of arguments,
+ instead of '3').
+Author: Steve Langasek <steve.langasek at ubuntu.com>
+Last-Update: 2022-12-10
+Forwarded: no
+
+Index: libsyntax-keyword-multisub-perl-0.02/lib/Syntax/Keyword/MultiSub.xs
+===================================================================
+--- libsyntax-keyword-multisub-perl-0.02.orig/lib/Syntax/Keyword/MultiSub.xs
++++ libsyntax-keyword-multisub-perl-0.02/lib/Syntax/Keyword/MultiSub.xs
+@@ -50,7 +50,7 @@
+ 
+   if(!jumpcv)
+     croak("Unable to find a function body for a call to &%s::%s having %d arguments",
+-      HvNAME(CvSTASH(runcv)), GvNAME(CvGV(runcv)), nargs);
++      HvNAME(CvSTASH(runcv)), GvNAME(CvGV(runcv)), (int)nargs);
+ 
+   /* Now pretend to be  goto &$cv
+    * Reuse the same PL_op structure and just call that ppfunc */
diff -Nru libsyntax-keyword-multisub-perl-0.02/debian/patches/series libsyntax-keyword-multisub-perl-0.02/debian/patches/series
--- libsyntax-keyword-multisub-perl-0.02/debian/patches/series	1969-12-31 16:00:00.000000000 -0800
+++ libsyntax-keyword-multisub-perl-0.02/debian/patches/series	2022-12-10 20:38:30.000000000 -0800
@@ -0,0 +1 @@
+correct-format-string-arguments.patch


More information about the pkg-perl-maintainers mailing list