Skip to content

Conversation

@radekdoulik
Copy link
Member

  • preserve the GetInstance method whenever the
    Mono.Unix.Native.FileNameMarshaler type is used

  • it avoids errors like:

      ReadlinkTest
      	ReadLink [FAIL] : System.ApplicationException : Custom marshaler 'FileNameMarshaler' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler.
      		  at (wrapper managed-to-native) Mono.Unix.Native.Syscall:readlinkat (int,string,byte[],ulong)
      		  at Mono.Unix.Native.Syscall.readlinkat (System.Int32 dirfd, System.String pathname, System.Byte[] buf) [0x0000a] in <75558c6e0e1f444f8a03d1c694a92a08>:0
      		  at MonoTests.Mono.Unix.ReadlinkTest.SetUp () [0x00007] in <9df8009b87984e1cb863e771d21f9f39>:0
      		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
      	readlink_byte [FAIL] : System.ApplicationException : Custom marshaler 'FileNameMarshaler' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler.
      TearDown : System.ArgumentException : ** Unknown error code: 9**
        ----> Mono.Unix.UnixIOException : ** Unknown error code: 9** [EBADF].
      		  at (wrapper managed-to-native) Mono.Unix.Native.Syscall:readlinkat (int,string,byte[],ulong)
      		  at Mono.Unix.Native.Syscall.readlinkat (System.Int32 dirfd, System.String pathname, System.Byte[] buf) [0x0000a] in <75558c6e0e1f444f8a03d1c694a92a08>:0
      		  at MonoTests.Mono.Unix.ReadlinkTest.SetUp () [0x00007] in <9df8009b87984e1cb863e771d21f9f39>:0
      		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
      		--TearDown
      		  at Mono.Unix.UnixMarshal.ThrowExceptionForLastError () [0x00006] in <75558c6e0e1f444f8a03d1c694a92a08>:0
      		  at MonoTests.Mono.Unix.ReadlinkTest.TearDown () [0x00011] in <9df8009b87984e1cb863e771d21f9f39>:0
      		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
      		--UnixIOException
    

@jonpryor
Copy link
Contributor

Instead of special-casing Mono.Unix.Native.FileNameMarshaler, I think you should instead preserve the static ICustomMarshaler GetInstance() method on any type that implements ICustomMarshaler. That would automatically handle FileNameMarshaler, and any other custom marshaler.

@radekdoulik
Copy link
Member Author

@jonpryor
Copy link
Contributor

build

1 similar comment
@jonpryor
Copy link
Contributor

build


if (type.HasMethods && type.HasInterfaces && type.Implements (ICustomMarshalerName)) {
foreach (MethodDefinition method in type.Methods)
if (method.Name == "GetInstance" && method.IsStatic && method.HasParameters && method.Parameters.Count == 1 && method.ReturnType.FullName == ICustomMarshalerName && method.Parameters.First ().ParameterType.FullName == "System.String")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check the remaining methods once this if has executed? Perhaps we can break after the MarkMethod(method)?

ProcessSystemCore (type);

if (type.HasMethods && type.HasInterfaces && type.Implements (ICustomMarshalerName)) {
foreach (MethodDefinition method in type.Methods)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces around the foreach.

 - preserve the static ICustomMarshaler GetInstance (string) method
   of types implementing ICustomMarshaler interface

 - it avoids errors like:

         ReadlinkTest
         	ReadLink [FAIL] : System.ApplicationException : Custom marshaler 'FileNameMarshaler' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler.
         		  at (wrapper managed-to-native) Mono.Unix.Native.Syscall:readlinkat (int,string,byte[],ulong)
         		  at Mono.Unix.Native.Syscall.readlinkat (System.Int32 dirfd, System.String pathname, System.Byte[] buf) [0x0000a] in <75558c6e0e1f444f8a03d1c694a92a08>:0
         		  at MonoTests.Mono.Unix.ReadlinkTest.SetUp () [0x00007] in <9df8009b87984e1cb863e771d21f9f39>:0
         		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
         		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
         	readlink_byte [FAIL] : System.ApplicationException : Custom marshaler 'FileNameMarshaler' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler.
         TearDown : System.ArgumentException : ** Unknown error code: 9**
           ----> Mono.Unix.UnixIOException : ** Unknown error code: 9** [EBADF].
         		  at (wrapper managed-to-native) Mono.Unix.Native.Syscall:readlinkat (int,string,byte[],ulong)
         		  at Mono.Unix.Native.Syscall.readlinkat (System.Int32 dirfd, System.String pathname, System.Byte[] buf) [0x0000a] in <75558c6e0e1f444f8a03d1c694a92a08>:0
         		  at MonoTests.Mono.Unix.ReadlinkTest.SetUp () [0x00007] in <9df8009b87984e1cb863e771d21f9f39>:0
         		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
         		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
         		--TearDown
         		  at Mono.Unix.UnixMarshal.ThrowExceptionForLastError () [0x00006] in <75558c6e0e1f444f8a03d1c694a92a08>:0
         		  at MonoTests.Mono.Unix.ReadlinkTest.TearDown () [0x00011] in <9df8009b87984e1cb863e771d21f9f39>:0
         		  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
         		  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <9f55149ed93f4bad9226ce1d7634fe5b>:0
         		--UnixIOException
@radekdoulik
Copy link
Member Author

Updated. It would probably still not build as it is on cycle9 branch.

@jonpryor
Copy link
Contributor

I don't understand why, I don't know what's going on, but the PR builder doesn't like this commit.

Pr Builds 451, 455, and 456 have all taken "unreasonable" amounts of time -- taking over 5 hours, where a normal PR build is less than 20 minutes -- because they can't connect to the emulator:

03:32:54 		Executing: "/Users/builder/android-toolchain/sdk/platform-tools/adb"   uninstall Mono.Android_Tests
03:32:54 		Environment variables being passed to the tool:
03:32:55 		- waiting for device -

I don't understand why this only appears to impact this PR, and none of the others.

@jonpryor
Copy link
Contributor

Updated. It would probably still not build as it is on cycle9 branch.

Oh! That's because PR builds don't work on the cycle 9 branch.

Doh!

Why is this going to the cycle9 branch and not master? Surely master needs this fix, too, no? Or is the fix in external/linker?

@radekdoulik
Copy link
Member Author

It is cycle9 bug, so it needs to be fixed in cycle9 I guess.

For master I would like to create patch for mono/linker repo.

@jonpryor jonpryor merged commit c62d79f into dotnet:cycle9 Jan 26, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants