Demystify memory access violations
- An explanation of the memory access violation
- A code snippet that illustrates what code causes the relevant category of memory access violation
- A live test to show how Stensal SDK can help developers find the cause with unambiguous error message.
Out-of-bounds array access
Out-of-bounds (OOB) array access (buffer overrun or buffer overflow) is the most common mistake made by developers. Traditional C/C++ implementations often do not enforce complete array bounds checking. OOB array access can read undefined values, silently corrupt data, or cause segmentation faults without any diagnostic information.
Stensal DTS enforces array bounds checking, and pinpoints OOB array accesses with diagnostic information and backtrace. It helps developers fix them much more quickly.
arrayOOB, but it does not always crash the program. It confused a developer. Test it
Null (or uninitialized) pointer dereference
Accessing null (or uninitialized) pointers is a common mistake resulting in "unexpected" segmentation faults.
Stensal DTS helps developers identify and fix the causes of "unexpected" segmentation fault by enforcing null pointer checks and reporting dereference of null pointers with diagnostic information and backtrace.
ais a stack allocated variable and is not initialized before being used at the highlighted line. Test it
In C/C++, stack allocated memory can be out-of-scope, and heap allocated memory can be freed even if it is still accessible in a program. Consequently, reading from a freed (or out-of-scope) memory might read undefined values, and writing a freed (or out-of-scope) memory might cause segmentation fault or corrupt data if the freed memory (or out-of-scope memory) is recycled and reused. Use-after-free, a term for such bugs, causes unpredictable behavior and is often hard to diagnose.
Stensal DTS detects use-after-free memory access violations with high probability, and reports the allocation information and the backtrace of access violation.
In C/C++, the pointer (or address) of a freed memory might still be accessible in a program, and be freed again. The memory that is freed once can be reallocated and reinitialized before the second free, which can cause intermittent crashes.
Stensal DTS detects double free with high probability. Double free is reported with the first allocation information and the backtrace of second free.
xafter the second malloc might be equal to the previous allocated address of
y. The highlighted
free(y)could free the memory pointed by
xand the subsequent using of
xcauses intermittent crashes. Test it
Constant data corruption
Constant data are mapped to read-only memory address space in C/C++. Writing data to read-only memory address space causes segmentation fault. Stensal DTS reports constant data corruption.