Repository navigation
iOS,macOS: add tsan and ubsan support for Swift - #190497
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the compiler configuration in BUILD.gn to add Swift sanitization flags for TSan and UBSan, and documents why ASan is excluded. The review feedback points out that the Swift compiler does not support -sanitize=undefined (UBSan), which will cause a build failure, and suggests removing this flag.
cbracken
force-pushed
the
swift-tsan-instrument
branch
from
August 4, 2026 02:21
957d7c5 to
4a9911e
Compare
cbracken
commented
Aug 4, 2026
| # Framework plugin_ffi template: packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl | ||
| # When Android requires new flags consider also editing the flags in the | ||
| # following locations. Framework plugin_ffi template: | ||
| # packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl |
Member
Author
There was a problem hiding this comment.
This and the change below were introduced by gn format :/
10 tasks done
This propagates `-sanitize=thread` to swiftflags when is_tsan is true.
Sanitizer builds previously added `-fsanitize=<san>` only to the C/C++
cflags/ldflags, never to swiftflags. The sanitizer runtime was linked,
but Swift code was left uninstrumented, so data races in Swift went
undetected even under --tsan.
TSan is the only sanitizer propagated to Swift; the other two are excluded for
separate reasons:
ASan:
Swift is instrumented but can't link. Swift is compiled with the Apple
toolchain while C/C++ and the link step use the Fuchsia clang from CIPD,
and their ASan runtimes disagree on the version-mismatch guard:
Swift objects reference: ___asan_version_mismatch_check_apple_clang_2100
Fuchsia asan runtime has: ___asan_version_mismatch_check_v8
UBSan:
The Swift compiler accepts `-sanitize=undefined` but emits no UBSan
instrumentation for Swift code since its own runtime already traps this
behaviour.
cbracken
force-pushed
the
swift-tsan-instrument
branch
from
August 4, 2026 06:57
4a9911e to
3f9b669
Compare
This was referenced Aug 5, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Aug 10, 2026
…12420) Manual roll requested by stuartmorgan@google.com flutter/flutter@b766512...27b0988 2026-08-05 kevmoo@users.noreply.github.com reland(tool): remove redundant --enable-experiment=record-use flag (flutter/flutter#190591) 2026-08-05 chris@bracken.jp Windows: Propagate enabled accessibility state (flutter/flutter#190507) 2026-08-05 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from ltbuIH9Z3T_yOuigu... to vcANVO8VIDQHasH1X... (flutter/flutter#190589) 2026-08-05 256906086+mvincentong@users.noreply.github.com Document frozen embedder API structs (flutter/flutter#186842) 2026-08-05 49402500+fahaddoc@users.noreply.github.com Document super call order for State.didChangeDependencies (flutter/flutter#185945) 2026-08-05 dkwingsmt@users.noreply.github.com Move examples of `flutter/widgets` widgets out from `flutter/material` (flutter/flutter#189532) 2026-08-05 93888664+ColeSpringer@users.noreply.github.com [web] Use thread local strike caches in skwasm (flutter/flutter#190048) 2026-08-05 43089218+chika3742@users.noreply.github.com doc: fix typo in see also section for PrimaryScrollController.maybeOf (flutter/flutter#190386) 2026-08-05 jason-simmons@users.noreply.github.com Migrate the shell unit tests from legacy Dart native functions to FFI (flutter/flutter#190473) 2026-08-05 47866232+chunhtai@users.noreply.github.com render proxy box now defaults baseline calculation to null (flutter/flutter#190269) 2026-08-05 36861262+QuncCccccc@users.noreply.github.com Update Widgets Localizations from Translation Console (flutter/flutter#190503) 2026-08-04 154381524+flutteractionsbot@users.noreply.github.com Revert: fix(tool): remove redundant --enable-experiment=record-use flag (flutter/flutter#190583) 2026-08-04 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from 1frGe_KltAJKkeyPg... to ltbuIH9Z3T_yOuigu... (flutter/flutter#190561) 2026-08-04 chris@bracken.jp iOS,macOS: add tsan and ubsan support for Swift (flutter/flutter#190497) 2026-08-04 34465683+rkishan516@users.noreply.github.com fix: update on_message_ to nullptr after window destroy so that dart gets destroy message (flutter/flutter#185807) 2026-08-04 bkonyi@google.com [flutter_tools] Gracefully handle locked Windows files during clean (flutter/flutter#190095) 2026-08-04 chris@bracken.jp iOS,macOS: make Logger thread-safe, conform to Sendable (flutter/flutter#190488) 2026-08-04 chris@bracken.jp iOS: Eliminate use of IOSContextNoop in platform view tests (reland) (flutter/flutter#190509) 2026-08-04 kevmoo@users.noreply.github.com fix(tool): remove redundant --enable-experiment=record-use flag (flutter/flutter#190475) 2026-08-04 awolff@google.com android_hardware_smoke_test: Detect blank image failures or EGL initialization warnings and retry (flutter/flutter#190110) 2026-08-04 30870216+gaaclarke@users.noreply.github.com Bumps text gamma on windows to match skia. (flutter/flutter#190477) 2026-08-04 engine-flutter-autoroll@skia.org Roll Skia from 48b58ee222f1 to a8583a0a2c11 (2 revisions) (flutter/flutter#190537) 2026-08-04 kevmoo@users.noreply.github.com [tool][web] Intercept dart2wasm errors & append JS migration footers (flutter/flutter#190476) 2026-08-04 dacoharkes@google.com [record_use] Migrate IconTreeShaker to `package:record_use` (flutter/flutter#190225) 2026-08-04 s4bre.py@gmail.com Handle unexpected exceptions during Azure metadata detection (flutter/flutter#189457) 2026-08-04 15619084+vashworth@users.noreply.github.com Fix merge conflict from flutter/flutter#190369 (flutter/flutter#190544) 2026-08-04 15619084+vashworth@users.noreply.github.com Prepare device support symbols (flutter/flutter#190369) 2026-08-04 engine-flutter-autoroll@skia.org Roll Packages from ac87e65 to 3498b9d (1 revision) (flutter/flutter#190532) 2026-08-04 engine-flutter-autoroll@skia.org Roll Skia from a08d918ebd6a to 48b58ee222f1 (11 revisions) (flutter/flutter#190527) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Previously asan/tsan/ubsan builds applied only to C[++]/Obj-C[++] builds but not Swift since the flags were never wired up. This adds support for TSan (
-fsanitize=thread) and UBSan (-fsanitize=undefined) for Swift.ASan is intentionally excluded. Swift is compiled with the Apple toolchain, while C/C++ and the link step use the Fuchsia clang from CIPD, and the two ship different ASan runtimes. Apple's swift-frontend stamps each instrumented module with a version-mismatch guard that the linked Fuchsia runtime doesn't provide, so Swift + ASan fails to link with an undefined symbol:
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.