OLD | NEW |
(Empty) | |
| 1 ; Invalid access of a freed heap object. |
| 2 |
| 3 ; RUN: opt < %s -asan -S -asan-opt=1 -asan-opt-known-bounds=1 | FileCheck %s -ch
eck-prefix=OPT1 |
| 4 ; RUN: opt < %s -asan -S -asan-opt=0 | FileCheck %s -check-prefix=OPT0 |
| 5 |
| 6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
2:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:6
4-S128" |
| 7 target triple = "x86_64-unknown-linux-gnu" |
| 8 |
| 9 define noalias i32* @example(i64 %n) address_safety nounwind uwtable { |
| 10 entry: |
| 11 %call = tail call noalias i8* @malloc(i64 200) nounwind |
| 12 %0 = bitcast i8* %call to i32* |
| 13 tail call void @free(i8* %call) nounwind |
| 14 %conv = trunc i64 %n to i32 |
| 15 %arrayidx = getelementptr inbounds i8* %call, i64 12 |
| 16 %1 = bitcast i8* %arrayidx to i32* |
| 17 store i32 %conv, i32* %1, align 4 |
| 18 ret i32* %0 |
| 19 } |
| 20 |
| 21 declare noalias i8* @malloc(i64) nounwind |
| 22 |
| 23 declare void @free(i8* nocapture) nounwind |
| 24 |
| 25 ; OPT1: @example |
| 26 ; OPT1: call void @__asan_report_ |
| 27 ; OPT1-NOT: call void @__asan_report_ |
| 28 ; OPT1: @asan.module_ctor |
| 29 |
| 30 ; OPT0: @example |
| 31 ; OPT0: call void @__asan_report_ |
| 32 ; OPT0-NOT: call void @__asan_report_ |
| 33 ; OPT0: @asan.module_ctor |
| 34 |
| 35 ; C-example: #include <stdlib.h> |
| 36 ; C-example: |
| 37 ; C-example: int* example(size_t n) { |
| 38 ; C-example: int *array = malloc(50 * sizeof(int)); |
| 39 ; C-example: free(array); |
| 40 ; C-example: array[3] = n; // BUG |
| 41 ; C-example: return array; |
| 42 ; C-example: } |
OLD | NEW |