Overview

msSanitizer is an exception detection tool based on Ascend AI Processor. It provides three functions: memory check, contention check, and uninitialization check. After testing the operator functions in a real-world hardware environment by using the msOpST tool, you can determine whether to use the msSanitizer tool for exception detection based on the actual test situation.

  • Memory check: During operator development, the tool can locate memory problems such as illegal read/write, multi-core corruption, non-aligned access, memory leak, and illegal release. In addition, the tool can detect the memory of the CANN software stack, helping users locate the module with memory exception in the software stack.
  • Contention check: The tool helps users locate data contention problems that may be caused by contention risks, including intra-core contention and inter-core contention. Intra-core contention includes inter-pipeline contention and intra-pipeline contention.
  • Uninitialization check: The tool helps users locate dirty data read problems that may be caused by uninitialized memory.

    msSanitizer cannot detect exceptions for multi-thread operators, level-2 pointer operators, and vector computation instructions that use masks.

Features

msSanitizer provides different error detection functions. The following functions are supported:

Table 1 msSanitizer functions

Use Cases

Example

Sample

Operator memory check

Memory Check

  • msSanitizer supports memory and contention check of Ascend C operators (including Vector, Cube, and Mix fusion operators) called by kernel launch symbols. For details, see Memory Check.
  • msSanitizer supports memory and contention check of Ascend C operators (including Vector, Cube, and Mix fusion operators) called by AscendCL. For details, see Contention Check.

Operator contention check

Contention Check

Operator uninitialization check

Uninitialization Check

msSanitizer supports uninitialization detection of Ascend C operators (including Vector, Cube, and Mix fusion operators) called by AscendCL. For details, see Uninitialization Check.

Memory check of the CANN software stack

Memory Check

For details, see Checking the Memory of the CANN Software Stack.

Commands

You can run the following command to call msSanitizer:

mssanitizer <options> -- <user_program> <user_options>   
  • options is the command line option of the detection tool. For details about the available options and their default values, see Table 2 and Table 3. user_program indicates the user operator program, and user_options indicates the command line option of the user program.
  • If the executable file or user-defined program to be loaded contains command line options, use -- to separate the detection tool from the user command before the executable file or applications.
    mssanitizer -- application parameter1 parameter2 ...
  • Ensure the security of executable files and user-defined applications.
  • You need to ensure the execution security of executable files or applications.
    • You are advised to restrict the operation permission on executable files or applications to avoid privilege escalation risks.
    • You are not advised to perform high-risk operations (such as deleting files, deleting directories, changing passwords, and running privilege escalation commands) to avoid security risks.
Table 2 Common parameters

Parameter

Description

Value

Required

-v, --version

Queries the msSanitizer version.

-

No

-t, --tool

Specifies the sub-tool for exception detection.

  • memcheck: memory check (default)
  • racecheck: contention detection
  • initcheck: uninitialization check

No

--log-file

Specifies that the detection report is exported to a file.

{file_name}, for example, test_log

NOTE:
  • Only digits, uppercase letters, lowercase letters, hyphens (-), periods (.), slashes (/), and underscores (_) are supported.
  • To prevent log leakage, you are advised to restrict the file permission to ensure that only authorized personnel can access the file.

No

--log-level

Specifies the output level of the detection report.

  • info: outputs running information at the info, warn, and error levels.
  • warn: outputs running information at the warn and error levels (default).
  • error: outputs running information at the error level.

No

--max-debuglog-size

Specifies the maximum size of a single file in the debugging logs output by the detection tool.

The value is an integer ranging from 1 to 10240, in MB.

Defaults to 1024.

NOTE:

--max-debuglog-size=100 indicates that the maximum size of a debug log file is 100 MB.

No

-h, --help

Outputs the help information.

-

No

Table 3 Memory check options

Parameter

Description

Value

Required

--check-unused-memory

Whether to detect unused allocated memory

  • yes
  • no (default)

No

--leak-check

Whether to enable memory leak detection

  • yes
  • no (default)

No

--check-device-heap

Whether to enable device memory detection

  • yes
  • no (default)

No

--check-cann-heap

Whether to enable memory detection of the CANN software stack

  • yes
  • no (default)

No

  • After --check-device-heap or --check-cann-heap is enabled, the kernel is not checked.
  • The device memory detection and CANN software stack memory detection cannot be enabled at the same time. If they are enabled at the same time, the message "--check-cann-heap and --check-device-heap CANNOT both enabled" is displayed.
  • The to-be-detected program that is recompiled using the API header file provided by the msSanitizer tool can be used only for leakage detection of AscendCL interfaces and cannot be used for detection of device interfaces.

Call Scenarios

The following operator call scenarios are supported

Result Files

Result File

Description

mssanitizer_{TIMESTAMP}_{PID}.log

msSanitizer logs generated in the current directory during msSanitizer running. TIMESTAMP indicates the current timestamp, and PID indicates the PID of the current detection tool.

kernel.{PID}.o

Operator cache file generated in the current path during the running of msSanitizer. PID is the PID of the detection tool in use. The operator cache file is used to parse the abnormal call stack.

  • In normal cases, the operator cache file is automatically cleared when msSanitizer exits.
  • When msSanitizer exits abnormally (for example, terminated by pressing CTRL+C), the operator cache file is retained in the file system. The operator cache file contains the debugging information of the operator. You are advised to restrict the access permission of other users to the file, and delete the file as soon as possible after the detection tool is executed.