Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
使用 build.sh --mssanitizer 编译单算子,编译“成功”,但产出的 kernel .o 不含任何 sanitizer 插桩符号(0 个 __sanitizer_report_*,对照 --ops-compile-options -sanitizer 有 500 个),运行 mssanitizer 工具时:
build.sh --mssanitizer
.o
__sanitizer_report_*
--ops-compile-options -sanitizer
racecheck
initcheck
synccheck
memcheck
此外纯 --mssanitizer(不带 --ops-compile-options -g)时连 debug 符号都没有(.o 的 .debug_* 段为 0)。
--mssanitizer
--ops-compile-options -g
.debug_*
bash build.sh --opkernel --soc=ascend910b --ops=moe_gating_top_k --mssanitizer # 验证:0 个插桩符号,0 个 debug 段 nm build/binary/ascend910b/bin/moe_gating_top_k/*.o | grep -c __sanitizer_report # -> 0 readelf -S build/binary/ascend910b/bin/moe_gating_top_k/*.o | grep -c '\.debug_' # -> 0 # 对照(正常路径):500 个插桩符号 + 15 个 debug 段 bash build.sh --opkernel --soc=ascend910b --ops=moe_gating_top_k --ops-compile-options -sanitizer
build/impl/dynamic/<op>.py
custom_compile_options.ini
cmake/config.cmake
prepare.sh
--enable_oom
ENABLE_MSSANITIZER
cmake/func.cmake
--cce-enable-sanitizer
is_enable_sanitizer
-sanitizer
-mllvm
libsanitizer_stub_dav-c220-*.a
undefined symbol: __sanitizer_report_store
opdesc_parser._set_all_options_to_opdescs
--ops-compile-options
-DNOT_DYNAMIC_COMPILE
--ops-compile-options=<value>
--op_debug_config=<value>
=
*)
check_param
--oom --ops-compile-options -sanitizer
--oom
'-g --cce-enable-oom'
-g
--mssanitizer 与 --ops-compile-options -sanitizer 等价:.o 含数百个 __sanitizer_report_* weak 符号 + debug 段(自动带 -g),mssanitizer 四种工具(memcheck/racecheck/initcheck/synccheck)均正常检测。
如上
/assign @weihao18
Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述 (Mandatory / 必填)
使用
build.sh --mssanitizer编译单算子,编译“成功”,但产出的 kernel.o不含任何 sanitizer 插桩符号(0 个__sanitizer_report_*,对照--ops-compile-options -sanitizer有 500 个),运行 mssanitizer 工具时:racecheck/initcheck/synccheck:被静默忽略(运行时库打 WARN "not supported on the kernel that without `--cce-enable-sanitizer' compiler option, thus it's temporarily ignored")memcheck:以降级模式工作(仅 GM 搬运指令的非法读写/非对齐检查,无调用栈、无泄漏检测),导致用户误以为编译链路正常此外纯
--mssanitizer(不带--ops-compile-options -g)时连 debug 符号都没有(.o的.debug_*段为 0)。Environment Information / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
根因(两层,任缺其一修复无效)
build/impl/dynamic/<op>.py)在 prepare 阶段按当时的custom_compile_options.ini固化编译选项。cmake/config.cmake调prepare.sh时传了--enable_oom却未传ENABLE_MSSANITIZER(prepare.sh 也不解析该参数),导致--mssanitizer的选项在 adapt py 生成前就已丢失;主阶段写回的 ini 不会被重新消费,直接 cat ini 看到的内容具有迷惑性。cmake/func.cmake注入--cce-enable-sanitizer(双横线,bisheng 层拼写),而 CANN 侧is_enable_sanitizer按 list 元素精确匹配-sanitizer(单横线,算子工程层拼写),判定失败后不追加-mllvm配套、不链接libsanitizer_stub_dav-c220-*.a——即使选项透传到 bisheng 也会链接失败(undefined symbol: __sanitizer_report_store)。附带问题(同 PR 一并修复)
opdesc_parser._set_all_options_to_opdescs对多行 ALL 配置直接赋值,后行覆盖前行:用户传--ops-compile-options会把 func.cmake 注入的行(含-sanitizer、-DNOT_DYNAMIC_COMPILE等)整行冲掉--ops-compile-options=<value>/--op_debug_config=<value>的=传值形式落入*)分支,静默打印 usage 退出(exit 1,无报错提示)check_param互斥检查只查变量组合:--oom --ops-compile-options -sanitizer等组合可绕过--mssanitizer的互斥拦截--oom虚标'-g --cce-enable-oom'(实际不带-g),未标注互斥关系Describe the expected behavior / 预期结果 (Mandatory / 必填)
--mssanitizer与--ops-compile-options -sanitizer等价:.o含数百个__sanitizer_report_*weak 符号 + debug 段(自动带-g),mssanitizer 四种工具(memcheck/racecheck/initcheck/synccheck)均正常检测。Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
如上
Special notes for this issue/备注 (Optional / 选填)