Bug 19460 - View Accessor for Zero byte file MemoryMappedFile
Summary: View Accessor for Zero byte file MemoryMappedFile
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Core ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-05-01 14:42 UTC by nicholas.rudh
Modified: 2014-06-19 19:10 UTC (History)
2 users (show)

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

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:

Description nicholas.rudh 2014-05-01 14:42:07 UTC
  Hello, I am currently using Mono on a Xilinx Zynq board. I have been trying to use /dev/mem to increase the speed at which I can toggle GPIO pins. However i have found that there is an error with how the MemoryMappedFile handles Zero byte files. The first was addressed in the current Master solution(error with "capacity"), but there is another when one tries to create a MemroyMapedViewAccessor from a Zero byte file the "size" will always be set to zero because of this logic (line 165 MemoryMapImpl.Map)

   if (size == 0 || size > fsize)
      size = fsize;

  fsize will always be zero resulting in size being set to zero and the Syscall.mmap will fail and return a -1 resulting in the IOException being thrown.

 Steps to Reproduce: 
1) create MemoryMap of /dev/mem
2) create MemoryMappedViewAccessor

 Actual Results: 
  Throws the IOException (line 186) because the mmap fails

 Expected Results: 
  Create a MemoryMappedViewAccessor, which should allow for size to be greater than the file size.

 Build Date & Platform: 
  5/1/2014 PetaLinux v2013.10 Yocto 1.4

 Additional Builds and Platforms: 

if you need anymore information I can provide it. Thanks
Comment 1 Rodrigo Kumpera 2014-06-19 19:10:57 UTC
Fixed in master.