This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9e0390259ad7771c0cb54d1d06c952cd3faff78d Author: dengwenqi <[email protected]> AuthorDate: Sat Oct 3 14:30:44 2026 +0800 backtrace: skip KASAN instrumentation in backtrace_remove to fix busyloop backtrace_remove() runs whenever a backtrace record is released. On KASAN-enabled debug builds its loads of entry->ref, the bucket slot and the collision chain each trip a __asan_loadN_noabort shadow check, which adds up when records are released at a high rate, e.g. for every free during a recursive directory scan. backtrace_hash(), backtrace_find() and backtrace_alloc() on the same path already skip the instrumentation. Add nosanitize_address to backtrace_remove(). All pointers it touches are pool-internal (entry, bucket, freelist nodes), so skipping the shadow check is safe. Signed-off-by: dengwenqi <[email protected]> --- libs/libc/misc/lib_backtrace.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/libc/misc/lib_backtrace.c b/libs/libc/misc/lib_backtrace.c index fd53fbdad93..e4f697acaf1 100644 --- a/libs/libc/misc/lib_backtrace.c +++ b/libs/libc/misc/lib_backtrace.c @@ -493,6 +493,18 @@ FAR void *backtrace_record(int skip) * Return 0 if success, otherwise return a negative value. ****************************************************************************/ +/* nosanitize_address: backtrace_remove is on the hot path of every + * allocation/free (mempool_record calls it for each when + * CONFIG_MM_RECORD_STACK is on). On KASAN-enabled debug builds the loads + * of entry->ref, the bucket slot and the collision chain each trip a + * per-access shadow check; across a heavy allocation phase (e.g. recursive + * directory scan at boot) this pushes wall time past the test framework's + * busy-loop threshold. All pointers touched are pool-internal, so skipping + * the check is safe -- same reasoning as backtrace_hash()/backtrace_find(); + * this is the remaining uninstrumented accessor on the same path. + */ + +nosanitize_address void backtrace_remove(FAR void *index) { FAR struct backtrace_pool_s *bp = &g_backtrace_pool;
