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

protect against SANY race conditions on the filesystem #3046

Merged
merged 8 commits into from
Dec 13, 2024
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
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" "$@"
Loading