Skip to main content

C++ Crash Explainer

PyPI version CI Tests License: MIT Python Versions

A command-line developer tool that translates technical C++ AddressSanitizer (ASan) and LeakSanitizer (LSan) diagnostic reports into structured, actionable explanations.

Package distribution: https://pypi.org/project/cpp-crash-explainer/


Overview

AddressSanitizer is the standard instrumentation tool for detecting memory corruption and safety bugs in C and C++ programs. However, raw sanitizer reports are verbose, low-level, and difficult for students and junior developers to interpret quickly.

cpp-crash-explainer parses raw sanitizer output and provides:

  • Accurate error classification based on the report header.
  • Exact source code locations (file path, line number, and function name).
  • Extracted runtime metrics (access size, buffer dimensions, offset direction, allocation site, deallocation site).
  • Concrete debugging steps focused on common root causes (off-by-one errors, pointer scope, missing deallocations).
  • Explicit limitations regarding what cannot be derived from the report alone.

The tool does not compile code, execute binaries, or guess causes without report evidence.


Supported Categories

Category Extracted Data Typical Root Cause
Heap Buffer Overflow Access type (READ/WRITE), byte count, offset, buffer size, allocation site Out-of-bounds array access, incorrect loop bounds, allocation size mismatch
Heap Use-After-Free Access size, deallocation location, original allocation site, crash location Accessing dangling pointers, duplicate deletion, premature object cleanup
Stack Buffer Overflow Target stack variable, access size, crash function and line Exceeding fixed-size local stack array bounds
Stack Use-After-Scope Target scoped variable, frame location Storing or returning pointers to variables defined in inner blocks
Global Buffer Overflow Global variable name, definition file and line, overflow offset Out-of-bounds indexing of global or static variables
Null Pointer Dereference Target address (0x0 / zero page), access operation Dereferencing uninitialized pointers or unchecked return values
Memory Leak Leaked byte total, allocation count, allocation call site Failure to release dynamically allocated memory before program exit

Installation

Install the package directly from PyPI:

pip install cpp-crash-explainer

View the official package distribution page on PyPI: cpp-crash-explainer.

Requirements: Python 3.8 or higher. Standard library only; no external runtime dependencies.


Usage

1. File Input

Pass the path to a saved AddressSanitizer report:

cpp-crash-explainer report.txt

2. Standard Input (Piping)

Pipe the output of a sanitized binary directly:

./my_program 2>&1 | cpp-crash-explainer

3. Command-Line Options

usage: cpp-crash-explainer [-h] [--no-color] [report_file]

Explain C++ AddressSanitizer diagnostic reports in plain English.

positional arguments:
  report_file  Path to the file containing the AddressSanitizer report (reads stdin if omitted).

options:
  -h, --help   show this help message and exit
  --no-color   Disable ANSI colorized output.

Example Output

Given a standard AddressSanitizer report for an out-of-bounds heap read, cpp-crash-explainer produces:

C++ CRASH EXPLAINER

ERROR TYPE
Heap buffer overflow

WHAT HAPPENED
The program attempted to read or write memory outside the valid boundaries of a dynamically allocated (heap) array or object.

WHERE
/home/student/projects/buffer_test.cpp:14 (in function 'main')

WHAT THE REPORT TELLS US
The program crashed while reading 4 byte(s). The memory access occurred 4 byte(s) past the end of a 40-byte allocated heap buffer. The heap buffer was allocated at /home/student/projects/buffer_test.cpp:10.

WHAT TO CHECK NEXT
1. Check the array/buffer indexing at the crash location to see if the index exceeds the size.
2. Remember that in C++, an array of size N has valid indices from 0 to N-1 (off-by-one errors are common).
3. Check loop bounds (e.g., using '<=' instead of '<').
4. If using raw pointers or manual allocation (new[] / malloc), verify that the allocated byte size matches the data type.

LIMITATIONS
AddressSanitizer detects that an out-of-bounds address was accessed, but it cannot know what value you intended to calculate or why the index became invalid. Inspect the logic leading up to the access.

Development and Testing

Clone the repository and install development tools:

git clone https://github.com/khushi-sharma2506/cpp-crash-explainer.git
cd cpp-crash-explainer
pip install -e .
pip install pytest

Run the automated test suite:

pytest

Publishing and Releases

Releases to the Python Package Index (PyPI) are automated through GitHub Actions using OpenID Connect (OIDC) Trusted Publishing. Creating a published release on GitHub triggers the build, verification test matrix across Linux, Windows, and macOS, and uploads the distribution packages directly to PyPI.


License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for cpp-crash-explainer 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpp-crash-explainer 0.2.1
File Size Uploaded Provenance Actions
cpp_crash_explainer-0.2.1.tar.gz 14.9 kB Without provenance Details for cpp_crash_explainer-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cpp-crash-explainer 0.2.1
File Interpreter ABI Platform Actions
cpp_crash_explainer-0.2.1-py3-none-any.whl Python 3 none any Details for cpp_crash_explainer-0.2.1-py3-none-any.whl

Total release size: 28.8 kB

Release files / cpp_crash_explainer-0.2.1.tar.gz

Download URL cpp_crash_explainer-0.2.1.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
efdcd1dd11cf1fd95eb02078e58646fab365d1c7291e546c7effe7bc6d15d4fe
BLAKE2b-256 checksum
How to use checksums
310e2d868e714db6d1975d72ba2a8ff6622f2d4db53827264534f1db46a91735
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / cpp_crash_explainer-0.2.1-py3-none-any.whl

Download URL cpp_crash_explainer-0.2.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e584c8759774ac1548c902b9f57937cac7a31e04136c511736a762bd62d352c9
BLAKE2b-256 checksum
How to use checksums
70031b8ae966ce089c395b8a434714b4979f2317c99e9cd9aff5154674655cf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for cpp-crash-explainer 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page