examples/performance-thread: fix crash with gcc 5
authorTomasz Kulasek <tomaszx.kulasek@intel.com>
Tue, 26 Apr 2016 15:47:56 +0000 (17:47 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 27 Apr 2016 15:41:46 +0000 (17:41 +0200)
commit3e7bced6a6f29f980c4d72574bb0f4301f06e272
tree58b5b8adfa131c3d9cd31d55204ab91d2ea45fe6
parentea977ff1cb0b8afe03e994b3a8346696cbf27ea2
examples/performance-thread: fix crash with gcc 5

It seems that with gcc >5.x and -O2/-O3 optimization breaks packet
grouping algorithm in l3fwd-thread application causing segfault.

When last packet pointer "lp" and "pnum->u64" buffer points the same
memory buffer, high optimization can cause unpredictable results.
It seems that assignment of precalculated group sizes may interfere
with initialization of new group size when lp points value inside
current group and didn't should be changed.

With gcc >5.x and optimization we cannot be sure which assignment will be
done first, so the group size can be counted incorrectly causing segfault.

This patch eliminates intersection of assignment of initial group size
(lp[0] = 1) and precalculated group sizes when gptbl[v].idx < 4.

The same patch was applied for original l3fwd (af1694d94).

Fixes: d48415e1fee3 ("examples/performance-thread: add l3fwd-thread app")

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
examples/performance-thread/l3fwd-thread/main.c