Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data race detection fixes #235

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ fun getXcfaErrorPredicate(
ErrorDetection.DATA_RACE -> {
Predicate<XcfaState<out ExprState>> { s ->
val xcfa = s.xcfa!!
if (s.mutexes.containsKey("")) return@Predicate false
for (process1 in s.processes)
for (process2 in s.processes)
if (process1.key != process2.key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ private fun List<VarAccessMap>.mergeAndCollect(): VarAccessMap = this.fold(mapOf
(acc.keys + next.keys).associateWith { acc[it].merge(next[it]) }
}

private operator fun VarAccessMap?.plus(other: VarAccessMap?): VarAccessMap =
listOfNotNull(this, other).mergeAndCollect()

/**
* The list of mutexes acquired by the label.
*/
Expand Down Expand Up @@ -150,17 +153,17 @@ fun XcfaLabel.collectVarsWithAccessType(): VarAccessMap = when (this) {
is StmtLabel -> {
when (stmt) {
is HavocStmt<*> -> mapOf(stmt.varDecl to WRITE)
is AssignStmt<*> -> StmtUtils.getVars(stmt).associateWith { READ } + mapOf(stmt.varDecl to WRITE)
is AssignStmt<*> -> ExprUtils.getVars(stmt.expr).associateWith { READ } + mapOf(stmt.varDecl to WRITE)
else -> StmtUtils.getVars(stmt).associateWith { READ }
}
}

is NondetLabel -> labels.map { it.collectVarsWithAccessType() }.mergeAndCollect()
is SequenceLabel -> labels.map { it.collectVarsWithAccessType() }.mergeAndCollect()
is InvokeLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ }
is StartLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ } + mapOf(pidVar to READ)
is JoinLabel -> mapOf(pidVar to READ)
is ReadLabel -> mapOf(global to READ, local to READ)
is StartLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ } + mapOf(pidVar to READ)
is WriteLabel -> mapOf(global to WRITE, local to WRITE)
else -> emptyMap()
}
Expand Down