Skip to content

Commit b225711

Browse files
committed
fixed examples and added a finalized PNG for #3 double-free
1 parent b1c1fdb commit b225711

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed
Loading

docs/sanitizers/examples-double-free.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help viewer_keywords: ["ASan","AddressSanitizer","Address Sanitizer","ASan examp
88

99
# Double free
1010

11-
In `C`, you can call `free()` erroneously. In `C++`, you can call delete more than once. In the following examples, we show errors with `delete`, `free()` and `HeapCreate()`. Sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
11+
In `C`, you can call `free()` erroneously. In `C++`, you can call `delete` more than once. In the following examples, we show errors with `delete`, `free()` and `HeapCreate()`. Sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
1212

1313
## Example C++ - double operator delete
1414

@@ -57,7 +57,6 @@ int main(int argc, char **argv) {
5757
return res;
5858
}
5959

60-
6160
```
6261
6362
From a **Developer Command Prompt**:

docs/sanitizers/examples-global-overflow.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ help viewer_keywords: ["ASan","AddressSanitizer","Address Sanitizer","ASan examp
88

99
# Global buffer overflow
1010

11-
The compiler generates metadata for any variable in the `.data` or `.bss` sections. These variables have language scope globals or file statics that are allocated in memory before main() starts. Global variables in `C` are treated much differently than `C++`. This difference is because of the complex rules for linking.
11+
The compiler generates metadata for any variable in the `.data` or `.bss` sections. These variables have language scope of global or file static. They are allocated in memory before main() starts. Global variables in `C` are treated much differently than `C++`. This difference is because of the complex rules for linking.
1212

1313
In `C`, a global variable can be declared in several source files and each definition can have different types. The compiler can't see all the possible definitions. The linker will see all the different definitions. The linker defaults to selecting the largest size of all the different declarations.
1414

1515
In `C++`, a global is allocated by the compiler. There can only be one definition so the size of each definition is known at compile time.
1616

17-
Examples sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
18-
1917
## Example - globals in 'C' with multiple type definitions
2018

2119
```cpp
@@ -53,6 +51,8 @@ From a **Developer Command Prompt**:
5351

5452
## Example - simple function level static
5553

54+
Example sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
55+
5656
```cpp
5757
#include <string.h>
5858

@@ -85,6 +85,8 @@ From a **Developer Command Prompt**:
8585
8686
## Example - all global scopes in C++
8787
88+
Example sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
89+
8890
```cpp
8991
// Run 4 different ways with the choice of one of these flags:
9092
//

docs/sanitizers/examples-stack-use-after-return.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This functionality requires code generation that is activated under an extra com
1212

1313
Consider the [Clang summary](https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn) of the algorithm supporting use after return, and the larger performance costs.
1414

15-
**Warning**: If you create an object file using the extra flag /fsanitize-address-use-after-return the code, generated by the compiler, will make a runtime decision on how to allocate a stack frame. If the environment variable ASAN_OPTIONS is **not** set to detect_stack_use_after_return, the code is still slower than **only** using /fsanitize=address. There's additional overhead from some stack frames allocating a frame using alloca() instead of putting the frame in the heap. It's best to delete these object files when you are finished processing use-after-return errors.
15+
**Warning**: If you create an object file using the extra flag `-fsanitize-address-use-after-return`, the code generated by the compiler, will make a runtime decision about how to allocate a stack frame. If the environment variable ASAN_OPTIONS is **not** set to detect_stack_use_after_return errors, the code is still slower than **only** using `/fsanitize=address`. It's slower because there's still additional overhead from some stack frames allocating space for parts of a frame using alloca(). It's best to delete these object files when you are finished processing use-after-return errors.
1616

1717
Examples sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
1818

0 commit comments

Comments
 (0)