Article View: linux.debian.bugs.dist
Article #2563Bug#1152433: 4ti2: FTBFS on ppc64el with GCC 15/16 (-O2/-O3): out-of-bounds array access in VectorAux (src/ppi/ppi.cpp)
From: Viktor Pashaiev
Date: Thu, 29 Oct 2026 09:00
Date: Thu, 29 Oct 2026 09:00
94 lines
6093 bytes
6093 bytes
--===============5917353260978654905==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Source: 4ti2
Version: 1.6.15+ds-1
Severity: important
Tags: patch upstream
Forwarded: https://github.com/4ti2/4ti2/pull/61
Dear Maintainer,
4ti2 fails its build-time test suite (test/ppi/check_ppi) on ppc64el when bui=
lt with GCC 15/16 at -O2 or -O3 (including Ubuntu's default -O3 on ppc64el, t=
racked in https://bugs.launchpad.net/ubuntu/+source/4ti2/+bug/2170794).
In src/ppi/ppi.cpp, struct VectorAux declares a fixed-size array `signed char=
Stuff[4]`, stores the vector length in `Stuff[0]`, and returns `Stuff + 1` f=
rom `Data()`. Accessing `v(i)` for `i >=3D 4` indexes `Stuff[i]` past the 4-b=
yte array bound.
In `ExtendPPI()`, the loop:
for (int p =3D 1; p <=3D (n+1)/2; p++) {
v(p)--, v(n+1-p)--;
...
}
decrements both `v(p)` and `v(n+1-p)`. Because `p` starts within `Stuff[1..3]=
` while `n+1-p` exceeds `Stuff[3]` for `n >=3D 3`, GCC alias analysis on ppc6=
4el concludes that the two accesses cannot alias and schedules the load `lbzu=
` of `v(n+1-p)` before the store `stb` of `v(p)`. When `n + 1` is even and `p=
=3D=3D n + 1 - p` (first hit at `n =3D 3, p =3D 2`), `v(2)` is decremented f=
rom 0 to -1 instead of -2, producing the invalid identity `0 -1 0 1` and caus=
ing `4ti2-ppi 5` to output 50 vectors instead of 47.
The attached patch replaces `Stuff[4]` in `VectorAux` with an explicit `unsig=
ned char len_` field and a `signed char data_[]` flexible array member. Verif=
ied on ppc64el at -O3 -flto=3Dauto across ppi5 (47 vectors), ppi10 (2465 vect=
ors), and ppi16 (99328 vectors).
Thanks,
Viktor Pashaiev
--===============5917353260978654905==
Content-Type: text/x-diff; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="fix-ppi-vectoraux-ub.patch"
MIME-Version: 1.0
diff --git a/src/ppi/ppi.cpp b/src/ppi/ppi.cpp
index e42f4ae..da9bb12 100644
--- a/src/ppi/ppi.cpp
+++ b/src/ppi/ppi.cpp
@@ -82,21 +82,21 @@ typedef unsigned int attr_type; /* 32 bits are enough */
struct VectorAux {
/* order important */
attr_type Attribute;
- signed char Stuff[4];
+ unsigned char len_;
+ signed char data_[];
void *operator new(size_t s, int length) {
- if (length < 3) length=3;
- return malloc(s - 3 +length);
+ return malloc(s + length);
}
void operator delete(void *v) {
free(v);
}
VectorAux(int length) { Length() = length; }
VectorAux(const VectorAux &aux) {
- memcpy(this, &aux, sizeof(VectorAux) -4 + 1 + aux.Length());
+ memcpy(this, &aux, sizeof(VectorAux) + aux.Length());
}
- inline unsigned char &Length() { return (unsigned char &) Stuff[0]; }
- inline int Length() const { return (unsigned char) Stuff[0]; }
- inline signed char *Data() { return Stuff+1; }
+ inline unsigned char &Length() { return len_; }
+ inline int Length() const { return len_; }
+ inline signed char *Data() { return data_; }
};
class Vector {
@@ -118,7 +118,7 @@ public:
if (aux == NULL)
aux = new(v.aux->Length()) VectorAux(*v.aux);
else if (aux->Length() == v.aux->Length())
- memcpy(aux, v.aux, sizeof(VectorAux) -4 + 1 + v.aux->Length());
+ memcpy(aux, v.aux, sizeof(VectorAux) + v.aux->Length());
else {
delete aux;
aux = new(v.aux->Length()) VectorAux(*v.aux);
--===============5917353260978654905==--
Technical Details
Message-ID:
<NTu9k-8AyE-23@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!news.servidellagleba.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!news.servidellagleba.it!bofh.it!news.nic.it!robomod
From: Viktor Pashaiev <w.paszajew@gmail.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1152433: 4ti2: FTBFS on ppc64el with GCC 15/16 (-O2/-O3): out-of-bounds array access in VectorAux (src/ppi/ppi.cpp)
Date: Thu, 29 Oct 2026 10:00:02 +0100
Message-ID: <NTu9k-8AyE-23@gated-at.bofh.it>
X-Original-To: submit@bugs.debian.org
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Thu Oct 29 08:53:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -0.547
Reply-To: Viktor Pashaiev <w.paszajew@gmail.com>, 1152433@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: team+math@tracker.debian.org
X-Debian-Pr-Message: report 1152433
X-Debian-Pr-Package: src:4ti2
X-Debian-Pr-Keywords: patch upstream
X-Debian-Pr-Source: 4ti2
X-Gm-Message-State: AFq9FYJnVhy2BAV4f8iEW7ibu/Y5NxBbjYyG4cRI+7e1/PUrKzMuO2cj
yZ3GtCKjCQOAnNMxd/XU8e+PX892VOQBMpzd8gaodj3I63cBSxB9DJv6LVykSV17UeA=
X-Gm-Gg: AYBFou0Nza0e2xmPLSu6jOnDlOr8zjkJGMIojw7rSJDJzg4BOPdRF1DJBEAKvcm/4v4
Prp+McCi/T7yInlI8TVU0XS3O35e3f+pZAOniKI/P2yObG4RSJI06rahx9CpGVskc92UEAmUEqB
j8cBs8hyN8wfBHIV3le3hBfsdNOhCOEU532sg0Bfybn/nnGiY6Kxm9YGP3y8CUOwoL09bCFvf8P
OpuwN1zPU/LLGuRHR12rCVx1qfGd0RrzjCvfjVRfqVpstFAgHf++P3/GEg21shI72KM4neeNSPn
xlYFZE5HeNyLJJd2Q1nnUrBGsZncb/aY1xvEZi4hkvbqSEqd6SLHRmqLvljss9dtFvxPpjFJfrw
Gl2++2vboIRQDV4C/H4JOTZ9WfaJEn7eeZVu8R3Kn+5CtZkRaXZmMPIByOduTSIYDx6/e8FyW+i
RshAQJGXIiSyqcox96Q2XlFxu0XWamIj92AVbm5KJXnEOxsw17bBOkQnlugXxc9zTJjFx/9HjHL
09y88oxEK2zJC05NwP+k/FFfo+ZYudbjOBAIQs6kHyQsaEeK72alxf20qjNf2rYEAF8vLOxn/j4
rnwovMy4RFQN5xgllS1Auqw+geEpqomzhCQ=
X-Received: by 2002:a05:600c:1546:b0:49e:6581:7baf with SMTP id 5b1f17b1804b1-4aa86a42518mr46587895e9.2.1793263810512;
Thu, 29 Oct 2026 01:50:10 -0700 (PDT)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============5917353260978654905=="
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1999496
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 94
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Thu, 29 Oct 2026 01:50:09 -0700 (PDT)
X-Original-Message-ID: <6ae308c1.6be28edc.275494.51c1@mx.google.com>