* Only null check target for delegate if method is not static. Fixes regression introduced by 1cfd52452a.
* pass first stack arg to transform, so we get the correct delegate wrapper
the wrapper logic detects if the target method of a delegate is a static
method with an argument bound, and handles it properly in the generated
code.
fixes mono/tests/delegate14.cs
* [bcl] Add .NET 4.7.1 reference assemblies
Backport of #5974 to 2017-10
* [class] Add Obsolete message to ICSharpCode.SharpZipLib.dll
Users should use the nuget package instead, we'll remove the assembly in Mono 6.0
Don't install it into the 4.7.1 reference assembly directory anymore.
(cherry-pick of 2a03be316d)
* Bump API snapshot submodule
Follow up to https://github.com/mono/mono/pull/6431, we should
capture the exception that is passed to the methods.
Copied the SetResult() method that referencesource uses.
(cherry picked from commit ad5703adfd)
Also ensure that WebConnection calls nstream.EndRead().
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61002
This bug is a regression in HTTPS web request cancellation behavior
first introduced on the 2017-06 branch by
https://github.com/mono/mono/commit/1b5e0f73316ee7b83c8947bc738015443fabd7af.
It is in fact resolved already for the master branch by the refactoring
in https://github.com/mono/mono/pull/6125. But since that refactoring
is too large to backport and since the master branch won't be integrated
into a release for a while longer, it is worth adding a separate smaller
fix for the older active development branches.
This proposed fix is intentionally conservative in how it modifies
`WebConnection.EndWrite()` and `WebConnection.EndRead()`. It makes sure
to keep precisely the same return values and exceptions as before.
The fix also makes a small change to the `Close()` method to avoid
setting `nstream = null`. This allows any pending `EndWrite()`,
`EndRead()`, or `ReadDone()` callbacks to use the `nstream` field even
after `Close()` has run. This shouldn't cause any new garbage
collection issues because the closed `WebConnection` object is not
expected to live much longer than the `NetworkStream` object referenced
by `nstream`.
Example of the problem for canceling `HttpClient.SendAsync()`
=============================================================
1. `WebConnectionStream.SetHeadersAsync()` calls
`WebConnection.BeginWrite()`, passing in an anonymous callback method
that will later call `WebConnection.EndWrite()` when the asynchronous
write operation completes [1].
2. When the `CancellationToken` for the call to `HttpClient.SendAsync()`
is notified about the cancellation, it calls `HttpWebRequest.Abort()`
[2], which calls `WebConnection.Abort()`, which calls
`WebConnection.Close()`.
3. `WebConnection.Close()` calls `Close()` on both the
`MobileAuthenticatedStream` and the network `Socket` and nulls out
the `WebConnection`'s field references to those objects [3].
`MobileAuthenticatedStream.Close()` in turn calls
`MobileAuthenticatedStream.Dispose()`, which sets the `lastException`
field to an `ObjectDisposedException`. If the asynchronous write
operation from step 1 is still in progress at this point, it will
throw the `ObjectDisposedException`.
4. When `MobileAuthenticatedStream.StartOperation()` throws the
`ObjectDisposedException` (thus completing the running Task), the
anonymous callback method from step 1 gets invoked, and it calls
`WebConnection.EndWrite()`.
5. The problem is that now `WebConnection.EndWrite()` fails to call
`MobileAuthenticatedStream.EndWrite()`. There are 2 parts of the
problem:
(a) `WebConnection.EndWrite()` always returns _before_ calling
`MobileAuthenticatedStream.EndWrite()` [4] because the call to
`Abort()` at step 2 has set the request status to canceled [5].
(b) Even if the cancellation status check weren't there, the attempt
to call `MobileAuthenticatedStream.EndWrite()` still wouldn't work
because `Close()` has set the reference to the stream to `null` at
step 3.
The proposed fix addresses (a) by rearranging `WebConnection.EndWrite()`
and `WebConnection.EndRead()` so that they _always_ call the
corresponding `MobileAuthenticatedStream` methods. It addresses (b) by
removing the line in `Close()` that sets the `nstream` field to `null`.
How did mono/2017-06 commit 1b5e0f7 introduce this problem?
===========================================================
Commit 1b5e0f7 uses Tasks and the `TaskToApm()` helper method
_correctly_, so by itself it's OK. The problem is that the older
`WebConnection` methods already had underlying limitations _before_
commit 1b5e0f7. In the Asynchronous Programming Model, "for each call
to BeginOperationName, the application should also call EndOperationName
to get the results of the operation" [6]. But `WebConnection` did not
strictly follow this rule. For example, `WebConnection.EndWrite()` did
_not_ always call `MobileAuthenticatedStream.EndWrite()`. This
imprecise behavior worked until now because unlike unobserved exceptions
in Tasks, "unobserved" exceptions in AsyncResult objects don't trigger
any behaviors when the objects are finalized. (The exceptions are just
discarded.) But now that `MobileAuthenticatedStream.BeginWrite()` uses
Tasks behind the scenes, `WebConnection` needs to be stricter about
following the rules.
Testing the proposed fix against old bugs from `git blame`
==========================================================
- Commit 613c2a9182https://bugzilla.xamarin.com/show_bug.cgi?id=31507
Results: Verified still fixed. I was able to reproduce the original
behavior by intentionally removing the old fix. I then put the old
fix back, added the new proposed changes, and verified that the test
case still produced the good behavior (only task cancellation
messages).
- Commit 7584df6cf8
Neither of the bugs mentioned in the commit message for 7584df6cf8
appears to be related to the `Data.request` check. Since that check
is the only part of the commit touched by the new proposed changes,
neither of the bugs should be affected. But just to be thorough, I
quickly ran through the test cases associated with those bugs.
https://bugzilla.novell.com/show_bug.cgi?id=515931
Results: OK. I tried the test case from
https://bugzilla.novell.com/show_bug.cgi?id=515097 with
`AllowWriteStreamBuffering` set to `true` or `false`. The write
operation started successfully in both cases, and the call to
`Abort()` was able to cancel the operation as expected.
https://bugzilla.novell.com/show_bug.cgi?id=510642
Results: OK. The test case still produced the expected overflow
exception.
References
==========
[1] https://github.com/mono/mono/blob/b293f453027bc075ce636988b383451e5c346347/mcs/class/System/System.Net/WebConnectionStream.cs#L664-L666
[2] https://github.com/mono/mono/blob/b293f453027bc075ce636988b383451e5c346347/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs#L347
[3] https://github.com/mono/mono/blob/b293f453027bc075ce636988b383451e5c346347/mcs/class/System/System.Net/WebConnection.cs#L1131-L1143
[4] https://github.com/mono/mono/blob/b293f453027bc075ce636988b383451e5c346347/mcs/class/System/System.Net/WebConnection.cs#L1033-L1034
[5] https://github.com/mono/mono/blob/b293f453027bc075ce636988b383451e5c346347/mcs/class/System/System.Net/WebConnection.cs#L1169
[6] https://docs.microsoft.com/dotnet/standard/asynchronous-programming-patterns/asynchronous-programming-model-apm
Lack of it causes a build error in XA:
CMake Error at [..]mono/external/boringssl/util/android-cmake/android.toolchain.cmake:800 (message):
Specified Android native API level 'android-12' is not supported by your
The set of minimum API levels in `configure.ac` is incorrect. The current
NDK (r16) requires minimum API level of 14 for the 32-bit targets and level 21
for the 64-bit targets.
When we leave a try block and invoke finally blocks, we need to add try holes also for catch handlers, since they can invoke the previously handled finally blocks.
When doing an OP_CALL_HANDLER for a clause (from a leave opcode), all following instructions, up until the actual branch out of the try block, should be part of a hole for that clause. We were failing to account for a single leave instruction invoking multiple finally clauses sequentially, in which case a basic block can be a try hole for multiple clauses.
Some generic instances were not generated because they were only referenced by METHOD_RGCTX patches, and the gsharedvt
fallback didn't work because the method in question Unsafe.Add<T> uses a sizeof opcode on a gsharedvt type which is currently
not supported.
Testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Runtime.CompilerServices;
public class Tests
{
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void Foo55<T> () {
byte[] arr = new byte [10];
ref byte data0 = ref arr [0];
Unsafe.Add (ref data0, 0);
}
interface IFace {
void Foo55 <T> ();
}
class AClass : IFace {
public void Foo55 <T> () {
byte[] arr = new byte [10];
ref byte data0 = ref arr [0];
Unsafe.Add (ref data0, 0);
}
}
public static int Main () {
IFace iface = new AClass ();
iface.Foo55<int> ();
return 0;
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Implicitly add "Content-Length: 0" for all requests with a null body unless
we're using a body-less HTTP Verb (HEAD, GET, MKCOL, CONNECT, TRACE).
(cherry picked from commit 6beed5f791)
Instead of using find_method which relies on method name and exact signature
matching (and thus can't work for variant interfaces), use the vtable and the
interface offset to find the constrained method.
Terminology:
base method - a method of the base class to be called
base class - some general class or interface that declares a method
constraint class - a more specific class that also implements the method.
constrained method - the version of the base method in the constraint class.
To find the constrained method given the base method:
- if the base class is a class:
the constraint class can't be an interface. it's either the base class or
some subclass of it. If the base method isn't virtual there's nothing to do
the constrained method is the same one.
If the base method is virtual, get its vtable slot and find the corresponding
method in the constraint class's vtable.
- if the base class is an interface:
in this case the constraint class is either another interface or a class.
if the constraint class is an interface, since interfaces can't have
implementations, there's nothing to do.
if the constraint class is a class, then to find the constrained method
get the interface slot offset of the base method and find the base interface offset
of the base interface and look in the constrained class vtable.
(the base interface offset gives the starting vtable slot for the base
interface in the constraint class vtable; the slot offsets go consecutively
for each of the methods of the interface).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60545
This introduces the following changes.
By default, enable more events. Exceptions and Counters are on by default.
By default, if alloc or heapshot are enabled, we emit root events as well.
New `nodefaults` argument that disables the above changes to default arg processing.
Added "nocalls" argument for compat only purposes.
Restored "cycles/" prefix to sample frequency argument. It was already a dead argument, but kept for compat.
We restored that as existing clients pass that flag.
ModuleBuilder::GetArrayMethod returns a fresh MonoArrayMethod instance each
time it's called, even if you ask for the same method multiple times. On the
other hand, mono_image_get_array_token caches tokens by method signature.
Therefore mono_image_create_token should expect collisions.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60238
Preserve
`System.Runtime.Remoting.Activation.ActivationServices.CreateProxyForType`. It
is called from `object.c:mono_object_new_specific_checked` when
constructing remoting or com objects.
I didn't add `feature="remoting"` because it is used also for com
objects.
Added linker test. Without the LinkerDescriptor addition, it fails
like this:
Unhandled Exception:
System.NotSupportedException: Linked away.
at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_object_new_specific(intptr)
at C.Main () [0x00001] in /Users/rodo/git/mono/mcs/tools/linker/Tests/mscorlib/test-remoting.cs:11
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException: Linked away.
at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_object_new_specific(intptr)
at C.Main () [0x00001] in /Users/rodo/git/mono/mcs/tools/linker/Tests/mscorlib/test-remoting.cs:11
(cherry picked from commit 4b702c8d6a)
- Don't copy 14.0/Imports to 15.0 now, as we do that in nuget-buildtasks.
- And don't create symlinks for Microsoft.NuGet.targets as it is not
required anymore.
This is a candidate fix for:
https://bugzilla.xamarin.com/show_bug.cgi?id=60317
The bug was introduced by 1b5e0f7331.
Preliminary verification
========================
If I make just this _one_ change to a "bad" commit of Mono from after
commit 1b5e0f7, rebuild System.dll in the `xammac` profile, and then
overwrite that file in the MonoBundle directory of a Xamarin.Mac test
app, then I restore the old "good" behavior. (I started with
38da0b3b49 as the "bad" version for my
tests.)
I believe this confirms that the cause of bug 60317 was the usual
deadlocking issue when awaiting Tasks on the UI thread. As discussed on
https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html, if
any Tasks awaited anywhere up the call stack are missing
`ConfigureAwait (false)`, then you can run into trouble on the UI
thread.
Additional little checks
========================
1. Do the other `await` statements in commit
1b5e0f7331 all look OK? Yes, it looks
like this was the only `await` statement that was missing
`ConfigureAwait (false)`:
```
$ git show 1b5e0f7331 | grep await
+ await ProcessOperation (cancellationToken).ConfigureAwait (false);
+ var ret = await InnerRead (cancellationToken).ConfigureAwait (false);
+ await Parent.InnerWrite (RunSynchronously, cancellationToken);
+ var ret = await Parent.InnerRead (RunSynchronously, requestedSize, cancellationToken).ConfigureAwait (false);
+ result = await asyncRequest.StartOperation (CancellationToken.None).ConfigureAwait (false);
+ result = await asyncRequest.StartOperation (cancellationToken).ConfigureAwait (false);
+ var ret = await task.ConfigureAwait (false);
+ await task.ConfigureAwait (false);
```
2. Is it a concern that mcs/class/System did not contain any calls to
`ConfigureAwait ()` until commit 1b5e0f7:
```
$ git grep ConfigureAwait 1b5e0f73316ee7b83c8947bc738015443fabd7af^ -- mcs/class/System || echo 'None'
None
```
I do not think this is a concern. For example,
System.Net.Http.HttpClient has been using `ConfigureAwait (false)` for
several years, so there is a precedent for it.
* [Tests] Make Mono.Data.Sqlite tests more robuts.
There are cases in which the tests are ran in parallel and the files
used for the db are writte/read by several tests at the same time. This
changes ensures that we do have a diff test file per test case to ensure
that we do not have false negatives.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=59909
WebChannelFactory doesn't add the WebHttpBehavior on mobile:
https://github.com/mono/mono/blob/4272b68b769951c221ec39d3e844f8f715e1df62/mcs/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs#L87-L90
This makes the WebInvokeAttributeTest.RejectTwoParametersWhenNotWrapped
test fail on mobile since it doesn't reach the normal validation
method where it'd fail with InvalidOperationException, e.g. here''s
the stack on net_4_x profile:
```
System.InvalidOperationException : Operation 'Join' has multiple message body parts. Add parameters to the UriTemplate or change the BodyStyle to 'Wrapped' or 'WrappedRequest' on the WebInvoke/WebGet attribute.
at System.ServiceModel.Description.WebHttpBehavior.ValidateOperation (System.ServiceModel.Description.OperationDescription operation) [0x000f9] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs:249
at System.ServiceModel.Description.WebHttpBehavior.Validate (System.ServiceModel.Description.ServiceEndpoint endpoint) [0x00028] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs:268
at System.ServiceModel.Description.ServiceEndpoint.Validate () [0x0007f] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs:129
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) [0x0002b] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:148
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address) [0x00000] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:115
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00006] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:110
```
We can fix this by adding the WebHttpBehavior in the test manually.
NB: I'm actually not sure why this isn't done by default on MOBILE?
According to MSDN it should.
(cherry picked from commit 733b4a4c9f)
Some of the IO tests do not create a diff temp file per test but per
fixture. This is problematic when the test cases are ran in parallel.
Moving the creation of the tmp dirs to the SetUp to ensure that each
test case has its own path.
The zip tests were not using temp files which created bug #60480 when
trying to read the embeded resources. This also fixes the situation in
which tests are run in parallel for the Mac since we could have tests
that step on each other files.
d9922895d4 removed Mono.Unix.Native/SocketTest.cs
from the exclude list on the monodroid profile.
It turns out that some tests don't work there however,
they fail with an ArgumentOutOfRangeException on some socket options.
(cherry picked from commit 0dbdcf2e77)
Roslyn looks only inside `$msbuild_bin/Roslyn/` and does not fallback to
the framework path. msbuild worked around this by setting `CscToolPath`:
https://github.com/mono/msbuild/commit/157a0f4d1a7aadd4e561e3ca8c784cbc2529926f
But this kicks in only if the default msbuild target files are imported!
If the `Csc` task is being used without importing them, then we fail
with
`error MSB3082: Task failed because "csc.exe" was not found.`
`Microsoft.CodeAnalysis.VisualBasic.dll` is the only file not being
symlinked, after this change. So, instead we will symlink all the files.
Fixes bxc #60340 .
Cherry-pick 26ccf75f06
These tests classes are already included in the corlib test assembly.
Having them duplicated in System.Core causes issues in XA because
both test assemblies are in the same process.
To solve this we introduce abstract *TestBase classes that we can
share between the test assemblies and only mark the concrete test
class implementations with [TestFixture]
(cherry picked from commit 1e29ed0d7e)
quote from the darwin man page:
> The functions getpwnam_r(), getpwuid_r(), and getpwuuid_r()
> return 0 if no error occurred, or an error number to indicate
> failure. It is not an error if a matching entry is not found.
> (Thus, if result is NULL and the return value is 0, no
> matching entry exists.)
Just over a year ago Xamarin.Android switched to running BCL tests straight
from the Mono sources but at the time we decided we didn't want to enable
a number of "new" tests (in the sense - never previously ran on XA) to avoid
introducing new failures in time which required focusing on more important
goals.
Currently, Xamarin.Android no longer uses Mono **sources** to build its tests
but, rather, it uses test **assemblies** built by Mono. This commit restores
the previously excluded tests in preparation for full BCL test coverage in
the near future.
(cherry picked from commit d9922895d4)
--
[bcl] Fix test assembly build for monodroid profile
Those aren't yet tested in XA but they're built when running "make -C runtime test"
so XA had to suppress errors in that step.
To avoid this we make those test assemblies compile by removing the unit tests
that rely on classes not available in the monodroid profile.
(cherry picked from commit 464c5916d5)
When I added temp dir handling to SaveTest in https://github.com/mono/mono/pull/5727
I copied the Setup/TearDown from TypeBuilderTest.
However that class doesn't actually save+load the assemblies so
it doesn't run into the issue on Windows where assemblies can't
be deleted because they're still loaded in the AppDomain.
To fix this follow CustomAttributeBuilderTest and ModuleBuilderTest,
i.e. just catch all Exception's in teardown...
(cherry picked from commit 606f40e708)
We need this because XA is now starting to use the test assemblies
we build in the Mono repo instead of using the .cs source directly
and this would conflict.
(cherry picked from commit c89a3e55b7)
When I simplified MONO_CORLIB_VERSION to only include major.minor
instead of major.minor.build in https://github.com/mono/mono/pull/5449
I forgot to apply the same change to the msvc copy of that logic.
(cherry picked from commit 43757d67ef)
In the C parser check for empty at the outset.
In the managed parser, copy an empty string component to the built-up TypeSpec
and handle it in the Type.GetType (..., asmResolver, typeResolver) implementation
It'd fail to find System.Runtime.dll and System.ValueTuple.dll.
Changed the csi.rsp to include those from the Facades/ dir and added a test.
Workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=58965
(cherry picked from commit 75415afa76)
https://github.com/mono/mono/pull/5680 added mmap/sendfile prototypes
but we should only use those when ANDROID_UNIFIED_HEADERS is defined
to avoid getting errors like:
```
/Users/alexander/dev/xamarin-android/external/mono/mono/utils/mono-compiler.h:157:7: error: conflicting types for 'mmap'
void* mmap (void*, size_t, int, int, int, __mono_off32_t);
^
/Users/alexander/android-toolchain/toolchains/arm-linux-androideabi-clang/bin/../sysroot/usr/include/sys/mman.h:47:15: note: previous declaration is here
extern void* mmap(void *, size_t, int, int, int, off_t);
^
/Users/alexander/dev/xamarin-android/external/mono/mono/utils/mono-compiler.h:166:9: error: conflicting types for 'sendfile'
ssize_t sendfile (int out_fd, int in_fd, __mono_off32_t* offset, size_t count);
^
/Users/alexander/android-toolchain/toolchains/arm-linux-androideabi-clang/bin/../sysroot/usr/include/sys/sendfile.h:36:16: note: previous declaration is here
extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
```
(cherry picked from commit 4058c2be43)
It was writing to the current working directory before which
doesn't work on platforms where that directory is read-only.
Using the same setup/teardown methods as TypeBuilderTest we
instead create a directory in the temporary location and put
the files there.
(cherry picked from commit c9fc371e31)
* Add new profile for monodroid tools
This allows the XA build to use these instead of needing to build net_4_x.
We build the assemblies against the .NET 4.6 reference assemblies.
* Skip monodroid_tools in verify (aka mcs-compileall)
Exclude it from the test_profiles since running tests makes no sense there.
Also refactor to exclude binary_reference_assemblies as well,
it was already excluded manually in mcs-compileall before.
(cherry picked from commit b2a11ac756)
TestHelper was previously excluded because the XA tests weren't built
as part of Mono but rather as part of XA test suite which included
its own version of the helper. Now, however (https://github.com/xamarin/xamarin-android/commit/e9daf5ea35709ce1bc6ba81c7c37d72d385bace2),
XA uses BCL+friends test assemblies built by Mono itself and so
we need to restore TestHelper in the build.
Up until NDK release 14 Android SDK included a separate set of C header
files for each supported platform. NDK 14 introduced a new set of those
headers (they are NOT the same as the old ones) which unifies support
for all of the platforms so that bug fixes are available for all the
API levels without having to backport etc. With NDK 15 the unified headers
become the default ones (including when creating standalone toolchains)
and with NDK 16 (in beta currently) the old per-platform headers are removed.
Unfortunately, the new headers introduce breaking changes which made it
impossible to build Mono with NDK configured to use them. This commit makes
a handful of changes to Mono which make it build with unified headers.
Loaded 100 of 540 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.