Skip to content

Windows 投げ銭 IAP: 購入ダイアログ表示中のアプリ終了で teardown レース(native UAF / 閉鎖済み controller への add) #795

Closed

Description

@pooza

v1.43 リリース前レビュー(並行性・ライフサイクル観点)で検出した 黄 の follow-up。到達性は低い(Windows でアプリ終了と in-flight 購入ダイアログが同時、というシャットダウン時レースのみ)ため v1.43 はこのまま出荷し、次以降で対処する。

1. native detached worker の UAF

packages/capsicum/windows/runner/flutter_window.cpp の DispatchStoreWork。ワーカーは std::thread(...).detach() で this/hwnd を raw キャプチャし、RequestPurchaseAsync().get()(購入ダイアログ表示中ブロック)後に store_mutex_ ロック + PostMessage(hwnd, ...) する。購入ダイアログを開いたままメインウィンドウを閉じる(= Windows ではアプリ終了)と、FlutterWindow 破棄後にワーカーが解放済みメンバを触る(破棄済み mutex のロックは UB、stale/recycle された HWND への PostMessage)。

対処候補: lifetime token / weak guard、または destructor でワーカーを join する。既存の WNS/SMTC も同じ detached パターンだが、購入ダイアログは user 駆動でブロック窓が長く到達性が相対的に高い。

2. Dart 側 closed-controller への add

packages/capsicum/lib/src/provider/windows_store_backend.dart の buy()。dispose() が _events を close した後、buy() の channel 往復(ダイアログ表示中は数分)完了後に _events.add(...) すると閉鎖済み controller で StateError。supporterPurchaseProvider は app-lifetime の非 autoDispose なので container teardown 時のみ。mobile の in_app_purchase 経路(stream ベース・await 後 add 無し)には無い。

対処候補: add 前に _events.isClosed / disposed フラグを確認。

参照

Activity

  1. added this to the v1.45 milestone on Jul 2, 2026
  2. added
    bug
    on-hold
    desktop
    and removed
    on-hold
    on Jul 2, 2026
  3. added a commit that references this issue on Jul 7, 2026
  4. pooza commented on Jul 7, 2026

    @pooza
    OwnerAuthor

    修正済み(c285d8d)。Windows 投げ銭 IAP の、購入ダイアログ表示中のアプリ終了で起きる teardown レース(native UAF / 閉鎖済み controller への add)を塞いだ。終了タイミング依存の race で決定的な再現手順がなく、動作確認なしでクローズ(race 依存の検証困難バグは close 可の方針)。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdesktop

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions