Skip to content

Commit 1742832

Browse files
authored
Merge pull request #3046 from apalache-mc/igor/tmpdir
protect against SANY race conditions on the filesystem
2 parents 8b661d7 + 4e6279d commit 1742832

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.unreleased/bug-fixes/sany-tmpdir.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add extra protection against the SANY race conditions on the filesystem, see #3046

src/universal/bin/apalache-mc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,24 @@ then
3838
JVM_ARGS="${JVM_ARGS} -Xmx4096m"
3939
fi
4040

41+
# Avoid SANY concurrency issues: https://github.com/tlaplus/tlaplus/issues/688
42+
if [ -z "${TMPDIR:-}" ]; then
43+
TMPDIR="$(pwd)/tmp"
44+
mkdir -p "$TMPDIR"
45+
fi
46+
JAVA_IO_TMPDIR=`mktemp -d -t SANYXXXXXXXXXX`
47+
4148
# Check whether the CLI args contains the debug flag
4249
if [[ "$*" =~ '--debug' ]]
4350
then
4451
echo "# Tool home: $DIR"
4552
echo "# Package: $APALACHE_JAR"
4653
echo "# JVM args: $JVM_ARGS"
54+
echo "# -Djava.io.tmpdir: $JAVA_IO_TMPDIR"
4755
echo "#"
4856
fi
4957

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

0 commit comments

Comments
 (0)