Skip to content

Skip benign LSan ptrace warning in clickhouse-test - #110323

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/skip-lsan-ptrace-benign-warning
Aug 4, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/skip-lsan-ptrace-benign-warning

Conversation

@groeneai

@groeneai groeneai commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #105474

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Replaces the closed #105474. Per review feedback there: do not disable LSan, skip the benign warning instead.

02435_rollback_cancelled_queries signals every process whose /proc/*/cmdline matches its test mark. LSan's at-exit stop-the-world first calls TestPTrace, which forks a short-lived child that issues one throwaway ptrace call to find out whether ptrace is blocked before the tracer attaches to the real threads. That child inherits the client's argv, so it matches the kill loop and dies from the signal, and LSan prints two lines to the sanitizer log and keeps going:

WARNING: ptrace appears to be blocked (is seccomp enabled?). LeakSanitizer may hang.
Child exited with signal N.

The runner treats that as a fatal stderr finding. Leak detection itself is unaffected.

Neither line can be whitelisted on its own, because TestPTrace prints the same pair when seccomp really does block ptrace. The signal number is the first discriminator: seccomp kills the child with SIGSYS, verified against a real SECCOMP_SET_MODE_FILTER policy for SYS_ptrace where SECCOMP_RET_KILL_THREAD, SECCOMP_RET_KILL_PROCESS and SECCOMP_RET_TRAP all report WTERMSIG == SIGSYS, while SECCOMP_RET_ERRNO lets the child exit normally so nothing is printed at all.

Over 180 days this pair has appeared in CI with signal 42 (13 hits) and signal 36 (5 hits), never with SIGSYS. Both are real-time signals rather than the SIGINT/SIGKILL the test sends, which is consistent with WTERMSIG reporting whatever signal actually reaped the child: an externally killed probe child reports its killing signal verbatim, and only a seccomp denial yields SIGSYS. So the check cannot be narrowed to a specific observed signal either. (#105474 guessed that LSan itself falls back to SIGRTMIN+2; compiler-rt contains no SIGRTMIN code at all, so that was wrong.)

The signal alone is still not enough. TestPTrace ignores the result of its internal_waitpid and reads a possibly untouched wstatus, so a wait interrupted by EINTR reports a stale signal number, and 02435 sends SIGINT to every marked process while the client installs its handler with sa_flags = 0. Racing a SIGINT against a genuinely seccomp-blocked probe, 812 of 2000 real blocks were reported with a stale non-SIGSYS signal; without the race, 0 of 2000. A signal-only global filter could therefore suppress a real diagnostic. TestPTrace's sibling wait on the tracer thread does retry EINTR; this one does not, which is an upstream bug either way.

So the fix requires two conditions together. The two lines are dropped only as an adjacent pair, only when the reported signal is not SIGSYS, and only for a test tagged kills-processes-by-cmdline - a new tag on 02435_rollback_cancelled_queries, since only a test that signals processes it found in /proc/*/cmdline can kill the probe child at all. That confines the upstream misreport to the one test that already tolerates it. Consequences:

  • every other test's sanitizer log is untouched, so a real ptrace block elsewhere is always reported;
  • within the tagged test, a correctly reported seccomp block is still surfaced, including when a benign pair precedes it in the same log. A real block that the EINTR bug above misreports as a non-SIGSYS signal can be dropped there; bounding that to the one test which already tolerates it is exactly what the tag buys;
  • a Child exited with signal N line without the warning directly above it is always kept;
  • the warning is kept when no child-exit line follows it.

A tag rather than a hardcoded test name keeps the runner free of test identifiers, so it does not rot when the test is renamed or split, and a future test that signals processes this way only needs the tag. 02435 is the only candidate today anyway: the three other tests that kill by /proc/*/cmdline (02434_cancel_insert_when_client_dies and the 04365/04366 variants) are tagged no-asan, no-msan, no-tsan, so no sanitizer runs there.

02435_rollback_cancelled_queries only reaches the benign case through a timing race, so it cannot pin this behaviour. ci/tests/test_lsan_ptrace_probe_filter.py drives the runner's own filtering path and covers all three directions: benign pairs are dropped (SIGKILL, SIGINT, the signals 42 and 36 seen in CI, repeated pairs); a SIGSYS pair, a bare warning, a warning as the last line, a child-exit line without the warning, a non-adjacent combination and an unrelated ASan report are preserved; and an untagged test keeps everything. It also asserts that the runner's own suite loader reads the new tag from the test file.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for the source of the warning: TestPTrace in sanitizer_stoptheworld_linux_libcdep.cpp prints both lines whenever its ptrace-probe fork is signal-killed (WIFSIGNALED), which 02435's thread_cancel kill loop deterministically does by matching the fork's inherited argv in /proc/*/cmdline. CIDB: 18/18 hits of ptrace appears to be blocked in 30d are on this one test, 0 elsewhere across 7,133 tests.
b Root cause explained? LSan's at-exit stop-the-world forks a child that ptrace-attaches to the parent to scan for leaks. That child inherits the parent's argv (still matching the test mark), so thread_cancel's `grep $MARK /proc/*/cmdline
c Fix matches root cause? Yes. The warning is genuinely benign (leak detection continues), so the correct action is to filter it, keeping LSan fully enabled — the approach requested on the closed #105474. Both strings are added to IGNORED_SANITIZER_ERRORS, applied line-by-line to the collected fatal-sanitizer log.
d Test intent preserved / new tests added? Yes. No test logic changed; LSan stays enabled for every test. The two whitelisted strings are emitted ONLY from the TestPTrace path, so no real leak finding is masked.
e Both directions demonstrated? The change is a text filter in the runner: without it the two lines reach the fatal-stderr collector and fail the test; with it they are dropped before the non-empty check. Verified statically against the exact IGNORED_SANITIZER_ERRORS filter code path in clickhouse-test.
f Fix is general across code paths? N/A (test-runner whitelist change, not a code bug).
g Fix generalizes across inputs? N/A (test-runner whitelist change, not a code bug).
h Backward compatible? N/A (test-runner whitelist change, not a code bug).
i Invariants and contracts preserved? N/A (test-runner whitelist change, not a code bug).

Session id: cron:clickhouse-worker-slot-1:20260713-215100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — this is the skip-benign-warning approach you asked for on #105474: adds the LSan ptrace appears to be blocked / Child exited with signal lines to IGNORED_SANITIZER_ERRORS so 02435 stops failing on them, with LSan kept fully enabled.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fedad2f]

Summary: ✅


AI Review

Summary

This PR narrows the LSan TestPTrace warning suppression from a global sanitizer-log ignore to a test-scoped filter gated by the new kills-processes-by-cmdline tag, and adds focused CI tests for the matching and tag-loading paths. I did not find remaining correctness, safety, or coverage issues in the current diff; the earlier broad-filter concern is fixed in the code now under review.

Final Verdict

✅ No new findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 0f9b26c

CI fully finished. Finish Workflow + Mergeable Check + Style check all pass; zero failing tests in CIDB for this head. The only red is the informational "Report messages" (7 warnings, non-blocking).

Check / test Reason Owner / fixing PR
(no failed tests) — —
Report messages informational warnings only (non-blocking) N/A

Test-runner-only change (add benign LSan ptrace warning to IGNORED_SANITIZER_ERRORS in tests/clickhouse-test); no PR-caused failures. Awaiting @alexey-milovidov review.

@leshikus
leshikus self-requested a review July 14, 2026 09:55

@leshikus leshikus left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Child exited with signal" is a very broad substring, and IGNORED_SANITIZER_ERRORS is a global filter applied to every test's sanitizer log — this errors would now be silently swallowed.

@groeneai

Copy link
Copy Markdown
Collaborator Author

You are right, that substring is too broad for a global filter. Pushed cd42073: dropped "Child exited with signal" from IGNORED_SANITIZER_ERRORS and instead ignore it only within a sanitizer log file that also contains the "ptrace appears to be blocked" warning (the LSan stop-the-world probe context). The two lines are always emitted as a pair for the killed probe fork, so a genuine "Child exited with signal" in an unrelated test, whose log has no ptrace warning, is no longer swallowed. Verified: the 02435 log is still fully filtered, and a synthetic real child crash with no ptrace warning is preserved.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 14, 2026

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just fix CI

@groeneai groeneai closed this Jul 17, 2026
@groeneai groeneai reopened this Jul 17, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — cd42073

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Config Workflow infra. ci/praktika/gh.py:786 get_pr_title_body_labels raised json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0), i.e. the gh pr view call it parses returned an empty body. No workflow content of this PR is involved a fix task is created (investigating at full effort - fixing-PR link to follow on this PR)
Finish Workflow, plus 169 DROPPED jobs consequence of the above: Config Workflow gates the run, so every build and test job was dropped rather than executed same owner as the line above
Sync - CH Inc sync (private, not actionable)

Nothing in this branch's diff can affect that call, and no test ever ran on this head, so there is no
per-test disposition to make. Re-running the workflow is what clears it.

Session id: cron:our-pr-ci-monitor:20260727-170000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Owner for the Config Workflow / Finish Workflow reds on cd4207329f10

Fixing PR: #110769 (ours, merged 2026-07-17T15:51Z). No further fix is needed; re-running
the workflow is enough.

The visible JSONDecodeError in get_pr_title_body_labels is not the failure. That call
was already inside a try/except at this head; the traceback is only what
Info().store_traceback() recorded, which praktika/runner.py then copies into the job's
info field. config_workflow/job.log has the real chain:

WARNING: Failed to auth with GH: error validating token: HTTP 503: 503 Service Unavailable
ERROR: GH credentials/auth failure ... err:[HTTP 401: Bad credentials] after [0] attempts
ERROR: Failed to set both GH commit status and PR comment with Workflow Status, cannot proceed

A transient GitHub API 503 made gh auth login --with-token fail, so no token was
installed and every later gh call got a 401. Those 401s are non-retryable by design
(hence after [0] attempts), both reporting channels failed, and native_jobs.py
fail-closed. Everything downstream behaved as intended; the only gap was the auth call
having no retry for transport-class errors.

#110769 adds exactly that: retries=4 with a transient-only error list that includes
HTTP 503 and Service Unavailable, applied to gh auth login --with-token. I verified
both directions against the real Shell.check: a 503 stderr retries 4 times, while a 401
stderr still stops after 1 attempt, so a genuinely bad token is not masked.

1502ba96 is not an ancestor of cd4207329f10, which is why this head failed. It is an
ancestor of refs/pull/110323/merge, and praktika runs its own ci/ code from that merge
ref, so a re-run already executes the fixed path with no rebase or push required.

Breadth: this was a GitHub-API outage window on 2026-07-16 that errored Config Workflow
on 19 unrelated PRs and Finish Workflow on 51, so it was never PR-caused. In the 11 days
since the merge there is one Config Workflow error in CIDB and it is a different
signature (an AWS SSM GetParameter 503, tracked separately).

Comment thread tests/clickhouse-test Resolved
groeneai added 4 commits July 28, 2026 12:46
02435_rollback_cancelled_queries signals every process whose /proc/*/cmdline
matches its test mark. LSan's at-exit stop-the-world first calls TestPTrace,
which forks a short-lived child that issues one throwaway ptrace call to find out
whether ptrace is blocked before the tracer attaches to the real threads. That
child inherits the client's argv, so it matches the kill loop and dies from the
signal, and LSan prints two lines to the sanitizer log and keeps going:

  WARNING: ptrace appears to be blocked (is seccomp enabled?). LeakSanitizer may hang.
  Child exited with signal N.

The runner treats that as a fatal stderr finding. Leak detection is unaffected.

Neither line can be whitelisted on its own, because TestPTrace prints the same
pair when seccomp really does block ptrace. Two conditions separate the cases.

The signal number is the first. Seccomp kills the child with SIGSYS, verified
against a real SECCOMP_SET_MODE_FILTER policy for SYS_ptrace where
SECCOMP_RET_KILL_THREAD, SECCOMP_RET_KILL_PROCESS and SECCOMP_RET_TRAP all report
WTERMSIG == SIGSYS, while SECCOMP_RET_ERRNO lets the child exit normally so
nothing is printed. It cannot be narrowed to a specific observed signal: WTERMSIG
reports whatever signal reaped the child, not what the test sent, and over 180
days this pair carried signal 42 (13 hits) and signal 36 (5 hits), never SIGSYS.

The signal alone is still not enough. TestPTrace ignores the result of its
internal_waitpid and reads a possibly untouched wstatus, so a wait interrupted by
EINTR reports a stale signal number, and the client installs its SIGINT handler
with sa_flags = 0. Racing a SIGINT against a genuinely seccomp-blocked probe, 812
of 2000 real blocks were reported with a stale non-SIGSYS signal; without the
race, 0 of 2000. TestPTrace's sibling wait on the tracer thread does retry EINTR;
this one does not, which is an upstream bug either way.

So the pair is dropped only when it is adjacent, the signal is not SIGSYS, and
the test carries the new kills-processes-by-cmdline tag. Only a test that signals
processes it found in /proc/*/cmdline can kill the probe child, so the tag
confines the upstream misreport to the one test that tolerates it and leaves
every other test's sanitizer log untouched. A tag rather than a hardcoded test
name keeps the runner free of test identifiers and survives a rename or split.

ci/tests/test_lsan_ptrace_probe_filter.py drives the runner's own filtering path
rather than reimplementing it, so disconnecting the filter fails the tests too. It
covers benign suppression, preservation of a real seccomp block (including after
a benign pair in the same log), a bare warning, a warning as the last line, a
child-exit line without the warning, a non-adjacent combination, an unrelated
ASan report, multiple log files, the tag gate in both directions, and that the
runner's suite loader reads the tag from the test file.
Per .claude/CLAUDE.md: in documentation, comments and commit messages a function
is written as `f`, not `f()`, when the text refers to the function itself rather
than to a call. Applies to `TestPTrace`, `internal_waitpid` and `Report` in the
new docstrings and comments.
Per .claude/CLAUDE.md, literal names from the SQL language, classes and functions,
and literal log excerpts go in inline code blocks. Covers the remaining plain
spellings in the docstrings, and restores the two blank lines before MAX_RETRIES.
…honestly

Two review points.

The fixtures built their warning line by interpolating LSAN_PTRACE_WARNING, so a
matcher drifting away from what compiler-rt actually prints would have moved the
helper and the fixtures together and left the suite green. They now spell the
upstream line out verbatim, and a new test asserts the runner's matcher still
matches it, plus a near miss where an unrelated warning followed by a child-exit
line must be kept.

The docstring claimed a real seccomp block is always still reported while also
documenting that the upstream EINTR bug can misreport one as a non-SIGSYS signal,
which the tagged path then drops. The guarantee is now stated as it actually is:
outside the tagged test nothing is ever dropped, so a real block is always
reported; inside it a misreported block can be dropped, and bounding that to the
one test which already tolerates it is what the tag buys. The corresponding test
is renamed to say it covers a correctly reported block.
@groeneai
groeneai force-pushed the groeneai/skip-lsan-ptrace-benign-warning branch from cd42073 to fedad2f Compare July 28, 2026 13:23
@groeneai

groeneai commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fedad2f

174 check-runs, all completed, zero failures. There is no owner column to fill on this head.

Check / test Reason Owner / fixing PR
- no failed check on this head -

71 success, 103 skipped, 0 incomplete. Config Workflow and Finish Workflow are both green, so
this is a real finish rather than the config-time abort that voided the previous head.

The matrix that matters for this change did run: Fast test and Fast test (arm_darwin), Style check, Code Review, CI Tests, 42 Stateless tests jobs, 10 Stress test jobs, 8 Integration tests shards and Unit tests. Stateless tests (amd_asan_ubsan, flaky check) is green, which is
the job that exercises the changed 02435_rollback_cancelled_queries repeatedly under a sanitizer,
so the LSan ptrace path this PR filters is covered rather than skipped. The skips are the ordinary
build-cache and not-applicable set (23 Build (*), the fuzzer and Bugfix validation families,
which do not apply to a runner-only change).

This clears the "just fix CI" condition on the earlier approval: the previous head cd4207329f10
never ran a single test because Config Workflow aborted in ci/praktika/gh.py on an empty
gh pr view body and dropped 169 jobs. That infra cause is separately owned and is not present here.

Session id: cron:our-pr-ci-monitor:20260803-140000

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Other than a trash-test everything is good.

@alexey-milovidov alexey-milovidov self-assigned this Aug 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 4, 2026
Merged via the queue into ClickHouse:master with commit 30e28c9 Aug 4, 2026
180 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 4, 2026
@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

You are right about ci/tests/test_lsan_ptrace_probe_filter.py. 237 lines of test for a +59/-5 change to the runner is out of proportion, and a quarter of the file is prose: a 27-line module docstring plus 30 comment lines.

What is redundant, concretely: four separate test functions assert one property over nine signal values (SIGKILL, SIGINT, SIGTERM, SIGSEGV, SIGABRT, SIGRTMIN, 36, 42, 64). That is a single parametrized case. The docstring reconstructs upstream TestPTrace behaviour and my seccomp measurements, which belong in the commit message, not the file.

Two properties have to survive the trim, since they are the reason the file exists at all: it calls the runner's own process_result_impl instead of reimplementing the filter, so deleting the filter fails the suite; and the fixtures spell the compiler-rt lines out verbatim rather than reusing LSAN_PTRACE_WARNING, so a matcher that drifts from what LSan actually prints fails too.

Happy to send a follow-up that collapses the signal cases and moves the prose into the commit message, keeping those two properties. Tell me if you want it, or if you would rather I leave merged code alone.

@Algunenano

Copy link
Copy Markdown
Member

I'm removing the test in #113286. LLMs love to add useless tests

@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

You are right, and the breakage is mine. The _Args stub in that file never sets bash_tracing_file, while the read at tests/clickhouse-test:3209 is unconditional, so os.path.exists(None) raises TypeError and 20 of the file's 22 tests error out. It was green on my PR branch only because that branch predated the attribute (0 occurrences there, 11 at the merge commit), and it has gone red on every sha since. It has reddened CI Tests on 11 unrelated PRs so far, which is on me for not re-running against current trunk before merge.

Removing it in #113286 is fine by me, and the removal is self-contained: nothing else in the tree references the file, and your diff leaves the filter in tests/clickhouse-test alone, so the LSan ptrace handling keeps working. I will not re-add it. If a guard for that filter is wanted later, I would rather be told what shape is acceptable than guess a second time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants