Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[remoting] Set fRefine to false in call to Unmarshal(ObjRef) Fixes #49308 #5863

Closed
wants to merge 2 commits into from

Conversation

lambdageek
Copy link
Member

However if the server type has a ProxyAttribute custom attribute, set fRefine
back to true.

This matches logic in InternalUnmarshal in
https://github.com/mono/mono/blob/master/mcs/class/referencesource/mscorlib/system/runtime/remoting/remotingservices.cs#L834

The issue is that we may deserialize an ObjRef in some domain (domain2) when a
MarshalByRef instance is passed as an argument to a method of a server object
running in domain2. The observed .NET framework behavior is that this should
not cause domain2 to try to load the type (and consequently the assembly) of
the MarshalByRef object (except in the case where it's actually a
ContextBoundObject that has a ProxyAttribute). (Note however that the
transparent proxy of the MarshalByRef instance in domain2 must be handled
lightly - as long as its treated as an opaque reference and just loaded/stored
from System.Object variables or members, the type won't be loaded).

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=49308

Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=49308

We try to trick the remoting code into causing an assembly from a bad directory
to be loaded too eagerly into an appdomain.  If we succeed, we call a method
that doesn't exist.  Expected behavior is that the bad assembly is not loaded
and instead we can do an Assembly.LoadFrom of a good assembly.
…9308

However if the server type has a ProxyAttribute custom attribute, set fRefine
back to true.

This matches logic in InternalUnmarshal in
referencesource/mscorlib/system/runtime/remoting/remotingservices.cs

The issue is that we may deserialize an ObjRef in some domain (domain2) when a
MarshalByRef instance is passed as an argument to a method of a server object
running in domain2.  The observed .NET framework behavior is that this shoudl
not cause domain2 to try to load the type (and consequently the assembly) of
the MarshalByRef object (except in the case where it's actually a
ContextBoundObject that has a ProxyAttribute).  (Note however that the
transparent proxy of the MarshalByRef instance in domain2 must be handled
lightly - as long as its treated as an opaque reference and just loaded/stored
from System.Object variables or members, the type won't be loaded).

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=49308
@lambdageek
Copy link
Member Author

This broke. DebuggerTests.MemberInOtherDomain
ApplicationHostTest.ConstructorTest - calling Object:GetType() on a MarshalByRef subclass (or rather - its transparent proxy) doesn't do the right thing after this PR. Investigating

@lambdageek
Copy link
Member Author

This approach won't work. See Bugzilla 49308, Comment 4.

Closing this PR; going to open a new PR just to push the (disabled) test case.

@lambdageek lambdageek closed this Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants