You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Darwing.Common Icon tests failures on Mono on Windows. #47759
This code depends on COM support and currently Mono on Windows have not enabled COM support (inline with other Mono netcore platforms). This triggers a rather subtle problem that can cause crash depending on what registers has been used up to this point.
Mono will not do anything specific with the signature:
so OleCreatePictureIndirect expects parameters in rcx,rdx,r8 and r9 inline with Windows x64 ABI, but since above dllimport is not handled differently on Mono compared to other dllimports, it will assume 3 parameters and that returned interface will be placed in rax, and that will, depending on content in r9 cause random crashes or undefined behaviour.
IconTests that hits this code path will be disabled with this issue as its active issue.
Yes, I believe that is something we should probably investigate doing, one thing I was a little curious around is how CoreClr handles that signature, is there some logic that will detect that the return in this case is actually the forth parameter of the underlying method so the interop can do the right thing or is that an effect of PreserveSig=false? Reading docs on PreserveSig it only says it will handle HRESULT and raise exception on failure, and that the method will return void, https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig?view=net-5.0#remarks, couldn't find anything saying that the return value of the signature will be appended as an out parameter to underlying call. Don't believe Mono implement PreserveSig at all, and certainly not using that behaviour.
is there some logic that will detect that the return in this case is actually the forth parameter of the underlying method so the interop can do the right thing or is that an effect of PreserveSig=false?
It is effect of PreserveSig=false. PreserveSig=false changes the unmanaged return type to HRESULT and moves the managed return type into an extra unmanaged out argument.
OK, that was what I suspected, then I believe this hits several underlying issues on Mono, first COM is not enabled/supported, and second, Mono doesn't implement the PreserveSig attribute, so above signature will not be adjusted. Is that behaviour of PreserveSig=false documented?
Activity
jkotas commentedon Feb 2, 2021
Should Mono throw when it encounters unsupported type in the PInvoke signatures? It is what CoreCLR does on non-Windows.
lateralusX commentedon Feb 2, 2021
Yes, I believe that is something we should probably investigate doing, one thing I was a little curious around is how CoreClr handles that signature, is there some logic that will detect that the return in this case is actually the forth parameter of the underlying method so the interop can do the right thing or is that an effect of PreserveSig=false? Reading docs on PreserveSig it only says it will handle HRESULT and raise exception on failure, and that the method will return void, https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute.preservesig?view=net-5.0#remarks, couldn't find anything saying that the return value of the signature will be appended as an out parameter to underlying call. Don't believe Mono implement PreserveSig at all, and certainly not using that behaviour.
jkotas commentedon Feb 2, 2021
It is effect of
PreserveSig=false.PreserveSig=falsechanges the unmanaged return type to HRESULT and moves the managed return type into an extra unmanagedoutargument.lateralusX commentedon Feb 2, 2021
OK, that was what I suspected, then I believe this hits several underlying issues on Mono, first COM is not enabled/supported, and second, Mono doesn't implement the PreserveSig attribute, so above signature will not be adjusted. Is that behaviour of
PreserveSig=falsedocumented?jkotas commentedon Feb 2, 2021
Submitted the documentation fix in dotnet/dotnet-api-docs#5303
JeremyKuhne commentedon Apr 4, 2023
System.Drawing.Common has moved to WinForms.