Windows: endpoints hang or crash when several bind at once (concurrent WMI default-route queries?)
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
- 領域
- backend, networking
調査の方向性
Start with src/interfaces/windows.rs and inspect get_default_route, which the issue identifies as the WMI query path. Compare it with the reported GetIpForwardTable2(AF_INET) approach and check how Windows dependencies and route detection are handled. Done means concurrent endpoint binds no longer hang or crash on Windows while default route detection retains the described behavior.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
We're seeing this in our project and wanted to share it in case it's useful.
On Windows, when several iroh endpoints are created at the same time in one process, Endpoint::bind()
sometimes hangs (it never returns) or the process crashes. In our CI, a test that binds five endpoints at once
on loopback failed in about 3 of every 4 runs on GitHub's Windows runners. It never fails on Linux or macOS.
This looks related to #124, but it still happens with the spawn_blocking fix from #127 (we're on 0.19.3).
The difference here is several WMI queries running at the same time, one per netmon::Monitor.
What we found:
- The hangs and crashes happen inside the WMI query that
interfaces::windows::get_default_routeruns over
COM (Win32_IP4RouteTable). With full page heap enabled, our runs stopped on freed memory inside COM during
those queries (combase!OXIDEntry::DecRefCnt,CROIDTable::ClientDeRegisterOIDFromPingServer, and once in
an already unloadedwbemprox.dll). - Initializing COM ourselves first (MTA, security) and keeping a WMI connection open didn't help.
- Reading the route table with
GetIpForwardTable2(AF_INET)and checking for a route with prefix length 0
avoids COM entirely. With only that change, the failures stopped: our Windows CI has passed every run since,
including repeated runs of the same commit.
A side note we noticed: Win32_IP4RouteTable.Name is the route's destination, not an interface name, so on
Windows default_route_interface is always "0.0.0.0". The replacement below keeps that value, so
is_major_change behaves the same. Returning the real interface (the row's InterfaceIndex) could be a
follow-up.
This is the replacement we're using in a patched copy (it drops the wmi and serde dependencies on
Windows):
fn get_default_route() -> Result<DefaultRouteDetails, Error> {
let mut table: *mut MIB_IPFORWARD_TABLE2 = std::ptr::null_mut();
// SAFETY: Windows allocates the table and returns it in `table`.
unsafe { GetIpForwardTable2(AF_INET, &mut table) }.ok()?;
// SAFETY: on success `table` points to `NumEntries` rows, read here only, and freed once below.
let found = unsafe {
let rows = std::slice::from_raw_parts((*table).Table.as_ptr(), (*table).NumEntries as usize);
let found = rows.iter().any(|row| row.DestinationPrefix.PrefixLength == 0);
FreeMibTable(table.cast());
found
};
if !found {
return Err(e!(Error::NoRoute));
}
Ok(DefaultRouteDetails { interface_name: "0.0.0.0".to_string() })
}
(still called through tokio::task::spawn_blocking, as now.)
The full change is here: https://github.com/alexpacheli/hext-remote/tree/main/vendor/netwatch (see
PATCHED.md and src/interfaces/windows.rs).
Relevant Logs
No useful trace logs: the process just stops inside the WMI query. The page heap stacks are the ones above.
Expected behavior
Several endpoints can bind at the same time on Windows without hanging or crashing.
netwatch, portmapper
Version: netwatch 0.19.3 (through iroh 1.4.1), wmi 0.18.4
Platform(s)
Desktop:
- OS: Windows Server 2025 (GitHub Actions
windows-2025runner) - Version: x86_64-pc-windows-msvc
Additional Context / Screenshots / GIFs
Happy to test a fix or provide more details. The investigation was done with the help of an AI coding
assistant; the results above (the failures and the fix) come from our CI runs.
lolwut
- This issue was created by a human that thought critically about
the issue being reported and wrote this as concisely and clearly
as they could. Taking full responsibility for the issue being
accurate. - This issue isn't slop, and is backed up by evidence.
- 主要言語
- Rust
- スター
- 34
- フォーク
- 56
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
n0-computer/net-tools のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 33/100
n0-computer/net-tools#280 ·
メンテナーはふだん 2 日以内に返信
-
netwatch: objc2-system-configuration with default features pulls objc2-security into every macOS build対応中かも @flub が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
n0-computer/net-tools#278 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
n0-computer/net-tools#276 ·
メンテナーはふだん 2 日以内に返信
-
netwatch never turns on noq-udp's Apple fast path, so iroh's `fast-apple-datapath` does nothingオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
n0-computer/net-tools#272 ·
メンテナーはふだん 2 日以内に返信
-
portmapper: synchronous HomeRouter lookup blocks the Tokio worker対応中かも @TNTcraftHIM が 19 日前に担当しました。 オープンready-for-pr
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
n0-computer/net-tools#266 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
n0-computer/net-tools の issue をすべて見る
似ている issue
-
area:web kind:bug priority:p2 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
sims1253/r-typeshed#140 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
storytold/craft-libs#2867 ·
メンテナーはふだん 1 日以内に返信
-
help wanted needs investigation priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100