Source: perl-tk
Version: 1:804.036+dfsg1-1
Severity: serious
Tags: ftbfs patch
User: debian-p...@lists.debian.org
Usertags: perl-5.38-transition

This package failed to build against Perl 5.38 on s390x, ppc64, sparc64,
and alpha.

This is because Perl upstream changed the implementation of SvPV() et
al., triggering a latent bug in perl-tk that bites on big endian 64-bit
architectures. The attached patch fixes this, see the commit message
for more detail. I've tested that it works on both s390x and amd64,
on Perl 5.36 (trixie) and 5.38 (sid).

Not sure why alpha is failing too, but it has a slightly different
failure mode. I suspect alignment issues.

This is currently a hard blocker for the ongoing Perl 5.38 transition as
perl-tk has quite a few reverse dependencies that are now uninstallable
on s390x.


   #   Failed test 'Creating Balloon widget'
   #   at t/balloon.t line 31.
   #          got: 'couldn't recognize image data at 
/<<PKGBUILDDIR>>/blib/lib/Tk/Image.pm line 21.
   #  at /<<PKGBUILDDIR>>/blib/lib/Tk/Balloon.pm line 62.
   # '
   #     expected: ''
   
   [...]
   
   Test Summary Report
   -------------------
   t/balloon.t                (Wstat: 512 (exited 2) Tests: 12 Failed: 11)
     Failed tests:  2-12
     Non-zero exit status: 2
     Parse errors: Bad plan.  You planned 14 tests but ran 12.
   t/canvas.t                 (Wstat: 0 Tests: 166 Failed: 0)
     TODO passed:   124
   t/canvas2.t                (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
     Non-zero exit status: 255
     Parse errors: Bad plan.  You planned 87 tests but ran 0.
   t/listbox.t                (Wstat: 0 Tests: 537 Failed: 0)
     TODO passed:   320-322, 328, 502
   t/photo.t                  (Wstat: 65280 (exited 255) Tests: 100 Failed: 0)
     Non-zero exit status: 255
     Parse errors: Bad plan.  You planned 111 tests but ran 100.
   t/text.t                   (Wstat: 0 Tests: 415 Failed: 0)
     TODO passed:   121
   t/wm-tcl.t                 (Wstat: 0 Tests: 315 Failed: 0)
     TODO passed:   86-87, 154-157, 164-165, 175-178, 221-224
                   237-239, 264-265, 275-276, 280-283
   t/zzScrolled.t             (Wstat: 0 Tests: 94 Failed: 0)
     TODO passed:   52, 66, 80, 94
   Files=76, Tests=4267, 36 wallclock secs ( 0.23 usr  0.05 sys +  6.02 cusr  
0.69 csys =  6.99 CPU)
   Result: FAIL

-- 
Niko Tyni   nt...@debian.org
>From a26233c844c52f49ef9cca5f88dd9063aac60d0f Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Thu, 11 Jan 2024 18:28:58 +0000
Subject: [PATCH] Fix STRLEN vs int pointer confusion in
 Tcl_GetByteArrayFromObj()

Perl 5.37.2, more precisely commit

 https://github.com/Perl/perl5/commit/1ef9039bccbfe64f47f201b6cfb7d6d23e0b08a7

changed the implementation of SvPV() et al., breaking t/balloon.t,
t/canvas2.t and t/photo.t on big-endian 64-bit architectures such as
ppc64 and s390x because StringMatchGIF() no longer recognized GIF files.

This is because Tcl_GetByteArrayFromObj() was calling SvPV() with an int
pointer instead of a correct STRLEN pointer, and the new implementation
is more sensitive to this: it assigns the pointers as-is, resulting in
the int pointer pointing at the wrong end of the 64-bit length.

Other functions taking a length pointer, at least Tcl_GetStringFromObj()
already seem to do things correctly, so presumably this is not a
systematic issue.
---
 objGlue.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/objGlue.c b/objGlue.c
index d4927ea..dbd6a50 100644
--- a/objGlue.c
+++ b/objGlue.c
@@ -627,7 +627,10 @@ Tcl_GetByteArrayFromObj(Tcl_Obj * objPtr, int * lengthPtr)
  sv_utf8_downgrade(objPtr, 0);
  if (lengthPtr)
   {
-   return (unsigned char *) SvPV(objPtr, *lengthPtr);
+   STRLEN len;
+   unsigned char *s = SvPV(objPtr, len);
+   *lengthPtr = len;
+   return s;
   }
  else
   {
-- 
2.30.2

Reply via email to