Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a51aba9
First attempt at invariant encoding
zafer-esen Sep 4, 2025
0eb901b
Merge branch 'master' into invariant-encoding
zafer-esen Sep 10, 2025
3f96674
Fixes several issues within the invariant encoding
zafer-esen Sep 11, 2025
232ce0c
Bug fixes in the invariant encoding
zafer-esen Sep 15, 2025
4f4ba9d
Add RW-fun and an Empty encoding
zafer-esen Sep 15, 2025
17a8de8
Change to standard directory structure, and other changes.
zafer-esen Sep 24, 2025
f401d97
Fixes nullAddr being used with invEncoding
zafer-esen Sep 24, 2025
9ad8895
Fixes a bug in handling jump statemetns
zafer-esen Sep 24, 2025
d7fd391
More helpful error message for stack ptrs + recursive functions
zafer-esen Sep 25, 2025
d6514b8
Update encodings
zafer-esen Sep 25, 2025
936c7c7
Fix error in RW-tag
zafer-esen Sep 26, 2025
c385c95
Fixes a bug in chained struct ptr accesses with the invariant heap en…
zafer-esen Sep 30, 2025
9693565
Invariant encoding: optimizes writes to structs with a single field a…
zafer-esen Sep 30, 2025
87d436f
Invariant encoding: fixes multiple bugs
zafer-esen Oct 1, 2025
cd28a2e
Invariant encoding: fixes a bug when comparing null with ptrs.
zafer-esen Oct 1, 2025
e4f1cbc
Removes abort and exit support in the grammar.
zafer-esen Oct 2, 2025
5c498f4
Treat static globals as global
zafer-esen Oct 2, 2025
365b47e
Move C preprocessor to own file, support size_t when using -cppLight
zafer-esen Oct 2, 2025
b81da26
Add support for bool to -cppLight
zafer-esen Oct 2, 2025
488723f
Fixes a bug in the heap model, update opt2 encoding
zafer-esen Oct 3, 2025
add32c5
Add mem safety assumption when not checking mem safety
zafer-esen Oct 3, 2025
2af7496
Fix a bug introduced in last commit when checking memsafety
zafer-esen Oct 3, 2025
95a90ca
Invariant encoding: add R-opt, R-tag-opt, RW-tag-opt. Clean up the ot…
zafer-esen Oct 6, 2025
1a4e552
Inv encoding: variant that adds p to the invariants
zafer-esen Oct 10, 2025
c6c21af
Merge branch 'master' into invariant-encoding
zafer-esen Oct 16, 2025
dc5bb9d
Merge branch 'master' into invariant-encoding
zafer-esen Oct 16, 2025
c10e734
Merge branch 'master' into invariant-encoding
zafer-esen Oct 16, 2025
84b3cec
Fix bug introduced during merge
zafer-esen Oct 16, 2025
abb2b54
Merge branch 'master' into invariant-encoding
zafer-esen Oct 16, 2025
34c9389
Answers
zafer-esen Oct 16, 2025
79ec168
Merge branch 'master' into invariant-encoding
zafer-esen Feb 1, 2026
c16c7cb
Fix errors from merge
zafer-esen Feb 1, 2026
fcae820
Include cpp headers in native image
zafer-esen Feb 1, 2026
dc645d1
Include heap encodings in native image
zafer-esen Feb 2, 2026
d9ccb02
Add reflect config for invariant encoding parser
zafer-esen Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ settings(
nativeImageOptions ++= Seq(
"--no-fallback",
"-H:+ReportExceptionStackTraces",
"--allow-incomplete-classpath"
"--allow-incomplete-classpath",
"-H:IncludeResources=tricera/headers/.*",
"-H:IncludeResources=tricera/heap/encodings/.*"
),

nativeImageAgentMerge := true
Expand Down
Binary file modified cc-parser/cc-parser.jar
Binary file not shown.
13 changes: 13 additions & 0 deletions regression-tests/horn-hcc-heap/inv-compare-zero-bug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
struct Node
{
struct Node* next;
int data;
};

void main()
{
struct Node* head = calloc(sizeof(struct Node));
assert(0 == head->next);
// This was failing when evaluating the RHS was adding clauses.
// E.g., when using the invariant encoding.
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
[
{
"name": "tricera.concurrency.heap.InvariantEncodingParser$Declaration",
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true
},
{
"name": "tricera.concurrency.heap.InvariantEncodingParser$Argument",
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true
},
{
"name": "tricera.concurrency.heap.InvariantEncodingParser$Predicate",
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true
},
{
"name": "tricera.concurrency.heap.InvariantEncodingParser$FunctionDef",
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true
},
{
"name": "tricera.concurrency.heap.InvariantEncodingParser$ParsedEncoding",
"allDeclaredFields": true,
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredConstructors": true,
"allPublicConstructors": true
},
{
"name": "ap.parser.IAtom[]"
},
Expand Down
42 changes: 42 additions & 0 deletions src/main/resources/tricera/headers/macros_ilp32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef MACROS_ILP32_H
#define MACROS_ILP32_H

#define CHAR_BIT 8

#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255

#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 65535

#define INT_MIN (-2147483648)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U

#define LONG_MIN (-2147483648L)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL

#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL

#define SIZE_MAX 4294967295U

typedef unsigned int size_t;
typedef int ptrdiff_t;

#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1

#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#define bool _Bool
#define true 1
#define false 0
#endif /* __bool_true_false_are_defined */

#endif
42 changes: 42 additions & 0 deletions src/main/resources/tricera/headers/macros_llp64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef MACROS_LLP64_H
#define MACROS_LLP64_H

#define CHAR_BIT 8

#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255

#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 65535

#define INT_MIN (-2147483648)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U

#define LONG_MIN (-2147483648L)
#define LONG_MAX 2147483647L
#define ULONG_MAX 4294967295UL

#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL

#define SIZE_MAX 18446744073709551615ULL

typedef unsigned long long size_t;
typedef long long ptrdiff_t;

#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1

#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#define bool _Bool
#define true 1
#define false 0
#endif /* __bool_true_false_are_defined */

#endif
42 changes: 42 additions & 0 deletions src/main/resources/tricera/headers/macros_lp64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef MACROS_LP64_H
#define MACROS_LP64_H

#define CHAR_BIT 8

#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255

#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 65535

#define INT_MIN (-2147483648)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U

#define LONG_MIN (-9223372036854775808L)
#define LONG_MAX 9223372036854775807L
#define ULONG_MAX 18446744073709551615UL

#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL

#define SIZE_MAX 18446744073709551615UL

typedef unsigned long size_t;
typedef long ptrdiff_t;

#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1

#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#define bool _Bool
#define true 1
#define false 0
#endif /* __bool_true_false_are_defined */

#endif
36 changes: 36 additions & 0 deletions src/main/resources/tricera/headers/macros_math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef MACROS_MATH_H
#define MACROS_MATH_H

#define CHAR_BIT 8

#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255

#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 65535

#define INT_MIN (-2147483648)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U

#define LLONG_MIN (-9223372036854775808LL)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL

#define NULL 0
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1

typedef unsigned int size_t;
typedef int ptrdiff_t;

#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#define bool _Bool
#define true 1
#define false 0
#endif /* __bool_true_false_are_defined */

#endif
81 changes: 81 additions & 0 deletions src/main/resources/tricera/heap/encodings/R-opt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Pointer type
ptr_type: "int"

# Global variables
global_decls:
- { name: "$allocCtr", type: "int", initial_value: "0" }
- { name: "$cnt", type: "unsigned int", initial_value: "0" }
- { name: "$last", type: "HEAP_TYPE", initial_value: null }
- { name: "$last_addr", type: "unsigned int", initial_value: null }
- { name: "$last_data", type: "HEAP_TYPE", initial_value: null }
- { name: "$p_g", type: "int", initial_value: null } # nondet init value

# Uninterpreted predicates
predicates:
- name: "$R"
args:
- { name: "cnt", type: "int" }
- { name: "last", type: "HEAP_TYPE" }

# Initialisation code injected to the start of entry function
init_code:
- "$p_g = _;"
- "$last = $HEAP_TYPE_DEFAULT();"

# Heap operations
read_fn:
return_type: "HEAP_TYPE"
args:
- { name: "p", type: "PTR_TYPE" }
- { name: "loc", type: "int" }
body: |
HEAP_TYPE result;
++$cnt;
if ($last_addr == p) {
result = $last_data;
} else {
if ($p_g == p) {
assert($R($cnt, $last));
result = $last;
} else {
result = HAVOC_HEAP;
assume($R($cnt, result));
}
$last_addr = p;
$last_data = result;
}
return result;

write_fn:
return_type: "void"
args:
- { name: "p", type: "PTR_TYPE" }
- { name: "e", type: "HEAP_TYPE" }
- { name: "loc", type: "int" }
body: |
++$cnt;
if (0 < p && p <= $allocCtr) {
$last_addr = p;
$last_data = e;
if ($p_g == p) { $last = e; }
}

alloc_fn:
return_type: "PTR_TYPE"
args:
- { name: "e", type: "HEAP_TYPE" }
- { name: "loc", type: "int" }
body: |
int p = ++$allocCtr;
++$cnt;
$last_addr = p;
$last_data = e;
if ($p_g == p) { $last = e; }
return p;

free_fn:
return_type: "void"
args:
- { name: "p", type: "PTR_TYPE" }
- { name: "loc", type: "int" }
body: ""
Loading
Loading