Example: unrep1.c

up: index
prev: ghost2.c
next: unrep1a.c

    #include <stdint.h>
    #include <stdio.h>
    #include "capprint.h"
    
    int main()
    {
        int x=42;
        intptr_t ip = (intptr_t)&x;
        fprintf(stderr,"Before %" PTR_FMT "\n", sptr((void*)ip));
        intptr_t ip1 = ip - 0xffff0000; //may become non-representable
        fprintf(stderr,"Intermediate %" PTR_FMT "\n", sptr((void*)ip1));
        ip1 = ip1 + 0xffff0000;
        fprintf(stderr,"After %" PTR_FMT "\n", sptr((void*)ip1));
        fprintf(stderr,"Value=%d\n", *((int*)ip1));
    }

Experimental data (what does this mean?)

cerberus-cheri-no-pnvi
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia-no-pnvi
 exit codes: compile 0 / execute 1 Undefined {ub: "UB_CHERI_UndefinedTag", loc: "<14:36--14:48>"}
Before (@disabled, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Intermediate (@disabled, 0xe700 [?-?] (notag))
After (@disabled, 0xffffe700 [?-?] (notag))
 
cerberus-cheri
cerberus-cheri-revocation
cerberus-cheri-cornucopia
 exit codes: compile 0 / execute 1 Undefined {ub: "UB_CHERI_UndefinedTag", loc: "<14:36--14:48>"}
Before (@83, 0xffffe700 [rwRW,0xffffe700-0xffffe704])
Intermediate (@empty, 0xe700 [?-?] (notag))
After (@83, 0xffffe700 [?-?] (notag))
 
clang-riscv-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cs2.
0x0000000000102142 in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000102142 in main () at tests/cheri/unrep1.c:14
x = <optimized out>
ip = <optimized out>
ip1 = <optimized out>


Before 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Intermediate 0x3effe0ff1c [rwRW,0x3effe0ff1c-0x3effe0ff20] (invalid)
After 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)
 
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 tag fault caused by register ca2.
0x0000000000102112 in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000102112 in main () at tests/cheri/unrep1.c:14
x = 42
ip = -61824678692139721007568759220435157140
ip1 = -61824678692139721007568759220435157140


Before 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Intermediate 0x3effe0ff6c [rwRW,0x3effe0ff6c-0x3effe0ff70] (invalid)
After 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70] (invalid)
 
clang-riscv-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault caused by register cfp.
0x000000000010212c in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x000000000010212c in main () at tests/cheri/unrep1.c:14
x = <optimized out>
ip1 = <optimized out>
ip = <optimized out>


Before 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20]
Intermediate 0x3effe0ff1c [rwRW,0x3effe0ff1c-0x3effe0ff20] (invalid)
After 0x3fffdfff1c [rwRW,0x3fffdfff1c-0x3fffdfff20] (invalid)
 
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 tag fault caused by register ca1.
0x00000000001020be in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x00000000001020be in main () at tests/cheri/unrep1.c:14
x = 42
ip = -61824678692139721007568759220435157140
ip1 = -61824678692139721007568759220435157140


Before 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70]
Intermediate 0x3effe0ff6c [rwRW,0x3effe0ff6c-0x3effe0ff70] (invalid)
After 0x3fffdfff6c [rwRW,0x3fffdfff6c-0x3fffdfff70] (invalid)
 
clang-morello-O3-bounds-subobject-safe exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
0x0000000000111178 in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000111178 in main () at tests/cheri/unrep1.c:14
x = 42
ip = 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
ip1 = 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0] (invalid)


Before 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0]
Intermediate 0xfffefff8feec [rwRW,0xfffefff8feec-0xfffefff8fef0] (invalid)
After 0xfffffff7feec [rwRW,0xfffffff7feec-0xfffffff7fef0] (invalid)
 
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 tag fault.
0x0000000000110f90 in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000110f90 in main () at tests/cheri/unrep1.c:14
x = 42
ip = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
ip1 = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)


Before 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Intermediate 0xfffefff8ff5c [rwRW,0xfffefff8ff5c-0xfffefff8ff60] (invalid)
After 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)
 
clang-morello-O3-bounds-conservative exit codes: compile 0 / execute 1
Program received signal SIGPROT, CHERI protection violation.
Capability tag fault.
main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 main () at tests/cheri/unrep1.c:14
x = 42
ip = <optimized out>
ip1 = 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10] (invalid)


Before 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10]
Intermediate 0xfffefff8ff0c [rwRW,0xfffefff8ff0c-0xfffefff8ff10] (invalid)
After 0xfffffff7ff0c [rwRW,0xfffffff7ff0c-0xfffffff7ff10] (invalid)
 
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 tag fault.
0x0000000000110f3c in main () at tests/cheri/unrep1.c:14
14 fprintf(stderr,"Value=%d\n", *((int*)ip1));
#0 0x0000000000110f3c in main () at tests/cheri/unrep1.c:14
x = 42
ip = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
ip1 = 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)


Before 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60]
Intermediate 0xfffefff8ff5c [rwRW,0xfffefff8ff5c-0xfffefff8ff60] (invalid)
After 0xfffffff7ff5c [rwRW,0xfffffff7ff5c-0xfffffff7ff60] (invalid)
 
gcc-morello-O3 Before 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Intermediate 0xffffffff8000ffdc [rwRW,0xffffffff8000ffdc-0xffffffff8000ffe0] (invalid)
After 0x7fffffdc [rwRW,0x7fffffdc-0x7fffffe0]
Value=42
 
gcc-morello-O0 exit codes: compile 0 / execute 137 Before 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0]
Intermediate 0xffffffff8000ffbc [rwRW,0xffffffff8000ffbc-0xffffffff8000ffc0] (invalid)
After 0x7fffffbc [rwRW,0x7fffffbc-0x7fffffc0] (invalid)