Skip to content

Commit

Permalink
Merge pull request #3046 from apalache-mc/igor/tmpdir
Browse files Browse the repository at this point in the history
protect against SANY race conditions on the filesystem
  • Loading branch information
konnov authored Dec 13, 2024
2 parents 8b661d7 + 4e6279d commit 1742832
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .unreleased/bug-fixes/sany-tmpdir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add extra protection against the SANY race conditions on the filesystem, see #3046
10 changes: 9 additions & 1 deletion src/universal/bin/apalache-mc
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ then
JVM_ARGS="${JVM_ARGS} -Xmx4096m"
fi

# Avoid SANY concurrency issues: https://github.com/tlaplus/tlaplus/issues/688
if [ -z "${TMPDIR:-}" ]; then
TMPDIR="$(pwd)/tmp"
mkdir -p "$TMPDIR"
fi
JAVA_IO_TMPDIR=`mktemp -d -t SANYXXXXXXXXXX`

# Check whether the CLI args contains the debug flag
if [[ "$*" =~ '--debug' ]]
then
echo "# Tool home: $DIR"
echo "# Package: $APALACHE_JAR"
echo "# JVM args: $JVM_ARGS"
echo "# -Djava.io.tmpdir: $JAVA_IO_TMPDIR"
echo "#"
fi

# Run with `exec` to replace the PID, rather than running in a subshell.
# This saves one process, and ensures signals are sent to the replacement process
# C.f. https://github.com/sbt/sbt-native-packager/blob/e72f2f45b8cab5881add1cd62743bfc69c2b9b4d/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template#L141-L142
exec java $JVM_ARGS -jar "$APALACHE_JAR" "$@"
exec java $JVM_ARGS -Djava.io.tmpdir=$JAVA_IO_TMPDIR -jar "$APALACHE_JAR" "$@"

0 comments on commit 1742832

Please sign in to comment.