Skip to content

ci: complete sanitizer instrumentation and fix test data races - #370

Merged
voidvec merged 12 commits into
masterfrom
ci/tsan-instrumented-framework-dependencies
Nov 27, 2026
Merged

voidvec merged 12 commits into
masterfrom
ci/tsan-instrumented-framework-dependencies

Conversation

@voidvec

@voidvec voidvec commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Complete ThreadSanitizer compilation coverage for Drogon/Trantor, AuthForge test/server targets, and the SDK consumer. Dependency package IDs carry the instrumentation flags; installed symbols and actual Session/main/server/SDK links are checked. UTC, ten consecutive real-Session passes, and a complete CTest run with JUnit rejection of empty, skipped, or not-run tests form the TSan gate.

First-party fixes

  • Serialize JwkManager::init() and copy/move/assignment, and publish immutable shared_ptr<const KeySet> snapshots atomically. Readers before, during, and after initialization observe a consistent empty or initialized snapshot; getKeyId() no longer returns a reference into mutable state.
  • Preserve the production read-only publication contract (shared_ptr<const JwkManager>) and init-once semantics: a repeated successful init() remains a logged no-op returning true, while failed initialization remains retryable.
  • Keep the author's init-before-publish regression and add concurrent init/readers plus assignment/init regression coverage.
  • Correct ConfigManager alias precedence, empty-value fallback, .env precedence over process environment, and FULLA_ENV consistency.
  • Remove runtime global log-level mutation, replace stack-reference HTTP callbacks with bounded synchronous checks, and load test configuration through ConfigManager so environment overrides apply.
  • Isolate test database selection with FULLA_DB_NAME and bounded DB/HTTP timeouts.
  • Avoid signed-left-shift UB in the back-channel logout test's base64url decoder.
  • Fail closed on /oauth2/login when memory storage has no identity repository, instead of falling through to the PostgreSQL-only legacy AuthService and crashing the process.
  • Register the legacy out-of-process endpoint suite only for PostgreSQL-backed configurations; memory-storage CI covers the login failure path with Integration_P1_Auth_InvalidCredentials_DoNotCrashServer. Endpoint wrappers now fail rather than skip when the server cannot become ready.

Validation at 846a7ee

  • Rebased onto master 3b4abb87; the author's two JWK test commits are preserved unchanged in the final history.
  • Local Windows Release build after rebase: passed.
  • Local targeted regressions after rebase: invalid-credentials HTTP test passed (5 assertions); back-channel logout suite passed (6/6).
  • Static gates passed after rebase: arch-guard (R4 frozen at 69), double-move guard, audit-event guard, migration-check, SDK API diff (237 headers, v1.6.0), test naming, Drogon macro operands, manage-script parity, doc links, and OpenAPI governance (144 routes / 142 docs / 140 YAML operations).
  • Local full TSan gate: not completed locally after the WSL runtime became unavailable; merge remains blocked on a complete green CI run at 846a7ee0.

No first-party suppression, skip, or expected-failure marker was added. The documented TSan suppressions are limited to upstream Trantor/OpenSSL/libpq boundaries; first-party reports remain gate failures.

Addresses #366

@voidvec voidvec changed the title ci: instrument framework dependencies for ThreadSanitizer ci: complete TSan instrumentation and use a fixed UTC test environment Nov 24, 2026
@voidvec voidvec changed the title ci: complete TSan instrumentation and use a fixed UTC test environment ci: complete sanitizer instrumentation and fix test data races Nov 25, 2026
wangrh0909
wangrh0909 previously approved these changes Nov 25, 2026
wangrh0909
wangrh0909 previously approved these changes Nov 26, 2026
@voidvec
voidvec force-pushed the ci/tsan-instrumented-framework-dependencies branch from fbcb57e to 882583d Compare November 27, 2026 04:47
@voidvec
voidvec marked this pull request as ready for review November 27, 2026 04:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T04:50:20.387005Z 882583d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 882583d1d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +308 to +311
start.store(true, std::memory_order_release);
writer.join();
start.store(false, std::memory_order_release);
reader.join();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Separate the reader's start signal from its stop signal

If the reader is descheduled after reaching the barrier, the writer can complete all 2,000 iterations and the main thread can reset start to false before the reader observes true. The reader then spins forever in its initial while (!start.load(...)), and reader.join() hangs until CTest times out. The barrier only establishes arrival, not that the reader has observed the subsequent start signal. Use a one-shot start latch and a separate stop flag, or wait for reader acknowledgement before clearing the flag.

Useful? React with 👍 / 👎.

@voidvec

voidvec commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

PR 评审:阻碍合入项清单

基于当前 head 882583d1 的代码与 CI 核查(已确认本 PR 已 rebase 至 master 763e7f1d 并转为 Ready for review,新增 JwkManager 原子快照、ConfigManager 别名覆盖修正及 TSan 门禁加固):

1. [CI 门禁未完成] 当前 head 882583d1 的全量 CI 与 TSan 验证仍在运行中

  • 必须等待全部工作流运行通过后方可合入,包括:
    • CI Run 45942027674(前端、三平台 Build & Test 及 SDK Smoke)
    • Sanitizers PR Run 45942027495(ASan + UBSan)
    • Sanitizers 手动 dispatch Run 45942107737(含 TSan nightly + check_ctest_junit.py + SDK smoke 链接校验)
    • Optional Feature Matrix Run 45942027471
    • Coverage Run 45942027604

2. [合入策略] 原审批已失效,缺少针对新 head 882583d1 的外部审阅批准(REVIEW_REQUIRED)

  • 先前 wangrh0909 在 fbcb57ec 上的 APPROVED 已因新提交被 DISMISSED。
  • 本次新增了 JwkManager 并发重构、ConfigManager 行为修正、tools/api-diff/api-baseline.txt 变更及 tools/sanitizers/tsan.supp 新增 OpenSSL 抑制规则,需外部审阅者重新评审并 Approve。

补充评审关注点(建议审阅与合入前澄清)

  • libs/oauth2/src/jwk/JwkManager.cc:658-666 中 JwkManager::getKeyId() 仍返回 const std::string &(来自局部 std::atomic_load(&keySet_) 的 keySet->activeKid,局部 shared_ptr 在函数返回即销毁)。在生产只读发布(shared_ptr<const JwkManager>,无并发赋值)场景下安全,但若与 operator= 并发调用仍存在返回悬空引用(UAF)的窗口。PR 正文称 "getKeyId() no longer returns a reference into mutable state" 易引起误解,建议修正 PR 描述并在 libs/oauth2/include/fulla/oauth2/jwk/JwkManager.h 注释中明确“不可与赋值并发调用 getKeyId()”。

…shots

Replace the unsynchronized initialized_/kid_/keys_ members with a
mutex-serialized init() that atomically publishes one shared immutable
KeySet snapshot. Readers load the snapshot lock-free and are safe before,
during, and after the first init(); copy/move construction and assignment
serialize with init() and with assignment on the other object. The
init-once no-op and read-only publication contract are preserved.
Fix environment alias resolution and override precedence in ConfigManager
and cover the corrected behavior with unit tests.
…zation

Instrument unit/SDK-smoke test targets for ThreadSanitizer, add a CTest
JUnit checker so sanitizer failures cannot pass silently, fix security
header and social login test initialization, and refresh the API baseline
and TSan suppression/verification tooling.
@voidvec
voidvec merged commit a40b7d8 into master Nov 27, 2026
18 checks passed
@voidvec
voidvec deleted the ci/tsan-instrumented-framework-dependencies branch December 2, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants