stack: fix pile GCC memcpy warnings
PATCH 1/1 stack: fix pile GCC memcpy warnings
On architectures where rte_memcpy() is defined as memcpy(), GCC warns about source/destination overflow when copying more than the source/destination size, even for code paths that are not taken in cases where the sizes are smaller.
The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86 rte_memcpy() disabled sligthly similar warnings for.
PS:
The alternative was to obfuscate the code, but that would make the code less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Bugzilla ID: 2061
The pile was introduce with this DPDK release, so no need to backport.
--- lib/stack/rte_stack_pile.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
lib/stack/rte_stack_pile.h +26 -0
@@ -154,12 +154,25 @@ __rte_stack_pile_push(struct rte_stack *s,* Construct the bulk elements. * Copy bulks in reverse order, but ignore the object order within each bulk. */ +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +/* +* On architectures where rte_memcpy() is defined as memcpy(), +* although GCC knows that this code path is not taken when the source's size is smaller than +* RTE_STACK_PILE_BULK_SIZE, it still warns about memcpy() source overread. +* So we disable the compiler warning for this memcpy() instance. +*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif tmp = (struct rte_stack_lf_elem *)bulk_first;__rte_assume (n_bulk >0 );for (i =0 ; i < n_bulk; i++, tmp = tmp->next)rte_memcpy (((struct rte_stack_pile_bulk_elem *)tmp)->objs, &obj_table[(n_bulk - i -1 ) *RTE_STACK_PILE_BULK_SIZE ],sizeof (void *) *RTE_STACK_PILE_BULK_SIZE ); +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +#pragma GCC diagnostic pop +#endif /* Push them to the bulk list. */ __rte_stack_pile_bulk_push_elems (&pile->bulk, bulk_first, bulk_last, n_bulk);
@@ -271,7 +284,20 @@ __rte_stack_pile_pop(struct rte_stack *s, bulk: /* Fetch n_bulk * RTE_STACK_PILE_BULK_SIZE objects as bulk elements. */ +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +/* +* On architectures where rte_memcpy() is defined as memcpy(), +* although GCC knows that this code path is not taken when the destination's size is smaller than +* RTE_STACK_PILE_BULK_SIZE, it still warns about memcpy() destination overflow. +* So we disable the compiler warning for this memcpy() instance. +*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif bulk_first =__rte_stack_pile_bulk_pop_elems (&pile->bulk, n_bulk, obj_table, &bulk_last); +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +#pragma GCC diagnostic pop +#endif if (unlikely (bulk_first ==NULL )) {/* * Not available.
Signature · 1 line
2.43.0
Quoted 43 lines · Morten Brørup
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more than the source/destination size, even for code paths that are not taken in cases where the sizes are smaller.The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make the code less readable, and might have unintended effects on architectures and compilers not suffering by this issue.Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to backport.
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>--- lib/stack/rte_stack_pile.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)lib/stack/rte_stack_pile.h +6
-0@@ -154,12 +154,25 @@ __rte_stack_pile_push(struct rte_stack *s,* Construct the bulk elements. * Copy bulks in reverse order, but ignore the object order within each bulk. */ +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +/* +* On architectures where rte_memcpy() is defined as memcpy(), +* although GCC knows that this code path is not taken when the source's size is smaller than +* RTE_STACK_PILE_BULK_SIZE, it still warns about memcpy() source overread. +* So we disable the compiler warning for this memcpy() instance.
lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s, · line 172
Quoted 10 lines
lib/stack/rte_stack_pile.h +4
-0+*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif tmp = (struct rte_stack_lf_elem *)bulk_first;__rte_assume (n_bulk >0 );for (i =0 ; i < n_bulk; i++, tmp = tmp->next)rte_memcpy (((struct rte_stack_pile_bulk_elem *)tmp)->objs, &obj_table[(n_bulk - i -1 ) *RTE_STACK_PILE_BULK_SIZE ],sizeof (void *) *RTE_STACK_PILE_BULK_SIZE );
An rte_assume before the memcpy asserting the sizes doesn't help?
Quoted 3 lines
lib/stack/rte_stack_pile.h +3
-0+#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +#pragma GCC diagnostic pop +#endif
Quoted 52 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 11.19Quoted 2 lines · Morten Brørup
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more thanthe
Quoted 1 line
source/destination size, even for code paths that are not taken in
cases
Quoted 5 lines
where the sizes are smaller.
The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
Quoted 7 lines
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make thecode
Quoted 7 lines
less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to
backport.
Quoted 12 lines
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>--- lib/stack/rte_stack_pile.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)lib/stack/rte_stack_pile.h +0
-0lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s, · line 155
Quoted 2 lines
lib/stack/rte_stack_pile.h +0
-0@@ -154,12 +154,25 @@ __rte_stack_pile_push(struct rte_stack *s,* Construct the bulk elements. * Copy bulks in reverse order, but ignore the object order within each bulk.
lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s,
Quoted 5 lines
lib/stack/rte_stack_pile.h +4
-0*/ +#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +/* +* On architectures where rte_memcpy() is defined as memcpy(), +* although GCC knows that this code path is not taken when the source's size is smaller than
lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s, · line 161
Quoted 1 line
lib/stack/rte_stack_pile.h +1
-0+* RTE_STACK_PILE_BULK_SIZE, it still warns about memcpy() source
Quoted 8 lines
overread.
lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s, · line 168
Quoted 7 lines
lib/stack/rte_stack_pile.h +5
-0+* So we disable the compiler warning for this memcpy() instance. +*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif tmp = (struct rte_stack_lf_elem *)bulk_first;__rte_assume (n_bulk >0 );
I also tried removing this __rte_assume(). No effect.
Quoted 7 lines
lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s,
Quoted 3 lines
lib/stack/rte_stack_pile.h +0
-0for (i =0 ; i < n_bulk; i++, tmp = tmp->next)rte_memcpy (((struct rte_stack_pile_bulk_elem *)tmp)->objs, &obj_table[(n_bulk - i - 1) *
RTE_STACK_PILE_BULK_SIZE],lib/stack/rte_stack_pile.h __rte_stack_pile_push(struct rte_stack *s, · line 172
Quoted 1 line
lib/stack/rte_stack_pile.h +0
-0sizeof(void *) * RTE_STACK_PILE_BULK_SIZE);An
rte_assumebefore the memcpy asserting the sizes doesn't help?
GCC complains about the size of the obj_table.memcpy() overruns it when n==1, and thus the compiler knows that the size of obj_table is only one object. Which is true, because this instance of memcpy() copies 32 (RTE_STACK_PILE_BULK_SIZE) objects. But GCC ignores the fact that this code path is not taken when n==1, and warns anyway.
GCC completely ignores that the code path is not taken.
Referring to description in Bugzilla, it warns when called with pushing/popping 1 object.
For verifying that the compiler knows that the problematic code is part of the code path when handling 1 object, and ignores this fact anyway, I even tried something like:
if (n >= RTE_STACK_PILE_BULK_SIZE) {
bulk copy loop;
}And it still warns.
Quoted 4 lines
Quoted 4 lines
lib/stack/rte_stack_pile.h +3
-0+#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=100000 ) +#pragma GCC diagnostic pop +#endif
Quoted 18 lines · Morten Brørup
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more than the source/destination size, even for code paths that are not taken in cases where the sizes are smaller.The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make the code less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Quoted 8 lines
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to backport.
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>---
Build passes with this patch.
Thanks,
Ali
Quoted 18 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more than the source/destination size, even for code paths that are not taken in cases where the sizes are smaller.The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make the code less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Quoted 8 lines
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to backport.
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>---
I don't like using compiler pragmas for this. It also means that if compiler gets fixed or behaves differently you will never see it.
AI analysis shows some other options.
Root cause is --buildtype=debug, i.e. -O0, not the GCC version. At -O0 nothing removes the dead n_bulk > 0 path for rte_stack_push(s, &obj, 1), so the constant 256-byte memcpy is checked against obj (8 bytes) and warns. Reproduced with GCC 13.3 and 14.2 at -O0; silent at -Og and above. That means the GCC_VERSION >= 100000 gate is wrong at both ends: any GCC with the warning fires (overflow since 8, overread since 11), and on GCC 10 the -Wstringop-overread pragma itself is a -Wpragmas error under -Werror. If the pragma stays, drop the version gate (keep RTE_TOOLCHAIN_GCC) and fix the comment: GCC does not “know” the path is dead, that is the whole problem.
This should have a big ass comment, and it should use same pragma set as existing one in lib/ring.
Other alternative is to use bulk object array as structure and do assignment. But that replaces ugly pragmas with ugly casts...
--- a/lib/stack/rte_stack_pile.h
+++ b/lib/stack/rte_stack_pile.h
@@
+/* Bulk object array as a single object, so a copy is one assignment. */ +struct rte_stack_pile_bulk_objs {
+ void *objs[RTE_STACK_PILE_BULK_SIZE];
+};
+
@@ __rte_stack_pile_bulk_pop_elems
for (unsigned int i = 0; i < num; i++, tmp = tmp->next)
- rte_memcpy(&obj_table[i * RTE_STACK_PILE_BULK_SIZE],
- ((struct rte_stack_pile_bulk_elem *)tmp)->objs,
- sizeof(void *) * RTE_STACK_PILE_BULK_SIZE);
+ *(struct rte_stack_pile_bulk_objs *)&obj_table[i * RTE_STACK_PILE_BULK_SIZE] =
+ *(struct rte_stack_pile_bulk_objs *)((struct rte_stack_pile_bulk_elem *)tmp)->objs;
@@ __rte_stack_pile_push
for (i = 0; i < n_bulk; i++, tmp = tmp->next)
- rte_memcpy(((struct rte_stack_pile_bulk_elem *)tmp)->objs,
- &obj_table[(n_bulk - i - 1) * RTE_STACK_PILE_BULK_SIZE],
- sizeof(void *) * RTE_STACK_PILE_BULK_SIZE);
+ *(struct rte_stack_pile_bulk_objs *)((struct rte_stack_pile_bulk_elem *)tmp)->objs =
+ *(const struct rte_stack_pile_bulk_objs *)&obj_table[(n_bulk - i - 1) * RTE_STACK_PILE_BULK_SIZE];
Quoted 43 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 16.24Quoted 2 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more thanthe
Quoted 1 line
source/destination size, even for code paths that are not taken in
cases
Quoted 5 lines
where the sizes are smaller.
The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
Quoted 7 lines
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make thecode
Quoted 7 lines
less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to
backport.
Quoted 4 lines
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>---
I don't like using compiler pragmas for this. It also means that if compiler gets fixed or behaves differently you will never see it.
AI analysis shows some other options.
Quoted 10 lines
Root cause is --buildtype=debug, i.e. -O0, not the GCC version. At -O0 nothing removes the dead
n_bulk> 0 path forrte_stack_push(s, &obj, 1), so the constant 256-byte memcpy is checked against obj (8 bytes) and warns. Reproduced with GCC 13.3 and 14.2 at -O0; silent at -Og and above. That means theGCC_VERSION>= 100000 gate is wrong at both ends:
any GCC with the warning fires (overflow since 8, overread since 11), and on GCC 10 the -Wstringop-overread pragma itself is a -Wpragmas error under -Werror. If the pragma stays, drop the version gate (keepRTE_TOOLCHAIN_GCC) and fix the comment: GCC does not “know” the path is dead, that is the whole problem.
Continuing this line of thinking...
GCC defines an "__OPTIMIZE__" macro if any optimization above level 0 is turned on. We could gate such pragmas with:
#if defined(RTE_TOOLCHAIN_GCC) && !defined(__OPTIMIZE__)
Quoted 4 lines
This should have a big ass comment, and it should use same pragma set as existing one in lib/ring.
I generally prefer having the pragma coverage as narrow as possible, so they don't prevent catching unrelated bugs in the same file.
On the other hand,
I also like the suggestion in your other email - disabling these false-positive GCC warnings globally across DPDK for non-optimized builds.
And since the default build type is debugoptimized, it will not prevent GCC from emitting relevant warnings during normal development.
Quoted 4 lines
Other alternative is to use bulk object array as structure and do assignment.
But that replaces ugly pragmas with ugly casts...
Yeah, let's not do that.
But thank you for exploring!
Quoted 32 lines
lib/stack/rte_stack_pile.h +0
-0@@
+/* Bulk object array as a single object, so a copy is one assignment. */lib/stack/rte_stack_pile.h +4
-0+struct rte_stack_pile_bulk_objs { +void *objs[RTE_STACK_PILE_BULK_SIZE ]; +}; +@@
__rte_stack_pile_bulk_pop_elemslib/stack/rte_stack_pile.h +0
-2for (unsigned int i =0 ; i < num; i++, tmp = tmp->next) - rte_memcpy(&obj_table[i * RTE_STACK_PILE_BULK_SIZE], - ((struct rte_stack_pile_bulk_elem *)tmp)-Quoted 1 line
objs,
lib/stack/rte_stack_pile.h +0
-1- sizeof(void *) *
RTE_STACK_PILE_BULK_SIZE);lib/stack/rte_stack_pile.h +1
-0+ *(struct rte_stack_pile_bulk_objs *)&obj_table[i *
RTE_STACK_PILE_BULK_SIZE] =lib/stack/rte_stack_pile.h +1
-0+ *(struct rte_stack_pile_bulk_objs *)((struct
rte_stack_pile_bulk_elem*)tmp)->objs;
@@__rte_stack_pile_pushlib/stack/rte_stack_pile.h +0
-2for (i =0 ; i < n_bulk; i++, tmp = tmp->next) -rte_memcpy (((struct rte_stack_pile_bulk_elem *)tmp)->objs, - &obj_table[(n_bulk - i - 1) *
RTE_STACK_PILE_BULK_SIZE],lib/stack/rte_stack_pile.h +1
-1- sizeof(void *) * RTE_STACK_PILE_BULK_SIZE); + *(struct rte_stack_pile_bulk_objs *)((struct
rte_stack_pile_bulk_elem*)tmp)->objs =lib/stack/rte_stack_pile.h +1
-0+ *(const struct rte_stack_pile_bulk_objs*)&obj_table[(n_bulk - i - 1) *
RTE_STACK_PILE_BULK_SIZE];
Quoted 81 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 17.16
To: Stephen Hemminger
Cc: [email protected]; Thomas Monjalon; Konstantin Ananyev; Andrew Rybchenko; Bruce Richardson; Ali Alnubani
Subject: RE: [PATCH] stack: fix pile GCC memcpy warningsQuoted 20 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 16.24Quoted 2 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more thanthe
Quoted 1 line
source/destination size, even for code paths that are not taken in
cases
Quoted 9 lines
where the sizes are smaller.
The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warningsfor.
Quoted 5 lines
Quoted 3 lines
PS:
The alternative was to obfuscate the code, but that would make thecode
Quoted 1 line
less readable, and might have unintended effects on architectures
and
Quoted 12 lines
Quoted 6 lines
compilers not suffering by this issue.
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to
backport.
Quoted 4 lines
Reported-by Ali Alnubani <[email protected]>Signed-off-by Morten Brørup <[email protected]>---
Quoted 7 lines
I don't like using compiler pragmas for this. It also means that if compiler gets fixed or behaves differently you will never see it.
AI analysis shows some other options.
Root cause is --buildtype=debug, i.e. -O0, not the GCC version. At -
O0
Quoted 3 lines
nothing removes the dead
n_bulk> 0 path forrte_stack_push(s, &obj, 1), so the constant 256-byte memcpy is checked against obj (8 bytes) and warns. Reproduced with GCC 13.3 and 14.2 at -O0; silent at -Ogand
Quoted 1 line
above. That means the
GCC_VERSION>= 100000 gate is wrong at bothends:
Quoted 4 lines
any GCC with the warning fires (overflow since 8, overread since 11), and on GCC 10 the -Wstringop-overread pragma itself is a -Wpragmas error under -Werror. If the pragma stays, drop the version gate (keep
RTE_TOOLCHAIN_GCC) and fix the comment: GCC does not “know” the pathis
Quoted 1 line
dead, that is the whole problem.
Continuing this line of thinking...
GCC defines an "__OPTIMIZE__" macro if any optimization above level 0 is turned on.
We could gate such pragmas with:
#ifdefined(RTE_TOOLCHAIN_GCC)&& !defined(__OPTIMIZE__)Quoted 4 lines
This should have a big ass comment, and it should use same pragma set as existing one in lib/ring.
I generally prefer having the pragma coverage as narrow as possible, so they don't prevent catching unrelated bugs in the same file.
Quoted 6 lines
On the other hand,
I also like the suggestion in your other email - disabling these false- positive GCC warnings globally across DPDK for non-optimized builds.And since the default build type is debugoptimized, it will not prevent GCC from emitting relevant warnings during normal development.
The "other email" I'm referring to:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
I prefer that solution over my patch.
Marking my patch as superseded.
Quoted 43 lines
Quoted 5 lines
Other alternative is to use bulk object array as structure and do assignment.
But that replaces ugly pragmas with ugly casts...Yeah, let's not do that.
But thank you for exploring!
Quoted 5 lines
lib/stack/rte_stack_pile.h +0
-0@@
+/* Bulk object array as a single object, so a copy is oneassignment.
Quoted 27 lines
*/
lib/stack/rte_stack_pile.h +4
-0+struct rte_stack_pile_bulk_objs { +void *objs[RTE_STACK_PILE_BULK_SIZE ]; +}; +@@
__rte_stack_pile_bulk_pop_elemslib/stack/rte_stack_pile.h +0
-2for (unsigned int i =0 ; i < num; i++, tmp = tmp->next) - rte_memcpy(&obj_table[i * RTE_STACK_PILE_BULK_SIZE], - ((struct rte_stack_pile_bulk_elem *)tmp)-Quoted 1 line
objs,
lib/stack/rte_stack_pile.h +0
-1- sizeof(void *) *
RTE_STACK_PILE_BULK_SIZE);lib/stack/rte_stack_pile.h +1
-0+ *(struct rte_stack_pile_bulk_objs *)&obj_table[i *
RTE_STACK_PILE_BULK_SIZE] =lib/stack/rte_stack_pile.h +1
-0+ *(struct rte_stack_pile_bulk_objs *)((struct
rte_stack_pile_bulk_elem*)tmp)->objs;
@@__rte_stack_pile_pushlib/stack/rte_stack_pile.h +0
-2for (i =0 ; i < n_bulk; i++, tmp = tmp->next) -rte_memcpy (((struct rte_stack_pile_bulk_elem *)tmp)->objs, - &obj_table[(n_bulk - i - 1) *
RTE_STACK_PILE_BULK_SIZE],lib/stack/rte_stack_pile.h +1
-1- sizeof(void *) * RTE_STACK_PILE_BULK_SIZE); + *(struct rte_stack_pile_bulk_objs *)((struct
rte_stack_pile_bulk_elem*)tmp)->objs =lib/stack/rte_stack_pile.h +1
-0+ *(const struct rte_stack_pile_bulk_objs*)&obj_table[(n_bulk - i - 1) *
RTE_STACK_PILE_BULK_SIZE];
Quoted 18 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…
On architectures where
rte_memcpy()is defined asmemcpy(), GCC warns about source/destination overflow when copying more than the source/destination size, even for code paths that are not taken in cases where the sizes are smaller.The relevant compiler warnings were disabled for GCC at the two occurrences, and comments describing the reason were added.
NB:
It has not been investigated which GCC versions are affected. GCC version 10 and up was chosen because that was what the previous versions of x86rte_memcpy()disabled sligthly similar warnings for.PS:
The alternative was to obfuscate the code, but that would make the code less readable, and might have unintended effects on architectures and compilers not suffering by this issue.
Quoted 4 lines
Bugzilla ID: 2061
Fixes ee0822a0ef41 ("stack: introduce pile")The pile was introduce with this DPDK release, so no need to backport.
Rather than playing "what a bug with pragmas" a better solution is to disable the warning globally if optimization is disabled.
From d79d5a1c4d7b7d43e31b26f5d5e218155f699ac0 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Tue, 20 Oct 2026 07:26:42 -0700
Subject: [PATCH] build: disable GCC string op warnings when unoptimized
Without optimization GCC's -Wstringop-overflow and -Wstringop-overread are flow-insensitive: they check a memcpy() against the object size even on paths that are dead for the inlined arguments. This breaks debug builds of app/test with -Werror on lib/stack/rte_stack_pile.h, and has required local pragma workarounds elsewhere.
Disable both warnings when optimization is 0. They stay enabled for optimized builds, where the analysis is flow-sensitive.
Bugzilla ID: 2061
--- config/meson.build | 6 ++++++ 1 file changed, 6 insertions(+)
config/meson.build +6 -0
@@ -378,6 +378,12 @@ if cc.has_argument('-Wno-comma') no_comma_cflag = '-Wno-comma' endif +# GCC's string/memory access warnings are flow-insensitive without +# optimization and produce false positives on dead paths of inlined code. +if get_option('optimization') == '0' and cc.get_id() == 'gcc' + global_cflags += ['-Wno-stringop-overflow', '-Wno-stringop-overread'] ++endif + foreach arg: global_cflags if cc.has_argument(arg) add_project_arguments(arg, language: 'c')
Signature · 1 line
2.53.0
Morten Brørup
Acked-byQuoted 34 lines
From: Stephen Hemminger <[email protected]>
Date: Tue, 20 Oct 2026 07:26:42 -0700
Subject: [PATCH] build: disable GCC string op warnings when unoptimizedWithout optimization GCC's -Wstringop-overflow and -Wstringop-overread are flow-insensitive: they check a
memcpy()against the object size even on paths that are dead for the inlined arguments. This breaks debug builds of app/test with -Werror onlib/stack/rte_stack_pile.h, and has required local pragma workarounds elsewhere.Disable both warnings when optimization is 0. They stay enabled for optimized builds, where the analysis is flow-sensitive.
Bugzilla ID: 2061
Reported-by Ali Alnubani <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>--- config/meson.build | 6 ++++++ 1 file changed, 6 insertions(+)config/meson.build +2
-0@@ -378,6 +378,12 @@ if cc.has_argument('-Wno-comma') no_comma_cflag = '-Wno-comma' endif +# GCC's string/memory access warnings are flow-insensitive without +# optimization and produce false positives on dead paths of inlinedcode.
config/meson.build +2
-0+if get_option('optimization') == '0' and cc.get_id() == 'gcc' + global_cflags += ['-Wno-stringop-overflow', '-Wno-stringop-
Quoted 8 lines
overread']
++endif
+
foreach arg:global_cflags
ifcc.has_argument(arg)
add_project_arguments(arg, language: 'c')
--
2.53.0
Also '-Warray-bounds'?
Consider making it a series, and also remove existing overflow/overread pragmas in the code (if viable):lib/ring/rte_ring_elem_pvt.hlib/eal/ppc/include/rte_memcpy.h
With or without suggested changes,