Skip to content

Commit 4b6bdc5

Browse files
hernanponcedeleonhernan-poncedeleonxeren
committed
Version 4.3.1 (hernanponcedeleon#954)
This PR adds several changes related to SVCOMP 2026 - minor fixes (witness generation for data-races, UBSAN instrumentation options, removed unsound intrinsic) - support for the mem-track property - fix missing calls to TSS destructors --------- Signed-off-by: Hernan Ponce de Leon <hernanl.leon@huawei.com> Co-authored-by: Hernan Ponce de Leon <hernanl.leon@huawei.com> Co-authored-by: René Maseli <r.maseli@tu-bs.de>
1 parent ca84bd2 commit 4b6bdc5

54 files changed

Lines changed: 3025 additions & 2025 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/miscellaneous/pthread.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void key_test()
402402
status = pthread_key_delete(local_data);
403403
assert(status == 0);
404404

405-
//assert(pthread_equal(latest_thread, worker));//TODO add support for destructors
405+
assert(pthread_equal(latest_thread, worker));
406406
}
407407

408408
// -------- detaching threads
@@ -455,9 +455,11 @@ void detach_test()
455455

456456
int main()
457457
{
458-
mutex_test();
459-
cond_test();
460-
rwlock_test();
461-
key_test();
462-
detach_test();
458+
switch (__VERIFIER_nondet_int()) {
459+
case 1: mutex_test(); break;
460+
case 2: cond_test(); break;
461+
case 3: rwlock_test(); break;
462+
case 4: key_test(); break;
463+
case 5: detach_test(); break;
464+
}
463465
}

benchmarks/mixed/memtrack1-fail.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdlib.h>
2+
int* volatile m_global;
3+
int main()
4+
{
5+
m_global = (int*) malloc(sizeof(int));
6+
*((char volatile*) &m_global) = '\0';
7+
return 0;
8+
}

benchmarks/mixed/memtrack2-pass.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdlib.h>
2+
int* volatile m_global;
3+
int main()
4+
{
5+
m_global = (int*) malloc(sizeof(int));
6+
int* temp = m_global;
7+
*((char volatile*) &m_global) = '\0';
8+
m_global = temp;
9+
return 0;
10+
}

benchmarks/mixed/memtrack3-pass.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdlib.h>
2+
int* volatile m_global;
3+
int main()
4+
{
5+
m_global = (int*) malloc(sizeof(int));
6+
int* temp = m_global;
7+
*((char volatile*) &m_global) = '\0';
8+
free(temp);
9+
return 0;
10+
}

dartagnan/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.dat3m</groupId>
77
<artifactId>dat3m</artifactId>
8-
<version>4.3.0</version>
8+
<version>4.3.1</version>
99
</parent>
1010
<artifactId>dartagnan</artifactId>
1111
<packaging>jar</packaging>

dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.dat3m.dartagnan.program.event.Tag;
2020
import com.dat3m.dartagnan.program.event.core.Assert;
2121
import com.dat3m.dartagnan.program.event.core.CondJump;
22+
import com.dat3m.dartagnan.program.memory.MemoryObject;
2223
import com.dat3m.dartagnan.program.processing.LoopUnrolling;
2324
import com.dat3m.dartagnan.program.Entrypoint;
2425
import com.dat3m.dartagnan.utils.ExitCode;
@@ -316,7 +317,7 @@ private static void generateWitnessIfAble(VerificationTask task, ProverEnvironme
316317
// ------------------ Generate Witness, if possible ------------------
317318
final EnumSet<Property> properties = task.getProperty();
318319
if (task.getProgram().getFormat().equals(SourceLanguage.LLVM) && modelChecker.hasModel()
319-
&& (properties.contains(PROGRAM_SPEC) || properties.contains(DATARACEFREEDOM)) && properties.size() == 1
320+
&& (properties.contains(PROGRAM_SPEC) || properties.contains(DATARACEFREEDOM))
320321
&& modelChecker.getResult() != UNKNOWN) {
321322
try {
322323
WitnessBuilder w = WitnessBuilder.of(modelChecker.getEncodingContext(), prover,
@@ -362,14 +363,7 @@ private static ResultSummary summaryFromResult(VerificationTask task, ModelCheck
362363
.stream().filter(model::assertionViolated)
363364
.toList();
364365
for (Assert ass : violations) {
365-
final String callStack = makeContextString(synContext.getContextInfo(ass).getContextOfType(CallContext.class), " -> ");
366-
details
367-
.append("\tE").append(ass.getGlobalId())
368-
.append(":\t")
369-
.append(callStack.isEmpty() ? callStack : callStack + " -> ")
370-
.append(getSourceLocationString(ass))
371-
.append(": ").append(ass.getErrorMessage())
372-
.append("\n");
366+
appendTo(details, ass, synContext);
373367
}
374368
// In validation mode, we expect to find the violation, thus NORMAL_TERMINATION
375369
ExitCode code = task.getWitness().isEmpty() ? PROGRAM_SPEC_VIOLATION : NORMAL_TERMINATION;
@@ -385,14 +379,7 @@ private static ResultSummary summaryFromResult(VerificationTask task, ModelCheck
385379
&& model.isBlocked(barrier);
386380

387381
if (isStuckLoop || isStuckBarrier) {
388-
final String callStack = makeContextString(
389-
synContext.getContextInfo(e).getContextOfType(CallContext.class), " -> ");
390-
details
391-
.append("\tE").append(e.getGlobalId())
392-
.append(":\t")
393-
.append(callStack.isEmpty() ? callStack : callStack + " -> ")
394-
.append(getSourceLocationString(e))
395-
.append("\n");
382+
appendTo(details, e, synContext);
396383
}
397384
}
398385
// In validation mode, we expect to find the violation, thus NORMAL_TERMINATION
@@ -405,6 +392,16 @@ private static ResultSummary summaryFromResult(VerificationTask task, ModelCheck
405392
ExitCode code = task.getWitness().isEmpty() ? DATA_RACE_FREEDOM_VIOLATION : NORMAL_TERMINATION;
406393
return new ResultSummary(path, filter, FAIL, condition, reason, details.toString(), time, code);
407394
}
395+
if (props.contains(TRACKABILITY) && model.propertyViolated(TRACKABILITY)) {
396+
reason = ResultSummary.SVCOMP_UNTRACKABLE_OBJECT_REASON;
397+
for (MemoryObject o : p.getMemory().getObjects()) {
398+
if (model.isLeaked(o) && !model.isTrackable(o)) {
399+
appendTo(details, o.getAllocationSite(), synContext);
400+
}
401+
}
402+
ExitCode code = task.getWitness().isEmpty() ? MEMORY_TRACKABILITY_VIOLATION : NORMAL_TERMINATION;
403+
return new ResultSummary(path, filter, FAIL, condition, reason, details.toString(), time, code);
404+
}
408405
final List<Axiom> violatedCATSpecs = !props.contains(CAT_SPEC) ? List.of()
409406
: task.getMemoryModel().getAxioms().stream()
410407
.filter(Axiom::isFlagged)
@@ -447,6 +444,17 @@ private static ResultSummary summaryFromResult(VerificationTask task, ModelCheck
447444
return new ResultSummary(path, filter, result, condition, reason, details.toString(), time, code);
448445
}
449446

447+
private static void appendTo(StringBuilder details, Event event, SyntacticContextAnalysis synContext) {
448+
final String callStack = makeContextString(synContext.getContextInfo(event).getContextOfType(CallContext.class), " -> ");
449+
details.append("\tE").append(event.getGlobalId())
450+
.append(":\t").append(callStack.isEmpty() ? callStack : callStack + " -> ")
451+
.append(getSourceLocationString(event));
452+
if (event instanceof Assert ass) {
453+
details.append(": ").append(ass.getErrorMessage());
454+
}
455+
details.append("\n");
456+
}
457+
450458
private static void increaseBoundAndDump(List<Event> boundEvents, Configuration config) throws IOException {
451459
if(!config.hasProperty(BOUNDS_SAVE_PATH)) {
452460
return;

dartagnan/src/main/java/com/dat3m/dartagnan/configuration/Property.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ public enum Property implements OptionInterface {
1414
PROGRAM_SPEC, // Litmus queries OR assertion safety in C-code
1515
TERMINATION, // All executions terminate (absence of deadlocks/livelocks)
1616
CAT_SPEC, // CAT-spec defined via flagged axioms in .cat file (~bug specification)
17-
DATARACEFREEDOM; // Special option for data-race detection in SVCOMP only
18-
17+
DATARACEFREEDOM, // Special option for data-race detection in SVCOMP only
18+
TRACKABILITY, // All heap-allocated objects are either freed or remain reachable at the end of the execution.
19+
;
1920

2021
public enum Type {
2122
SAFETY,
@@ -31,6 +32,7 @@ public String toString() {
3132
case DATARACEFREEDOM -> "Data-race freedom (SVCOMP only)";
3233
case TERMINATION -> "Termination";
3334
case CAT_SPEC -> "CAT specification";
35+
case TRACKABILITY -> "Memory Trackability";
3436
};
3537
}
3638

@@ -66,7 +68,7 @@ public static EnumSet<Property> getDefault() {
6668

6769
// Used to decide the order shown by the selector in the UI
6870
public static Property[] orderedValues() {
69-
Property[] order = {PROGRAM_SPEC, TERMINATION, CAT_SPEC, DATARACEFREEDOM};
71+
Property[] order = {PROGRAM_SPEC, TERMINATION, CAT_SPEC, DATARACEFREEDOM, TRACKABILITY};
7072
// Be sure no element is missing
7173
assert (Arrays.asList(order).containsAll(Arrays.asList(values())));
7274
return order;

dartagnan/src/main/java/com/dat3m/dartagnan/encoding/EncodingContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ public BooleanFormula sameValue(MemoryCoreEvent first, MemoryCoreEvent second) {
209209
return objSize.get(memoryObject);
210210
}
211211

212+
/// Describes that {@code object} has been allocated, but has not been deallocated during the execution.
213+
public BooleanFormula leakVariable(MemoryObject object) {
214+
final int allocationSiteId = object.getAllocationSite().getGlobalId();
215+
return booleanFormulaManager.makeVariable(formulaManager.escape("leak%d".formatted(allocationSiteId)));
216+
}
217+
218+
/// Describes that {@code object} is reachable from static memory at the end of the execution.
219+
public BooleanFormula trackVariable(MemoryObject object) {
220+
final int allocationSiteId = object.getAllocationSite().getGlobalId();
221+
return booleanFormulaManager.makeVariable(formulaManager.escape("track%d".formatted(allocationSiteId)));
222+
}
223+
212224
public TypedFormula<?, ?> value(MemoryCoreEvent event) {
213225
return values.get(event);
214226
}

dartagnan/src/main/java/com/dat3m/dartagnan/encoding/IREvaluator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ public TypedValue<IntegerType, BigInteger> size(MemoryObject memoryObject) {
114114
return (TypedValue<IntegerType, BigInteger>) evaluate(ctx.size(memoryObject));
115115
}
116116

117+
public boolean isLeaked(MemoryObject object) {
118+
return object.isHeapAllocated() && TRUE.equals(smtModel.evaluate(ctx.leakVariable(object)));
119+
}
120+
121+
public boolean isTrackable(MemoryObject object) {
122+
return object.isHeapAllocated() && TRUE.equals(smtModel.evaluate(ctx.trackVariable(object)));
123+
}
124+
117125
// ====================================================================================
118126
// Memory Model
119127

0 commit comments

Comments
 (0)