MemoryMappedFile (Windows): failed MEM_COMMIT is ignored, accessor over reserved memory crashes the process
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- backend, operating-systems
Hướng nghiên cứu
Đọc src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs, đặc biệt là các dòng 62–70, nơi VirtualAlloc commit các trang cho việc cấp phát trì hoãn. Kiểm tra cách mã gần đó báo lỗi cấp phát native và giải phóng view. Công việc hoàn tất khi commit thất bại khiến việc tạo view ném ngoại lệ thay vì trả về một accessor có thể gặp sự cố khi ghi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
VirtualAllocresult, and on failure dispose the view and throw with the last error.
- Ngôn ngữ chính
- C#
- Star
- 18.4k
- Fork
- 5.8k
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 631
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/runtime
-
area-System.ComponentModel untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/runtime#136608 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-System.IO untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dotnet/runtime#136577 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[mono] Native memory leak on the first invoke of every open-instance delegate to a virtual methodĐang mởarea-VM-meta-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dotnet/runtime#136284 · 6 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Several MemoryExtensions.LastIndexOfAnyExcept overloads incorrectly document "first occurrence"Có thể đã có người làm @ehsan-raoufi đã nhận 6 ngày trước. Đang mởarea-System.Memory untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
dotnet/runtime#136282 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MemoryExtensions.LastIndexOf ignores a custom comparer for bitwise-equatable element typesCó thể đã có người làm @aw0lid đã nhận 7 ngày trước. Đang mởarea-System.Runtime untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
dotnet/runtime#136281 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/runtime
Issue tương tự
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Include host.wslc.internal in the HTTPS development certificateCó thể đã có người làm @afscrome đã nhận hôm nay. Đang mởarea-commandlinetools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
dotnet/aspnetcore#70122 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:1st_place_medal: good first issue :cowboy_hat_face: refactor :roller_coaster: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ApplETS/Backend-Hello#78 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Custom component in Summary2 no longer receives raw formData (regression from app-frontend v4)Đang mởstatus/triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Altinn/altinn-studio#21642 ·
Maintainer thường phản hồi trong vòng 1 ngày