Bug 42068 - System.IO.DriveInfo.GetDrives() returns random garbage when certain mount point present
Summary: System.IO.DriveInfo.GetDrives() returns random garbage when certain mount poi...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 4.4.0 (C7)
Hardware: PC Windows
: --- normal
Target Milestone: 4.8.0 (C9)
Assignee: Alexander Köplinger [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-06-22 09:11 UTC by Gerald
Modified: 2016-10-17 12:55 UTC (History)
3 users (show)

Tags: C8SR1
Is this bug a regression?: Yes
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:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Gerald 2016-06-22 09:11:57 UTC
My C# backup program has recently developed a habit for occasionally failing. I've dug into this and found the following:

System.IO.DriveInfo.GetDrives() is also causing weird problems for me.
This might be related to Bug 11923 (https://bugzilla.xamarin.com/show_bug.cgi?id=11923), but our versions are pretty far apart and I think mine was once working in Mono 4.2.x and before...
I'm using Mono Stable 4.4.0.148/fcf7a6d on Linux 4.4.13 (Gentoo x64).

Andrews simple test case code from Bug 11923 fails for me in the following way:

Drive: ࢋ㸐»
Drive.RootDirectory: ࢋ㸐»
  File type: Unknown
  Volume label: ࢋ㸐»
  File system:

Unhandled Exception:
System.IO.FileNotFoundException: Could not find file "ࢋ㸐»"
File name: 'ࢋ㸐»'
  at System.IO.DriveInfo.GetDiskFreeSpace (System.String path, System.UInt64& availableFreeSpace, System.UInt64& totalSize, System.UInt64& totalFreeSpace) <0x414fb4f0 + 0x00063> in <filename unknown>:0
  at System.IO.DriveInfo.get_AvailableFreeSpace () <0x414fb470 + 0x0003f> in <filename unknown>:0
  at Test.Main () <0x414dde00 + 0x000f7> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not find file "ࢋ㸐»"
File name: 'ࢋ㸐»'
  at System.IO.DriveInfo.GetDiskFreeSpace (System.String path, System.UInt64& availableFreeSpace, System.UInt64& totalSize, System.UInt64& totalFreeSpace) <0x414fb4f0 + 0x00063> in <filename unknown>:0
  at System.IO.DriveInfo.get_AvailableFreeSpace () <0x414fb470 + 0x0003f> in <filename unknown>:0
  at Test.Main () <0x414dde00 + 0x000f7> in <filename unknown>:0

(the exact weird chinese symbols change on EVERY run of the exe and once in about ten runs i get "Assertion at strenc.c:183, condition `utf8!=NULL' not met" and it doesn't even get this far and crashes instantly before listing something - which is probably what causes my backup program to fail in some cases)

The problematic "drive" that causes this to fail is a SMB mount of my Synology NAS share. It is listed by mount as:
//192.168.88.251/FILESERVER-BACKUP on /mnt/backup/nvBackup/smb_mount_201606212201 type cifs (rw,relatime,vers=1.0,cache=strict,username=HerrFileServer,domain=BIVLX1-BACKUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.88.251,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=1048576,actimeo=1,user=HerrFileServer)

Once I unmount my SMB share the problem is gone.

I did some tests. The path where I mount the share to triggers this:

WORKS ==> /mnt/test/
WORKS ==> /mnt/smb_mount_201606212201/
WORKS ==> /mnt/something_really_long_but_not_very_complicated_long_path/
WORKS ==> /mnt/backup/nvBackup/smb_mount_2016/
WORKS ==> /mnt/smb_mount_201606212201/
FAILS ==> /mnt/backup/nvBackup/smb_mount_201606212201/
WORKS ==> /mnt/backup/nvBackup/smb_mount_201606212201a/
FAILS ==> /mnt/backup/nvBackup/smb_mount_20160621220a/
FAILS ==> /mnt/backup/aaaaaaaa/bbbbbbbbbbbbbbbbbbbbbb/
WORKS ==> /mnt/backup/aaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbb/

There seems to be a specific length case for the path it is mounted to or something else in the length of the mount options that causes newer versions of mono to cause some really weird problems.
Comment 1 Gerald 2016-06-22 10:33:53 UTC
I've now tried older and even newer versions of mono:

4.4.0.182 => NOT OK (from "dotnet" overlay, not yet in gentoo portage tree)
4.4.0.148 => NOT OK (original version I tried)
4.4.0.40  => NOT OK
4.2.2.30  => WORKS!
Comment 2 Luis Aguilera 2016-09-12 20:09:06 UTC
since C8 is now closed, and is shipping this week, I will move this but to the C8SR1 milestone. We'll continue working on the issue seeking it's resolution as soon as possible.
Comment 3 Alexander Köplinger [MSFT] 2016-10-17 12:02:06 UTC
Hey, so I finally had a chance to look at the issue and unfortunately I can't reproduce it here.

Scenarios I tried (with the problematic mount points you listed):

- Accessing a Windows file share from OSX with Mono 4.4+ - works
- Accessing an Ubuntu share from OSX with Mono 4.4+ - works
- Accessing an OSX share from Ubuntu with Mono 4.4+ - works
- Accessing an Ubuntu share from Gentoo Live CD with Mono 4.4 from portage - works
- Accessing an OSX share from Gentoo Live CD with Mono 4.4 from portage - works
- Accessing a Windows share from Gentoo Live CD with Mono 4.4 from portage - works

I even ask a colleague to try it against his Synology NAS - works too.

Another thing is that the code paths involved are virtually unchanged between Mono 4.2 and 4.4. It might be something specific to how your system is configured.

At this point I'd need a way to reproduce this to find out more. If you can find a simple example setup/config that shows the problem please post it here. Thank you!
Comment 4 Gerald 2016-10-17 12:27:10 UTC
Thank you for trying to reproduce this. I just logged into the server which had the problem and even though it was 100% reproducible this summer the problem is gone now.

I can't really say what fixed it. It could be that Mono 4.6.0.245/746756c, which is currently in use on the server fixed it. Or maybe this weird problem was only present with a certain kernel version or glibc version and upgrading this fixed it somewhere else...

So since my test case has disappeared I don't have something for you to debug/reproduce. I suggest you close the bug for now...

Thanks!
Comment 5 Alexander Köplinger [MSFT] 2016-10-17 12:55:42 UTC
Ok, thanks for the info!