Repository navigation
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: kernelReviewers: @GorrayLi @ReviewSun @hamburger-os @lianux-mm @wdfk-prog @xu18838022837 Changed Files (Click to expand)
🏷️ Tag: workflowReviewers: @Rbb666 @kurisaW @supperthomas Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-24 17:11 CST)
📝 Review Instructions
|
|
|
这部分以什么方式加入?直接加也并不合适,不应该把它做为一个独立的组件放到 components 目录下,可以考虑的方式是 |
感谢反馈,我理解后觉得放 关于「软件包方式」,有一点技术约束想说明:ASan 依赖 GCC 的 |
|
感谢PR,看到了描述中支持了ARM和RV,作者能否添加下代表性的BSP(qemu-a9)进行编译看护,并添加utest使用utest-auto-run ci看护起来? |
好的,我处理一下 |
|
感谢建议,已补充 utest 测试用例和 CI 看护。 新增测试用例(
CI 看护:
过程中发现并修复的一个问题: 已在 qemu-vexpress-a9 上本地验证:6 个测试单元全部 PASSED。 |
| # AddressSanitizer (kernel-address): instrument memory accesses. The | ||
| # runtime is provided by components/utilities/asan and does not need libasan. | ||
| if rtconfig.PLATFORM in ['gcc'] and 'RT_USING_ASAN' in BuildOptions: | ||
| env.Append(CFLAGS=' -fsanitize=kernel-address -fno-omit-frame-pointer') |
There was a problem hiding this comment.
参数只追加到 CFLAGS,但 C++ 命令没有,需要同步设置下 CXXFLAGS。
There was a problem hiding this comment.
已在 7010717 中同步向 CXXFLAGS 添加 -fsanitize=kernel-address -fno-omit-frame-pointer,并新增 C++ 越界回归用例。
| static void asan_realloc_entry_hook(void **ptr, rt_size_t size) | ||
| { | ||
| RT_UNUSED(size); | ||
| asan_realloc_old_ptr = (rt_uintptr_t)*ptr; | ||
| } | ||
|
|
||
| static void asan_realloc_exit_hook(void **ptr, rt_size_t size) |
There was a problem hiding this comment.
这里有点问题,就是这两个 hook 均位于堆锁之外。若线程 A 进入 realloc 后被抢占,B 完成 realloc,再恢复 A,就会用 B 的指针处理 A 的释放操作。
There was a problem hiding this comment.
确实存在这个问题,已在 7010717 中移除全局旧指针和成对 hook 的实现,将 ASan 分配状态更新接入堆锁保护范围。同时处理了旧块释放后、shadow 更新前被其他线程复用的窗口。
| asan_track_add(p, size); | ||
| asan_unpoison_range(p, size); | ||
| if (aligned > size) | ||
| { | ||
| asan_poison_range(p + size, aligned - size); |
There was a problem hiding this comment.
这块是只把向上对齐后多出来的字节设为了保护区,没有额外预留保护空间。
如果申请16 字节,就不存在被标记为不可访问的区域了吧?如果 rt_malloc(16),p[16] = 1 这种是不是就检测不到了?
There was a problem hiding this comment.
是的,原实现只标记对齐填充,16 字节这类请求会漏报。已在 7010717 中实际预留右侧保护区,并按用户请求长度设置 shadow;普通分配和对齐分配均已覆盖。补充了整齐/非整齐大小、对齐分配及 realloc 缩小后的边界测试
在 |
感谢指出,我确认了 DefineGroup 的实现,SConscript 中的 CFLAGS/CXXFLAGS 确实可以追加到全局编译环境。之前的表述不准确,也不能据此认定软件包只能实现不插桩的版本。 |
已在 ebfd73c 中完成上述调整,将全局 CFLAGS/CXXFLAGS/LINKFLAGS 配置收回 components/utilities/asan/SConscript,移除了 tools/building.py 中的 ASan 专用逻辑。分配器和运行时的局部排除插桩设置保持有效。 |
| * | ||
| * @return the pointer to allocated memory or NULL if no free memory was found. | ||
| */ | ||
| rt_weak void *rt_malloc(rt_size_t size) |
There was a problem hiding this comment.
其实在这里是专门留了weak的,这样可以在需要重载系统动态内存分配器的地方重新实现这些函数,这样就可以做到对内核的无侵入修改了。
There was a problem hiding this comment.
明白了,当前直接在 kservice.c 中接入 ASan 的方式没有充分利用weak这个机制。我会按组件内覆盖弱符号的方向调整,并核对底层分配器接入、锁和原有接口行为,尽量消除 ASan 对内核源码的直接修改。
There was a problem hiding this comment.
我已在本地按覆盖 weak 接口的方式调整:由 ASan 组件提供分配、释放、对齐分配及内存统计等接口,移除了 kservice.c 中的 ASan 专用分支。
调整过程中发现,四个 hook 设置接口、两个 slab 页分配接口,以及两个测试用堆锁接口目前不是 weak,而且依赖 kservice.c 内部的静态状态。为保持这些接口与组件接管后的堆一致,当前方案为这八个接口补充了 weak 声明。分配器排除插桩的构建设置暂时保留。
这个方案保留了现有功能,代价是仍有少量通用内核改动,且组件需要维护一套堆适配和锁管理逻辑。想请教您是否接受补齐这些通用 weak 扩展点,还是更倾向于严格保持内核不变、相应限定首版组件的支持范围?我再按确定的方向整理提交。
| * raise false positives, so disable instrumentation for them. | ||
| */ | ||
| #ifdef RT_USING_ASAN | ||
| #define RT_KLIB_NO_ASAN __attribute__((no_sanitize_address)) |
There was a problem hiding this comment.
当前 rt_memcpy/rt_memset/rt_memmove 被整体排除插桩,且没有补充范围检查。即使开启了自动插桩,对 rt_malloc(10) 返回的缓冲区执行 13 字节的上述操作,也不会报告越界。
There was a problem hiding this comment.
感谢指出,这个例子确实属于当前版本的检测盲区。批量内存函数的 ASan 适配原本计划放在二期,通过提供带范围检查的对应实现,并配合编译器重定向或接口包装接入;当前版本尚未覆盖这部分,因此 rt_memcpy/rt_memset/rt_memmove 的越界操作可能漏报。
当前整体排除插桩并不是完整的解决方案,现有注释以“按字操作可能越过请求长度”解释也不准确。我会修正注释,并在功能说明中明确这一期的检测范围,避免误解为已经覆盖所有堆访问。如果这部分覆盖是本次合入的必要条件,我再将其提前到当前 PR 中完善。
| @@ -0,0 +1,624 @@ | |||
| /* | |||
There was a problem hiding this comment.
已将 ASan 的 C/C++ 测试及对应配置、构建逻辑迁至 components/utilities/asan/utest/,移除了 src/utest/ 中的 ASan 专用入口。测试保持独立构建并启用插桩,已通过本地 11 组配置回归验证。
|
@RogerNext commit上还需要精简下,保留必要的commit即可。 |
Make heap hook setters, slab page APIs and test heap locks weak so alternate allocators can consistently own their state. Reject calloc multiplication overflow and invalid or overflowing aligned allocations; include aligned allocation regression tests.
Add GCC kernel-address instrumentation and a component-owned heap adapter using weak API overrides. Track redzones, allocation sizes and shadow memory under allocator synchronization; require cross-CPU heap locking for SMP. Keep allocator/runtime code uninstrumented and document deferred bulk-memory checks and allocator-specific UAF coverage.
Add instrumented C/C++ regression tests for heap boundaries, realloc, alignment, hooks, heap statistics and concurrency. Cover SMP lock dependencies with Kconfig tests and run the ASan suite in QEMU A9 CI. Keep test build flags separate from the runtime exclusions.
ed67ae9 to
524e431
Compare
|
已将提交精简为内核通用调整、ASan 组件、测试与 CI 三个提交,合并了格式修复和目录迁移等中间改动,并完成本地验证。请再帮忙看看,谢谢。 |
Wrap common libc memory, string and formatting calls with explicit heap checks. Preserve native formatting behavior, validate string and writeback arguments, and limit output to known heap bounds. Add boundary and compatibility tests, fix RT string precision handling, and preserve structured SCons compiler and linker arguments. Validation: 27 ARM build/configuration combinations, local CI configuration, 9 Python tests, native LP64 UBSan checks, and negative controls.
|
rt_memcpy/rt_memset/rt_memmove 的范围检查,以及可选的 memcpy/strcpy/sprintf 等 libc 接口包装。 |
|
@RogerNext 这个PR产生了冲突文件,帮忙解决下,我再复核 |
Preserve upstream formatting, calloc overflow protection and new CI entries while retaining ASan heap overrides, libc range checks and precision regression tests. Validation: 9 Python tests and 19 ARM build/QEMU configurations, including the ASan CI configuration.
已合并最新 master 并解决冲突,更新至 27fb079。保留了主线修复与 ASan 检测逻辑,本地多配置回归通过,新一轮 CI 已启动,麻烦再帮忙复核,谢谢。@Rbb666 |
BernardXiong
left a comment
There was a problem hiding this comment.
CI 的 “Scan code format and license” 仍失败,属本 PR 引入的格式问题,本轮不做完整 review:
- asan_tc.c:89 等 7 处(89/112/135/136/167/193/217)
- kstdio.c:57(
(size_t) - 1) - kstring.c:25 / kstring.c:26(续行反斜杠对齐)
请先对上述文件运行 clang-format;CI 绿后再复核。冲突已解决,可继续 Rbb666 请求的复核。
Format affected runtime, test and klibc files with clang-format 22.1.8. Validate all PR source changes with the repository CI checker; changes are whitespace only.
|
|
||
| if (limit) | ||
| { | ||
| bounded = rt_asan_accessible_size(src, &available); |
There was a problem hiding this comment.
strnlen(buf, 1) 也会在关闭本核中断期间扫描到整个堆块末尾,大缓冲区会拉长中断延迟。请让影子内存查询遵守本次读取上限,无界字符串按小块检查,遇到结束符即停止。
There was a problem hiding this comment.
已在 ea6b9d4e 修复,感谢指出。修复补丁:patch。
影子内存查询现在接收本次访问上限;strnlen(buf, 1) 只查询对应范围。字符串每次最多检查 64 个应用字节,释放 shadow 锁后再读取字符,遇到 NUL 立即停止,不因同块中 NUL 后的 redzone 误报。长范围检查与格式化目标查询复用分段扫描逻辑,每段释放锁;非对齐情况下每次持锁最多读取 9 个 shadow 单元。
本地验证:19 组 ARM 编译/QEMU 配置(含 ASan CI 配置)、10 项 Python 测试、clang-format 22.1.8 检查均通过。新增测试包含零上限、分块边界、非对齐地址、部分 granule、shadow 覆盖末尾和 SIZE_MAX;主机测试直接使用运行时查询代码,并在临时编译单元中计数 shadow 读取和持锁次数。取消分块持锁或忽略查询上限的两个负向验证均能被检出。生产运行时未增加测量计数器。
QEMU 实测报告
- 环境:QEMU 8.2.0,
vexpress-a9,单核,ARM GCC 9.2.1,-Os,smallmem,shadow 为 262144 字节,tracking 表为 512 项,关闭 ASan backtrace。 - 计时:SP804 1 MHz 虚拟计数器;独立 SP804 通道每 100 μs 产生一次中断,记录相对预计到期时间的 ISR 响应延迟。频率已通过 QEMU
info qtree确认为 1 MHz。 - QEMU 参数:
-icount shift=3,align=off,sleep=off。下表单位均为 QEMU 虚拟 μs,采用三轮独立启动中的观测最大值,不作为 WCET 保证。 - 基线:
aab8c4d1;修复:ea6b9d4e。测量覆盖 64 B、4 KiB、64 KiB、256 KiB 四种缓冲区和九种场景。每个场景每轮 64 次调用,完整字符串和完整范围扫描每轮 8 次调用。 - 分别进行了带 shadow 锁内计时探针和不带探针的对照:每种模式、每个版本均启动三轮,共 432 行汇总记录。锁内时长取自带探针运行;下表的 ISR 响应延迟与调用总耗时取自不带锁内探针的运行,避免每个批次的额外 MMIO 计时影响总耗时。
256 KiB 缓冲区的最大观测值
| 场景 | shadow 锁内时长:修复前 → 后 | ISR 响应延迟:修复前 → 后 | 调用总耗时:修复前 → 后 |
|---|---|---|---|
strnlen(buf, 1) |
3671 → 1 | 3671 → 3 | 3690 → 1 |
strlen(buf),首字节为 NUL |
3671 → 2 | 3672 → 3 | 3694 → 6 |
snprintf(..., "%.1s", buf) |
3671 → 1 | 3672 → 3 | 3714 → 19 |
snprintf(buf, 1, "hello") |
3671 → 1 | 3671 → 3 | 3695 → 10 |
完整字符串 strlen |
3671 → 2 | 3672 → 6 | 25502 → 21194 |
| 完整范围检查 | 3409 → 2 | 3403 → 4 | 3422 → 4059 |
sprintf(buf, "hello") |
3671 → 2 | 3672 → 6 | 3699 → 4075 |
短读取不再随分配块大小增长(strnlen(buf, 1),带探针测得的 shadow 锁内最大时长):
| 缓冲区大小 | 修复前 | 修复后 |
|---|---|---|
| 64 B | 2 | 1 |
| 4 KiB | 58 | 1 |
| 64 KiB | 918 | 1 |
| 256 KiB | 3671 | 1 |
代价也一并记录:256 KiB 完整范围检查的调用最大耗时从 3422 μs 增至 4059 μs(约 +18.6%);无界格式化目标搜索也有额外开销。这是分段释放/获取锁、让出中断响应机会的代价。短读取则避免了与本次访问无关的整块扫描。
空循环对照的最大调用时间为 1 μs、定时器响应延迟为 3 μs。锁内计时覆盖 shadow 临界段主体,包含探针开销;ISR 延迟也包含内核其他临界段与中断处理的影响,初次装载定时器存在固定的寄存器写入相位偏差。调用方已关中断时仍保留其原状态;本次单核结果不涵盖 SMP 锁竞争、分配器自身、错误报告打印及回溯的延迟。
复现配置与基准代码(仅放入临时测试 worktree)
分别基于上述修复前/后版本,在 bsp/qemu-vexpress-a9 使用下列最小配置生成 .config/rtconfig.h(通过 scons --pyconfig-silent),将 rtconfig.py 的 BUILD 设为 release。基准文件放在 ASan 组件临时工作目录中,由现有 SConscript 的非插桩运行时组编译。构建后运行:
qemu-system-arm -M vexpress-a9 -smp 1 -m 128M -kernel rtthread.bin \
-nographic -net none -monitor none -icount shift=3,align=off,sleep=off在 FinSH 执行 asan_latency。下面代码保留了测量时的输出字段;每组样本量小于 100,call_p99_us 字段与样本最大值相同,本报告只使用最大观测值。
最小配置:
CONFIG_RT_NAME_MAX=16
CONFIG_RT_THREAD_PRIORITY_256=y
CONFIG_RT_TICK_PER_SECOND=100
CONFIG_IDLE_THREAD_STACK_SIZE=4096
CONFIG_RT_TIMER_THREAD_STACK_SIZE=4096
CONFIG_RT_USING_SLAB=y
CONFIG_RT_USING_MEMHEAP=y
CONFIG_RT_USING_MEMTRACE=y
CONFIG_RT_USING_INTERRUPT_INFO=y
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_MAIN_THREAD_STACK_SIZE=8196
CONFIG_RT_MAIN_THREAD_PRIORITY=10
CONFIG_RT_USING_LEGACY=y
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_HISTORY_LINES=10
CONFIG_FINSH_CMD_SIZE=256
CONFIG_DFS_FD_MAX=32
CONFIG_RT_USING_DFS_V2=y
CONFIG_RT_USING_DFS_ELMFAT=y
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
CONFIG_RT_USING_DFS_ROMFS=y
CONFIG_RT_USING_DFS_TMPFS=y
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=8196
CONFIG_RT_SERIAL_RB_BUFSZ=256
CONFIG_RT_USING_I2C=y
CONFIG_RT_USING_NULL=y
CONFIG_RT_USING_ZERO=y
CONFIG_RT_USING_RANDOM=y
CONFIG_RT_USING_MTD_NOR=y
CONFIG_RT_USING_MTD_NAND=y
CONFIG_RT_MTD_NAND_DEBUG=y
CONFIG_RT_USING_RTC=y
CONFIG_RT_USING_SOFT_RTC=y
CONFIG_RT_USING_SDIO=y
CONFIG_RT_SDIO_STACK_SIZE=4096
CONFIG_RT_MMCSD_STACK_SIZE=16384
CONFIG_RT_USING_SPI=y
CONFIG_RT_USING_SPI_MSD=y
CONFIG_RT_USING_SFUD=y
CONFIG_RT_USING_WDT=y
CONFIG_RT_USING_POSIX_SELECT=y
CONFIG_RT_USING_POSIX_TERMIOS=y
CONFIG_RT_USING_POSIX_AIO=y
CONFIG_RT_USING_POSIX_TIMER=y
CONFIG_RT_USING_POSIX_PIPE=y
CONFIG_RT_USING_POSIX_MESSAGE_QUEUE=y
CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE=y
CONFIG_RT_USING_CPLUSPLUS=y
CONFIG_RT_USING_ASAN=y
CONFIG_RT_ASAN_USING_LIBC=y
CONFIG_RT_ASAN_SHADOW_SIZE=262144
# CONFIG_RT_ASAN_BACKTRACE is not set
CONFIG_RT_USING_UTESTCASES=y
CONFIG_RT_UTEST_MEM_ALIGN=y
CONFIG_RT_UTEST_ASAN=y
临时基准代码:
/* Temporary, single-core vexpress-a9 SP804 benchmark. Not production code. */
#include <rtthread.h>
#include <rthw.h>
#include <stdio.h>
#include <string.h>
#include "asan.h"
#include "realview.h"
#include <finsh.h>
#define REG(off) (*(volatile rt_uint32_t *)(0x10011000u + (off)))
#define PERIOD 100
volatile int asan_perf_active;
volatile rt_uint32_t asan_perf_begin, asan_perf_max, asan_perf_locks;
static volatile rt_uint32_t irq_max, irq_count, missed, next_due;
static volatile size_t sink;
static size_t (* volatile length_fn)(const char *) = strlen;
size_t strnlen(const char *, size_t);
static size_t (* volatile bounded_fn)(const char *, size_t) = strnlen;
static int (* volatile output_fn)(char *,size_t,const char *,...) = snprintf;
static int (* volatile unbounded_fn)(char *,const char *,...) = sprintf;
rt_uint32_t asan_perf_clock(void) { return ~REG(0x04); }
static void latency_irq(int vector, void *parameter)
{
rt_uint32_t now = asan_perf_clock();
rt_int32_t delay = (rt_int32_t)(now - next_due);
REG(0x2c) = 1;
if (delay >= 0)
{
rt_uint32_t skipped = (rt_uint32_t)delay / PERIOD;
next_due += (skipped + 1) * PERIOD;
if (asan_perf_active)
{
irq_count++;
missed += skipped;
if ((rt_uint32_t)delay > irq_max) irq_max = delay;
}
}
}
static void sample(const char *name, char *p, size_t size, int operation)
{
rt_uint32_t elapsed[64], i,j,value;
unsigned int count = operation == 3 || operation == 6 ? 8 : 64;
char output[32];
irq_max = irq_count = missed = asan_perf_max = asan_perf_locks = 0;
asan_perf_active = 1;
for (i=0;i<count;i++)
{
rt_uint32_t start = asan_perf_clock();
switch(operation)
{
case 0: sink = bounded_fn(p,0); break;
case 1: sink = bounded_fn(p,1); break;
case 2: sink = length_fn(p); break;
case 3: sink = length_fn(p); break;
case 4: sink = output_fn(output,sizeof(output),"%.1s",p); break;
case 5: sink = output_fn(p,1,"hello"); break;
case 6: sink = rt_asan_check_read(p,size); break;
case 7: sink = unbounded_fn(p,"hello"); break;
case 8: asm volatile("" ::: "memory"); break;
}
elapsed[i] = asan_perf_clock() - start;
}
/* Ensure pending timer delivery is observed before stopping measurement. */
rt_uint32_t wait = asan_perf_clock();
while (asan_perf_clock() - wait < 2*PERIOD) asm volatile("" ::: "memory");
asan_perf_active = 0;
for(i=1;i<count;i++)
{
value=elapsed[i]; j=i;
while(j && elapsed[j-1]>value) { elapsed[j]=elapsed[j-1];j--; }
elapsed[j]=value;
}
rt_kprintf("PERF name=%s size=%u count=%u call_p50_us=%u call_p99_us=%u call_max_us=%u irq_off_max_us=%u irq_delay_max_us=%u irq_count=%u missed=%u locks=%u\n",name,(unsigned)size,count,elapsed[count/2],elapsed[count-1],elapsed[count-1],asan_perf_max,irq_max,irq_count,missed,asan_perf_locks);
}
static void asan_latency(void)
{
static const rt_size_t sizes[]={64,4096,65536,262144};
unsigned i;
REG(0x08)=0; REG(0x00)=0xffffffff; REG(0x08)=0x82;
REG(0x28)=0; REG(0x2c)=1; REG(0x20)=PERIOD;
rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1,latency_irq,RT_NULL,"asan-perf");
next_due=asan_perf_clock()+PERIOD;
REG(0x28)=0xe2;
rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
for(i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++)
{
char *p=rt_malloc(sizes[i]);
if(!p) {rt_kprintf("PERF allocation failed\n");break;}
memset(p,'a',sizes[i]); p[sizes[i]-1]=0;
sample("empty_loop",p,sizes[i],8);
sample("strnlen0",p,sizes[i],0);
sample("strnlen1",p,sizes[i],1);
sample("precision1",p,sizes[i],4);
sample("strlen_full",p,sizes[i],3);
sample("range_full",p,sizes[i],6);
p[0]=0;sample("strlen_empty",p,sizes[i],2);
sample("snprintf1",p,sizes[i],5);
sample("sprintf",p,sizes[i],7);
rt_free(p);
}
REG(0x28)=0;rt_hw_interrupt_mask(IRQ_PBA8_TIMER0_1);
rt_kprintf("PERF DONE\n");
}
MSH_CMD_EXPORT(asan_latency, measure single-core shadow scan IRQ latency);不带探针时运行时保持原样,只用上述定时器记录调用时间及 ISR 响应延迟。带探针的运行中,在 asan.c 声明:
extern volatile int asan_perf_active;
extern volatile rt_uint32_t asan_perf_begin, asan_perf_max, asan_perf_locks;
rt_uint32_t asan_perf_clock(void);在 asan_lock() 关闭本核中断后插入:
if (asan_perf_active)
{
asan_perf_begin = asan_perf_clock();
asan_perf_locks++;
}在 asan_unlock() 恢复中断前插入:
if (asan_perf_active)
{
rt_uint32_t duration = asan_perf_clock() - asan_perf_begin;
if (duration > asan_perf_max) asan_perf_max = duration;
}以上探针和基准代码仅用于此次 QEMU 测量,未加入生产补丁。
432 行原始汇总数据(CSV)
before/after 带 shadow 锁内计时探针;before-unprobed/after-unprobed 不带该探针。无探针记录的 irq_off_max_us、locks 为 0 表示未采集,不表示没有临界段。missed 是相邻 ISR 交付间跳过的预计定时周期数。
variant,repeat,name,size,count,call_p50_us,call_p99_us,call_max_us,irq_off_max_us,irq_delay_max_us,irq_count,missed,locks
before,0,empty_loop,64,64,0,1,1,0,3,2,0,0
before,0,strnlen0,64,64,0,1,1,0,3,2,0,0
before,0,strnlen1,64,64,2,6,6,2,4,4,0,64
before,0,precision1,64,64,20,24,24,8,10,15,0,320
before,0,strlen_full,64,8,7,11,11,1,3,3,0,8
before,0,range_full,64,8,2,2,2,1,3,2,0,8
before,0,strlen_empty,64,64,2,6,6,2,4,3,0,64
before,0,snprintf1,64,64,7,11,11,2,3,6,0,128
before,0,sprintf,64,64,8,12,12,2,3,7,0,192
before,0,empty_loop,4096,64,0,1,1,0,3,2,0,0
before,0,strnlen0,4096,64,0,4,4,0,3,3,0,0
before,0,strnlen1,4096,64,62,66,66,58,60,41,0,65
before,0,precision1,4096,64,80,80,80,58,60,53,0,320
before,0,strlen_full,4096,8,401,409,409,58,3,34,0,9
before,0,range_full,4096,8,57,58,58,53,54,6,0,8
before,0,strlen_empty,4096,64,62,63,63,58,60,41,0,64
before,0,snprintf1,4096,64,67,71,71,58,58,44,0,129
before,0,sprintf,4096,64,68,68,68,58,58,44,0,192
before,0,empty_loop,65536,64,0,1,1,0,3,2,0,0
before,0,strnlen0,65536,64,0,1,1,0,3,2,0,0
before,0,strnlen1,65536,64,922,944,944,918,916,66,527,84
before,0,precision1,65536,64,940,951,951,918,920,79,526,326
before,0,strlen_full,65536,8,6376,6394,6394,918,912,446,66,27
before,0,range_full,65536,8,857,864,864,853,847,10,60,9
before,0,strlen_empty,65536,64,922,930,930,918,916,69,524,70
before,0,snprintf1,65536,64,927,948,948,918,920,70,526,148
before,0,sprintf,65536,64,928,953,953,918,920,70,526,212
before,0,empty_loop,262144,64,0,1,1,0,3,2,0,0
before,0,strnlen0,262144,64,0,1,1,0,3,3,0,1
before,0,strnlen1,262144,64,3675,3700,3700,3671,3672,71,2285,115
before,0,precision1,262144,64,3696,3721,3721,3671,3670,101,2268,386
before,0,strlen_full,262144,8,25491,25498,25498,3671,3673,1754,287,56
before,0,range_full,262144,8,3413,3420,3420,3408,3402,10,265,11
before,0,strlen_empty,262144,64,3675,3696,3696,3671,3671,68,2288,116
before,0,snprintf1,262144,64,3680,3705,3705,3671,3671,73,2287,193
before,0,sprintf,262144,64,3681,3702,3702,3671,3672,68,2292,243
before,1,empty_loop,64,64,0,1,1,0,3,2,0,0
before,1,strnlen0,64,64,0,1,1,0,3,2,0,0
before,1,strnlen1,64,64,2,6,6,2,4,4,0,64
before,1,precision1,64,64,20,24,24,8,10,15,0,320
before,1,strlen_full,64,8,7,11,11,1,3,3,0,8
before,1,range_full,64,8,2,2,2,1,3,2,0,8
before,1,strlen_empty,64,64,2,6,6,2,4,3,0,64
before,1,snprintf1,64,64,7,11,11,2,3,6,0,128
before,1,sprintf,64,64,8,12,12,2,3,7,0,192
before,1,empty_loop,4096,64,0,1,1,0,3,2,0,0
before,1,strnlen0,4096,64,0,4,4,0,3,3,0,0
before,1,strnlen1,4096,64,62,66,66,58,60,41,0,65
before,1,precision1,4096,64,80,80,80,58,60,53,0,320
before,1,strlen_full,4096,8,401,409,409,58,3,34,0,9
before,1,range_full,4096,8,57,58,58,53,54,6,0,8
before,1,strlen_empty,4096,64,62,63,63,58,60,41,0,64
before,1,snprintf1,4096,64,67,71,71,58,58,44,0,129
before,1,sprintf,4096,64,68,68,68,58,58,44,0,192
before,1,empty_loop,65536,64,0,1,1,0,3,2,0,0
before,1,strnlen0,65536,64,0,1,1,0,3,2,0,0
before,1,strnlen1,65536,64,922,944,944,918,916,66,527,84
before,1,precision1,65536,64,940,951,951,918,920,79,526,326
before,1,strlen_full,65536,8,6376,6394,6394,918,912,446,66,27
before,1,range_full,65536,8,857,864,864,853,847,10,60,9
before,1,strlen_empty,65536,64,922,930,930,918,916,69,524,70
before,1,snprintf1,65536,64,927,948,948,918,920,70,526,148
before,1,sprintf,65536,64,928,953,953,918,920,70,526,212
before,1,empty_loop,262144,64,0,1,1,0,3,2,0,0
before,1,strnlen0,262144,64,0,1,1,0,3,3,0,1
before,1,strnlen1,262144,64,3675,3700,3700,3671,3672,71,2285,115
before,1,precision1,262144,64,3696,3721,3721,3671,3670,101,2268,386
before,1,strlen_full,262144,8,25491,25498,25498,3671,3673,1754,287,56
before,1,range_full,262144,8,3413,3420,3420,3408,3402,10,265,11
before,1,strlen_empty,262144,64,3675,3696,3696,3671,3671,68,2288,116
before,1,snprintf1,262144,64,3680,3705,3705,3671,3671,73,2287,193
before,1,sprintf,262144,64,3681,3702,3702,3671,3672,68,2292,243
before,2,empty_loop,64,64,0,1,1,0,3,2,0,0
before,2,strnlen0,64,64,0,1,1,0,3,2,0,0
before,2,strnlen1,64,64,2,6,6,2,4,4,0,64
before,2,precision1,64,64,20,24,24,8,10,15,0,320
before,2,strlen_full,64,8,7,11,11,1,3,3,0,8
before,2,range_full,64,8,2,2,2,1,3,2,0,8
before,2,strlen_empty,64,64,2,6,6,2,4,3,0,64
before,2,snprintf1,64,64,7,11,11,2,3,6,0,128
before,2,sprintf,64,64,8,12,12,2,3,7,0,192
before,2,empty_loop,4096,64,0,1,1,0,3,2,0,0
before,2,strnlen0,4096,64,0,4,4,0,3,3,0,0
before,2,strnlen1,4096,64,62,69,69,58,60,41,0,65
before,2,precision1,4096,64,80,80,80,58,60,53,0,320
before,2,strlen_full,4096,8,401,409,409,58,3,34,0,9
before,2,range_full,4096,8,57,58,58,53,43,6,0,8
before,2,strlen_empty,4096,64,62,63,63,58,58,40,0,64
before,2,snprintf1,4096,64,67,74,74,58,60,44,0,129
before,2,sprintf,4096,64,67,68,68,58,32,45,0,192
before,2,empty_loop,65536,64,0,1,1,0,3,2,0,0
before,2,strnlen0,65536,64,0,1,1,0,3,2,0,0
before,2,strnlen1,65536,64,922,948,948,918,918,67,526,84
before,2,precision1,65536,64,940,951,951,918,920,79,526,326
before,2,strlen_full,65536,8,6376,6394,6394,918,915,446,66,27
before,2,range_full,65536,8,857,864,864,853,849,10,60,9
before,2,strlen_empty,65536,64,922,933,933,918,920,67,526,70
before,2,snprintf1,65536,64,927,949,949,918,915,73,523,148
before,2,sprintf,65536,64,928,953,953,918,919,74,523,212
before,2,empty_loop,262144,64,0,1,1,0,3,2,0,0
before,2,strnlen0,262144,64,0,4,4,0,3,3,0,1
before,2,strnlen1,262144,64,3675,3696,3696,3671,3673,69,2287,115
before,2,precision1,262144,64,3696,3721,3721,3671,3670,100,2269,386
before,2,strlen_full,262144,8,25491,25498,25498,3671,3671,1754,287,56
before,2,range_full,262144,8,3413,3420,3420,3409,3401,10,265,11
before,2,strlen_empty,262144,64,3675,3696,3696,3671,3673,67,2289,116
before,2,snprintf1,262144,64,3680,3705,3705,3671,3673,72,2288,193
before,2,sprintf,262144,64,3681,3705,3705,3671,3673,68,2292,243
after,0,empty_loop,64,64,0,1,1,0,3,2,0,0
after,0,strnlen0,64,64,0,1,1,0,3,2,0,0
after,0,strnlen1,64,64,1,6,6,1,3,3,0,64
after,0,precision1,64,64,13,18,18,1,3,10,0,320
after,0,strlen_full,64,8,6,10,10,2,3,3,0,8
after,0,range_full,64,8,2,2,2,1,3,2,0,8
after,0,strlen_empty,64,64,2,7,7,2,3,4,0,64
after,0,snprintf1,64,64,6,11,11,1,3,6,0,128
after,0,sprintf,64,64,9,14,14,1,3,7,0,256
after,0,empty_loop,4096,64,0,1,1,0,3,2,0,0
after,0,strnlen0,4096,64,0,5,5,0,3,3,0,0
after,0,strnlen1,4096,64,1,5,5,1,3,3,0,64
after,0,precision1,4096,64,13,18,18,1,3,11,0,320
after,0,strlen_full,4096,8,358,359,359,2,4,30,0,512
after,0,range_full,4096,8,90,90,90,2,4,9,0,512
after,0,strlen_empty,4096,64,2,6,6,2,3,3,0,64
after,0,snprintf1,4096,64,6,11,11,1,3,6,0,128
after,0,sprintf,4096,64,97,105,105,2,4,64,0,4289
after,0,empty_loop,65536,64,0,1,1,0,3,2,0,0
after,0,strnlen0,65536,64,0,1,1,0,3,3,0,0
after,0,strnlen1,65536,64,1,5,5,1,3,3,0,64
after,0,precision1,65536,64,13,18,18,1,3,11,0,320
after,0,strlen_full,65536,8,5711,5712,5712,2,4,458,0,8196
after,0,range_full,65536,8,1423,1448,1448,2,4,116,0,8207
after,0,strlen_empty,65536,64,2,7,7,2,3,4,0,64
after,0,snprintf1,65536,64,6,11,11,1,3,6,0,128
after,0,sprintf,65536,64,1430,1442,1442,2,4,919,0,65737
after,0,empty_loop,262144,64,0,1,1,0,3,2,0,0
after,0,strnlen0,262144,64,0,1,1,0,3,2,0,0
after,0,strnlen1,262144,64,1,6,6,1,3,3,0,64
after,0,precision1,262144,64,13,18,18,1,3,11,0,320
after,0,strlen_full,262144,8,22834,22857,22857,2,4,1829,0,32815
after,0,range_full,262144,8,5703,5704,5704,2,4,458,0,32772
after,0,strlen_empty,262144,64,2,6,6,2,3,3,0,64
after,0,snprintf1,262144,64,6,11,11,1,3,6,0,128
after,0,sprintf,262144,64,5710,5731,5731,2,5,3656,0,262428
after,1,empty_loop,64,64,0,1,1,0,3,2,0,0
after,1,strnlen0,64,64,0,1,1,0,3,2,0,0
after,1,strnlen1,64,64,1,6,6,1,3,3,0,64
after,1,precision1,64,64,13,18,18,1,3,10,0,320
after,1,strlen_full,64,8,6,10,10,2,3,3,0,8
after,1,range_full,64,8,2,2,2,1,3,2,0,8
after,1,strlen_empty,64,64,2,7,7,2,3,4,0,64
after,1,snprintf1,64,64,6,11,11,1,3,6,0,128
after,1,sprintf,64,64,9,14,14,1,3,7,0,256
after,1,empty_loop,4096,64,0,1,1,0,3,2,0,0
after,1,strnlen0,4096,64,0,5,5,0,3,3,0,0
after,1,strnlen1,4096,64,1,5,5,1,3,3,0,64
after,1,precision1,4096,64,13,18,18,1,3,11,0,320
after,1,strlen_full,4096,8,358,359,359,2,4,30,0,512
after,1,range_full,4096,8,90,90,90,2,4,9,0,512
after,1,strlen_empty,4096,64,2,6,6,2,3,3,0,64
after,1,snprintf1,4096,64,6,11,11,1,3,6,0,128
after,1,sprintf,4096,64,97,105,105,2,9,64,0,4289
after,1,empty_loop,65536,64,0,1,1,0,3,2,0,0
after,1,strnlen0,65536,64,0,13,13,0,8,3,0,1
after,1,strnlen1,65536,64,1,6,6,1,3,3,0,64
after,1,precision1,65536,64,13,17,17,1,3,10,0,320
after,1,strlen_full,65536,8,5711,5712,5712,2,9,458,0,8196
after,1,range_full,65536,8,1427,1447,1447,2,25,117,0,8207
after,1,strlen_empty,65536,64,2,7,7,2,4,4,0,64
after,1,snprintf1,65536,64,6,11,11,1,3,6,0,128
after,1,sprintf,65536,64,1430,1443,1443,2,9,919,0,65737
after,1,empty_loop,262144,64,0,1,1,0,3,2,0,0
after,1,strnlen0,262144,64,0,1,1,0,3,2,0,0
after,1,strnlen1,262144,64,1,6,6,1,3,3,0,64
after,1,precision1,262144,64,13,18,18,1,3,11,0,320
after,1,strlen_full,262144,8,22833,22858,22858,2,25,1829,0,32815
after,1,range_full,262144,8,5703,5704,5704,2,9,458,0,32772
after,1,strlen_empty,262144,64,2,7,7,2,3,3,0,64
after,1,snprintf1,262144,64,6,11,11,1,3,6,0,128
after,1,sprintf,262144,64,5710,5731,5731,2,25,3655,0,262428
after,2,empty_loop,64,64,0,1,1,0,3,2,0,0
after,2,strnlen0,64,64,0,1,1,0,3,2,0,0
after,2,strnlen1,64,64,1,6,6,1,3,3,0,64
after,2,precision1,64,64,13,18,18,1,3,10,0,320
after,2,strlen_full,64,8,6,10,10,2,3,3,0,8
after,2,range_full,64,8,2,2,2,1,3,2,0,8
after,2,strlen_empty,64,64,2,7,7,2,3,4,0,64
after,2,snprintf1,64,64,6,11,11,1,3,6,0,128
after,2,sprintf,64,64,9,14,14,1,3,7,0,256
after,2,empty_loop,4096,64,0,1,1,0,3,2,0,0
after,2,strnlen0,4096,64,0,5,5,0,3,3,0,0
after,2,strnlen1,4096,64,1,5,5,1,3,3,0,64
after,2,precision1,4096,64,13,18,18,1,3,11,0,320
after,2,strlen_full,4096,8,358,359,359,2,4,30,0,512
after,2,range_full,4096,8,90,90,90,2,4,9,0,512
after,2,strlen_empty,4096,64,2,6,6,2,3,3,0,64
after,2,snprintf1,4096,64,6,11,11,1,3,6,0,128
after,2,sprintf,4096,64,97,105,105,2,4,64,0,4289
after,2,empty_loop,65536,64,0,1,1,0,3,2,0,0
after,2,strnlen0,65536,64,0,1,1,0,3,3,0,0
after,2,strnlen1,65536,64,1,5,5,1,3,3,0,64
after,2,precision1,65536,64,13,18,18,1,3,11,0,320
after,2,strlen_full,65536,8,5711,5712,5712,2,4,458,0,8196
after,2,range_full,65536,8,1423,1448,1448,2,4,116,0,8207
after,2,strlen_empty,65536,64,2,7,7,2,3,4,0,64
after,2,snprintf1,65536,64,6,11,11,1,3,6,0,128
after,2,sprintf,65536,64,1430,1442,1442,2,4,919,0,65737
after,2,empty_loop,262144,64,0,1,1,0,3,2,0,0
after,2,strnlen0,262144,64,0,1,1,0,3,2,0,0
after,2,strnlen1,262144,64,1,6,6,1,3,3,0,64
after,2,precision1,262144,64,13,18,18,1,3,11,0,320
after,2,strlen_full,262144,8,22834,22857,22857,2,4,1829,0,32815
after,2,range_full,262144,8,5703,5704,5704,2,4,458,0,32772
after,2,strlen_empty,262144,64,2,6,6,2,3,3,0,65
after,2,snprintf1,262144,64,6,11,11,1,3,6,0,128
after,2,sprintf,262144,64,5710,5731,5731,2,4,3656,0,262428
before-unprobed,0,empty_loop,64,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen0,64,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen1,64,64,2,6,6,0,3,3,0,0
before-unprobed,0,precision1,64,64,18,22,22,0,9,14,0,0
before-unprobed,0,strlen_full,64,8,7,11,11,0,3,3,0,0
before-unprobed,0,range_full,64,8,1,2,2,0,3,2,0,0
before-unprobed,0,strlen_empty,64,64,2,6,6,0,3,4,0,0
before-unprobed,0,snprintf1,64,64,6,10,10,0,3,6,0,0
before-unprobed,0,sprintf,64,64,6,11,11,0,3,6,0,0
before-unprobed,0,empty_loop,4096,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen0,4096,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen1,4096,64,61,62,62,0,58,40,0,0
before-unprobed,0,precision1,4096,64,77,78,78,0,58,51,0,0
before-unprobed,0,strlen_full,4096,8,401,401,401,0,49,34,0,0
before-unprobed,0,range_full,4096,8,57,64,64,0,52,7,0,0
before-unprobed,0,strlen_empty,4096,64,61,62,62,0,59,40,0,0
before-unprobed,0,snprintf1,4096,64,66,67,67,0,60,44,0,0
before-unprobed,0,sprintf,4096,64,66,67,67,0,58,44,0,0
before-unprobed,0,empty_loop,65536,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen0,65536,64,0,7,7,0,3,2,0,0
before-unprobed,0,strnlen1,65536,64,922,937,937,0,918,66,527,0
before-unprobed,0,precision1,65536,64,938,949,949,0,920,78,525,0
before-unprobed,0,strlen_full,65536,8,6375,6388,6388,0,911,446,66,0
before-unprobed,0,range_full,65536,8,856,867,867,0,842,11,59,0
before-unprobed,0,strlen_empty,65536,64,922,932,932,0,919,67,526,0
before-unprobed,0,snprintf1,65536,64,926,945,945,0,917,68,528,0
before-unprobed,0,sprintf,65536,64,927,942,942,0,919,72,524,0
before-unprobed,0,empty_loop,262144,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen0,262144,64,0,1,1,0,3,2,0,0
before-unprobed,0,strnlen1,262144,64,3675,3690,3690,0,3670,70,2285,0
before-unprobed,0,precision1,262144,64,3694,3710,3710,0,3672,83,2284,0
before-unprobed,0,strlen_full,262144,8,25490,25502,25502,0,3672,1755,286,0
before-unprobed,0,range_full,262144,8,3412,3422,3422,0,3393,11,264,0
before-unprobed,0,strlen_empty,262144,64,3675,3694,3694,0,3670,69,2286,0
before-unprobed,0,snprintf1,262144,64,3679,3695,3695,0,3668,72,2287,0
before-unprobed,0,sprintf,262144,64,3680,3699,3699,0,3669,74,2285,0
before-unprobed,1,empty_loop,64,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen0,64,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen1,64,64,2,6,6,0,3,3,0,0
before-unprobed,1,precision1,64,64,18,22,22,0,9,14,0,0
before-unprobed,1,strlen_full,64,8,7,11,11,0,3,3,0,0
before-unprobed,1,range_full,64,8,1,2,2,0,3,2,0,0
before-unprobed,1,strlen_empty,64,64,2,6,6,0,3,4,0,0
before-unprobed,1,snprintf1,64,64,6,10,10,0,3,6,0,0
before-unprobed,1,sprintf,64,64,6,11,11,0,3,6,0,0
before-unprobed,1,empty_loop,4096,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen0,4096,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen1,4096,64,61,62,62,0,58,40,0,0
before-unprobed,1,precision1,4096,64,77,78,78,0,58,51,0,0
before-unprobed,1,strlen_full,4096,8,401,401,401,0,49,34,0,0
before-unprobed,1,range_full,4096,8,57,64,64,0,52,7,0,0
before-unprobed,1,strlen_empty,4096,64,61,62,62,0,59,40,0,0
before-unprobed,1,snprintf1,4096,64,66,67,67,0,60,44,0,0
before-unprobed,1,sprintf,4096,64,66,67,67,0,58,44,0,0
before-unprobed,1,empty_loop,65536,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen0,65536,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen1,65536,64,922,937,937,0,920,67,526,0
before-unprobed,1,precision1,65536,64,938,948,948,0,920,78,525,0
before-unprobed,1,strlen_full,65536,8,6375,6388,6388,0,909,446,66,0
before-unprobed,1,range_full,65536,8,856,863,863,0,853,10,60,0
before-unprobed,1,strlen_empty,65536,64,922,933,933,0,920,68,525,0
before-unprobed,1,snprintf1,65536,64,926,942,942,0,918,67,529,0
before-unprobed,1,sprintf,65536,64,927,942,942,0,920,70,526,0
before-unprobed,1,empty_loop,262144,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen0,262144,64,0,1,1,0,3,2,0,0
before-unprobed,1,strnlen1,262144,64,3675,3690,3690,0,3671,67,2289,0
before-unprobed,1,precision1,262144,64,3694,3714,3714,0,3669,88,2279,0
before-unprobed,1,strlen_full,262144,8,25490,25497,25497,0,3671,1755,286,0
before-unprobed,1,range_full,262144,8,3412,3419,3419,0,3403,10,265,0
before-unprobed,1,strlen_empty,262144,64,3675,3690,3690,0,3672,71,2285,0
before-unprobed,1,snprintf1,262144,64,3679,3695,3695,0,3671,71,2288,0
before-unprobed,1,sprintf,262144,64,3680,3695,3695,0,3672,70,2288,0
before-unprobed,2,empty_loop,64,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen0,64,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen1,64,64,2,6,6,0,3,3,0,0
before-unprobed,2,precision1,64,64,18,22,22,0,9,14,0,0
before-unprobed,2,strlen_full,64,8,7,11,11,0,3,3,0,0
before-unprobed,2,range_full,64,8,1,2,2,0,3,2,0,0
before-unprobed,2,strlen_empty,64,64,2,6,6,0,3,4,0,0
before-unprobed,2,snprintf1,64,64,6,10,10,0,3,6,0,0
before-unprobed,2,sprintf,64,64,6,11,11,0,3,6,0,0
before-unprobed,2,empty_loop,4096,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen0,4096,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen1,4096,64,61,62,62,0,58,40,0,0
before-unprobed,2,precision1,4096,64,77,78,78,0,58,51,0,0
before-unprobed,2,strlen_full,4096,8,401,401,401,0,49,34,0,0
before-unprobed,2,range_full,4096,8,57,64,64,0,52,7,0,0
before-unprobed,2,strlen_empty,4096,64,61,62,62,0,59,40,0,0
before-unprobed,2,snprintf1,4096,64,66,67,67,0,60,44,0,0
before-unprobed,2,sprintf,4096,64,66,67,67,0,58,44,0,0
before-unprobed,2,empty_loop,65536,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen0,65536,64,0,7,7,0,3,2,0,0
before-unprobed,2,strnlen1,65536,64,922,937,937,0,918,66,527,0
before-unprobed,2,precision1,65536,64,938,949,949,0,920,78,525,0
before-unprobed,2,strlen_full,65536,8,6375,6388,6388,0,911,446,66,0
before-unprobed,2,range_full,65536,8,856,867,867,0,842,11,59,0
before-unprobed,2,strlen_empty,65536,64,922,932,932,0,919,67,526,0
before-unprobed,2,snprintf1,65536,64,926,945,945,0,917,68,528,0
before-unprobed,2,sprintf,65536,64,927,942,942,0,919,72,524,0
before-unprobed,2,empty_loop,262144,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen0,262144,64,0,1,1,0,3,2,0,0
before-unprobed,2,strnlen1,262144,64,3675,3690,3690,0,3670,70,2285,0
before-unprobed,2,precision1,262144,64,3694,3710,3710,0,3672,83,2284,0
before-unprobed,2,strlen_full,262144,8,25490,25502,25502,0,3672,1755,286,0
before-unprobed,2,range_full,262144,8,3412,3422,3422,0,3393,11,264,0
before-unprobed,2,strlen_empty,262144,64,3675,3694,3694,0,3670,69,2286,0
before-unprobed,2,snprintf1,262144,64,3679,3695,3695,0,3668,72,2287,0
before-unprobed,2,sprintf,262144,64,3680,3699,3699,0,3669,74,2285,0
after-unprobed,0,empty_loop,64,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen0,64,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen1,64,64,1,6,6,0,3,3,0,0
after-unprobed,0,precision1,64,64,11,16,16,0,3,9,0,0
after-unprobed,0,strlen_full,64,8,5,6,6,0,3,2,0,0
after-unprobed,0,range_full,64,8,1,2,2,0,3,2,0,0
after-unprobed,0,strlen_empty,64,64,2,6,6,0,4,3,0,0
after-unprobed,0,snprintf1,64,64,5,10,10,0,3,6,0,0
after-unprobed,0,sprintf,64,64,7,12,12,0,3,7,0,0
after-unprobed,0,empty_loop,4096,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen0,4096,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen1,4096,64,1,6,6,0,3,3,0,0
after-unprobed,0,precision1,4096,64,11,16,16,0,3,9,0,0
after-unprobed,0,strlen_full,4096,8,330,342,342,0,3,28,0,0
after-unprobed,0,range_full,4096,8,65,66,66,0,3,7,0,0
after-unprobed,0,strlen_empty,4096,64,2,6,6,0,3,3,0,0
after-unprobed,0,snprintf1,4096,64,5,10,10,0,3,6,0,0
after-unprobed,0,sprintf,4096,64,71,74,74,0,3,47,0,0
after-unprobed,0,empty_loop,65536,64,0,1,1,0,3,3,0,0
after-unprobed,0,strnlen0,65536,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen1,65536,64,1,6,6,0,3,3,0,0
after-unprobed,0,precision1,65536,64,11,15,15,0,3,9,0,0
after-unprobed,0,strlen_full,65536,8,5300,5300,5300,0,4,426,0,0
after-unprobed,0,range_full,65536,8,1012,1019,1019,0,4,83,0,0
after-unprobed,0,strlen_empty,65536,64,2,6,6,0,3,3,0,0
after-unprobed,0,snprintf1,65536,64,5,10,10,0,3,5,0,0
after-unprobed,0,sprintf,65536,64,1018,1036,1036,0,4,654,0,0
after-unprobed,0,empty_loop,262144,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen0,262144,64,0,1,1,0,3,2,0,0
after-unprobed,0,strnlen1,262144,64,1,1,1,0,3,2,0,0
after-unprobed,0,precision1,262144,64,11,19,19,0,3,10,0,0
after-unprobed,0,strlen_full,262144,8,21184,21194,21194,0,4,1697,0,0
after-unprobed,0,range_full,262144,8,4051,4059,4059,0,4,326,0,0
after-unprobed,0,strlen_empty,262144,64,2,6,6,0,3,3,0,0
after-unprobed,0,snprintf1,262144,64,6,10,10,0,3,6,0,0
after-unprobed,0,sprintf,262144,64,4057,4075,4075,0,4,2600,0,0
after-unprobed,1,empty_loop,64,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen0,64,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen1,64,64,1,6,6,0,3,3,0,0
after-unprobed,1,precision1,64,64,11,16,16,0,3,9,0,0
after-unprobed,1,strlen_full,64,8,5,6,6,0,3,2,0,0
after-unprobed,1,range_full,64,8,1,2,2,0,3,2,0,0
after-unprobed,1,strlen_empty,64,64,2,6,6,0,4,3,0,0
after-unprobed,1,snprintf1,64,64,5,10,10,0,3,6,0,0
after-unprobed,1,sprintf,64,64,7,12,12,0,3,7,0,0
after-unprobed,1,empty_loop,4096,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen0,4096,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen1,4096,64,1,6,6,0,3,3,0,0
after-unprobed,1,precision1,4096,64,11,16,16,0,3,9,0,0
after-unprobed,1,strlen_full,4096,8,330,342,342,0,3,28,0,0
after-unprobed,1,range_full,4096,8,65,66,66,0,3,7,0,0
after-unprobed,1,strlen_empty,4096,64,2,6,6,0,3,3,0,0
after-unprobed,1,snprintf1,4096,64,5,10,10,0,3,6,0,0
after-unprobed,1,sprintf,4096,64,71,79,79,0,3,47,0,0
after-unprobed,1,empty_loop,65536,64,0,1,1,0,3,3,0,0
after-unprobed,1,strnlen0,65536,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen1,65536,64,1,1,1,0,3,3,0,0
after-unprobed,1,precision1,65536,64,11,15,15,0,3,9,0,0
after-unprobed,1,strlen_full,65536,8,5300,5300,5300,0,4,425,0,0
after-unprobed,1,range_full,65536,8,1012,1019,1019,0,4,83,0,0
after-unprobed,1,strlen_empty,65536,64,2,6,6,0,3,3,0,0
after-unprobed,1,snprintf1,65536,64,5,10,10,0,3,5,0,0
after-unprobed,1,sprintf,65536,64,1018,1036,1036,0,6,654,0,0
after-unprobed,1,empty_loop,262144,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen0,262144,64,0,1,1,0,3,2,0,0
after-unprobed,1,strnlen1,262144,64,1,1,1,0,3,2,0,0
after-unprobed,1,precision1,262144,64,11,19,19,0,3,10,0,0
after-unprobed,1,strlen_full,262144,8,21184,21194,21194,0,6,1697,0,0
after-unprobed,1,range_full,262144,8,4051,4059,4059,0,4,326,0,0
after-unprobed,1,strlen_empty,262144,64,2,6,6,0,3,3,0,0
after-unprobed,1,snprintf1,262144,64,5,10,10,0,3,6,0,0
after-unprobed,1,sprintf,262144,64,4057,4075,4075,0,6,2600,0,0
after-unprobed,2,empty_loop,64,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen0,64,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen1,64,64,1,6,6,0,3,3,0,0
after-unprobed,2,precision1,64,64,11,16,16,0,3,9,0,0
after-unprobed,2,strlen_full,64,8,5,6,6,0,3,2,0,0
after-unprobed,2,range_full,64,8,1,2,2,0,3,2,0,0
after-unprobed,2,strlen_empty,64,64,2,6,6,0,4,3,0,0
after-unprobed,2,snprintf1,64,64,5,10,10,0,3,6,0,0
after-unprobed,2,sprintf,64,64,7,12,12,0,3,7,0,0
after-unprobed,2,empty_loop,4096,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen0,4096,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen1,4096,64,1,6,6,0,3,3,0,0
after-unprobed,2,precision1,4096,64,11,16,16,0,3,9,0,0
after-unprobed,2,strlen_full,4096,8,330,342,342,0,3,28,0,0
after-unprobed,2,range_full,4096,8,65,66,66,0,3,7,0,0
after-unprobed,2,strlen_empty,4096,64,2,6,6,0,3,3,0,0
after-unprobed,2,snprintf1,4096,64,5,10,10,0,3,6,0,0
after-unprobed,2,sprintf,4096,64,71,74,74,0,3,47,0,0
after-unprobed,2,empty_loop,65536,64,0,1,1,0,3,3,0,0
after-unprobed,2,strnlen0,65536,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen1,65536,64,1,6,6,0,3,3,0,0
after-unprobed,2,precision1,65536,64,11,15,15,0,3,9,0,0
after-unprobed,2,strlen_full,65536,8,5300,5300,5300,0,4,426,0,0
after-unprobed,2,range_full,65536,8,1012,1019,1019,0,4,83,0,0
after-unprobed,2,strlen_empty,65536,64,2,6,6,0,3,3,0,0
after-unprobed,2,snprintf1,65536,64,5,10,10,0,3,5,0,0
after-unprobed,2,sprintf,65536,64,1018,1036,1036,0,4,654,0,0
after-unprobed,2,empty_loop,262144,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen0,262144,64,0,1,1,0,3,2,0,0
after-unprobed,2,strnlen1,262144,64,1,1,1,0,3,2,0,0
after-unprobed,2,precision1,262144,64,11,19,19,0,3,10,0,0
after-unprobed,2,strlen_full,262144,8,21184,21194,21194,0,4,1697,0,0
after-unprobed,2,range_full,262144,8,4051,4058,4058,0,4,326,0,0
after-unprobed,2,strlen_empty,262144,64,2,6,6,0,3,3,0,0
after-unprobed,2,snprintf1,262144,64,5,10,10,0,3,6,0,0
after-unprobed,2,sprintf,262144,64,4057,4075,4075,0,4,2600,0,0Honor per-call read limits, check strings in 64-byte chunks and stop at NUL. Share batched shadow scanning with range checks and bounded formatting output queries. Add shadow-read/lock-count and partial-granule boundary regressions. Validate 19 ARM/QEMU configurations, 10 Python tests, negative controls and QEMU SP804 latency comparisons.
BernardXiong
left a comment
There was a problem hiding this comment.
复核范围:27fb0794 → ea6b9d4e 的增量(9 个文件)。
aab8c4d已按仓库锁定的 clang-format 22.1.8 修复asan_tc.c、kstdio.c、kstring.c的格式问题,"Scan code format and license" 已转绿;ea6b9d4将 shadow 查询改为每 64 字节一次加锁批处理,新增 prefix 语义、在 NUL 处提前结束字符串检查,并补充 host 侧 oracle 测试(tools/testcases/test_asan_query.py,+185);- 复核 asan.c:123 的批处理边界、部分 granule 的 prefix 计算、limit 截断与 coverage 结束路径,未发现新的阻塞问题;
rt_asan_accessible_size()的签名变更仅影响组件内部及测试。
覆盖说明:本 PR 共 30 个文件、+4800 行,本次仅做增量复核,不宣称已完成完整代码审查;此前遗留的行内事项以 Rbb666/维护者结论为准。
Description / 描述
Add a heap-only runtime AddressSanitizer (kernel-address) for RT-Thread. It instruments memory accesses via GCC's
-fsanitize=kernel-addressand detects heap-buffer-overflow and use-after-free at runtime, with a FinSHasan_infocommand for interactive diagnosis.为 RT-Thread 新增仅针对堆的运行时 AddressSanitizer(kernel-address)。通过 GCC 的
-fsanitize=kernel-address对内存访问插桩,在运行时检测 堆缓冲区越界(heap-buffer-overflow) 和 释放后使用(use-after-free),并提供 FinSHasan_info命令进行交互式诊断。Why / 为什么需要
RT-Thread 在 MCU 目标上缺乏运行时内存安全检查(ASan 之前仅存在于 x86 模拟器)。堆越界与 use-after-free 是最常见的嵌入式内存 bug,本组件提供目标机上的运行时检测,且报告包含触发线程名与内存块归属信息。
What / 修改了哪些文件
components/asan/Kconfig:注册RT_USING_ASAN(含 shadow 大小 / track 表大小 / backtrace 开关)components/asan/SConscript:runtime 自身以-fno-sanitize=kernel-address编译避免递归components/asan/asan.c:shadow memory + 插桩访问检查 + 报告 + malloc/free/realloc hookcomponents/Kconfig:rsource "asan/Kconfig"src/SConscript:将 mem/memheap/slab 分配器移入非插桩编译组tools/building.py:GCC 下注入-fsanitize=kernel-addressHeap algorithm support / 堆算法支持
RT_USING_SMALL_MEM_AS_HEAP)RT_USING_SLAB_AS_HEAP)RT_USING_MEMHEAP_AS_HEAP)RT_USING_USERHEAP)Verification / 验证
asan_test_overflow(overflow by 2 bytes)、asan_test_uaf(USE-AFTER-FREE, offset +0)、asan_info全部命中kernel-address