Skip to contentSkip to conversation

stack: fix pile GCC memcpy warnings

PATCH In review Morten Brørup 4 participants 9 messages Oct 20 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

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

Fixes ee0822a0ef41 ("stack: introduce pile")

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
index 819bd1d47a..69aa0cbf88 100644
@@ -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
#1 lore raw
Quoted 43 lines · Morten Brørup

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

Fixes ee0822a0ef41 ("stack: introduce pile")

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 +6 -0
index 819bd1d47a..69aa0cbf88 100644
@@ -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
#2 lore raw
Quoted 52 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 11.19

Quoted 2 lines · Morten Brørup

On architectures where rte_memcpy() is defined as memcpy(), GCC warns about source/destination overflow when copying more than

the

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 x86 rte_memcpy() disabled sligthly similar warnings for.

PS:
The alternative was to obfuscate the code, but that would make the

code

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
---
 lib/stack/rte_stack_pile.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
lib/stack/rte_stack_pile.h +0 -0
index 819bd1d47a..69aa0cbf88 100644

lib/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 -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],

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 -0
 				sizeof(void *) * RTE_STACK_PILE_BULK_SIZE);

An rte_assume before 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
Tested-by on v1 1/1
#3 lore raw
In reply to Morten Brørup
Quoted 18 lines · Morten Brørup

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.

Quoted 8 lines

Bugzilla ID: 2061

Fixes ee0822a0ef41 ("stack: introduce pile")

The pile was introduce with this DPDK release, so no need to backport.

---

Build passes with this patch.

Thanks,
Ali

#4 lore raw
In reply to Morten Brørup
Quoted 18 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…

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.

Quoted 8 lines

Bugzilla ID: 2061

Fixes ee0822a0ef41 ("stack: introduce pile")

The pile was introduce with this DPDK release, so no need to backport.

---

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];

#5 lore raw
Quoted 43 lines

From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 16.24

Quoted 2 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…

On architectures where rte_memcpy() is defined as memcpy(), GCC warns about source/destination overflow when copying more than

the

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 x86 rte_memcpy() disabled sligthly similar warnings for.

PS:
The alternative was to obfuscate the code, but that would make the

code

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

---

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 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.

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_elems

lib/stack/rte_stack_pile.h +0 -2
 		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)-
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_push

lib/stack/rte_stack_pile.h +0 -2
 	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],

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];

#6 lore raw
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 warnings

Quoted 20 lines

From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 16.24

Quoted 2 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…

On architectures where rte_memcpy() is defined as memcpy(), GCC warns about source/destination overflow when copying more than

the

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 x86 rte_memcpy() disabled sligthly similar warnings

for.

Quoted 5 lines
Quoted 3 lines

PS:
The alternative was to obfuscate the code, but that would make the

code

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

---

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 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

Quoted 1 line

above. That means the GCC_VERSION >= 100000 gate is wrong at both

ends:

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 path

is

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:
#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.

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 one

assignment.

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_elems

lib/stack/rte_stack_pile.h +0 -2
 		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)-
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_push

lib/stack/rte_stack_pile.h +0 -2
 	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],

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];

#7 lore raw
In reply to Morten Brørup
Quoted 18 lines · On Tue, 20 Oct 2026 08:49:44 +0000 Morten Brørup <[email protected]>…

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.

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
index 745097e8aa..ac90b9d4fa 100644
@@ -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
author Acked-by
#8 lore raw
Quoted 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 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 +2 -0
index 745097e8aa..ac90b9d4fa 100644
@@ -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.

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
if cc.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.h
lib/eal/ppc/include/rte_memcpy.h

With or without suggested changes,