Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

MemoryMappedFile (Windows): failed MEM_COMMIT is ignored, accessor over reserved memory crashes the process

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

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

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

評価

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

調査の方向性

src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.csを読み、特に遅延割り当て用にVirtualAllocがページをコミットする62~70行目を確認してください。近くのコードがネイティブ割り当ての失敗をどのように報告し、ビューを破棄するかを確認してください。コミットに失敗した場合、書き込み時にクラッシュする可能性のあるアクセサーを返すのではなく、ビューの作成時に例外がスローされれば完了です。

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

説明

area-System.IO bug untriaged

Description

MemoryMappedView.CreateView calls Interop.VirtualAlloc(..., MEM_COMMIT, ...) for DelayAllocatePages views but discards its return value. The following failure check tests viewHandle.IsInvalid (the already-valid map view handle) instead, so a failed commit is treated as success and the view is published over MEM_RESERVE pages.

Repro

Plain safe C#. The view is larger than the system commit limit.

using System.IO.MemoryMappedFiles;

using var mmf = MemoryMappedFile.CreateNew(null, 1L << 42, MemoryMappedFileAccess.ReadWrite,
    MemoryMappedFileOptions.DelayAllocatePages, HandleInheritability.None);
using var acc = mmf.CreateViewAccessor(0, 1L << 40);
Console.WriteLine("accessor created, capacity=" + acc.Capacity);
acc.Write(0, (byte)1);
Console.WriteLine("write succeeded");

Actual behavior

net11.0 RC2, win-x64 (64 GB RAM, commit limit ~103 GB). CreateViewAccessor succeeds, then an in-range write is a fatal AccessViolationException:

accessor created, capacity=1099511627776
Fatal error.

(1L << 36 = 64 GB views succeed on this machine, so it only reproduces above the commit limit.)

Expected behavior

CreateViewAccessor / CreateViewStream throws (e.g. IOException / Win32Exception for the commit failure). Safe accessor APIs never fault.

Notes

  • src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs:62-70.
  • Fix: capture the VirtualAlloc result, and on failure dispose the view and throw with the last error.
主要言語
C#
スター
18.4k
フォーク
5.8k
平均マージ
2日 16時間
マージ済み PR(30日)
631

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

dotnet/runtime のほかの issue

dotnet/runtime の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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