The code: void mul(double *p) { *p *= 2.0; } failed on x86_64 because register was not loaded after bound checking call. Also printed size when pointer indir failes.
Unified · Split
| @@ -588,8 +588,9 @@ void * __bound_ptr_indir ## dsize (void *p, size_t offset) \ · 587 unmodified lines | |||
| 588 | if (addr <= tree->size) { \ | 588 | if (addr <= tree->size) { \ |
| 589 | if (tree->is_invalid || addr + offset + dsize > tree->size) { \ | 589 | if (tree->is_invalid || addr + offset + dsize > tree->size) { \ |
| 590 | POST_SEM (); \ | 590 | POST_SEM (); \ |
| 591 | bound_warning("%p is outside of the region (0x%lx..0x%lx)", \ | 591 | bound_warning("%p (size %d) is outside of the region " \ |
| 592 | p + offset, (long)tree->start, \ | 592 | "(0x%lx..0x%lx)", \ |
| 593 | p + offset, dsize, (long)tree->start, \ | ||
| 593 | (long)(tree->start + tree->size - 1)); \ | 594 | (long)(tree->start + tree->size - 1)); \ |
| 594 | if (never_fatal <= 0) \ | 595 | if (never_fatal <= 0) \ |
| 595 | return INVALID_POINTER; /* return an invalid pointer */ \ | 596 | return INVALID_POINTER; /* return an invalid pointer */ \ |
| @@ -1,2 +1,2 @@ | |||
| 1 | 126_bound_global.c:11: at main: BCHECK: ........ is outside of the region (..................) | 1 | 126_bound_global.c:11: at main: BCHECK: ........ (size 4) is outside of the region (..................) |
| 2 | 126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access | 2 | 126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access |
| @@ -21,9 +21,17 @@ double scale(double d) · 20 unmodified lines | |||
| 21 | return x.d; | 21 | return x.d; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | void mul(double *p) | ||
| 25 | { | ||
| 26 | *p *= 2.0; | ||
| 27 | } | ||
| 28 | |||
| 24 | int | 29 | int |
| 25 | main(void) | 30 | main(void) |
| 26 | { | 31 | { |
| 32 | double d = 4.0; | ||
| 27 | printf("%g\n", scale(42)); | 33 | printf("%g\n", scale(42)); |
| 34 | mul(&d); | ||
| 35 | printf("%g\n", d); | ||
| 28 | return 0; | 36 | return 0; |
| 29 | } | 37 | } |
| @@ -1 +1,2 @@ | |||
| 1 | 42000 | 1 | 42000 |
| 2 | 8 | ||
| @@ -120,6 +120,7 @@ ST_FUNC void gen_struct_copy(int size); · 119 unmodified lines | |||
| 120 | 120 | ||
| 121 | ST_DATA const char * const target_machine_defs = | 121 | ST_DATA const char * const target_machine_defs = |
| 122 | "__x86_64__\0" | 122 | "__x86_64__\0" |
| 123 | "__x86_64\0" | ||
| 123 | "__amd64__\0" | 124 | "__amd64__\0" |
| 124 | ; | 125 | ; |
| 125 | 126 | ||
| @@ -2020,6 +2021,7 @@ void gen_opf(int op) · 1894 unmodified lines | |||
| 2020 | gv(RC_FLOAT); | 2021 | gv(RC_FLOAT); |
| 2021 | vswap(); | 2022 | vswap(); |
| 2022 | fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */ | 2023 | fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */ |
| 2024 | r = vtop->r; | ||
| 2023 | } | 2025 | } |
| 2024 | 2026 | ||
| 2025 | if ((ft & VT_BTYPE) == VT_DOUBLE) { | 2027 | if ((ft & VT_BTYPE) == VT_DOUBLE) { |