Ascend/msagent / skills/operator/mssanitizer-basic-usage
mssanitizer-basic-usage
Unverified昇腾AscendC算子异常检测工具(msSanitizer)。检测内存越界、内存泄漏、数据竞争、未初始化读取、同步异常等缺陷。触发关键词:mssanitizer、sanitizer、检测工具、内存检测、竞争检测、初始化检测、同步检测
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 24.7 KB |
| evals/evals.json | config | 6.8 KB |
| references/alarms.md | markdown | 29.6 KB |
| references/official_workflow.md | markdown | 25.1 KB |
| references/sample_initcheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_initcheck/README.md | markdown | 4.8 KB |
| references/sample_initcheck/initcheck.asc | other | 2.3 KB |
| references/sample_memcheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_memcheck/README.md | markdown | 4.9 KB |
| references/sample_memcheck/memcheck.asc | other | 2.4 KB |
| references/sample_racecheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_racecheck/README.md | markdown | 6.6 KB |
| references/sample_racecheck/racecheck.asc | other | 2.5 KB |
| references/sample_synccheck/CMakeLists.txt | markdown | 1.2 KB |
| references/sample_synccheck/README.md | markdown | 4.1 KB |
| references/sample_synccheck/synccheck.asc | other | 2.8 KB |
| scripts/parse_mssanitizer_report.py | script | 19.0 KB |
| scripts/run_mssanitizer.py | script | 12.3 KB |
references/sample_initcheck/initcheck.asc
View on GitHub/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
/* !
* \file initcheck.asc
* \brief 算子未初始化检测样例,演示 mssanitizer 对算子读取未初始化内存异常的检测和定位
*/
#include "acl/acl.h"
#include "kernel_operator.h"
class UninitReadDemo {
public:
__aicore__ inline UninitReadDemo() = default;
__aicore__ inline void Init(GM_ADDR buf)
{
srcGlobal.SetGlobalBuffer((__gm__ uint8_t*)buf, bufSize);
}
__aicore__ inline void Process()
{
AscendC::LocalMemAllocator<AscendC::Hardware::UB> ubAlloc;
AscendC::LocalTensor<uint8_t> localBuf = ubAlloc.Alloc<uint8_t, bufSize>();
// 从 Global Memory 读取数据,但 main() 中有意未初始化该内存
AscendC::DataCopy(localBuf, srcGlobal, bufSize);
}
private:
constexpr static uint32_t bufSize = 256;
AscendC::GlobalTensor<uint8_t> srcGlobal;
};
__global__ __vector__ void uninit_read_demo(GM_ADDR buf)
{
AscendC::InitSocState();
UninitReadDemo op;
op.Init(buf);
op.Process();
}
int32_t main(int32_t argc, char* argv[])
{
constexpr uint32_t bufSize = 256;
size_t bufBytes = bufSize * sizeof(uint8_t);
aclInit(nullptr);
int32_t deviceId = 0;
aclrtSetDevice(deviceId);
aclrtStream stream = nullptr;
aclrtCreateStream(&stream);
uint8_t* devBuf = nullptr;
aclrtMalloc((void**)&devBuf, bufBytes, ACL_MEM_MALLOC_HUGE_FIRST);
// 有意不对 devBuf 做初始化,算子内读取将触发未初始化告警
uninit_read_demo<<<1, nullptr, stream>>>(devBuf);
aclrtSynchronizeStream(stream);
aclrtFree(devBuf);
aclrtDestroyStream(stream);
aclrtResetDevice(deviceId);
aclFinalize();
return 0;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |