Skip to content

Commit 34dc9d1

Browse files
authored
Merge pull request #407 from kdroidFilter/fix/sni-bus-thread-safety
Fix sd-bus thread-safety crash in Linux tray (#405)
2 parents 03cd59a + 9706d15 commit 34dc9d1

3 files changed

Lines changed: 289 additions & 26 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Build and run the issue #405 concurrency regression test.
3+
# Runs the stress harness several times under a private D-Bus session.
4+
# Exit 0 only if every run completes without crashing.
5+
6+
set -u
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
SDBUS_CFLAGS=$(pkg-config --cflags libsystemd)
9+
SDBUS_LIBS=$(pkg-config --libs libsystemd)
10+
BIN="$SCRIPT_DIR/test_sni_concurrency"
11+
12+
echo "Compiling concurrency test..."
13+
gcc -O2 -g -fPIC -Wall -Wextra -Wno-unused-parameter \
14+
-I "$SCRIPT_DIR" $SDBUS_CFLAGS \
15+
"$SCRIPT_DIR/sni.c" "$SCRIPT_DIR/test_sni_concurrency.c" \
16+
$SDBUS_LIBS -lpthread -lm -o "$BIN" || { echo "compile failed"; exit 2; }
17+
18+
RUNS="${1:-5}"
19+
rc=0
20+
for i in $(seq 1 "$RUNS"); do
21+
echo "--- run $i/$RUNS ---"
22+
dbus-run-session -- "$BIN"
23+
status=$?
24+
if [ $status -ne 0 ]; then
25+
echo "FAIL: run $i exited with status $status (signal $((status-128)) if >128)"
26+
rc=1
27+
break
28+
fi
29+
done
30+
31+
rm -f "$BIN"
32+
if [ $rc -eq 0 ]; then
33+
echo "PASS: all $RUNS runs completed without crash"
34+
fi
35+
exit $rc

0 commit comments

Comments
 (0)