Skip to main content

C++ Crash Explainer

PyPI version CI Tests License: MIT Python Versions

A beginner-friendly developer tool that translates cryptic C++ AddressSanitizer (ASan) and LeakSanitizer (LSan) diagnostic reports into plain, actionable English.


🎯 Supported Diagnostic Categories

Error Type What Gets Extracted Common Root Cause
Heap buffer overflow Access type (READ/WRITE), byte count, offset past buffer, allocation site. Off-by-one array loop, improper new[] size.
Heap use-after-free Byte size, deallocation line, original allocation site, crash line. Dangling pointer, premature delete.
Stack buffer overflow Overflowed local stack variable name, byte count, crash line. Writing past fixed-size local array (buf[N]).
Stack use-after-scope Variable name that went out of scope, frame location. Storing/returning pointer to inner block variable.
Global buffer overflow Global variable name, definition file & line, overflow offset. Writing past bounds of global/static array.
Null pointer deref Null target address (0x0 / zero page), memory access type. Dereferencing unchecked nullptr return.
Memory leaks Leaked byte count, allocation count, allocation call site. Missing delete / free before program exit.

Compiling C++ programs with -fsanitize=address is the gold standard for catching memory safety errors (like buffer overflows and use-after-free bugs). However, the default diagnostic output is verbose, technical, and often overwhelms students and beginners.

C++ Crash Explainer parses the raw ASan crash report and provides:

  1. Error Type: What kind of bug happened in clear terms.
  2. Where: The exact source file, line number, and function where the crash occurred.
  3. What The Report Tells Us: Facts extracted from the report (how many bytes were read/written, buffer size, allocation site).
  4. What To Check Next: Actionable hints on common root causes (off-by-one errors, loop boundaries, pointer math).
  5. Limitations: Clear statements on what the report cannot know so beginners don't make assumptions.

🚀 Quick Start

Installation

pip install cpp-crash-explainer

Usage

Pass a saved AddressSanitizer report file directly:

cpp-crash-explainer report.txt

Or pipe a crash output directly via standard input:

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

💡 Example

Given an AddressSanitizer heap-buffer-overflow report, the tool outputs:

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. You must inspect the logic leading up to the access.

🧪 Running Tests

pytest

Metadata

Release files for cpp-crash-explainer 0.2.0

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.0
File Size Uploaded Provenance Actions
cpp_crash_explainer-0.2.0.tar.gz 13.9 kB Without provenance Details for cpp_crash_explainer-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 27.4 kB

Release files / cpp_crash_explainer-0.2.0.tar.gz

Download URL cpp_crash_explainer-0.2.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bb1894b158cb44d1f802588b9abab16fe0f4a4b2c730f465e92948d926dc2604
BLAKE2b-256 checksum
How to use checksums
0778d7e501bd65c8e7ed6ed1c1d4cbf205a84500e8768313a7bf30965186a86e
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.0-py3-none-any.whl

Download URL cpp_crash_explainer-0.2.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12cc9e4235f30c04a967e1c47757b6a9795d092e0955d12eef26df69e7857ede
BLAKE2b-256 checksum
How to use checksums
a6b279debc063a3d96affb438b9e3f6c51305aa5e2157bfd44cc1b19601c0c3b
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.0

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