ci: cancel stuck runs; cap ASan wall time; silence path snprintf warning

The sanitizers job wedged the only runner by printing AddressSanitizer
DEADLYSIGNAL forever (Docker without SYS_PTRACE). Concurrency now cancels
in-progress jobs on a new push, and make asan is wrapped in timeout -s KILL
480 with shallow ASAN_OPTIONS.

Also copy the path with memcpy after the length check so -O1 asan builds
do not warn about snprintf truncation into OS_PATH_MAX.
This commit is contained in:
WHC
2026-10-07 01:55:51 +08:00
parent 77de812207
commit 41c7e04940
2 changed files with 25 additions and 3 deletions
+22 -1
View File
@@ -4,9 +4,16 @@ on:
push: push:
pull_request: pull_request:
# One runner: cancel the previous push's jobs (avoids a stuck ASan job
# blocking every later commit).
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
linux: linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -38,6 +45,7 @@ jobs:
sanitizers: sanitizers:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
@@ -48,10 +56,22 @@ jobs:
$SUDO apt-get install -y --no-install-recommends \ $SUDO apt-get install -y --no-install-recommends \
build-essential pkg-config libcurl4-openssl-dev libncurses-dev build-essential pkg-config libcurl4-openssl-dev libncurses-dev
- name: ASan + UBSan - name: ASan + UBSan
run: make asan timeout-minutes: 10
env:
# Docker runners without SYS_PTRACE can spin forever on
# AddressSanitizer:DEADLYSIGNAL; keep the handler shallow and
# hard-cap wall time so the single runner is not wedged.
ASAN_OPTIONS: abort_on_error=1:halt_on_error=1:detect_leaks=0:use_sigaltstack=0
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
run: |
if ! timeout -s KILL 480 make asan; then
echo "::error::make asan failed or timed out after 8m (if the log is only DEADLYSIGNAL, give the runner SYS_PTRACE / seccomp=unconfined)"
exit 1
fi
musl: musl:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30
container: alpine:3.20 container: alpine:3.20
steps: steps:
- name: Install dependencies - name: Install dependencies
@@ -71,6 +91,7 @@ jobs:
macos: macos:
if: ${{ vars.HAVE_MACOS_RUNNER == 'true' }} if: ${{ vars.HAVE_MACOS_RUNNER == 'true' }}
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
+3 -2
View File
@@ -566,9 +566,10 @@ static void sc_rewrite(int pid, const char *in, char *out, size_t n) {
static int sc_abs_ok(const sc_state_t *s, const char *full, int follow, static int sc_abs_ok(const sc_state_t *s, const char *full, int follow,
int strict) { int strict) {
char path[OS_PATH_MAX], real[OS_PATH_MAX], loc[2 * OS_PATH_MAX + 2]; char path[OS_PATH_MAX], real[OS_PATH_MAX], loc[2 * OS_PATH_MAX + 2];
if (strlen(full) >= sizeof(path)) size_t flen = strlen(full);
if (flen >= sizeof(path))
return 0; return 0;
snprintf(path, sizeof(path), "%s", full); memcpy(path, full, flen + 1);
size_t n = strlen(path); size_t n = strlen(path);
while (n > 1 && path[n - 1] == '/') while (n > 1 && path[n - 1] == '/')
path[--n] = 0; path[--n] = 0;