From: Vladimir Smirnov Date: Fri, 3 Jan 2025 20:47:56 +0000 (+0100) Subject: vlib: fail in runtime if workers > nelts X-Git-Tag: v25.06-rc0~13 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F42089%2F7;p=vpp.git vlib: fail in runtime if workers > nelts Type: fix With a release build, if you configure more than 55 workers, vpp will start, but will corrupt memory as a lot of internal datastrctures are allocated with assumption that there will be not more than FRAME_QUEUE_MAX_NELTS threads. Add a warning if amount of configured workers more than MAX_NELTS. Anticipate that next commit would add a compile-time configurable variable and name it VPP_MAX_THREADS. Change-Id: I015f4f9aa5e8b828c7d90c90142d7a7c1ce68f97 Signed-off-by: Vladimir Smirnov --- diff --git a/src/vlib/threads.c b/src/vlib/threads.c index f3fcb4043a0..fa8d949d549 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -282,6 +282,11 @@ vlib_thread_init (vlib_main_t * vm) tr->first_index = first_index; first_index += tr->count; n_vlib_mains += (tr->no_data_structure_clone == 0) ? tr->count : 0; + if (n_vlib_mains >= FRAME_QUEUE_MAX_NELTS) + return clib_error_return (0, + "configured amount of workers %u is" + " greater than VPP_MAX_WORKERS (%u)", + n_vlib_mains, FRAME_QUEUE_MAX_NELTS); /* construct coremask */ if (tr->use_pthreads || !tr->count)