Full jcode-app-core --lib suite deadlocks at viewer_attach_reuses_live_owner_without_tracking_placeholder (pre-existing on v0.88.0)
Summary
The full jcode-app-core --lib test suite deadlocks deterministically at:
server::client_session::tests::concurrency::viewer_attach_reuses_live_owner_without_tracking_placeholder
Reproduces in both serial and parallel modes. This is pre-existing on v0.88.0 itself — it is not introduced by any downstream merge or fork patch.
Reproduction
Run the full library suite (not a filtered subset):
cargo test -p jcode-app-core --lib
The run stalls at the test above. All threads are parked/sleeping and CPU usage is flat — a genuine deadlock, not a slow test. The blocked frame is a park inside reqwest::blocking::ClientHandle::new.
Provenance (three trees, identical harness)
| Tree | Full-parallel result | Signature | Target test stuck? |
|---|---|---|---|
Upstream v0.88.0 (ee4cd3db3) alone |
deadlock @ ok=283 |
reqwest::blocking::ClientHandle::new park |
yes |
Downstream fork pre-merge (115170054) |
2-test pair EXIT=137 |
same | yes |
Downstream merge of v0.88.0 |
deadlock @ ok=286 |
same | yes |
Control: running the target test alone in the same trees exits 0. So the target test is healthy in isolation and is killed only by contamination from other tests in the same process.
Bisection
Two tests in agent::tests are each independently sufficient to deadlock the target:
agent::tests::agent_drop_removes_its_configured_session_tool_policyagent::tests::agent_clear_moves_tool_policy_registration_to_new_session
Both mutate the global SESSION_TOOL_POLICIES static and swap JCODE_HOME via env. Either one alone reproduces the hang against the target test.
A skip-2 full serial run still deadlocked, so more contaminating tests exist beyond these two — this is a class of isolation bug, not a single pair.
No fork-added reqwest::blocking call sites reach this path; the call is reached transitively from code that is identical across both parents.
Suggested direction
Global-state pollution between the agent::tests module and the server tests, combined with a blocking reqwest client created while another test holds a lock the request path needs. Candidates:
- Scope
SESSION_TOOL_POLICIESand theJCODE_HOMEenv swap per-test (e.g. a lock held across the test, or thread-local state) soagent::testscannot mutate process-global state observed byservertests. - Avoid creating a
reqwest::blockingclient inside the test process —reqwest::blockingspawns a runtime thread and can deadlock when the pool is already parked or when the process is under test harness contention. - Audit remaining tests for the same
JCODE_HOME/global-static mutation pattern; the skip-2 result shows the pair above is not the whole set.
Impact
CI is unaffected today because .github/workflows/ci.yml never runs the full jcode-app-core --lib suite — it runs only filtered gates (retention_readiness, tool::bash::tests::test_stdin_forwarding) plus --no-run compile checks. That means the suite-wide deadlock is invisible to CI, but it blocks any contributor who runs the full suite locally.
Environment
- macOS (aarch64), Rust nightly toolchain
- Reproduced with
--test-threads=1(serial) and default (parallel) - Machine load does not affect reproduction; CPU goes flat on hang
Thanks for the careful bisection. I couldn't reproduce this on Linux at current master: the full cargo test -p jcode-app-core --lib suite completes in both parallel and --test-threads=1 modes, and the two agent::tests you named each pass when paired with viewer_attach_reuses_live_owner_without_tracking_placeholder. That points to something macOS-specific, probably reqwest's blocking client setup (system proxy or TLS root loading) on a path the test env doesn't fully isolate, such as telemetry. Could you check whether it still hangs on current master, and if so, attach a sample <pid> (or lldb bt all) of the stuck process? It would also help to know whether JCODE_NO_TELEMETRY=1 cargo test -p jcode-app-core --lib still deadlocks.
--- — Jcode agent (automated triage), on behalf of @1jehuang
Current-master macOS follow-up (2026-10-06). In a clean detached worktree at upstream a0c41dc2f30a936b7944e282fbd2b11d81683dfb on macOS arm64, I ran the entire jcode-app-core --lib suite three ways:
cargo test -p jcode-app-core --lib -- --test-threads=1: 1497 passed, 3 failed, 32 ignored, finished in 113.50s. The formerly stuckviewer_attach_reuses_live_owner_without_tracking_placeholderexplicitly reportsok.JCODE_NO_TELEMETRY=1 cargo test -p jcode-app-core --lib: 1496 passed, 4 failed, 32 ignored, finished in 29.98s. The formerly stuck test reportsok.cargo test -p jcode-app-core --lib: 1497 passed, 3 failed, 32 ignored, finished in 67.53s. The formerly stuck test reportsok.
No hang on current master in these runs, so there is no stuck PID to sample or meaningful bt all to attach. The failing tests are unrelated: tool::compile_remote::source::tests::rejects_non_utf8_git_paths panics with macOS Illegal byte sequence when constructing a non-UTF8 path; tool::tests::tool_descriptions_stay_under_token_cap and tool::tests::tool_parameter_descriptions_stay_under_token_cap fail on existing tool descriptions. In the telemetry-disabled parallel run, server::tests::background_task_wake_runs_live_session_immediately_when_idle additionally timed out, likely a separate parallel timing issue. This does not prove why v0.88.0 deadlocked or that a particular commit fixed it; it only narrows #1636 to the historical version/environment. I did not alter installed Jcode or the running daemon.
Cannot reproduce this on current master (4bb16b96c, macOS 26 arm64, Darwin 25.6.0). The full library suite now finishes in 34 seconds.
Three checks:
- The named test no longer exists.
rg "viewer_attach|tracking_placeholder"over the tree returns nothing; the last commits that touched the name are0392c7117and458af80d7, which introduced it. - The frame the report names is gone too: there is no
reqwest::blockingusage left anywhere in the tree. - Full-suite run, unfiltered:
$ ./jcode_app_core --test-threads=4
test result: FAILED. 1698 passed; 10 failed; 34 ignored; 0 measured; 0 filtered out; finished in 33.82s
No hang, no stalled thread, CPU flat only during the last few tests. Serial-vs-parallel no longer matters because the deadlock source is absent.
The suite is still red on macOS, but for unrelated reasons. Current failures on clean master:
tool::tests::tool_descriptions_stay_under_token_cap-macos_computer_use(~159 tokens) andbash(~53) over the 20-token cap. These tools only exist on macOS, so Linux CI never sees them (see #1177).tool::tests::tool_parameter_descriptions_stay_under_token_cap- same cause, 14 parameter descriptions.tool::tests::only_the_known_open_world_tools_are_ineligible_for_openai_strict_mode- actual set has an extratodo.tool::tests::post_tool_feedback_hook_appends_stdout_to_tool_resultagent::cache_monitor_tests::same_account_zero_read_explains_what_was_ruled_outagent::tests::compile_remote::locked_snapshots_ignore_runtime_description_changestool::compile_remote::source::tests::rejects_non_utf8_git_pathsserver::provider_control::tests::automatic_failover_revalidates_after_waiting_for_agent_lockserver::tests::background_task_wake_runs_live_session_immediately_when_idleserver::client_lifecycle::tests::accepted_reload_recovery_continuation_marks_intent_delivered
The last two look environmental or timing-dependent rather than platform-specific, and the run used the ambient HOME/JCODE_HOME, so some of these may be the config-leak shape from #1473. I did not isolate each one.
Suggest closing this as resolved (the deadlock and its test are both gone) and tracking the remaining macOS suite gaps under #1177, which is the general gate for "compiled but never run". Leaving the decision here since closing is the maintainer's call.
— Jcode agent (automated triage), on behalf of @1jehuang