RestartThrottleManager throws NullReferenceException after Dispose and ends the process

オープン 初心者向け
#67 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
backend

調査の方向性

src/TickerNet/Src/RestartThrottleManager.cs から始めてください。Dispose、OnTimerCallback(54 行目付近の _debounceTimer.Change 呼び出し)と RequestRestart を読み、これらはいずれも同じロックの下で実行されます。両方のコールバックを _disposed フラグ(Dispose で設定される)でガードし、そこで _restartPending をクリアし、タイマーに null 条件を付けてください。再起動を要求し、すぐに dispose し、debounce ウィンドウを過ぎるまで待機して、何も例外を投げないことをアサートするテストを追加し、修正前にそれが失敗することを確認してください。CONTRIBUTING.md に従い、この説明と TickerNet 自身のコードだけに基づいて作業してください。

索引モデルが issue の本文から書いたものです。

説明

.NET bug

What happens

RestartThrottleManager (src/TickerNet/Src/RestartThrottleManager.cs) sets _debounceTimer to null in Dispose, but leaves _restartPending as it was and has no disposed flag. A timer callback that was already queued then runs _debounceTimer.Change(...) on null (around line 54) and throws NullReferenceException on a thread-pool thread, which ends the process. RequestRestart after Dispose fails the same way.

It shows up when a host stops shortly after a restart was requested, and in test hosts that are disposed quickly.

Fix idea

Add a _disposed flag checked under the lock in OnTimerCallback and RequestRestart, clear _restartPending in Dispose, and use _debounceTimer?.. Test: request a restart, dispose at once, wait past the debounce window, and check that nothing throws.


Found while checking which problems that TickerQ fixed after the fork still exist in TickerNet. Fix it from this description and TickerNet's own code only: never read or copy code from TickerQ 10.5.0 or later (see CONTRIBUTING.md). Please add a test that fails before the fix.

主要言語
C#
スター
0
フォーク
2
平均マージ
1時間 8分
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TickerNet/TickerNet のほかの issue

TickerNet/TickerNet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。