* Use the right FileSystemWatcher sources
The corefx code for FileSystemEventArgs has some changes to support
constructing one with a null filename.
Fixes#16486
* Remove the mono sources for the newly replaced files
* [csproj] Update project files
Resolves#16122
Since we put in the corefx version of GZipStream, it is expected that
our version of DeflateStream actually implements Write+ReadAsyncMemory.
This change does that by just calling the plain WriteAsync & ReadAsync
methods until we decide (or not) to pull in the corefx DeflateStream.
Backport of #16523.
As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.
This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.
However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.
Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.
Backport of https://github.com/mono/mono/pull/16441
Fixes https://github.com/mono/mono/issues/16032
When we switched to corefx File.Copy on unix, the behavior changed where it opened a source and destination stream in order to pass the safe handles to Interop.Sys.CopyFile. This exposed a flaw in our sharing validation rules in MonoIO.Open, which threw an exception in this scenario:
new FileStream("source.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 2048, FileOptions.DeleteOnClose);
new FileStream("source.txt", FileMode.Open, FileAccess.Read, FileShare.Read, 2048, FileOptions.None);
Simplified the FileShare check down to:
1. If the caller specifies FileShare.None, then it's an exclusive lock and no
sharing is allowed.
2. If the caller specifies some other FileShare option, then FileShare.None
cannot be specified.
* [marshal] Always use gchandles in delegate_hash_table
Makes the code easier to follow and it also fixes race from https://github.com/mono/mono/commit/caa4a753ca8e15d43baaa01adb0f56f374b74a2b with boehm.
* [marshal] Free delegates with target that are passed to native code.
For static method delegates, we have a unique delegate_trampoline that is shared among all delegates. We always keep alive the first static method delegate passed to native, by creating a normal gchandle to it and storing it in delegate_hash_table. For instance methods, each delegate will create a separate wrapper and these wrappers are never shared (which was wrongly assumed in https://github.com/mono/mono/commit/caa4a753ca8e15d43baaa01adb0f56f374b74a2b). We shuldn't keep the delegate alive and this commit reverts the behavior for delegate with instance methods introduced in the mentioned commit.
Fixes https://github.com/mono/mono/issues/15751
We need to clearly distinguish between synchronous and asynchronous completions
and avoid any ambiguities and race conditions when it comes to error handling.
On synchronous completion, we must not invoke the async completion delegate.
In `System.Net.Sockets/Socket.cs`, the internal `BeginSConnect()` and `BeginMConnect()`
now return a `bool` indicating whether or not an async operation is pending.
If any error happens prior to starting the async operation, then we shall call
`SocketAsyncResult.Complete(..., true)` and return `false`. And since this is
a synchronous completion, it's `AsyncCallback` will not be invoked.
In `referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs`,
I compared the entire file against the CoreFX version and then copied the
`AttemptConnection()` method from their implementation to adapt their behavior.
The difference is that on synchronous completion, the `InternalConnectCallback(null, args)`
should be invoked.
Backport of #15947.
Sometimes Google DNS is/was returning "dns.google" for reverse query of 8.8.8.8 and 8.8.4.4 instead of the expected "google-public-dns-a.google.com" and "google-public-dns-b.google.com". Since "dns.google" resolves to both 8.8.8.8 and 8.8.4.4 in random order the round-trip tests for IP -> hostname -> IP were failing when they got the other IP.
This changes the logic in the hostname -> IP check to check whether the expected IP is any one of the returned ones (ie. non necessarily the first one).
(cherry picked from commit 7ea8460025)
This was suggested by XA folks to fix the weird mingw llvm issues we've been seeing.
(cherry picked from commit 4b6f49bb06)
(cherry picked from commit ea8da188ef)
* Time zone DST out fix
* Add unit tests for Europe/Vatican, Iran and Europe/Guernsey time zones
* Disable the tests on WINAOT; fixed Iran time zone id
Homebrew Git 2.22.0 misparses the submodule command and passes arguments like --hard and -xdff to git-submodule instead of to git-reset or git-clean. Passing the entire command as a single argument seems to help.
* When the catch found is in a MONO_WRAPPER_RUNTIME_INVOKE the exception should be treated as an UNHANDLED by the debugger.
* Adding unit test.
* trying to fix side effect.
* I've tested the MonoTests.DebuggerTests.UnhandledException_2 test on VsWin using .net Framework and I think the test is wrong because the first break is in throw and the next break will be on breakpoint. In our implementation we were ignoring the unhandled exception and stopping only on breakpoint.
Work around a weird bug in Homebrew git 2.22.0:
git submodule foreach --recursive git reset --hard HEAD
errors out with:
error: unknown option `hard'
usage: git submodule--helper foreach [--quiet] [--recursive] [--] <command>
which is nonsense because `git foreach -h` says:
usage:
...
or: git submodule [--quiet] foreach [--recursive] <command>
The workaround is to call
git submodule foreach --recursive scripts/ci/git-reset-hard.sh HEAD
and hide the `--hard` option in the shell script
We have several issues (e.g. https://github.com/mono/mono/issues/14181) where the installer occasionally fails in the postinstall script for unknown causes, on some hosts.
This seems to be sometimes the culpable section and this patch should help trace the issue or alleviate the common symptoms of it (see https://github.com/mono/mono/issues/14181)
Xamarin.Mac can call back here from a native thread that isn't attached to the
runtime. SGen gchandle code is lockfree, and the profiler event can fire
without involving Mono.
Some profiler events (for example gc_handle_deleted) could be raised on threads
that aren't attached to the runtime. Since the thread won't participate in
Mono's stop the world (since the runtime can't see it), there's no need to do
the transition to GC Safe while the thread is trying to grab the profiler
buffer lock.
This is unfortunate.
The general pattern of:
if initialized
use the data
else:
initialize the data, possibly with lots of locks and barriers
mark initialized
is racy, because "use the data" can be scheduled ahead of "if initialized".
"Barriers come in pairs" generally, and this was missing one.
It depends somewhat. If the data is all pointers, initialized in the else path,
from null to non-null, and use includes dereferencing, which is a common
but not universal case, then it is ok on all non-Alpha processors, due
to "data dependency".
But if the data includes reading globals, then there is a race.
This is a bit of a slow down on fast paths on arm, and possibly
other architectures.
There are barrier-free ways to solve this, involving a thread local,
that should seriously be considered, and applied throughout the runtime.
The runtime has a lot of on-demand initialization and a lot of looks racy.
See www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm.
Which would have to be adopted to be coop-friendly which should not be difficult.
Notice that the existing "lazy" mechanism is also not coop-friendly.
That is not changed by this PR.
* [System.Net.Http]: Add hack to the legacy HttpClient to pass down Timeout property. #12577.
* `HttpClientHandler`, `IMonoHttpClientHandler`: add new internal `MonoSetTimeout (TimeSpan)` function.
* `HttpClient.SendAsyncWorker()`: if `handler` is `HttpClientHandler`, call the new internal
`MonoSetTimeout()` function to pass down the timeout.
* `MonoWebRequestHandler.SendAsync()`: this is only used here to pass the timeout to the `HttpWebRequest`.
* Address feedback.
* Update HttpMessageInvoker.cs
* Make it build.
* Really make it build (forgot monotouch_watch).
(cherry picked from commit a44db72a1c)
Prevent the SDKs from making dangling symlinks when packaging the MXE
cross-compilers: should hav
mono.exe -> mono-sgen.exe
rather than
mono -> mono-sgen (dangling).
* Implement RSACertificateExtensions.CopyWithPrivateKey(). #14152. (#14860)
* Implement RSACertificateExtensions.CopyWithPrivateKey(). #14152.
* RSACertificateExtensions.CopyWithPrivateKey(): implement.
Since `RSACertificateExtensions` lives in `System.Core` and only `mscorlib`
internals (but not `System` internals) are visible to it, we need to use a
little trick here:
* System.Security.Cryptography.X509Certificates.X509CertificateImpl:
add new abstract methods CopyWithPrivateKey() and CreateCertificate().
* System.Security.Cryptography.X509Certificates.X509Certificate2Impl:
sealed implement them here.
The `httpcfg` tool, only checks whether the key is valid, so we don't really
need to call `CopyWithPrivateKey()` (which requires us to take a dependency
on `System.Core`).
* Do the same thing in HttpListener.
(cherry picked from commit ac908dd334)
* Bump API snapshot submodule
If we have a ref struct and a method that takes it as an argument:
```
[Serializable]
public ref struct R {
public int i;
}
public interface I {
public void M1 (R r, SomeClass o);
}
public class M : MarshalByRefObject, I {
public void M1 (R r, SomeClass o) { ... }
}
```
If we create an instance of M in another domain and try to call it:
```
I obj = (I)otherDomain.CreateInstanceAndUnwrap (typeof(M).Assembly.FullName,
nameof(M));
R r;
r.i = 42;
SomeClass o = ...;
obj.M1 (r, o);
```
Mono will need to create a wrapper that can invoke M.M1 in the other domain.
The way the wrapper works in `mono_marshal_get_xappdomain_invoke` is by
creating an array of all the arguments that need to be serialized (see
`mono_get_xdomain_marshal_type`) and then serializing the whole array (by
calling out to `System.Runtime.Remoting.RemotingServices.SerializeCallData`).
In the example it would make a two element array and try to serialize `r` and
`o` into it. For valuetypes it normally does this by boxing the argument.
However since `R` is a ref-struct, boxing it is not allowed.
This works on .NET Framework.
However for Mono we would need to serilize `R` without boxing it, which seems
challenging with our current setup.
So for now we generate a wrapper that just throws a NotImplementedException if
it is ever called.
This fixes https://github.com/mono/mono/issues/14809 (in that marshalling a
TextWriter across domains works again) but in an unsatisfactory way (because
you can't call any of the ReadOnlySpan<char> overloads on the transparent proxy
object).
1) CC_MD5_Init, CC_MD5_Update and CC_MD5_Final are deprecated.
```c
mono-md5.c:45:2: error: 'CC_MD5_Init' is deprecated: first deprecated in macOS 10.15 - This function is
cryptographically broken and should not be used in security contexts. Clients should migrate to SHA256
(or stronger). [-Werror,-Wdeprecated-declarations]
CC_MD5_Init (ctx);
^
```
2) objc_msgSend is deprecated
```
mono-threads-mach-helper.c:95:17: error: too many arguments to function call, expected 0, have 2
objc_msgSend (value, release);
~~~~~~~~~~~~ ^~~~~~~~~~~~~~
```
XCode has a special switch `Enable Strict Checking of objc_msgSend Calls` which is now `true` by default. It's fixed by `-DOBJC_OLD_DISPATCH_PROTOTYPES=1` flag to clang or the corresponding define in the source file.
3) Fixes https://github.com/mono/mono/issues/14793
It worked on pre 10.15 without `-framework GSS`, because it got pulled in through the dependencies. You can see it by running DYLD_PRINT_LIBRARIES=1 csharp and then trace it back. On Mojave /System/Library/Frameworks/GSS.framework/Versions/A/GSS got loaded as dependency of /usr/lib/libcups.2.dylib and so on. Unlike Windows, macOS will resolve the symbols to whatever is already available so it was just happy that someone loaded GSS before libmono-native[-compat/-unified].
[2019-02] [arm64] Correct exception filter stack frame size
Fixes: https://github.com/mono/mono/issues/14170
Fixes: https://github.com/xamarin/xamarin-android/issues/3112
The `call_filter()` function generated by `mono_arch_get_call_filter()`
was overwriting a part of the previous stack frame because it was not
creating a large enough new stack frame for itself. This had been
working by luck before the switch to building the runtime with Android
NDK r19.
I used a local build of [xamarin/xamarin-android/d16-1@87a80b][0] to
verify that this change resolved both of the issues linked above. I
also confirmed that I was able to reintroduce the issues in my local
environment by removing the change and rebuilding.
After this change, the generated `call_filter()` function now starts by
reserving sufficient space on the stack to hold a 64-bit value at the
`ctx_offset` location. The 64-bit `ctx` value is saved to the
`ctx_offset` location (offset 344 in the new stack frame) shortly
afterwards:
stp x29, x30, [sp,#-352]!
mov x29, sp
str x0, [x29,#344]
As expected, the invocation of `call_filter()` now no longer modifies
the top of the previous stack frame.
Top of the stack before `call_filter()`:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
Top of the stack after `call_filter()` (unchanged):
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
<details>
<summary>Additional background information</summary>
### The original lucky, "good" behavior for [mono/mono/2018-08@725ba2a built with Android NDK r14][1]
1. The `resume` parameter for `mono_handle_exception_internal()` is
held in register `w23`.
2. That register is saved into the current stack frame at offset 20 by
a `str` instruction:
0x00000000000bc1bc <+3012>: str w23, [sp,#20]
3. `handle_exception_first_pass()` invokes `call_filter()` via a `blr`
instruction:
2279 filtered = call_filter (ctx, ei->data.filter);
0x00000000000bc60c <+4116>: add x9, x22, x24, lsl #6
0x00000000000bc610 <+4120>: ldr x8, [x8,#3120]
0x00000000000bc614 <+4124>: ldr x1, [x9,#112]
0x00000000000bc618 <+4128>: add x0, sp, #0x110
0x00000000000bc61c <+4132>: blr x8
Before the `blr` instruction, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x0a8b31d8 0x00000071
0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071
4. `call_filter()` runs. This function is generated by
`mono_arch_get_call_filter()` and starts with:
stp x29, x30, [sp,#-336]!
mov x29, sp
str x0, [x29,#344]
Note in particular how the first line subtracts 336 from `sp` to
start a new stack frame, but the third line writes to a position
that is 344 bytes beyond that, back within the *previous* stack
frame.
5. After the invocations of `call_filter()` and
`handle_exception_first_pass()`, `w23` is restored from the stack:
0x00000000000bc820 <+4648>: ldr w23, [sp,#20]
At this step, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071
Notice how `call_filter()` has overwritten bytes 8 through 15 of the
stack frame. In this original lucky scenario, this does not affect
the value restored into register `w23` because that value starts at
byte 20.
6. `mono_handle_exception_internal()` tests the value of `w23` to
decide how to set the `ji` local variable:
2574 if (resume) {
0x00000000000bb960 <+872>: cbz w23, 0xbb9c4 <mono_handle_exception_internal+972>
Since `w23` is `0`, `mono_handle_exception_internal()` correctly
continues into the `else` branch.
### The bad behavior for [mono/mono/2018-08@725ba2a built with Android NDK r19][2] works slightly differently
1. As before, the local `resume` parameter starts in register `w23`.
2. This time, the register is saved into the stack frame at offset 12
(instead of 20):
0x00000000000bed7c <+3200>: str w23, [sp,#12]
3. As before, `handle_exception_first_pass()` invokes `call_filter()`
via a `blr` instruction.
At this step, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
4. `call_filter()` runs as before. And the first few instructions of
that function are the same as before:
stp x29, x30, [sp,#-336]!
mov x29, sp
str x0, [x29,#344]
5. `w23` is again restored from the stack, but this time from offset 12:
0x00000000000bf2c0 <+4548>: ldr w23, [sp,#12]
The problem is that `call_filter()` has again overwritten bytes 8
through 15 of the stack frame:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
So after the `ldr` instruction, `w23` has an incorrect value of
`0x7f` rather than the correct value `0`.
6. As before, `mono_handle_exception_internal()` tests the value of `w23` to
decide how to set the `ji` local variable:
2574 if (resume) {
0x00000000000be430 <+820>: cbz w23, 0xbe834 <mono_handle_exception_internal+1848>
But this time because `w23` is *not* zero, execution continues
*incorrectly* into the `if` branch rather than the `else` branch.
The result is that `ji` is set to `0` rather than a valid
`(MonoJitInfo *)` value. This incorrect value for `ji` leads to a
null pointer dereference, as seen in the bug reports.
[0]: https://github.com/xamarin/xamarin-android/tree/xamarin-android-9.3.0.22
[1]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1432/Azure/
[2]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1436/Azure/
</details>
Backport of #14757.
/cc @lambdageek @brendanzagaeski
When passing a delegate to native code, we pass the delegate_trampoline which can be used to invoke the delegate from native code and we store this mapping (delegate_trampoline->delegate) in a hashtable so we can get a delegate for the delegate_trampoline, when marshalling the opposite way. If we are trying to marshal a ftnptr (for managed code) to a delegate and we don't find this mapping we can crash. This could happen if the finalization for some other delegate that uses the same ftnptr removes this entry from the table. We solve this by never freeing these entries. The first delegate-ftnptr pair will always be alive. This is easier, faster and potentially uses less memory than tracking in the hashtable every pair. There should be a small and limited set of methods marshalled to native.
Fixes https://github.com/mono/mono/issues/13231
We didn't set all the categories that the products used in our profiles.
Now that the products can consume the exclude categories from mono we
need to unify the values.
Removed ValueAdd since it's not used anymore and combined MacNotWorking
into NotOnMac.
(cherry picked from commit f46191114b)
During XI integration we noticed that just using the verbatim commandline
-exclude or -notrait is not ideal since XI uses the nunit/xunit APIs to
pass that information and not the command line parser.
Instead we now write the exclude categories/traits as a newline-separated file.
(cherry picked from commit 07c58ee2ed)
We used to use the static MXE toolchain, but after switching to Homebrew, we
have to explicitly pass flags to build binaries that don't depend on the
MinGW32 GCC support libraries (libstdc++-6.dll, libwinpthread-1.dll and others)
when building the LLVM and Mono binaries.
The simplest approach is just to pass CMAKE_EXE_LINKER_FLAGS=-static to cmake
and LDFLAGS=-all-static to libtool. The rest of the changes are just to make
it easier to do that by adding a configure flag and updating the SDKs
infrastructure.
We will also need an LLVM bump to actually build a new llvm archive with the
new build flags; until then, building Mono will provision an old build of LLVM
with the old build flags that still depends on libstdc++-6.dll.
---
An alternative approach instead of passing -all-static and -static would be to
probe for the assorted -static-libXYZ flags to GCC at configure time. (For the
LLVM build we would need to hardcode them as that build doesn't go through
autoconf). Right now Mono doesn't have any other DLL dependencies (other than
the core windows DLLs), so -all-static works just as well and is simpler.
Otherwise the Xcode linker tries to guess the version from the path,
and since we use Xcode101.app it'd use sdk=101 as the version which is wrong.
By explicitly specifying e.g. `$(XCODE_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
as the sysroot it correctly guesses sdk=12.1 instead.
See also https://github.com/xamarin/xamarin-macios/commit/834c0a9fd7062c0c25011721fd7d524b8a60b41e
Some of the packages/bockbuild caches have somehow ended up with a Nuget 5.0.0 binary, even after the 5.0.2 bump. We suspect that the wrong binary was temporarily published on the 5.0.2 URL
* Throw ObjectDisposedException instead of crashing when Cairo.Context.handle == IntPtr.Zero
We are seeing instances where VS for Mac is crashing with a SIGSEGV when
calling into certain Cairo.Context functions. Looking at the code, it's clear
that it's possible to have Context.handle == IntPtr.Zero after disposing the
object.
From research, it looks like passing a nullptr to raw cairo functions can
result in a SIGSEGV:
https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/93807
This change adds check to see if Conext.handle == IntPtr.Zero in Context
painting, font, and path methods. This will turn uncatchable SIGSEGVs
into ObjectDisposedException.
* Update Context.cs
* Ensure SetTarget results in a valid handle
* [System.Core] Ensure monotouch[_runtime] API are identical
Ensure the API surface for `System.Core.dll` is identical between the
`monotouch` and `monotouch_runtime` (used for REPL and the interpreter).
This ensure code compiled against one will be fine when building against
the other (e.g. avoiding linker errors).
Removed methods:
```csharp
public void CompileToMethod (System.Reflection.Emit.MethodBuilder method);
public void CompileToMethod (System.Reflection.Emit.MethodBuilder method, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator);
```
Removed methods:
```csharp
[Obsolete ("do not use this method")]
public static IRuntimeVariables MergeRuntimeVariables (IRuntimeVariables first, IRuntimeVariables second, int[] indexes);
[Obsolete ("do not use this method")]
public static System.Linq.Expressions.Expression Quote (System.Linq.Expressions.Expression expression, object hoistedLocals, object[] locals);
```
* [csproj] Update project files
* Bump API snapshot submodule
* [csproj] Update project files
It was using an unescaped makefile variable in the template, i.e. ended up empty which meant the build just took the host version as the min version.
Fixed the variable and also moved it to CFLAGS/CXXFLAGS instead of CPPFLAGS to be consistent with ios.mk
Context: https://github.com/xamarin/xamarin-android/issues/2780
On Android the executable for the application is going to be
`/system/bin/app_process{32,64}` depending on the application's architecture.
However, libraries for the different architectures live in different
subdirectories of `/system`: `lib` for 32-bit apps and `lib64` for 64-bit ones.
Thus appending `/lib` below will fail to load the DSO for a 64-bit app, even if
it exists there, because it will have a different architecture. The quickest fix
is to use `lib64` explicitly for 64-bit Android apps.
* Bump msbuild to track mono-2019-02
.. to pick up an update for the NuGetSdkResolver and nuget.
* Update nuget.exe too
* [msbuild] Bump to pick up test fixes
* [msbuild] Bump to pick up more fixes
* [monodroid] Introduce 'win32 host' BCL build
* [sdks] Add _bcl_$(1)_BUILD_FLAGS variable to BclTemplate build step
Allows Android SDK on Windows to pass PROFILE_PLATFORM=win32
* [sdks] Pass _bcl_$(1)_BUILD_FLAGS when building the tests, too
* Copy test source exclusion files from the general monodroid profile
Apparently we don't fall back to the general exclusion sources for tests if the platorm-specific exclusion file does not exist.
* Also add win32 copies of the nunit exclude files:
files=$(find . -name "monodroid*_test*exclude.sources")
for file in $files
do
name=$(basename $file)
pushd $(dirname $file)
cp $name win32_$name
git add win32_$name
popd
done
* Adjust sources for 2019-02 backport
* [csproj] Update project files
* [sdks] allow building on cygwin
* [sdks] Cherrypick platform detection from f83d9f3575
* [sdks] Start adding stub templates to llvm.mk
* [sdks] provision-android stubs for win32
* [sdks] Pass cygwin host triple to calls to configure on win32
* [sdks] Add runtime stub templates
* [sdks] Add android stub templates for win32
This is enough to get configure-android to work on cygwin x86_64
* [sdks] On win32, the HostMxe build is the host buildwe want the x86_64-w64-mingw32 toolchain, not the cygwin toolchain
* [sdks] For android on cygwin depend on the mingw64-{x86_64,i686}-zlib
* [sdks] Add android SDK build artifacts to .gitignore
* [sdks] Add AndroidCrossMXETemplate stub to android.mk for Windows builds
* [sdks] Fixup comments in android.mk
* [sdks] use UNAME=Windows for Cygwin and WSL
Don't assume Cygwin is the build platform for Windows Android SDK builds.
Keep using UNAME for coarse platform descriptions.
Switch to HOST_ARCH_MINGW32 instead of CYGWIN_BUILD_MACHINE for variable holding
the machine part of the host triplet for Windows.
* [sdks] Dummy provision-mxe target for windows
* [ci] Don't provision-android on Windows
It doesn't work yet.
* [sdks] temporarily turn off android-host-mxe-Win64-release
Needs mingw64-x86_64-zlib on all the CI builds bots.
* FIXME: hack - don't set MONO_EXECUTABLE to the msvc mono for Android SDK build
* [sdks] drop LLVMProvisionTemplateStub
* [WinForms] If DataGridViewCheckBoxCell not in threeState mode EditingCellFormattedValue must return true or false, instead of value of CheckState type
* [WinForms] DataGrid: fix type check in EditingCellFormattedValue setter. When set bool value to EditingCellFormattedValue there will be exception. Type equality must be done through IsAssignableFrom not direct
* [WinForms] DataGrid: Add test for EditingCellFormattedValue getter and setter.
* Revert "[System] Add FSEvent FileSystemWatcher to 'monotouch' BCL profile"
This reverts commit 46fc5352f3dfe0027e684a0f61e71130fccd559f.
While iOS FileSystemWatcher works, we now find that it is used unofficially-available symbols and cannot publish apps using those.
Fixes https://github.com/mono/mono/issues/14290
* [csproj] Update project files
[2019-02] [metadata] use handle stack in mono_runtime_object_init_handle
Fixes this crash on watchOS with llvmonly:
https://gist.github.com/lewurm/921b77a238c6fd60757a5ee9f54279d1
The hint here was that the crash happened in `mono_handle_stack_scan ()` and inspecting the handle stack there. After enabling `MONO_HANDLE_TRACK_OWNER` and `MONO_HANDLE_TRACK_SP` in `handle.h`, I got this:
https://gist.github.com/lewurm/71f936a126879ef2b96d00399e6b2bd9
@lambdageek suggested this fix after showing this trace to him. As far as I understand we do _not_ know the root cause yet. The handle leak happens in this trace:
https://gist.github.com/lewurm/b76fbc391f22d897bfd532ac1b67e2aa
`mono_runtime_object_init_checked ()` already should take care of the handle stack 😕
Contributes to #13006
Backport of #14399.
/cc @akoeplinger @lewurm
[2019-02] [arm64] set MONO_ARCH_HAVE_UNWIND_BACKTRACE for watch4
Fixes a couple of mscorlib test failures, failing with
> Stack walks are not supported on this platform
Backport of #14440.
/cc @lewurm
During GC we allocate a gray queue protected by a mutex, sgen_gray_object_queue_init.
This mutex is never destroyed when clearing up the object containing it,
sgen_gray_object_queue_dispose, so it will leak. Overtime this could cause
OOM on some systems depending on how memory related to system primitives are
handled and partitioned.
[2019-02] Usually do not create a handle in mono_runtime_invoke_handle.
Use mono_runtime_invoke_handle_void instead.
Backport of https://github.com/mono/mono/pull/14404
* [loader] Dont't store through a null ptr
If 'status' is null, don't try to write to it.
Fixes https://github.com/mono/mono/issues/13941
* [metadata] Protect writes to MonoImageOpenStatus* in a few places.
When possible assert that `MonoImageOpenStatus *status` arguments to various
functions in the runtime aren't null. There are a few places (MONO_API) where
it's possible that callers are passing null. In that case, use a local
MonoImageOpenStatus, or check for null before doing assignments.
Don't use popcount intrinsic.
Alternative but not exactly contradictory to https://github.com/mono/mono/pull/14248.
Note that this is a single inlinable instruction on x86,
if you assume at least SSE4 from circa 2007, which I am avoiding here.
(cherry picked from commit 90a91429ae)
We're seeing occasional build errors on CI that seem to be some kind
of race when compiling nunit-lite and nunit-lite-console.
(cherry picked from commit c3541fc543)
* When moving parameters for tailcall, and having pushed ip, and adjusting the offset to account for that, split the adjustment between sp and frame pointer, as frame pointer may or may not be sp. This fixes https://github.com/mono/mono/issues/11489.
* Revert "[Tailcall] [arm] [jit] Fix moving tailcall parameters. (#12701)"
This reverts commit 257efc6374.
We were inadvertently running the roslyn tests against the system mono in CI.
Instead we now install mono to a custom prefix, prepend that to PATH and run
the roslyn tests against the correct mono we just built.
This method returns a function pointer that can be called with a calli instruction. On interpreter we use a pointer to InterpMethod while on jit we use the native code address. Normally, GetFunctionPointer should return the InterpMethod pointer if called from interp or the native code address if called from jit. Since we don't have any information about the execution engine of the caller, we solve this by intrinsifying all these calls, that happen in the interpreter.
Passing such function pointers between jitted and interp code is probably still unreliable.
Fixes https://github.com/mono/mono/issues/13654
We need to emit a real call here. On arm/android we would emit this now:
```asm
ldr pc, =label
.ltorg # place address of `label` here.
```
which is a jump to `label`, not a call.
We need a different solution to make larger assemblies work, but for now
I revert it so the `2019-02` intergration is unblocked.
Partial revert of #14043
The test case CopyFileWithData_MemberData with input of size 1024 * 1024 * 10
causes the Xamarin.Android.Bcl_Tests to crash for some reason. Temporarily
exclude this entire set of tests from running.
Also disable System.IO.Tests.FileInfo_CopyTo_str because it derives from the
above test class.
When a static method is called the obj is not used, so it can be null and it doesn't need to be boxed. Adding an assert in the method to prevent other crash in this method if a NULL is received.
* [msbuild] Install msbuild bits in to Current instead of 15.0
This is to prepare for the update to msbuild which expects
`lib/mono/{xbuild,msbuild}/Current`
Except for Roslyn which still installs and expects to be in
`lib/mono/msbuild/15.0/bin/Roslyn`
.. but we install it to `Current` here and create the symlink for it at
msbuild installation time. This allows us to have consistent symlinks:
15.0 -> Current
Note: That *Current* is the new ToolsVersion, it isn't meant to just
point to the current *version*.
(cherry picked from commit cc23e2fc242ac5ed55ad3caab3fba91603e14af8)
* nuget-hash-extractor: Add msbuild extensions nuget version from
.. xplat-master msbuild branch.
Microsoft.NET.Build.Extensions : 2.1.600-preview-63821-02
Version from:
https://github.com/dotnet/cli/blob/4b9d6502f8061db4a56b730d3d4e65262c72ad5c/build/DependencyVersions.props
None of the assemblies were newer, so none of the lists have any
changes.
(cherry picked from commit 6ce599387ef3ecd9b5954d9282a275fbeacc7aaf)
* Bump msbuild to track mono-2019-02
* [msbuild] fsharp: Install msbuild files for 16.0
(cherry picked from commit dbfedcf430968eb4a92cafad2a7ea89f723dfde3)
* Bump bockbuild to pick up a fix for msbuild update.
There are many minor arguments here.
Where this matters most -- iOS -- the pool is already dynamic.
Other platforms could use a dynamic pool or JIT (despite FullAOT).
Using JIT would defeat the test coverage.
Mitigates https://github.com/mono/mono/issues/13888.
If this feels too tenative, go bigger.
Use fallbacks when link() fails
System.IO.Filesystem's MoveFile() and ReplaceFile() use link under some conditions to avoid a copy. This fixes two problems with that:
* MoveFile()'s fall-back does not recognize Android's error as non-critical, and bails out on the fall-back with an exception. From logs we know that 'strerror_r(android_error)' = 'Permission denied' so the Android error should be EACCES (we already check for EPERM)
* While MoveFile() was using a fall-back, ReplaceFile() wasn't.
* Use a custom prefix instead of trying to infer it, which doesn't work under bockbuild.
The following line is problematic in the scope of building the Mac SDK package (using bockbuild):
https://github.com/fsharp/fsharp/blob/ccfccbacfdb16b2ab143cf83f5ece20f738fd864/mono/config.make#L5
It's problematic because where `mono` lives in this case would be something like `/macsdk-staging-dir/bin/mono` which is not the actual prefix (prefix here being the final destination, `/Library/Frameworks/Mono.framework/...`) but a staging area that bockbuild uses (this is how we build on system prefixes without installing on CI)
For the F# build, bockbuild expects things to end up in `/fsharp-staging-dir/$(prefix)` (because that's what most `make install`s do when given `DESTDIR=/fsharp-staging-dir/`). If things end up in _any other_ directory in `/fsharp-staging-dir/` (like `/fsharp-staging-dir/macsdk-staging-dir` in our case) that would cause us to miss packaging those files (this has happened before, with packages that have broken or different use of `DESTDIR`). So there is an added write-protection for anywhere in `/fsharp-staging-dir` that *isn't* `/fsharp-staging-dir/$(prefix)` , because a write-protection error, while obtuse, is much preferable to missing the fact that some files are not packaged (as would have happened here)
So the fix is to stop trying to infer the prefix, and return to providing it explicitly to the build system (this used to be the case via the `configure` step)
* Also, if we are doing an override of the 'make' command, we need to take care of passing DESTDIR ourselves too
* Since now we perform 'make install' on the make step, make the 'install' step into a no-operation.
* Look for sn where mono is, not in the final destination (which again, may not be the same)
We were setting the stack type by using another global local named ins.
This lead to missing methods in the aot image due to invalid IL. Fixes https://github.com/mono/mono/issues/13479
[2019-02] [aot] change method table generation so that it works for larger assemblies on ARM
At the end of the AOT compilation, we dump a table containing all method
entrypoints using the toolchain linker to resolve the addresses. Previously
we used `bl` for that, however on larger assemblies the offset might
overflow the 24bit immediate (thus, the linker bailing out with
"Error: branch out of range"). Instead, using `ldr pc,=<label>` followed
by `.ltorg` emits the full 32bit address to a method. That takes 8 bytes
for each method instead of 4 bytes.
( I couldn't reopen https://github.com/mono/mono/pull/3486 anymore)
Backport of #14043.
/cc @marek-safar @lewurm
* [profiler] Do not print that many new lines (#13060)
The `mono_profiler_printf` already adds `\n` char, so we don't need to
add them in most cases.
Before the fix the output of aot profiler with verbose enabled looked
like:
02-19 10:50:02.877 22795 22815 I mono-prof: System.OutOfMemoryException:.ctor (string) 2
02-19 10:50:02.877 22795 22815 I mono-prof:
02-19 10:50:02.877 22795 22815 I mono-prof: System.SystemException:.ctor (string) 4
02-19 10:50:02.877 22795 22815 I mono-prof:
02-19 10:50:02.877 22795 22815 I mono-prof: System.Exception:.ctor (string) 6
02-19 10:50:02.877 22795 22815 I mono-prof:
02-19 10:50:02.877 22795 22815 I mono-prof: System.Exception:.cctor () 7
02-19 10:50:02.877 22795 22815 I mono-prof:
...
The `usage ()`'s output should now look similar to other profilers
usage output.
* [profiler] Add duration=NUM parameter to AOT profiler (#13688)
* [profiler] Add duration=NUM parameter to AOT profiler
It instructs the AOT profiler to write the data after NUM seconds
measured from runtime initialization.
* [profilers] Added aot:duration=NUM parameter description
GitHub provides a way to download a .zip/.tar.gz of the repository content in their UI, however the archive doesn't contain git submodules.
The mono build then fails with confusing "missing file" errors.
Since GitHub doesn't let us disable the archive download we should at least add some logic to detect this broken case and bail out.
(cherry picked from commit e8caaa1dbd)
The thread_stopped profiler event can be raised by the thread_info_key_dtor tls
key destructor when the thread is already doesn't have a domain set. In that
case, don't call process_profiler_event since it cannot handle a thread with
null TLS values.
Addresses https://github.com/xamarin/xamarin-android/issues/2920
with the following stack trace
```
* thread #20, name = 'Filter', stop reason = signal SIGSEGV: invalid address (fault address: 0xbc)
* frame #0: libmonosgen-2.0.so`mono_class_vtable_checked(domain=0x0000000000000000, klass=0x0000007200230648, error=0x00000071e92f9178) at object.c:1890
frame #1: libmonosgen-2.0.so`get_current_thread_ptr_for_domain(domain=0x0000000000000000, thread=0x00000071ebfec508) at threads.c:595
frame #2: libmonosgen-2.0.so`mono_thread_current at threads.c:1939
frame #3: libmonosgen-2.0.so`process_event(event=<unavailable>, arg=<unavailable>, il_offset=<unavailable>, ctx=<unavailable>, events=<unavailable>, suspend_policy=<unavailable>) at debugger-agent.c:3715
frame #4: libmonosgen-2.0.so`thread_end [inlined] process_profiler_event(event=EVENT_KIND_THREAD_DEATH, arg=0x00000071ebfec508) at debugger-agent.c:3875
frame #5: libmonosgen-2.0.so`thread_end(prof=<unavailable>, tid=<unavailable>) at debugger-agent.c:3991
frame #6: libmonosgen-2.0.so`mono_profiler_raise_thread_stopped(tid=<unavailable>) at profiler-events.h:105
frame #7: libmonosgen-2.0.so`mono_thread_detach_internal(thread=<unavailable>) at threads.c:979
frame #8: libmonosgen-2.0.so`thread_detach(info=0x00000071e949a000) at threads.c:3215
frame #9: libmonosgen-2.0.so`unregister_thread(arg=<unavailable>) at mono-threads.c:544
frame #10: libmonosgen-2.0.so`thread_info_key_dtor(arg=0x00000071e949a000) at mono-threads.c:774
frame #11: 0x00000072899c58e8 libc.so`pthread_key_clean_all() + 124
frame #12: 0x00000072899c5374 libc.so`pthread_exit + 76
frame #13: 0x00000072899c5264 libc.so`__pthread_start(void*) + 44
frame #14: 0x000000728996617c libc.so`__start_thread + 72
```
In my batch of changes here: https://github.com/mono/mono/commit/c3fe80a0c43be780e35f3a4091d3dc1023b35a00#diff-dca5f20c7ac28a5a4487805c49836fdbL340
I changed
```
if (!seq_points)
/* Could be AOT code */
continue;
```
into
```
seq_points = (MonoSeqPointInfo *) ji->seq_points;
if (!seq_points) {
MonoMethod *jmethod = jinfo_get_method (ji);
if (jmethod->is_inflated) {
MonoJitInfo *seq_ji;
MonoMethod *declaring = mono_method_get_declaring_generic_method (jmethod);
mono_jit_search_all_backends_for_jit_info (domain, declaring, &seq_ji);
seq_points = (MonoSeqPointInfo *) seq_ji->seq_points;
}
}
```
which doesn't account for the case when it can't find the seq_points. When seq_points is NULL at the end of that block, we don't `continue;` as we did before. Instead we assert, and crash the runtime.
This PR undoes this change, making us continue if `!seq_points`.
Backport of #13865.
It contained DllImports to some Windows APIs which causes issues on xamarin-macios which expects all pinvokes to exist.
Turns out we don't even need that file.
(cherry picked from commit 3903a50e43)
1. it doesn't touch the managed runtime
2. it may be called (arguably it ought to be called only) before the runtime is
initialized (and in particular before the current thread is attached).
* [System] Clear MONO_CFG_DIR before starting mcs in CodeDOM CSharpCodeGenerator
This showed up in the xamarin-macios 2019-02 integration.
When you used Xslt with a custom C# script in a Xamarin.Mac Full application
we'd try to launch mcs via CodeDOM to compile the script.
This started failing in 2019-02 because System.Native (mono-native) wasn't found,
the reason is that XM sets MONO_CFG_DIR to point to the Contents/MonoBundle
in the app bundle where it packages the global config file with dllmaps.
However the started Mono wasn't able to find mono-native since the config
there uses a different name for the file.
To prevent that we now clear MONO_CFG_DIR so it uses the default value for the
mono process we're starting (note that setting it to String.Empty doesn't work)
* Make it specific to XM 4.5
(cherry picked from commit 448cf31a8d)
It was set by xamarin-macios when they were still taking the raw .cs source files
but since we switched to prebuilt binaries we need to replace it with
some define we're actually setting in Mono.
Most cases can be replaced by just XAMMAC_4_5 since MOBILE is defined on the xammac profile.
(cherry picked from commit 50fc669f1ed3a6d60f03ebb26b25702effc59cdb)
When you use `Process.Start()` with `UseShellExecute=true` (which is the
default on Mono/.NET Framework, but false on .NET Core) then we'd still
try to first start the file directly, before falling back to trying the
"open" handlers like xdg-open to launch the file. Presumably we do this
so that on mobile you can still start a process without needing to
explicitly set `UseShellExecute=false`.
However we don't need to try the fallback on iOS/Android since the
"open" handlers won't work there anyway.
This recently showed up on the Xamarin.iOS Mono 2019-02 integration
where we started running the System.Diagnostics.ProcessTest suite and
the Start1_FileName_NotFound() would fail because the native error code
wasn't 2 (file not found) but 13 (invalid data). This is because it tried
to use /usr/bin/open which doesn't work of course so it got to the
`mono_w32error_set_last (ERROR_INVALID_DATA)` on L2088.
(cherry picked from commit 68077141a50a4295c8358cb04be620c093bdd2fe)
When we switched to using the corefx System.IO.File implementation we also
switched to an implementation uses the `copyfile()` standard library call
on macOS/iOS to copy files. This should preserve file metadata such as timestamps.
However there's a small edge case: when using an older version of the iOS
Simulator < 11.0 the `copyfile()` call doesn't copy sub-second timestamps,
presumably because older iOS ran on HFS which doesn't support that.
When we run this simulator on modern macOS which uses APFS and thus supports
sub-second timestamps the origin file used for the test _does_ have sub-second
timestamps and the test would fail.
We now skip the test in such environments.
PS: why did this not fail with the old Mono implementation? We used to
always call utimes() on the destination file after copying to copy metadata,
which in turn would update the file in the simulator host.
It doesn't seem worth it to replicate that behavior for this small edge case.
(cherry picked from commit d73da31eea646692beea64d8c9a4186bfe1162bd)
Helix wasn't running our runtime tests as expected, because the test runner expected newline-separated tests to run, and we were generating space-separated.
Following "be liberal in what you accept" philosophy, and to prevent this issue in the future, just deal with "whitespace separated" rather than "this specific whitespace and no other"
Backport of #13587.
[2019-02] [ssa] avoid code motion to try-blocks
Consider
```
BB4: // successor BB5, BB9
[...]
br [B9]
BB5: // catch handler block for BB4
[...]
br BB9
BB9:
aotconst R90
gc_safe_point R90
[...]
```
Previously, our invariant code motion pass would move `aotconst R90` to the end of BB4. Unfortunately, BB4 contains instructions that can cause an exception and thus control flow is broken and continues to BB5. `aotconst R90` wouldn't be loaded correctly in this scenario.
When lowered to LLVM IR this is more obvious, and the verification pass of LLVM catches this.
Fixes https://github.com/mono/mono/issues/13460
Backport of #13555.
/cc @lewurm
Concurrent request completions could cause following exception:
FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException:
Index was out of range. Must be non-negative and less than
the size of the collection.
Parameter name: index
at System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) [0x00009] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Collections.Generic.List`1[T].Remove (T item) [0x0000c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.Cleanup () [0x00011] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.set_IsCompleted (System.Boolean value) [0x00034] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.Complete (System.Exception ex) [0x0001a] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+<>c__DisplayClass7_1.<BeginProcessRequest>b__0 (System.IAsyncResult r) [0x000bd] in <28c4695205ef47378f5370502b066592>:0
This stack was captured after some changes in AwaitTaskContinuation.RunOrScheduleAction.
Unfortunately the current implementation of AwaitTaskContinuation.RunOrScheduleAction re-throws the above
exception with a wrong stack:
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00052] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageTwo () [0x000a1] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00003] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.TrySetException (System.Object exceptionObject) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00029] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__241`1[T].MoveNext () [0x000e0] in <3e9b3e26c4694baab3f689687ad40612>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00024] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00052] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x0004f] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x0003d] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Net.ServicePointScheduler+<WaitAsync>d__45.MoveNext () [0x000f7] in <3e9b3e26c4694baab3f689687ad40612>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <4a8a0
On an Android Xamarin installation this causes an app crash. Since no user code is active the exception cannot be caught.
Backport of #13304.
In https://github.com/mono/mono/pull/11172 we added passing `-march=arm` to `llc`, so that newer LLVM would generate code correctly for the target arch. Unfortunately this seems to break older LLVM, that is still used for 32bit code on Xamarin.iOS. For iOS we need to force it to armv7, otherwise it will try to substitute certain locking primitives with builtins that aren't available as hardware instructions on armv5.
Before this change:
```console
$ nm ./obj/iPhone/Release/mtouch-cache/armv7/mscorlib.dll-llvm.o | grep sync_
U ___sync_fetch_and_add_4
U ___sync_lock_test_and_set_4
U ___sync_synchronize
U ___sync_val_compare_and_swap_4
00079e1c T _mscorlib_System_Runtime_CompilerServices_AsyncMethodBuilderCore_ThrowAsync_System_Exception_System_Threading_SynchronizationContext
00057f80 T _mscorlib_System_Threading_SemaphoreSlim_WaitAsync_int_System_Threading_CancellationToken
00058430 T _mscorlib_System_Threading_SemaphoreSlim_WaitUntilCountOrTimeoutAsync_System_Threading_SemaphoreSlim_TaskNode_int_System_Threading_CancellationToken
U _p_1214_plt_mscorlib_System_Threading_SemaphoreSlim_WaitAsync_int_System_Threading_CancellationToken_llvm
U _p_1217_plt_mscorlib_System_Threading_SemaphoreSlim_WaitUntilCountOrTimeoutAsync_System_Threading_SemaphoreSlim_TaskNode_int_System_Threading_CancellationToken_llvm
U _p_1735_plt_mscorlib_System_Runtime_CompilerServices_AsyncMethodBuilderCore_ThrowAsync_System_Exception_System_Threading_SynchronizationContext_llvm
U _p_1976_plt_mscorlib_System_Threading_SemaphoreSlim_WaitAsync_llvm
U _p_37_plt_mscorlib__jit_icall_ves_icall_thread_finish_async_abort_llvm
```
After this change:
```console
$ nm ./obj/iPhone/Release/mtouch-cache/armv7/mscorlib.dll-llvm.o | grep sync_
0007008c T _mscorlib_System_Runtime_CompilerServices_AsyncMethodBuilderCore_ThrowAsync_System_Exception_System_Threading_SynchronizationContext
00050654 T _mscorlib_System_Threading_SemaphoreSlim_WaitAsync_int_System_Threading_CancellationToken
00050ab4 T _mscorlib_System_Threading_SemaphoreSlim_WaitUntilCountOrTimeoutAsync_System_Threading_SemaphoreSlim_TaskNode_int_System_Threading_CancellationToken
U _p_1214_plt_mscorlib_System_Threading_SemaphoreSlim_WaitAsync_int_System_Threading_CancellationToken_llvm
U _p_1217_plt_mscorlib_System_Threading_SemaphoreSlim_WaitUntilCountOrTimeoutAsync_System_Threading_SemaphoreSlim_TaskNode_int_System_Threading_CancellationToken_llvm
U _p_1735_plt_mscorlib_System_Runtime_CompilerServices_AsyncMethodBuilderCore_ThrowAsync_System_Exception_System_Threading_SynchronizationContext_llvm
U _p_1976_plt_mscorlib_System_Threading_SemaphoreSlim_WaitAsync_llvm
U _p_37_plt_mscorlib__jit_icall_ves_icall_thread_finish_async_abort_llvm
```
Fixes https://github.com/mono/mono/issues/13478
Backport of #13521.
/cc @lewurm
Writing to MonoClass:interface_id must be done with the loader lock held.
Fixes assertion:
```
* Assertion at class-init.c:1830, condition `i == 0 || interfaces_full [i]->interface_id >= interfaces_full [i - 1]->interface_id' not met
```
[2019-02] Revert "[mini] Inline Selector.GetHandle for tvOS and watchOS assemblies as well. (#13246)"
This reverts commit c99fe4b462.
It doesn't work when LLVM is enabled for tvOS: https://github.com/xamarin/xamarin-macios/pull/5742#issuecomment-471007078, it causes multiple compilation errors like this:
Process exited with code 1, command:
/Applications/Xcode101.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode101.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.1.sdk -Qunused-arguments -mtvos-version-min=12.1 -fembed-bitcode-marker -arch arm64 -c -o /private/var/folders/nh/n1y9qj2n40d7wpmx1mg9blg80000gn/T/mtouch.cache/arpl1vgs.js6/arm64/Xamarin.TVOS.dll-llvm.o -x assembler /private/var/folders/nh/n1y9qj2n40d7wpmx1mg9blg80000gn/T/mtouch.cache/arpl1vgs.js6/arm64/Xamarin.TVOS.dll-llvm.s
/private/var/folders/nh/n1y9qj2n40d7wpmx1mg9blg80000gn/T/mtouch.cache/arpl1vgs.js6/arm64/Xamarin.TVOS.dll-llvm.s:4665:14: error: invalid variant 'OBJC_SELECTOR_REFERENCES_.2@PAGE'
adrp x8, l_@OBJC_SELECTOR_REFERENCES_.2@PAGE
^
/private/var/folders/nh/n1y9qj2n40d7wpmx1mg9blg80000gn/T/mtouch.cache/arpl1vgs.js6/arm64/Xamarin.TVOS.dll-llvm.s:4673:18: error: invalid variant 'OBJC_SELECTOR_REFERENCES_.2@PAGEOFF'
ldr x1, [x8, l_@OBJC_SELECTOR_REFERENCES_.2@PAGEOFF]
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
Backport of #13418.
/cc @lambdageek @rolfbjarne
-> Doing stepping into in VSM in some situation the frame saved in TLS is not synchronised with what is really been executed in the main thread. This makes the debugger-agent crashes because it tries to get variable info in some memory that is not available anymore.
-> To fix it I forced the update of stack when CMD_THREAD_GET_FRAME_INFO is called.
-> Doing step over in Visual Studio for Windows, if you have the threads debugger window enabled, VSW calls frame_commands for each thread that is showed, and if the thread is not really_suspended it tries to get variable info from a memory that is not available anymore because the thread is not suspended yet.
-> To fix it I don't send variable info of a frame if the thread is not really_suspended and doesn't have an async_state valid.
#Fixes 12843
- sys/sysctl.h isn't available on Alpine and not needed by the code,
guard it using HAVE_SYS_SYSCTL_H like elsewhere. Added by https://github.com/mono/mono/pull/11855
(cherry picked from commit 0d7ce1f767)
* [corlib] Remove Interop.MountPoints.cs from .sources
We no longer need it since https://github.com/mono/mono/pull/13125 and having
it included makes xamarin-macios still complain about the missing symbol.
* [csproj] Update project files
* Ensure that the module cctor is run before the entry point is executed
We need to ensure that any module cctor for the 'main' image
is run *before* we invoke the entry point
This is required in order for tools like Costura
(https://github.com/Fody/Costura) to work properly. These tools inject
a module initializer which sets up event handlers (e.g. AssemblyResolve),
which allows the main method to run properly
For more information about module constructors,
see https://blogs.msdn.microsoft.com/junfeng/2005/11/19/module-initializer-a-k-a-module-constructor/
* Fix module-cctor-entrypoint.il
* moved assignment of keys in mono_conc_hashtable_insert after tombstone checks.
* fixed missing reset of element_counter and tombstone_counter after rehash.
* review finding: moved reset of element and tombstone counter to rehash_table function
* Bring back fix to utils hashtable and fix whitespace damage
[2019-02] [mini] Inline Selector.GetHandle for tvOS and watchOS assemblies as well.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
Backport of #13246.
/cc @luhenry @rolfbjarne
This reverts commit a3f69d7b21.
We actually want to only run one build per product on a node,
e.g. so that android-debug and android-release can't run on
the same node and stomp on each other's toolchain.
* [2019-02] [System.Net.Http] Move NSUrlSessionHandler from xamarin-macios to mono
This allows us to remove the need for a special custom System.Net.Http.dll
build in the xamarin-macios repository.
Part of #11397
* Bump API snapshot submodule
[2019-02] Fix multiple issues with response file option on Windows.
* If file is UTF8 encoded and include BOM mark, implementation failed to detect and remove BOM mark causing errors. Fix check for BOM mark and if found, remove it before passed to parsing. NOTE, current implementation only supports UTF8 (and ASCII) content in response file and won't detect or handle any other codepages.
* Since the content in --response file should mimic what should have been passed on command line, we should apply same parsing rules on Windows as done by the shell when running the arguments on the command line. Current implementation uses its own parsing that is not the same as used by the Windows shell, meaning that arguments can't be identical in response file compared to what's passed on command line. This commit fix parsing of the command line in the response file so its first parsed by the shell before added to internal argc, argv parameters (similar as done when passed to main function).
NOTE, most of the old code around mono_parse_options was just split to be reused by two different functions. No focus on rewriting any of the original parsing logic. Implemented specific parse methods for response file in order to minimize regression impact of change on Windows. On none windows platforms its a 1:1 between mono_parse_response_options and mono_parse_options but on Windows the behavior is different to mimic the command line arguments. Since mono_parse_options is used in a couple of other scenarios on Windows, the fix will make sure the original behavior of mono_parse_options is the same on Windows and only the new response file parsing will get the new ability to handle the arguments in the same way as the command line.
Backport of #13132.
/cc @luhenry @lateralusX
We need the recently introduced "unbox arbitrary" trampolines in one more
scenario: non-mscorlib AOT code calls a method from mscorlib with
interpreter. Before we just relied on the amodule not being available,
but mscorlib amodule is always present due to wrappers, trampolines,
etc.
[2019-02] [aot] abort lookup early when a method isn\u0027t available in AOT image
Mixed mode depends on that. Usually, compile_method of mini takes care
to request only existing methods from the AOT image, but in some cases,
e.g. from a trampoline, AOT runtime is quiered directly.
Contributes to https://github.com/xamarin/xamarin-macios/issues/5618
Backport of #13138.
/cc @lewurm
[2019-02] [aot] Resolve profile against compiled assembly
When trying to use AOT profile in XA for assembly AOT compilation, the
methods from the profile were not compiled.
Context: https://github.com/xamarin/xamarin-android/issues/2504
The problem was, the profile data were not resolved, as there was no
assembly loaded in the domain.
With this fix, the compiled assembly is used to resolve the profile as
well.
Backport of #13148.
/cc @luhenry @radekdoulik
- Previous test with 100 micro second timeout would fail on iOS device when running **all the socket tests** about 3 times out of 5.
- With a 1 millisecond timeout, it didn't fail the 10 times I tried locally, hopefully this is enough to fix the flakiness.
- Fixes#8360: [System.Net.Sockets] flakey failures of SocketTest.TestSelect1 on Darwin systems
(https://github.com/mono/mono/issues/8360)
- Also partial fix for maccore issue https://github.com/xamarin/maccore/issues/1069
(cherry picked from commit 0525583d1e)
Before 5e0d39a8a1, there used to be a handwritten binary search that traveersed `framework_assemblies` to determine if a given assembly was a framework assembly or not. The binary search used `last = G_N_ELEMENTS (framework_assemblies) - 1` as the initial condition, but it used an inclusive `first <= last` as the loop count.
After we switched to a hashtable, we used the same final value initialize `assembly_remapping_table`.
We didn't notice because `mscorlib` used to be the last assembly in the table and `mscorlib` already has a ton of special handling in the loader. But `netstandard` is not special. So we added it to the table, but it still doesn't get special handling.
This should fix instances where code references netstandard 2.0.0.0, but we give it netstandard 2.1.0.0
This makes us consistent with corefx; see also
https://github.com/dotnet/corefx/pull/35306.
Using `X509Certificate` has become a problem because the
`HttpClientHandler.ServerCertificateCustomValidationCallback`
callback takes an `X509Certificate2` parameter.
Backport of #12999.
The leading `.` in the script invocation causes the tests to fail on multiple platforms by causing the required argument to not be passed correctly resulting in bad output. Removal of the leading `.` ensures correct operation on all platforms.
Correct access permissions for run-msbuild.sh. Adding "user execute" seems to fix the following build error. With this change I'm able to build on windows in Cygwin. without, I see the below error:
```
$ make -j4
(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /cygdrive/c/mono/mono/missing autoheader)
rm -f stamp-h1
touch config.h.in
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
Git submodules updated successfully
make all-recursive
make[1]: Entering directory '/cygdrive/c/mono/mono'
Making all in msvc
make[2]: Entering directory '/cygdrive/c/mono/mono/msvc'
Building Mono runtime using Visual Studio.
../msvc/run-msbuild.sh "build" "i686"
**/bin/sh: ../msvc/run-msbuild.sh: Permission denied**
make[2]: *** [Makefile:614: all-local] Error 126
make[2]: Leaving directory '/cygdrive/c/mono/mono/msvc'
make[1]: *** [Makefile:583: all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/c/mono/mono'
make: *** [Makefile:513: all] Error 2
```
(cherry picked from commit fe7c3d43e5)
consider
```csharp
struct S3
{
public ushort X;
public ushort Y;
public ushort Z;
}
```
this would be 3 * 2 = 6 bytes. Structs, however, are passed around as i32
arrays in LLVM IR between functions. Those, if such a struct is passed, are
split to int32 depending on the struct's size. The previous calulation was
wrongly reserving one such i32 slot instead of two for `S3` above.
Additionally increase slot size to i64 so that it aligns with a
slightly different ABI on arm64_32.
This reverts commit 9c1fd50666.
This is wrong, net_4_x_SUBDIRS only includes common_deps_SUBDIRS, not common_SUBDIRS.
(cherry picked from commit d224a047e0)
* [crash] Add more detailed reporting for exceptions
This bumps the crash reporting file format to version 0.0.3.
* [crash] Fix exception stack walker to consider captured_traces
Previously we were missing these frames from the captured_traces fields
of MonoException and MonoStackTrace.
* [debugger] Reverting part of this commit https://github.com/mono/mono/pull/12114, removing this part the test ShouldCorrectlyStepOverOnExitFromArgsAfterStepInMethodParameter continues working and solve the regressions of 12881. Inserted a new test that reproduces the regression. Fixes#12881
* Changing {
* Changing {
* The interpreted version works different, because of that we can accept this 2 results in this test.
[2019-02] Fix issue where togglerefs might be incorrectly pinned by GC.
Due to current call order in sgen_client_stop_world to first process togglerefs and then take current threads stack could cause a problem where toogleref object references might be left in registers after running sgen_process_togglerefs and then those object reference would be put into current thread context, incorrectly pinning the object pointed to by a toggleref, preventing it from properly being handled by GC.
The problem was observed on Windows (in debug build) running sgen-toggleref.exe runtime test since
the compile of sgen_process_togglerefs used a register holding the current toogleref's object reference when walking the list of togglerefs. That register was then not re-used until the current threads stack was taken, causing incorrect pinning of the last toogleref object in the list. This problem could in theory happen on any platform depending on native compiler and optimization.
Fix takes current threads context before walking the togglerefs to make sure we are not getting managed references into registers as part of managing the toggleref list in sgen_process_togglerefs.
Backport of #12811.
/cc @marek-safar @lateralusX
[2019-02] [interp] Add method to seq_points table after we finish registering it
When adding a breakpoint (mono_de_set_breakpoint) we search in this table for seq_point information for the method. If we find the information we expect that the method is already compiled and has the metadata initialized when actually adding the breakpoint (set_bp_in_method). We were crashing if the jinfo field of the interp method was not yet initialized.
Fixes https://github.com/xamarin/xamarin-macios/issues/5381
Backport of #12902.
/cc @luhenry @BrzVlad
[2019-02] [arm/bitcode] mark valuetype returns as such when dealing with pinvokes
On armv7 our calling convention happens to be the same as the platform
one. However, when using a armv7 cross compiler to generate bitcode that
targets a different platform (e.g. arm64_32) the calling convention can
be different (e.g. on arm64_32, a return buffer must be passed via r8).
Thus, mark it properly for LLVM so it can generate correct code.
Backport of #12894.
/cc @luhenry @lewurm
* [metadata] Decouple dynamic method signature from its delegate invoke wrapper
The invoke wrapper should not be referencing the signature because it will be freed once with the dynamic method. The wrapper can outlive the dynamic method, it is cached based on the signature.
Fixes crash on old IronJS benchmark with interpreter (which uses a lot of delegate wrappers, compared to jit)
* [interp] Add debug method for printing transformed code
Normally strings are encoded as length-then-utf8 in ECMA-335. But a null
String is encoded as just the byte 0xFF.
When we make a CustomAttributeBuilder for a MarshalAsAttribute and attach it to
some parameter we first encode the CAB as a byte blob and then decode it in
CAB.get_umarshal into a UnmanagedMarshal attribute. But the decoding didn't
account for the possibility of null strings.
Fixes https://github.com/mono/mono/issues/12747
The 2018-10 lane seemed to be failing some tests because the merp-json-valid.exe test left behind the crash log file. I fixed that in this PR, but also move the tests into their separate folders so they can run at the same time safely.
Backport of #12830.
This fixes a regression introduced by https://github.com/mono/mono/commit/5187b0bdaaff56936d697b0753dad51e7498991d
The AOT compiler wasn't aware of the icalls since they are guarded by `ENABLE_MONOTOUCH`. Passing `--enable-monotouch` to configure of the AOT compiler enables that define, so it can properly resolve those icalls. However, to avoid `zlib` dependency for the cross compilers, we stub
them out.
Backport of #12834.
The managed linker removes the type embedded inside mscorlib and we don't want to whitelist it in linker xml since then it'd be kept for everyone.
Instead move the type to the test assembly and remove the reflection-based tests.
We were only doing the `-mmacosx-min-version` replacement magic on CFLAGS and LDFLAGS for mono-native-compat and -unified, but we need to do the same for CPPFLAGS/CXXFLAGS too.
Fixes an issue where the libraries were targeting the wrong minimum OSX version when built from xamarin-macios since they pass the minimum version in CPPFLAGS instead of CFLAGS for OSX.
Backport of #12801.
Provide a Mono-specific version of CoreFx's `SslConnectionInfo` and use it to implement some "Connection Info" properties in `SslStream`: `CipherStrength`, `HashStrength` and `KeyExchangeStrength`.
Fixes#12552.
Backport of #12687.
Define `PLATFORM_UNIX` in `mcs/build/platforms/unix.make` and make
`mcs/build/profiles/net_4_x.make` define `SOCKETSHTTPHANDLER=1` when set.
Backport of #12771.
@@ -583,6 +583,13 @@ if test x$have_zlib = xyes; then
])
fi
AC_ARG_WITH(static-zlib, [ --with-static-zlib=PATH use the specified static zlib instead of -lz],[STATIC_ZLIB_PATH=$with_static_zlib],[STATIC_ZLIB_PATH=])
if test "x$STATIC_ZLIB_PATH" != "x"; then
have_static_zlib=yes
AC_SUBST(STATIC_ZLIB_PATH)
fi
AM_CONDITIONAL(HAVE_STATIC_ZLIB, test x$have_static_zlib = xyes)
AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
AC_DEFINE(HAVE_ZLIB,1,[Have system zlib])
@@ -1111,7 +1118,7 @@ AC_ARG_WITH(unreal, [ --with-unreal=yes,no If you w
AC_ARG_WITH(wasm, [ --with-wasm=yes,no If you want to build the WebAssembly (defaults to no)], [], [with_wasm=default])
AC_ARG_WITH(runtime-preset, [ --with-runtime-preset=net_4_x,all,aot,aot_llvm,hybridaot,hybridaot_llvm,fullaot,fullaot_llvm,winaot,winaot_llvm,bitcode,unreal,fullaotinterp,fullaotinterp_llvm Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
AC_ARG_WITH(runtime-preset, [ --with-runtime-preset=net_4_x,all,aot,aot_llvm,hybridaot,hybridaot_llvm,fullaot,fullaot_llvm,winaot,winaot_llvm,bitcode,bitcodeinterp,unreal,fullaotinterp,fullaotinterp_llvm Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
AC_ARG_WITH(spectre-mitigation, [ --with-spectre-mitigation=yes,no If you want to build the runtime with compiler flags that enable Spectre mitigation (defaults to no)], [], [with_spectre_mitigation=default])
AC_ARG_WITH(spectre-indirect-branch-choice, [ --with-spectre-indirect-branch-choice=keep,thunk,inline,extern Convert indirect branches to the specified kind of thunk (defaults to inline)], [], [with_spectre_indirect_branch_choice=inline])
AC_ARG_WITH(spectre-function-return-choice, [ --with-spectre-function-return-choice=keep,thunk,inline,extern Convert function return instructions to the specified kind of thunk (defaults to inline)], [], [with_spectre_function_return_choice=inline])
if [ ! -f "TestResult-$(PROFILE).xml" ]; then echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='1' total='1' not-run='0' name='bcl-tests' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='$(strip $(test_assemblies))' success='False' time='0'><results><test-case name='$(notdir $(strip $(test_assemblies))).crash' executed='True' success='False' time='0'><failure><message>The test runner didn't produce a test result XML, probably due to a crash of the runtime. Check the log for more details.</message><stack-trace></stack-trace></failure></test-case></results></test-suite></test-results>" > TestResult-$(PROFILE).xml; fi; \
publicconststringInvalidColor="Color '{0}' is not valid.";
publicconststringInvalidEx2BoundArgument="Value of '{1}' is not valid for '{0}'. '{0}' should be greater than or equal to {2} and less than or equal to {3}.";
publicconststringPropertyValueInvalidEntry="IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.";
publicconststringTextParseFailedFormat="Text \"{0}\" cannot be parsed. The expected text format is \"{1}\".";
Loaded 100 of 1044 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.