Example: bounds1.c

up: index
prev: modptr7a.c
next: bounds2.c

    #include <stdio.h>
    
    int main()
    {
        int y=42;
        int x=43;
        int z=44;
    
        int v=*(&x -1); //OOB memory access
        
        fprintf(stderr,"Read: %d\n",v);
    }
    
    

Experimental data (what does this mean?)

cerberus-cheri
cerberus-cheri-no-pnvi
cerberus-cheri-revocation
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia
cerberus-cheri-cornucopia-no-pnvi
 exit codes: compile 0 / execute 1 Undefined {ub: "UB046_array_pointer_outside", loc: "<9:12--9:19>"}
 
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault caused by register ca0.
0x00000000001017b8 in main () at tests/cheri/bounds1.c:9
9 int v=*(&x -1); //OOB memory access
#0 0x00000000001017b8 in main () at tests/cheri/bounds1.c:9
y = 42
x = 43
z = <optimized out>
v = <optimized out>


 
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault caused by register ca0.
0x00000000001017e6 in main () at tests/cheri/bounds1.c:9
9 int v=*(&x -1); //OOB memory access
#0 0x00000000001017e6 in main () at tests/cheri/bounds1.c:9
y = 42
x = 43
z = 44
v = 0


 
clang-riscv-O0-bounds-conservative
clang-riscv-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault caused by register ca0.
main () at tests/cheri/bounds1.c:9
9 int v=*(&x -1); //OOB memory access
#0 main () at tests/cheri/bounds1.c:9
y = 42
x = 43
z = 44
v = 0


 
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault.
0x000000000011078c in main () at tests/cheri/bounds1.c:11
11 fprintf(stderr,"Read: %d\n",v);
#0 0x000000000011078c in main () at tests/cheri/bounds1.c:11
y = 42
x = 43
z = 44
v = <optimized out>


 
clang-morello-O0-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault.
0x0000000000110790 in main () at tests/cheri/bounds1.c:9
9 int v=*(&x -1); //OOB memory access
#0 0x0000000000110790 in main () at tests/cheri/bounds1.c:9
y = 42
x = 43
z = 44
v = 0


 
clang-morello-O3-bounds-conservative
clang-riscv-O3-bounds-conservative
 Read: 0
 
clang-morello-O0-bounds-conservative
clang-morello-O0-bounds-references-only
 exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability bounds fault.
main () at tests/cheri/bounds1.c:9
9 int v=*(&x -1); //OOB memory access
#0 main () at tests/cheri/bounds1.c:9
y = 42
x = 43
z = 44
v = 0


 
gcc-morello-O3 tests/cheri/bounds1.c: In function 'main':
tests/cheri/bounds1.c:9:9: warning: array subscript -1 is outside array bounds of 'int[1]' [-Warray-bounds]
9 | int v=*(&x -1); //OOB memory access
| ^
tests/cheri/bounds1.c:6:9: note: while referencing 'x'
6 | int x=43;
| ^
Read: 0
 
gcc-morello-O0 exit codes: compile 0 / execute 137