Hauptinhalt

Memory errors (-sanitizer-selection memory)

R2026b

Enable detection of memory errors at runtime

Since R2026b

Description

Specify whether the sanitizer detects memory safety violations at runtime. Memory errors include null pointer dereference, out-of-bounds pointer access, use-after-free, double deallocation, invalid free or delete operations, memory allocation errors, and standard library memory errors.

Set Option

Set the option using one of these methods:

  • Polyspace Platform user interface (desktop products only): In your project configuration, on the Testing and Profiling tab, select the Sanitizer node, select Select by category, and then select or clear this option.

  • Command line: Use the option -sanitizer-selection and include memory in the comma-separated list. See Command-Line Information.

  • Python® API: Set the Memory property in the testing and profiling configuration. See polyspace.project.TestConfiguration.

  • TOML configuration file (.toml.pscfg) — Use the key Memory in the [SanitizerOptions] table. For example:

    [SanitizerOptions]
    Memory = true

Why Use This Option

Use this option to detect memory safety violations in your code at runtime. The sanitizer instruments your source code to check for errors such as:

  • Null pointer dereference

  • Out-of-bounds pointer access

  • Use-after-free

  • Double deallocation

  • Invalid free or delete operations

  • Unprotected memory allocation

  • Standard library memory errors

Settings

On (default)

The sanitizer detects memory errors at runtime.

Off

The sanitizer does not detect memory errors.

Dependencies

This option is available only when you select Select by category as the sanitizer selection mode.

Command-Line Information

The command-line workflow for setting this option depends on your workflow.

  • If you build your source and tests using a Polyspace Platform Project — Once you set this option in the project using the Polyspace Platform user interface, you cannot override or modify this option using the polyspace-test command.

  • If you build your sources and xUnit tests using your own toolchain — Specify this option to the polyspace-code-profiler command.

Parameter: -sanitizer-selection
Value: Include memory in comma-separated list of error categories
Default: on
Example: polyspace-code-profiler -instrument -instrum-dir instrumFolder -sanitizer -sanitizer-selection numeric,memory -- compileCommand

Version History

Introduced in R2026b