Bug 56493 - Windows MMAP doesn't release file
Summary: Windows MMAP doesn't release file
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 5.0 (2017-02)
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: Niklas Therning
URL:
Depends on:
Blocks:
 
Reported: 2017-05-16 12:03 UTC by Michael DeRoy
Modified: 2017-05-16 17:40 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Standalone Xamarin Studio Project to r (21.48 KB, application/x-zip-compressed)
2017-05-16 12:03 UTC, Michael DeRoy
Details

Description Michael DeRoy 2017-05-16 12:03:12 UTC
Created attachment 22196 [details]
Standalone Xamarin Studio Project to r

MMAP on windows does not correctly release the file after it is done. To reproduce, download the standalone xamarin studio test project.

Build and run with .NET framework: We get the expected console output
----------
hello
hello
----------


Build and run with Mono 5.0: We get an I/O error on the second mmap
----------
hello

Unhandled Exception:
System.IO.IOException: Could not open file
  at System.IO.MemoryMappedFiles.MemoryMapImpl.OpenFile (System.String path, System.IO.FileMode mode, System.String mapName, System.Int64& capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options) [0x0001c] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:102
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, System.IO.FileMode mode, System.String mapName, System.Int64 capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access) [0x00056] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:177
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, System.IO.FileMode mode, System.String mapName) [0x00000] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:156
  at ReproMMAPFileOpenBug.MainClass.Main (System.String[] args) [0x0009c] in <217a32d6da324f858f64abcbf08d516d>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Could not open file
  at System.IO.MemoryMappedFiles.MemoryMapImpl.OpenFile (System.String path, System.IO.FileMode mode, System.String mapName, System.Int64& capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access, System.IO.MemoryMappedFiles.MemoryMappedFileOptions options) [0x0001c] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:102
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, System.IO.FileMode mode, System.String mapName, System.Int64 capacity, System.IO.MemoryMappedFiles.MemoryMappedFileAccess access) [0x00056] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:177
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, System.IO.FileMode mode, System.String mapName) [0x00000] in D:\j\workspace\y\repos\mono\mcs\class\System.Core\System.IO.MemoryMappedFiles\MemoryMappedFile.cs:156
  at ReproMMAPFileOpenBug.MainClass.Main (System.String[] args) [0x0009c] in <217a32d6da324f858f64abcbf08d516d>:0
----------
Comment 1 Niklas Therning 2017-05-16 14:54:17 UTC
A PR with a fix has been submitted: https://github.com/mono/mono/pull/4877
Comment 2 Niklas Therning 2017-05-16 17:40:19 UTC
PR has now been merged. Thanks for reporting this!

Note You need to log in before you can comment on or make changes to this bug.