Skip to content

[DO NOT MERGE] ci(linux): probe ASan/UBSan, TSan, -Wthread-safety, and multi-App stress tests - #1976

Draft
AustinBenoit wants to merge 3 commits into
mainfrom
ci/desktop-sanitizers-probe
Draft

AustinBenoit wants to merge 3 commits into
mainfrom
ci/desktop-sanitizers-probe

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

Diagnostic one-off draft PR to run Linux Clang -Wthread-safety, ASan+UBSan, TSan, and multi-App lifecycle stress tests (both offline and against the Firebase emulators) on CI and collect a full baseline report.

Includes:

Type of Change

  • Bug fix
  • New feature
  • Other, such as a build process or documentation change (diagnostic CI probe — do not merge).

@AustinBenoit AustinBenoit added the skip-release-notes Skip release notes check label Nov 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Clang Thread Safety Analysis (-Wthread-safety) to the Firebase C++ SDK, annotating several core classes like Mutex, CleanupNotifier, and ReferenceCountedFutureImpl to enforce compile-time thread safety checks. It also adds a new Python-based sanitizer test runner and comprehensive multi-App lifecycle stress tests (both offline and emulator-backed) to reproduce and prevent concurrency regressions. The review feedback highlights two key issues: first, an incorrect FIREBASE_REQUIRES(mutex_) annotation on RunCallback in ReferenceCountedFutureImpl that will cause a compilation failure because the lock is released before executing callbacks; second, a lack of error and timeout handling when invoking subprocess.run to list test cases in the sanitizer script, which could lead to unhandled exceptions if a binary hangs or crashes.

Comment on lines 554 to +556
void RunCallback(FutureBase* future_base,
FutureBase::CompletionCallback callback, void* user_data);
FutureBase::CompletionCallback callback, void* user_data)
FIREBASE_REQUIRES(mutex_);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The RunCallback function is annotated with FIREBASE_REQUIRES(mutex_). However, it is called from ReleaseMutexAndRunCallbacks which explicitly releases the mutex before running the callbacks (as noted in its documentation: 'The mutex is released before calling the callbacks'). Annotating RunCallback with FIREBASE_REQUIRES(mutex_) will cause Clang's -Wthread-safety analysis to fail with a compiler error because the mutex is not held when the callbacks are executed. Since user-defined callbacks should be executed without holding internal locks to prevent deadlocks, the FIREBASE_REQUIRES(mutex_) annotation should be removed from RunCallback.

  void RunCallback(FutureBase* future_base,\n                   FutureBase::CompletionCallback callback, void* user_data);

Comment on lines +40 to +43
proc = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
check=False, timeout=30
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The subprocess.run call is executed with a timeout=30 argument but is not wrapped in a try...except subprocess.TimeoutExpired block. If the test binary hangs or deadlocks during the --gtest_list_tests phase (e.g., due to static initialization issues or sanitizer startup deadlocks), the script will crash with an unhandled exception. Additionally, if the binary crashes during listing, proc.returncode will be non-zero, which should be checked to avoid parsing incomplete or invalid output. Wrapping the execution in a try...except block and checking the return code will make the test runner more robust and ensure that a failure in one binary does not prevent other binaries from being tested.

  try:\n    proc = subprocess.run(\n        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,\n        check=False, timeout=30\n    )\n  except subprocess.TimeoutExpired:\n    print(f'ERROR: timeout listing tests for {binary}', flush=True)\n    return []\n  except Exception as exc:\n    print(f'ERROR: failed to list tests for {binary}: {exc}', flush=True)\n    return []\n\n  if proc.returncode != 0:\n    print(f'ERROR: failed to list tests for {binary} (exit code {proc.returncode})', flush=True)\n    return []

Comment thread auth/src/data.h
/// User-supplied ID token listeners. All of these are updated when Auth's
/// ID token changes.
std::vector<IdTokenListener*> id_token_listeners;
std::vector<IdTokenListener*> id_token_listeners

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Lint warning: Add #include <vector> for vector<>

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

Labels

skip-release-notes Skip release notes check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant