Bug 19991 - Calling Syscall.GetLastError() throws ArgumentOutOfRange for 93
Summary: Calling Syscall.GetLastError() throws ArgumentOutOfRange for 93
Status: RESOLVED FIXED
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-05-22 08:32 UTC by Till Lorentzen
Modified: 2014-05-23 13:45 UTC (History)
2 users (show)

Tags:
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 Developer Community or GitHub 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 Till Lorentzen 2014-05-22 08:32:12 UTC
The following code produces a System.ArgumentOutOfRangeException:
"Current platform doesn't support this value.
Parameter name: value
93"


Code:

byte[] value;
Mono.Unix.Native.Syscall.getxattr(System.IO.Directory.GetCurrentDirectory(), "test", out value);
Mono.Unix.Native.Syscall.GetLastError();

MacOS Version 10.9.3

But it works on Linux.

Mono.Posix.dll:
Version 4.0.0.0 PublicKeyToken=0738eb9f132ed756
Comment 1 Jonathan Pryor 2014-05-23 12:23:13 UTC
The Errno enum values are based on the Linux values. On Linux, ENOATTR is an alias for ENODATA, and thus the Errno enum doesn't contain an entry for ENOATTR.

On OS X, ENOATTR is NOT an alias for ENODATA, and in this case getxattr() is setting errno to 93, which is ENOATTR. Since there's no mapping for ENOATTR, the exception is thrown.

Reviewing the OS X errno.h, I find that there are 20 error values which aren't yet bound in the Errno enum.

The fix is both simple and complicated: we need to add the missing constants to the Errno enum. The complication comes in adding the values without complicating the addition of future Linux error values; I see that Errno is also missing 7 new values from Linux as well.
Comment 2 Jonathan Pryor 2014-05-23 13:45:40 UTC
Fixed in mono/d2b52794.