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)

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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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!