* 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.
* [runtime] Switch to GC Unsafe in mono_property_get_value
It's external only, so it should switch from GC Safe to GC Unsafe when called.
Addresses crash in https://github.com/mono/mono/issues/12724
* [runtime] Make mono_image_loaded external only
Also mono_image_loaded_full
Runtime should use mono_image_loaded_internal
* [runtime] Make mono_get_exception_argument_null external only
Without this patch, Mono crashes while writing AOT profiling data at
shutdown (when instructed to do so via --profile=aot:output=out.aotprof)
if any of the sampled methods belong to a dynamic image, which doesn't
have a GUID.
This happens with e.g. the DynamicProxyGenAssembly2 image:
> DynamicProxyGenAssembly2 is a temporary assembly built by mocking
> systems that use CastleProxy like Moq or NSubsitute. It is generated
> when the mock is needed and disposed of after the tests are finished.
(cf. https://stackoverflow.com/a/17179923)
* Remove code that was already moved from System.Private.CoreLib.Native to System.Native.
* Move Interop files for System.Native to shared Interop directory.
* Add FeaturePortableThreadPool conditions to csproj files.
Signed-off-by: dotnet-bot <[email protected]>
LoadFile lost assembly load-context. If the logger assembly has any dependencies placed in same folder logger can't load it. Main.cs using LoadFrom to load assembly but assembly already loaded in the cache after GetLoggerTypeName.
When awaiting a task, there's a race between seeing whether the task has completed (in which case we just continue running synchronously), finding the task hasn't completed (in which case we hook up a continuation), and then by the time we try to hook up the continuation finding the task has already completed. In that final case, we don't want to just execute the callback synchronously, as we risk a stack dive, so we queue it. That queueing currently entails two allocations in the common case: one for the work item object, and one for the Action delegate we force into existence for the state machine box's MoveNext method (in the common case it's now never allocated because you only await Tasks and ValueTasks known to the runtime, which bypasses its creation). We can instead just queue the box itself, and avoid both allocations.
Signed-off-by: dotnet-bot <[email protected]>
It used to be that the CS0420 warning ("a reference to a volatile field will not be treated as volatile") would fire when a volatile was used with an Interlocked.* operation. That warning was unnecessary, as Interlocked.* would itself provide the relevant barriers, and these functions were special cased in Roslyn a long time ago. But there are still lots of places where pragmas disabling the warning have stuck around. I'm deleting them all.
Signed-off-by: dotnet-bot <[email protected]>
The solution from https://github.com/mono/mono/pull/12725 doesn't fully work
since e.g. gacutil seems to verify the strong name.
Instead follow what we do for other keys where we don't have the private key:
add them to the machine.config pubTokenMapping list.
* Updating Number.Formatting to always compute a round-trippable number by default.
* Adding a third-party notice entry for the Grisu3 reference implementation
* Fixing up the Grisu3 algorithm to better match the reference implementation (including comments, etc)
* Porting the Grisu3 implementation that generates the shortest roundtrippable sequence.
* Updating the Dragon4 algorithm to support printing the shortest roundtrippable string.
* Fixing the double/float formatters to ignore precision specifiers for 'R'
* Fixing the double/float formatters to handle +0.0 and -0.0
* Fix the casing of `point` in THIRD-PARTY-NOTICES
Co-Authored-By: tannergooding <[email protected]>
* Fixing the double/float formatting code to consider a precision specifier of 0 to be the same as default.
* Fixing the double/float formatter so that nMaxDigits is set appropriately.
* Changing the double/float formatting logic to account for the format when determining the correct precision to request.
* Updating the double/float formatter to take the format specifier into account when determining the number of digits to request.
* Fixing the double/float formatting code to continue handling zero correctly.
* Disabling some outdated CoreFX tests.
* Responding to various feedback from the PR
Signed-off-by: dotnet-bot <[email protected]>
* [bcl] Fix assembly identity of nunit/nunitlite
The new strong name key added in https://github.com/mono/mono/commit/acaa73b7026897f7e83a101a9bc331476b5ed169
changed the assembly identity which we can't do for shipping libraries.
Given that the old .snk is invalid (see https://github.com/dotnet/roslyn/issues/32502),
we just sign with the extracted public key and /publicsign.
For MCS_MODE builds we instead use the mono.snk since mcs doesn't support /publicsign
and we don't really care about having the correct identity there.
* [csproj] Update project files
Add support for building Windows x64 fullaot version of winaot profile
that can be run on CI. Initial changes also add execution of mini regression
tests on CI. More tests will be added going forward and when having full
pass rate.
Add support for building Windows x64 fullaot+llvm version of winaot profile
that can be run on CI. Initial changes also add execution of mini regression
tests on CI. More tests will be added going forward and when having full
pass rate.
In order to get deterministic build results and working build on CI, we need
to setup a correct build environment for the MSVC builds. Since MSVC build is
currently run from cygwin, there are environment problems, both general
but also in our CI environment, since we add cygwin bin folder to system path
(needed by Jenkins plugin). When running more complex cmake builds like
BTLS and LLVM, this will cause problems picking up incorrect tools,
failing builds on CI.
Another problem is the AOT compilation using MSVC toolchain. In the
past CI used some "hard coded paths" to make sure clang.exe and link.exe was found.
This is not optimal and won't work when including LLVM as part of full AOT since
link.exe will need access to more of the full build environment setup by VS
development environments (like platform libraries).
In order to get a better build environment on CI this commit includes and enhance
a couple of build scripts used to run msbuild.exe and mono-sgen.exe (as AOT compiler)
in a VS development environment, isolate that build process from cygwin environment.
The build scripts will locate installed VS tooling, VS2015 build tools or VS dev env,
VS2017 build tools or VS dev env and use corresponding development environment
scripts as part of running msbuild.exe and mono-sgen.exe in AOT mode.
In order to make sure mono-sgen.exe as AOT compiler is run through these scripts
an additional environment variable MONO_EXECUTABLE_WRAPPER is introduced and used
in mono-wrapper when set. Without this indirection there will be problems on CI
tests since the environment is using MONO_EXECUTABLE and pass that into for example
test driver that run child processes of mono-sgen.exe, meaning that we can't
use scripts for MONO_EXECUTABLE, but splitting the MONO_EXECUTABLE to represent
mono runtime and have a MONO_EXECUTABLE_WRAPPER that could be a launch script
solves this issue.
This commit also includes several smaller fixes made to the generic
fullaot build infrastructure.
Fix additional msbuild arguments.
Add Mono.SIMD assembly to winaot profile.
Run msbuild.exe as part of .bat file.
`CSharpCodeGenerator` runs a compiler while redirecting its standard error and
standard output streams for further reporting. However, in doing that it fails
to read the standard output data completely and also fails to properly wait for
the standard error output to complete. Depending on environment it may lead to
the process using `CSharpCodeGenerator` hanging while the process has already
exited but there still is data to be read from standard output and standard
error.
This commit changes the code to an implementation of reading standard error and output
that makes sure all the data is read before the process is closed.
The hope is that it may fix some of the timeouts/hangs we see on the
Xamarin.Android build bots as a portion of them hangs in test that use the
code generator.
* When moving parameters for tailcall, first copy the parameters using ARMREG_IP and after that get destination in ARMREG_IP, then it's not necessary the PUSH and POP to SP nor the saved_ip_offset.
Fixes#11489
* Removing unused variable.
Testing how much hate this is going to bring me.
These annotations let ProjectN deal with the fact that we now have two
definitions of System.Environment in the system. This is needed as long
as Project N is stuck on 2.1-level version of the framework.
Signed-off-by: dotnet-bot <[email protected]>
The former does extra work that the latter doesn't do, and they're equivalent when we know it contains a value, such as immediately after a HasValue check.
Signed-off-by: dotnet-bot <[email protected]>
Fixes dynamic-method-churn.exe timeouts, which was hanging on arm because the finalizer thread was hanging from taking too long to clear these hashtable entries.
* [runtime] Improve mono_print_ji ().
* [llvmonly] Add a few more preinited got slots. Avoid emitting TLS_TRAMP preinited got slots in llvmonly mode.
* [aot] Simplify the mangled name of icall wrappers.
* [llvmonly] Make direct calls to icalls/icall wrappers in llvmonly+static mode.
* [aot] Disable some dedup logging which is always 0.
* Fix an strstr call.
This requires merging/adapting the implementation with EnvironmentAugments (which goes away completely), the shared files, what corert has, etc.
Signed-off-by: dotnet-bot <[email protected]>
Fix leak if mono_assembly_setrootdir is called multiple times.
Fix leak if mono_assembly_setrootdir is called multiple times by freeing the
previously stored value.
<!--
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
-->
Fix leak if mono_set_config_dir is called multiple times.
Fix leak if mono_set_config_dir is called multiple times by freeing the
previously stored value.
<!--
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
-->
When we unified the implementations of these across all of our runtimes, we lost all size optimizations people have been doing on the Project N side over the past six years.
This restores a bit of the loss. For one sample app with lots of async usage, this removes 2.1 MB of generic instantiations.
There is more we can do, but I can't spend time on that right now. These two things jumped out on me when I was looking at it back in December and were an easy fix I wanted to do for a while.
Signed-off-by: dotnet-bot <[email protected]>
* [gshared] Make mono_method_lookup_or_register_info () static, its only used in mini-generic-shared.c. Simplify callers.
* [aot] Optimize the encoding/decoding of MonoJumpInfoRgctxEntry.
Previously, all entries were associated with a method, but thats only needed for entries which have
is_mrgctx set, the rest can be associated with a class. Also, emit the encoding of methods/classes
only once, then refer to the them using a blob offset.
* [aot] Optimize the encoding of generic contexts by emitting every ginst only once.
* [aot] Add a MONO_AOT_METHOD_FLAG_HAS_PATCHES flag to avoid having to write the number of patches if its 0.
* [aot] Add a preinited got slot for MONO_PATCH_INFO_GC_SAFE_POINT_FLAG, fix the equality test.
* [wasm] Fix crash with delegates.
Internally the javascript bridge support uses `System.Delegate` and `System.Delegate.DynamicInvoke` to support delegate callbacks. The linker, when executed over the assemblies, does not know about this code coverage and will strip out `System.Delegate.DynamicInvoke`.
To fix this:
- Add reference to `System.Delegate.DynamicInvoke` to the `WebAssembly.Bindings` linker xml file so the linker knows not to strip the code.
- Add detailed error messages in case something else goes wrong so the crash is not so cryptic.
* [wasm] WebSocket support initial commit.
- Connect to socket
- Basic Send and Receive support for Text and Binary - Needs work.
- Close socket.
* Add nuget packaging for build tools sdk
* Add Not Implemented Exceptions to the ClientWebSocketOptions implementation.
- The browser websocket specification does not provide for referencing the underlying http parameters.
- KeepAliveInterval - The browser websocket implementation implements the PING/PONG implementation and does not provide a mechanism via the websocket API.
* Remove validattion for keepalive as it is not implemented.
* a couple more Not Implemented Exceptions for WebSocketOptions
* Change to PlatformNotSupportedException.
* ProjectReference instead of assembly.
* Add websockets assembly to sdk build
* Add WebAssembly.Net.Websockets to packager.
- Treat as core for AOT linker. This should be linked out but the linker but will appear in the loaded assembly list.
- Make sure it is imported as part of the non AOT build.
* Cleanup code.
* Add WebAssembly.Net.WebSockets assemblies to package
Not yet enabled for mobile, build and basic profiles.
Doesn't require ICU dependency, also I created a small PR for dotnet/coreclr to improve TimeZoneInfo.DisplayName on unix: https://github.com/dotnet/coreclr/pull/20728
Part of #7737
<!--
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
-->
## Problem
`LinkLabels` ignore the text alignment for rendering the "hitbox" and the text color (= the `LinkArea`), and the focus rectangle. Also every text behind the end of this LinkArea/focus rectangle region is not painted at all.
This becomes visible if `AutoSize = false` and the `Size` is bigger than the text would need,
and if the text alignment is anything different than `TopLeft`.
## Cause
I think this is because the `piece.regions` are only translated regarding the padding, but neglecting the text alignment.
## Solution
Calculate the offset due to alignment and add it to the translation in `LinkLabel.CreateLinkPieces ()`
Fixes#12402
## One more problem:
~Right now, a very tiny bit at the end of the label is still cut off (see my zipped and attached comparison pictures). Maybe `GetBounds ()` returns a value little bit smaller than it should be.
Can someone help?~
Also, maybe I took the wrong approach to this issue, but I don't know the inner mechanisms of mono.
So feel free to either advise me to change something, or change it yourself(s) :)
* [cxx] Set CCLD and CXXLD for final linking
Essentialy bypass automake's automatic linker selection based on _SOURCES file
extensions.
The issue:
1. Right now we need to use the C linker unless we're linking with LLVM which
needs C++.
2. Later when we start using C++ in Mono we will still want the C linker,
because we will use a subset of C++ that doesn't depend on the C++ runtime
library (because we don't want to break embedders that don't expect us to
use C++).
So in either case which linker we use is a decision that we want to make
independent of what the file extensions look like.
So we set MONO_CXXLD in configure. If LLVM is enabled, we use $CXX, otherwise
$CC.
Then in mono/mini/Makefile.am.in we set CCLD and CXXLD to MONO_CXXLD. So
whatever automake decides we're going to use the linker that we want.
This partly reverts 988f4a2147 which tried
another approach (which turned out not to work).
This should also address https://github.com/mono/mono/issues/12060
Closes https://github.com/mono/mono/issues/12435
* [cxx] Fix link errors if both --enable-llvm and --enable-cxx are on
BinaryReader.ReadInt32() has nice optimization which was missing from the ReadUInt32() version. Now both implementations are aligned.
ReadUInt32 and all the 64 bits types are now 30% to 50% faster than original implementation.
Signed-off-by: dotnet-bot <[email protected]>
* Remove defunct netstandard code from ValueTask
* Remove several uses of VoidTaskResult
Currently TrySetResult/Canceled/Exception live on `Task<T>`. There's no reason `TrySetCanceled` and `TrySetException` need to live there, as they only access state from the base `Task`, and so can be moved down. `TrySetResult` needs the `TResult`, however in a variety of cases `Task<T>` is used with a `VoidTaskResult`, and for such cases we can just have a parameterless `TrySetResult()` on the base class as well, which can be used any time there is no `TResult` or when `default(TResult)` is the desired result. This lets us switch several cases where we were using `Task<VoidTaskResult>` to just be `Task`, which saves 8 bytes on the task instance on 64-bit. It also avoids an Interlocked.Exchange as part of the TrySetResult call.
This primarily affects Task.Delay and the non-generic variants of Task.WhenAll, ValueTask.AsTask(), Task.FromCanceled, and Task.FromException.
Signed-off-by: dotnet-bot <[email protected]>
* Move Timer to shared CoreLib partition.
* Move SignalNoCallbacksRunning back to shared code, add static EventWaitHandle.Set.
* Remove AppDomain references from shared Timer code, reshuffle some code out of SetTimer in non-shared code.
* Change m_ prefix to match code style.
Signed-off-by: dotnet-bot <[email protected]>
* Move more Marshal methods to shared partition (dotnet/coreclr#22205)
* Move more Marshal methods to shared partition
* Implement ThrowExceptionForHR in managed
Signed-off-by: dotnet-bot <[email protected]>
* Remove local copy
The intended behaviour on specifying a delay of zero is that the CancellationTokenSource is cancelled immediately - before this change, it would depend on the scheduling of the timer callback which could lead to seeing a non-cancelled token. Now, it marks itself as cancelled immediately, without invoking any callbacks (as this method is called only from within the constructor of the object, before any callbacks could have been registered.
Signed-off-by: dotnet-bot <[email protected]>
This PR still needs additional cleanup work to be ready to merge but it's getting close enough to be worth running tests and getting code review. The purpose of this PR is to make various bug fixes and infrastructure changes so that it is trivial to use the roslyn compiler server on a clean checkout.
Summary of the changes:
* configure.ac generates some additional variables in config.make that are used to configure the compiler server mode in make. You can then use the compiler server by passing ```ENABLE_COMPILER_SERVER=1``` to make or flipping the switch in config.make.
* config.make has two variables pointing to the compiler server version of roslyn. This lets you use a local build/checkout of roslyn but only when the compiler server is enabled. Once we update in-tree roslyn these vars can default to that. (The in-tree version of csc is not compatible with the compiler server.) The vars are named ```SERVER_CSC_LOCATION``` and ```VBCS_LOCATION```.
* config.make also has a variable that sets the name of the roslyn compiler server pipe. If you're trying to build multiple checkouts in parallel, or build in multiple user accounts, you'll need to use separate pipenames. You'll be able to set this from the command line once I tweak the config file with ```COMPILER_SERVER_PIPENAME=xxx```.
* basic_profile_check attempts to start the compiler server before any builds happen. I put it there because that was the only way I found to get it to always run before mcs builds. I spent a few hours trying to add a separate build target for this, and then gave up because makefiles. (I'd love to get suggestions on a better way to do this) Because it's nontrivial to track compiler server instances across builds, I just spawn a new one every time - this works fine because the compiler server has logic to detect an existing instance.
* I completely rewrote our implementation of Timer and its scheduler, because the existing one was burning an entire core at all times in the compiler server, mostly calling SortedList methods. The new implementation is probably not release-ready, but I focused on keeping it easy to audit and understand because attempts to preserve the existing logic kept breaking. Ideally we can just pull in corefx's timers here, but it looked non-trivial to do that.
* ReaderWriterLockSlim was checking Environment.ProcessorCount every time it was used, which in most configurations will result in a syscall to getpid() and another syscall to check our affinity. This was bottlenecking the compiler server really bad. I changed this to match most other threading code and use PlatformHelper.ProcessorCount instead.
* Our nunit.snk was corrupt (not sure how this happened) so I replaced it with the current nunit.snk from mainline nunit. Thanks to @jaredpar and other roslyn folks for troubleshooting this - it was causing problems for our msbuild infrastructure as well and I never figured that out.
Some work remains before the compiler server is good enough to use by default, which I will probably document here (or in tree? on a wiki?)
This fixes NullReferenceException that was thrown if:
-
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyEnable was set to true (1)
-
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ProxyServer was set to null
Fixes#10030
* Fixing the decimal formatting so that -0 prints as 0
* Fixing the decimal parser to consider digits still in the buffer as part of the zero/non-zero tail check
Signed-off-by: dotnet-bot <[email protected]>
* [wasm] Fix AOT test build error message 'Unable to compile method'.
* Remove `--aot-interp` command line option
* Remove a few more options
* add --linker option
* Speedup SpanHelpers.IndexOf(byte)
* 128 * 2 alignment
* Move TrailingZeroCountFallback to common SpanHelpers
So it can be used by other types than byte
* Speedup SpanHelpers.IndexOfAny(byte, ...)
* Indent for support flags
* More helpers, constency in local names/formatting, feedback
* Skip bounds check in software fallback
Signed-off-by: dotnet-bot <[email protected]>
* Move common ThreadPool code to shared CoreLib partition.
* Move numWorkingThreads counting out of shared code.
* Rename ThreadPoolGlobals.vmTpInitialized to threadPoolInitialized.
Remove exception handling from ThreadPoolWorkQueue.Dispatch.
Remove obsolete code from ThreadPoolWorkQueue.Dispatch.
Rename ThreadPool.EnsureVMInitialized to ThreadPool.EnsureInitialized.
Signed-off-by: dotnet-bot <[email protected]>
- Add `verbose` CL flag to control `--verbose` mode sent to `monolinker` during link phase.
```
--verbose (set verbose option on link)
type: bool default: false
```
The handler receive an `Open` and the a `Close` event but never a
`DataAvailable` event.
So it _hangs_ if only a `200` status is received (since the headers
are not considered _data_) received from the web server.
This is because some initialization only occurs inside
`HandleHasBytesAvailableEvent` which is now called, on `Close`,
to ensure the initialization is done before completing the request.
This, along with a cancellation check, makes the test case from
https://github.com/xamarin/xamarin-macios/issues/5190 work properly
with this handler.
Fixes https://github.com/xamarin/xamarin-macios/issues/5289
The values of the enum for the TcpState are different in Unix systems
than in .NET, so a function was added to convert between the two.
Signed-off-by: Bijan Tabatabai <[email protected]>
Different instantiations of generic virtual methods occupy the same slot in the vtable. We probe them using a single linked list, by the same logic of jit's imt trampolines.
We allocate a new interp vtable array that we store inside the type's vtable. This array has the same logic as the jit vtable array and it stores InterpMethod pointers. We embed the virtual method slot in the interp instruction stream.
Partly revert a change in https://github.com/mono/mono/pull/12478
CoreCLR treats `Assembly.Load (new AssemblyName ("System.Private.CoreLib.dll"))`
the same as `Assembly.Load (new AssemblyName ("System.Private.CoreLib"))` (and
.NET Framework behaves likewise with "mscorlib.dll").
* [runtime] Make infrastructure for merp tests
* [runtime] Fix dumping when crash happens without sigctx
* [runtime] Disable crashy (886/1000 runs) stacktrace walker
* [crash] Remove usage of allocating build/os info functions
* [crash] Remove often-crashing g_free on native crash path
* [crash] Add crash_reporter checked build
We add a checked build mode that asserts when mono mallocs inside of
the crash reporter. It makes risky allocations into assertions. It's
useful for automated testing because the double-abort often represents
itself as an indefinite hang. If it happens before the thread dumping
supervisor process is started, or after it ends, the crash reporter
hangs.
* [crash] Remove reliance on nested SIGABRT/double-fault (broken on OSX)
* [crash] Fix top-level handling of double faults/assertions
* [runtime] Make fatal unwinding errors return into handled error paths
* [crash] Change dumper logging for better info
* [runtime] Fix handling of segfault on sgen thread
Threads without domains that get segfaults will end up in
this handler. It's not safe to call this function with a NULL domain.
See crash below:
```
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10eff40f8)
* frame #0: 0x000000010e1510d9 mono-sgen`mono_threads_summarize_execute(ctx=0x0000000000000000, out=0x0000001000000000, hashes=0x0000100000100000, silent=4096, mem="", provided_size=2199023296512) at threads.c:6414
frame #1: 0x000000010e152092 mono-sgen`mono_threads_summarize(ctx=0x000000010effda00, out=0x000000010effdba0, hashes=0x000000010effdb90, silent=0, signal_handler_controller=1, mem=0x0000000000000000, provided_size=0) at threads.c:6508
frame #2: 0x000000010df7c69f mono-sgen`dump_native_stacktrace(signal="SIGSEGV", ctx=0x000000010effef48) at mini-posix.c:1026
frame #3: 0x000000010df7c37f mono-sgen`mono_dump_native_crash_info(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-posix.c:1147
frame #4: 0x000000010de720a9 mono-sgen`mono_handle_native_crash(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-exceptions.c:3227
frame #5: 0x000000010dd6ac0d mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48, debug_fault_addr=0xffffffffffffffff) at mini-runtime.c:3574
frame #6: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48) at mini-runtime.c:3612
frame #7: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
frame #8: 0x0000000110bb81c1
frame #9: 0x000000011085ffe1
frame #10: 0x000000010dd6d4f3 mono-sgen`mono_jit_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x00007ffee1ea9f08, error=0x00007ffee1eaa250) at mini-runtime.c:3215
frame #11: 0x000000010e11509d mono-sgen`do_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x0000000000000000, error=0x00007ffee1eaa250) at object.c:2977
frame #12: 0x000000010e10d961 mono-sgen`mono_runtime_invoke_checked(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, error=0x00007ffee1eaa250) at object.c:3145
frame #13: 0x000000010e11aa58 mono-sgen`do_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5042
frame #14: 0x000000010e118803 mono-sgen`mono_runtime_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5138
frame #15: 0x000000010e118856 mono-sgen`mono_runtime_run_main_checked(method=0x00007faae4f01fe8, argc=2, argv=0x00007ffee1eaa760, error=0x00007ffee1eaa250) at object.c:4599
frame #16: 0x000000010de1db2f mono-sgen`mono_jit_exec_internal(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1298
frame #17: 0x000000010de1d95d mono-sgen`mono_jit_exec(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1257
frame #18: 0x000000010de2257f mono-sgen`main_thread_handler(user_data=0x00007ffee1eaa6a0) at driver.c:1375
frame #19: 0x000000010de20852 mono-sgen`mono_main(argc=3, argv=0x00007ffee1eaa758) at driver.c:2551
frame #20: 0x000000010dd56d7e mono-sgen`mono_main_with_options(argc=3, argv=0x00007ffee1eaa758) at main.c:50
frame #21: 0x000000010dd5638d mono-sgen`main(argc=3, argv=0x00007ffee1eaa758) at main.c:406
frame #22: 0x00007fff73aaf015 libdyld.dylib`start + 1
frame #23: 0x00007fff73aaf015 libdyld.dylib`start + 1
thread #2, name = 'SGen worker'
frame #0: 0x000000010e2afd77 mono-sgen`mono_get_hazardous_pointer(pp=0x0000000000000178, hp=0x000000010ef87618, hazard_index=0) at hazard-pointer.c:208
frame #1: 0x000000010e0b28e1 mono-sgen`mono_jit_info_table_find_internal(domain=0x0000000000000000, addr=0x00007fff73bffa16, try_aot=1, allow_trampolines=1) at jit-info.c:304
frame #2: 0x000000010dd6aa5f mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0, debug_fault_addr=0x000000010e28fb20) at mini-runtime.c:3540
frame #3: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0) at mini-runtime.c:3612
frame #4: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
frame #5: 0x00007fff73bffa17 libsystem_kernel.dylib`__psynch_cvwait + 11
frame #6: 0x00007fff73dc8589 libsystem_pthread.dylib`_pthread_cond_wait + 732
frame #7: 0x000000010e28d76d mono-sgen`mono_os_cond_wait(cond=0x000000010e44c9d8, mutex=0x000000010e44c998) at mono-os-mutex.h:168
frame #8: 0x000000010e28df4f mono-sgen`get_work(worker_index=0, work_context=0x000070000fb81ee0, do_idle=0x000070000fb81ed4, job=0x000070000fb81ec8) at sgen-thread-pool.c:165
frame #9: 0x000000010e28d2cb mono-sgen`thread_func(data=0x0000000000000000) at sgen-thread-pool.c:196
frame #10: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
frame #11: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
frame #12: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
thread #3, name = 'Finalizer'
frame #0: 0x00007fff73bf6246 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x000000010e1d9c0a mono-sgen`mono_os_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:84
frame #2: 0x000000010e1d832d mono-sgen`mono_coop_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-coop-semaphore.h:41
frame #3: 0x000000010e1da787 mono-sgen`finalizer_thread(unused=0x0000000000000000) at gc.c:920
frame #4: 0x000000010e152919 mono-sgen`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=0x000070000fd85000) at threads.c:1178
frame #5: 0x000000010e1525b6 mono-sgen`start_wrapper(data=0x00007faae4f31bd0) at threads.c:1238
frame #6: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
frame #7: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
frame #8: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
thread #4
frame #0: 0x00007fff73c0028a libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff73dc7009 libsystem_pthread.dylib`_pthread_wqthread + 1035
frame #2: 0x00007fff73dc6be9 libsystem_pthread.dylib`start_wqthread + 13
(lldb)
```
* [crash] Add signal-safe mmap/file "allocator"
* [crash] Remove use of static memory from dumper
* [runtime] Reduce print buffer size for lockless printer.
Each frame that prints ends up increased by the size of buff.
In practice, clang often fails to deduplicate some of these buffers,
leading to 30k-big stackframes.
It was noticed by a series of hard-to-diagnose segfaults on stacks that
looked otherwise fine during the crash reporting stress test.
This change fixes this, making stacks a 1/10th of the size. It doesn't
seem to break the crash reporter messages anywhere (may need to shrink
other "max name length" fields), and it's not mission-critical anywhere
else.
* [crash] Use async-safe file memory for dumper internals
* [crash] Add memory barriers around merp configuration
* [crash] Use signal-safe printers on all native crash paths
* [crash] Move gdb/lldb lookup to startup
* [runtime] Move MOSTLY_ASYNC_SAFE_FPRINTF to eglib
* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_PRINTF
* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_FPRINTF
* [crash] Switch to signal-safe exit function
* [crash] Make dumper enum in managed
* [runtime] Add more information to managed frame
* [crash] Make async_safe printers inlined
* [runtime] Move basic pe_file functionality into proclib
* [crash] Fix handling of thread attributes
* Move MemoryFailPoint to shared CoreLib partition.
* Split MemoryFailPoint into Unix and Windows versions.
* Replace MemoryFailPoint.GetMemorySettings FCall with GC.GetSegmentSize to make sharing with CoreRT easier.
Signed-off-by: dotnet-bot <[email protected]>
- Add new experimental command line option
- --link-mode=None|SdkOnly|Full Set the link type used for AOT. (EXPERIMENTAL)
- `None` no linking.
- `SdkOnly` only link the Core libraries.
- `Full` link Core and User assemblies. **(default)**
- Add the Facades directory to the resolve paths.
- Treat netstandard, WebAssembly.Bindings and WebAssembly.Net.Http as core libraries. `monolinker.exe` does not see `netstandard` as a core library.
- The problem stems from void methods returning a corrupted MonoObject when the method that is invoked is marked as `void`.
- Internally the cwrap'd invoke method is defined as returning a `number` which internally will return the result from `mono_wasm_invoke_method` of the driver. In the case of `void` methods this may contain invalid address reference causing a memory access crash if referenced.
* Avoid intermediate strings in some StringBuilder formatting
Several appends to string builders are first creating strings and then appending those strings, and they're not using the existing Append(primitive) overloads because they want to customize the format string or provider as part of appending the value. This fixes a few of those cases, using another internal AppendSpanFormattable overload on StringBuilder.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* The version of the server and client should be bumped to call the elapsed_time.
* Removing extra {
* Calling correctly.
* This should be checked in ThreadMirror.ElapsedTime instead using vm.CheckProtocolVersion (), so calling the public method will fail.
Enable SHA256, SHA384 and SHA512 hash algorithms to be used for
Authenticode signatures. This enables producing digital signatures that
are trustworthy using the `mono` tooling.
Fixes#7517
* [llvmonly] Fix dynamic delegate creation in mixed mode.
* [llvmonly] Fix support for virtual calls in mixed mode. Handle calls which end up being not virtual, and add wrappers
for virtual call signatures too.
* [llvmonly] Disable calling aot-ed synchronized methods from the interpreter, it hits an assert in mono_jit_compile_method_jit_only ().
* [wasm] Add a 'wasm-tuner' helper tool which is ran during the app build process.
Currently it only supports one option: --gen-icall-table which generates a linked
icall table based on a linked mscorlib.dll.
* [wasm] Add support for linking out unused icalls in interpreter and aot+interp mode using a new --link-icalls option.
This involves the following steps:
- mono --print-icall-table > icall-table.json
- tuner.exe --gen-icall-table icall-table.json linker-out/mscorlib.dll > icall-table.h
- link icall-table.h into the final executable.
The downside is that this requires compiling a new mono.wasm even in interpreter mode.
* Update README.
* Fix thisdir.
* [csproj] Update project files
* Use ReadOnlySpan.ToArray in places
* Use List.ToArray
* Don't take .Length in to local and use as loop condition
Signed-off-by: dotnet-bot <[email protected]>
* [configure] --with-core should disable remoting, sre.save and appdomains
* [class-init] with ENABLE_NETCORE System.Array has some constant fields
* [object] for NETCORE don't handle appdomain unload exception specially
Since it doesn't exist in System.Private.CoreLib.dll (it's no netstandard.dll)
1. Add classes that the runtime depends on:
* System.Reflection.RuntimeAssembly and System.Reflection.MonoAssembly
* System.Mono.MonoDomain and System.Mono.MonoDomainSetup
2. Add fields to some classes so they match what `object-internals.h` expect on the native side.
3. Make a non-`abstract` `System.RuntimeType` stub.
`System.Type` and `System.RuntimeType` need to have fields that match `object-internals.h` and also the runtime wants to create instances of this type and things go wrong if it's abstract.
On android, the dlopen call will take around 1ms per AOT module we try to load. By not using dlopen with the existence check, we rely on a much slower dlopen check that happens later. I think they support dlopen of non-resolved names.
This might break a few things if we don't use the full path to dlopen. If it does, we should probably add existence checks at the caller, but this will be an optimization that works everywhere.
Rather than having Environment partially live in corefx and call into an EnvironmentAugments type in CoreLib that in turn calls into an Environment type in CoreLib, we're just moving Environment to live in CoreLib.
To start that, this PR moves Environment and its dependencies from their current locations into the shared CoreLib. Those changes will mirror over to coreclr. After that, I'll fix it up to work in CoreLib. And once those changes are built and available back to corefx, I'll update System.Runtime.Extensions to just use the functionality from CoreLib and delete remaining unnecessary code from corefx.
Signed-off-by: dotnet-bot <[email protected]>
I took the liberty of marking the types containing the hardware intrinsics as [Intrinsic] to avoid doing a name check on everything in the system module. It feels like we should take advantage of this attribute in CoreCLR too.
This doesn't actually enable the support because RyuJIT unconditionally disables HW intrinsics for prejit (both CoreRT and CPAOT are considered prejit). We might want to do something about this on the RyuJIT side to address that (for CPAOT, to be able to pregenerate best code possible ahead of time, assuming a fixed ISA; and for CoreRT without JIT, where the concerns about AVX-SSE penalty don't apply). See conversation in dotnet/coreclr#21603
Signed-off-by: dotnet-bot <[email protected]>
Use the MONO_ASSEMBLY_CORLIB_NAME define instead of hardcoding "mscorlib"
everywhere. If building for netcore, the define is set to
"System.Private.CoreLib" instead.
In some circumstances, a string comparison against assembly->aname.name is used to
check if something is in corelib. In cases like that, instead use
`mono_is_corlib_image (assembly->image)` instead. (This introduces a
dependency on mono_defaults.corlib being correctly initialized, so it's
inappropriate for code that runs very early during startup. Which I checked as
best I could.)
This should fix every use of literal "mscorlib" in the runtime.
This does _not_ fix every use of literal "mscorlib.dll" in the runtime, partly
because some of those uses are in the Framework-specific codepaths in the
loader and it doesn't necessarily make sense to perturb them.
Some unnecessary Span to ReadOnlySpan casts.
Some places where new Span(...).Slice(...) can be replaced with AsSpan(...).
Etc.
Signed-off-by: dotnet-bot <[email protected]>
* Avoid allocations in Utf8Formatter.TryFormat(float/double, ...)
Currently every call to Utf8Formatter.TryFormat for a float or a double allocates two strings, one for the format string and one for the resulting number. This avoids those in the common case where we can use float/double.TryFormat and format directly into a stack buffer. Also removes some unsafe code; the performance of StandardFormat.ToString isn't currently worth the extra nanoseconds gained by using unsafe code.
* Delete assert
There's a test that uses unsafe code to cause this to fail and validate that no exception is thrown.
Signed-off-by: dotnet-bot <[email protected]>
* [llvmonly] Move all runtime support code to a new llvmonly-runtime.c file.
* [llvmonly] Make mini_init_delegate () work in mixed mode, it needs to initialize both the interp and the llvmonly related data.
* [llvmonly] Implement EH support in mixed mode.
On interp->native transitions, add a try-catch. On native->interp transitions, rethrow the exception using a c++ throw.
* [llvmonly] Unify function naming, name all llvmonly runtime functions mini_llvmonly_.
* Fix a build failure.
* Fix windows build.
* Fix an aot failure.
* Fix the EH changes.
Internally the javascript bridge support uses `System.Delegate` and `System.Delegate.DynamicInvoke` to support delegate callbacks. The linker, when executed over the assemblies, does not know about this code coverage and will strip out `System.Delegate.DynamicInvoke`.
To fix this:
- Add reference to `System.Delegate.DynamicInvoke` to the `WebAssembly.Bindings` linker xml file so the linker knows not to strip the code.
- Add detailed error messages in case something else goes wrong so the crash is not so cryptic.
After .NET 4.5 .NET Framework has changed the System.ComponentModel.Composition ReflectionModelServices.IsExportFactoryImportDefinition to not throw.
Updating this to match the .NET Framework behavior.
The latest Android NDK releases no longer ship with per-platform C headers.
Instead they ship with a set of unified headers and require the presence of the
`__ANDROID_API__` macro in order to select the target platform.
The AOT offset dumper doesn't support this new layout and this commit changes
that by adding support for the unified headers (without removing support for the
older NDKs) thus fixing the following error when trying to dump the offsets with
newer NDK:
Processing triple: aarch64-v8a-linux-android
Error parsing '[...]/mono/mono/metadata/metadata-cross-helpers.c'
[...]/mono/mono/metadata/metadata-cross-helpers.c(5,10): fatal: 'stdio.h' file not found
Error parsing '[...]/mono/mono/mini/mini-cross-helpers.c'
[...]/mono/mono/mini/mini-cross-helpers.c(7,10): fatal: 'stdio.h' file not found
- Add linker xml descriptor to WebAssembly.Bindings and WebAssembly.Net.Http
- The XML linker descriptor will keep the full assembly for these assemblies during link.
- Fix Link Assemblies command line.
- Miscellaneous fixes for how the assemblies are linked whether they are framework or facades.
- Add the Facades directory to the resolve paths.
* [wasm] Add support for v8 style options to the packager, i.e. --option/--no-option.
Add a --linker option to turn on linking in interpreter mode.
* [wasm] Add a print-table.py helper script to print out the function table of a wasm module.
* [runtime] Add a --print-icall-table option to dump the icall table as json. Usable for linking the icall table.
* [runtime] Pass the method to the icall table lookup function.
* [arm] Set the LLVM data layout, without it, opt seems to make incorrect optimizations.
Fixes https://github.com/mono/mono/issues/12307.
* [x86] Set the LLVM data layout.
* [Debugger] Debugger failure when a method is called in watches and any field of the Class has the type of the field different of the value of the field because the assign was done in an unsafe way like this:
Now the datatypes check in the fields are only executed when it's not inside an invoke method.
_pinnable = Unsafe.As<Pinnable<T>>(array);
A unit test that reproduces the issue was created either.
Fixes#12374
Reverts a29ad08d00 (#9914)
The basic problem we want to solve is the following:
1. All access to InternalThread:state must be protected by the
InternalThread:synch_cs mutex
2. We must destroy the mutex when we are done with the thread.
3. We don't know which happens later - detaching the machine thread or
finalizing its InternalThread managed object.
The solution is to replace InternalThread:synch_cs by InternalThread:longlived
which is a refcounted struct that holds the synch_cs. The refcount starts out
at 2 when the thread is attached to the runtime and when we create the managed
InternalThread object that represents it.
Both detaching and finalizing the managed object will decrement the refounct,
and whichever one happens last will be responsible for destroying the mutex.
This addresses https://github.com/mono/mono/issues/11956 which was a race
condition due to the previous attempt to fix this lifetime problem. The
previous attempt incorrectly used CAS in mono_thread_detach_internal while
continuing to use locking of synch_cs elsewhere. In particular
mono_thread_suspend_all_other_threads could race with
mono_thread_detach_internal: it expects to take the thread lock and test
thread->state and use the thread->suspended event, while detaching deletes
thread->suspended without taking a lock.
As a result we had a concurrency bug: in suspend_all_other_threads it's
possible to see both the old (non-Stopped) value of thread->state and the
new (NULL) value of thread->suspended. Which leads to crashes.
---
Background - why we don't know if detaching or finalization happens first.
1. InternalThread normally outlives the machine thread. This can happen because
when one thread starts another it can hold a reference to the fresh thread's
Thread object which holds a reference to the InternalThread. So after the
machine thread is done, the older thread can query the state of the younger
Thread object. This is the normal situation.
2. During shutdown we can have the opposite situation: the InternalThread
objects are finalized first (this happens during root domain finalization), but
the machine threads are still running, and they may still return to
start_wrapper_internal and call detach_internal. So in this case we have an
InternalThread whose finalizer ran first and detach will run second.
* [Debugger] Debugger crashes when inside a class, there is an internal struct, with a field that is an enumerator.
files.myBucket.GetEnumerator().get_Current().Key
Fixes#10735
* [Debugger] Debugger crashes when there is a generic struct with a field that is an enumerator.
Example: files.get_Current().Key
A unit test that reproduces this crash was added too.
Fixes#10735
* Removing the extra space.
* [wasm] Add support for llvmonly+interp mixed mode.
* Add new --aot-interp and --aot-assemblies= options to packager.exe.
The former enables mixed mode, the latter specifies the list of assemblies which will be AOTed.
* Set the proper AOT_MODE and link in interp libraries in the driver when mixed mode is enabled.
* [llvmonly] Add beginnings of support for llvmonly+interp mixed mode. Treat cross assembly calls as possible places where execution can transition to the interpreter.
* [llvmonly] Add mixed mode tests.
* [llvmonly] Return NULL from mono_jit_compile_method_with_opt () if a method is not found in mixed mode, the caller needs to handle it.
* Implement interp entry support for delegate invokes.
* Implement interp entry for virtual calls.
* Implement interp entry in virtual delegate calls.
* Implement interp entry for virtual generic calls.
* Add runtime invoke test.
* [llvmonly] Add a mini_llvmonly_load_method () helper function to reduce the amount of duplicated code.
* [llvmonly] Add a mini_llvmonly_load_method_delegate () helper function.
* Fix the checked build.
* [runtime] Add a 'cleanup' --enable-minimal option to disable the shutdown cleanup code on platforms which don't need it. Enable it on wasm.
* [wasm] Disable mdb support in the device runtime.
* [runtime] Disable appdomain creation/unload icalls if DISABLE_APPDOMAINS is set.
Several recently added virtuals to TextWriter were missing overrides on SyncTextWriter.
We were missing overrides of the synchronous `Write(ReadOnlySpan<char>)` and `WriteLine(ReadOnlySpan<char>)` overloads. The impact here is primarily performance, though it'll still be an observable change in corner-case scenarios: rather than using the base implementation which would copy the span to an array and then invoke the properly overridden array-based Write{Line} methods, it'll now just delegate to the wrapped span methods. So it calls the correct overload now on the wrapped instance, and saves some cost in the process.
We were also missing overrides for the async `WriteLineAsync()`, `WriteAsync(ReadOnlyMemory<char>, CancellationToken)`, WriteLineAsync(ReadOnlyMemory<char>, CancellationToken)` overloads. Fixing these doesn't change the overload that's invoked on the wrapped writer, but it does cause the calls to become synchronous rather than queue a task that in turn calls the synchronized overload. Whether the new behavior is better is arguable, but it keeps it consistent with every other XxAsync method on SyncTextWriter, which in my opinion is more important... if we wanted to alter the behavior for all of the XxAsync methods, we should do it for all of them.
Also, in the StringBuilder-based overrides, we were ignoring cancellation. And in the recently added DisposeAsync, we should follow-suit with the rest of the async APIs and make it synchronous.
Signed-off-by: dotnet-bot <[email protected]>
We might need to adjust the ip in the same fashion when normally resuming to catch handler.
In the example from the testcase, we have these transitions : ... -> interp_frame -> jit -> eh1 -> interp_frame -> eh2. When eh1 unwinds to call the finally clause from interp_frame it also pops all other lmf entries until there. This means that eh2 thinks it was called directly from the interp_frame (as it would happen with the jit), but in this case there are still the jit frames in the middle. Eh2 doesn't know how to resume over the jit frames, it will just set the resume state to the interp_frame and eh1 will do the resuming over the jitted frames, after run_finally returns gracefully. If the exception were to be handled by frames parent to interp_frame and there are also pushed contexts on the lmf stack, then eh2 could both unwind and resume directly there, skipping eh1 and the jitted frames altogether.
* Cleanup Framework Bindings and HttpMessageHandler code.
- move to framework folder to match package structure. Simplifies packager code finding the framework libraries.
- create solution and project files
- split up the `bindings.cs`, now removed, into multiple files and reformat code
- Clean up xml documentation
- generate xml file documentation on build.
- modify make file to build the solution and modify tests to use framework output.
- modify `packager` to use the correct directory structure.
- modify `sdk` build targets.
- modify `package` target to package the correct assemblies along with source projects and solution.
Tested:
- JavaScript shell tests which run in jenkens
- Browser Tests
- AOT build and tests
* Modify projects to be netstandard instead of framework.
- use dotnet instead of msbuild which is not available.
- Modify test builds
* Fix Sdk.props to point to correct Bindings library path
* Fix build dependencies
* Fix AOT build - duplicate assembly key
* Fix package target
This is the first step to moving OperationStatus from corefx into coreclr. It'll be used by the transcoding APIs which live in System.Private.CoreLib.
Signed-off-by: dotnet-bot <[email protected]>
[interp] use interp_lmf wrapper for interp2native on platforms with wonky sigcontext
On some platforms (e.g. AppleTV) SigContext is available, but isn't as
precise as we would like to have it. For example, it doesn't save
callee-saved registers and thus aren't restored properly.
Unfortunately, this also means we can't use the fastpath for
interp2native, so we disable it on those platforms.
Needs backport to: 2018-08, 2018-10, 2018-12
* Changing the test behavior as discussed with Ludovic, because we already have knowledge about the unreliability of the crash reporter and the test is not about it.
So if in 10 times at least one of them works for now it's good.
Fixes#11385
* Removing extra message.
* Removing the crash log file after the test is finished.
It was never documented and it is not as useful now with a matured hybrid
suspend.
If MONO_ENABLE_BLOCKING_TRANSITION set, and mono is otherwise configured to use
preemptive suspend, the thread state machinery would perform RUNNING->BLOCKING
transitions (ie: MONO_ENTER_GC_SAFE and friends would be more than no-ops), but
still preemptively suspend every thread. This was useful for testing the
thread transitions separately from the coop suspend details.
* [llvmonly] Avoid generating/loading trampolines in llvmonly+interp mode.
Add a new execution mode MONO_AOT_MODE_LLVMONLY_INTERP and make --llvmonly-interp use that. INTERP_LLVMONLY defaults to the interpreter, while LLVMONLY_INTERP defaults to aot.
* [llvmonly] Save whenever a method has a gsharedvt variable signature into the aot image and use that instead of looking up its MonoJitInfo, which is a perf problem since its done for all methods.
* Add a case to append_mangled_wrapper_subtype ().
* [llvmonly] Move initialization of delegate->method_ptr to mini_init_delegate (), pass a handle to the callback.
* [llvmonly] Allow --regression to work in mixed mode.
* [llvmonly] Set param names for gsharedvt in/out wrappers.
* [llvmonly] Use the dedup mangler for setting method names for gsharedvt in/out wrappers, shorten the names a bit.
* Revert "[llvmonly] Allow --regression to work in mixed mode."
This reverts commit d7838c1ce7dc0e3d7bfc3c7f01214224f561db90.
* Fix c++-isms.
- Fix different errors when building via the nuget instead of locally.
- The nuget generated had a different structure so fixed the output generation to work for both local build as well as nuget build.
- Fix problem with the monolinker.exe not being located correctly.
- Move the monolinker.exe to tools directory within nuget.
* Moves common COM type to shared corelib partition
* Moves GetHRForException to PInvokeMarshal
* Add temporary CORECLR ifdef to ArrayWithOffset
* Apply cleanup from CoreCLR
Signed-off-by: dotnet-bot <[email protected]>
We hit the following issue when the upstream repo receives a new commit:
```
16:11:49 error: Your local changes to the following files would be overwritten by merge:
16:11:49 binaryen-tags.txt
16:11:49 emscripten-tags.txt
16:11:49 upstream/lkgr.json
```
To workaround we now clean the emsdk repo before pulling.
Several of the name changes fixes MSVC warnings where local variables
hides global variables using the same name.
Number of adjustments not building on platforms not defining HAVE_CLASSIC_WINAPI_SUPPORT.
Fix a couple of build projects not setting dependencies on build-init.vcxproj.
This could cause races in build order if projects depend on build initialization.
Added support to force external builds to use msbuild even if ninja is present.
The problem was in this line:
ss_nested_with_two_args(ss_nested_arg (), ss_nested_arg ());
The first step_into works correctly entering in the ss_nested_arg method, but the second one doesn't work.
The problem was because this flag MONO_SEQ_POINT_FLAG_NONEMPTY_STACK was set, so the debugger don't consider that it was a possible break.
The solution of the issue was create another flag to identify nested calls and ignore the MONO_SEQ_POINT_FLAG_NONEMPTY_STACK.
2 new tests were added to test other nested calls.
#Fixes 7326
* [wasm] Add stubs for a few functions needs by System.Native.
* [wasm] Enable Mono.Native.
* Enable Mono.Native in the mono build.
* Link libmono-native.a into the interpreter/aot builds.
* Add a dlopen fallback to driver.c to allow the runtime to look up the pinvoke declarations.
* [wasm] Enable direct pinvokes for AOT, disable the dl fallback in AOT mode, its not needed since the generate code links directly to the Mono.Native symbols.
* [wasm] Disable more corlib tests for wasm.
* [wasm] Enable running corlib tests on CI.
* [wasm] Pass -D_WASM_ to the Mono.Native build.
* Fix line numbers in stack frame tests.
* Revert "[wasm] Enable direct pinvokes for AOT, disable the dl fallback in AOT mode, its not needed since the generate code links directly to the Mono.Native symbols."
This reverts commit 2d2ba5261c6fa0b6c1c110d53f18c4248c11cdff.
Direct pinvokes need more support since it needs to link against objc-libs, btls, etc.
* [csproj] Update project files
* [mini] Use C++ linker iff building C++ that needs the C++ runtime
(This has nothing to do with --enable-cxx. This is about our LLVM .cpp files).
Explicitly set the linker for libmini. The issue is that the automatic
linker selection (See
https://www.gnu.org/software/automake/manual/html_node/How-the-Linker-is-Chosen.html)
looks at all the _SOURCES for a target, even those that are only
conditionally added, even if the condition is false. So because we sometimes
build mini-llvm-cpp.cpp we always get the c++ linker. But that's not what we
want.
The goal is:
- if there's any C++ code included into mono (either the shared lib or a
program) that needs the C++ runtime library, ensure that we link using the C++
linker. This was already true, we just need to make sure it stays true.
- if mono is built in such a way that it has no C++ code in it (that needs the
C++ runtime library), ensure that we link with the C linker and without
including the C++ runtime library.
This will address issues like https://github.com/mono/mono/issues/12060
We do this in two steps:
1. We split out all the c++ source code to libmini-cxx.la and include that into
libmini.la.
That's enough to force C++ linking if libmini-cxx.la has any code in it. If
there's no C++ code (right now that means there's no --enable-llvm or
--enable-llvm-runtime), we don't add libmini-cxx.la and all the C source in
libmini links in the normal manner.
2. We have a hack where we sometimes include libmono.a (the static library)
into the mono executable. In that case, we could forget about the C++
linker (which leads to build failures because llvm uses all the C++ runtime
library stuff that we forgot to link in).
So we use the "nodist_EXTRA_..._SOURCES=dummy.cpp` hack to make it look like
the mono executable has C++ source, which in turn forces the use of the C++
linker.
The conditional logic here has to match exactly what we do for deciding
whether to add libmini-cxx.la into libmini.la. If we do, then force the use
the C++ linker here.
It may seem like another option is to use something like
`mono_boehm_LINK=$(CXXLINK)` to set a target-specific linker. But this is
bad, actually, because in that case we will drop the `..._LDFLAGS` and other
linker flags unless we're very diligent to include all of them. The
`nodist_EXTRA_..._SOURCES` hack is more resilient because automake will
ensure that all the flags are kept.
* [llvm,wasm] Don't add -lstdc++ in llvm_config.mk
Leave it to the linker.
This is needed when building wasm cross compilers for windows which pass
-static-libstdc++ to configure. As a result we would get duplicate symbols by
linking against a static libstdc++.a and also the export stubs of libstdc++.dll
In mini, link monow using the C++ linker same as with mono by using the nodist_EXTRA_..._SOURCES
trick.
In wasm, pass -static-libstdc++ to CXXFLAGS, not LDFLAGS. c++ linking picks up
CXXFLAGS anyway, and -static-libstdc++ has no effect on the C linker and it
doesn't affect explicit -lstdc++ flags anyway.
* [Coop] Convert System.Threading.Semaphore.
Potential handles are avoided through fixed, but error path converting utf16 to utf8 is introduced.
* [Coop] Cleanup System.Threading.Mutex. Replace gchandle pinning with C# fixed.
* Remove two commented out lines that are not likely to materialize.
* [Coop] Cleanup System.Threading.NativeEventCalls. Replace gchandle with C# fixed.
* Don't assume ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal output is to stack.
[exceptions] Always process self aborts even if we have one pending
For example, in the following code, the abort that ends the thread should be the one thrown from the finally block instead of the try block :
```csharp
try {
Thread.CurrentThread.Abort ();
} finally {
Thread.CurrentThread.Abort ();
Console.WriteLine ("Why are you still here ?");
}
```
Apparently, on old versions of Autoconf, a AC_TRY_COMPILE block with an
empty action-if-true block, like:
```
if test x$fpabi = xauto; then
AC_TRY_COMPILE([], [
#ifdef __riscv_float_abi_double
#error "double"
#endif
], [
], [
fpabi=double
])
fi
```
emits invalid shell code, like:
```
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
else
```
`else` immediately after `then` is not valid.
This construct is fine on newer versions, where `then :` is used, which
does not count as invalid.
Even though we're not building for CentOS 6 RISC-V, the invalid shell
causes the configure script to fail entirely, e.g. https://jenkins.mono-project.com/view/Releases/job/ng-release-generate-rpm-packages/963/execution/node/142/log/
Add a useless action-if-true which won't affect the program flow, but
means we aren't emitting `then else` on old Autoconf.
Xamarin.Android is looking to switch to using the latest Android NDK, r18.
However, there are a few build issues in Mono and BTLS which need to be
addressed before that happens.
* BTLS fails to build some ARM assembly sources with NDK r18's clang.
https://github.com/mono/boringssl/pull/12 fixes this issue
* BTLS uses obsolete Android cmake toolchain file.
Add a configure option to set alternative toolchain file.
* NDK r18 minimu supported API level is 16.
This commit makes the API level configurable and sets the minimum platform
to API 16
* NDK r18 makes changes to declaration of `mmap` which break Mono build.
Detect NDK version in `mono-compiler.h` and act accordingly (do not
redeclare `mmap`)
* NDK r18 doesn't have `cpp` and SDKs build assumes it's present.
Detect whether `cpp` is present and, if not, use `compiler -E` instead.
* NDK r18 uses unified headers exclusively and requires __ANDROID_API__ to be
set in order to present the correct set of native APIs.
SDKs now define the macro when the `ANDROID_NEW_NDK` Make variable is set to
anything else than `no`.
- mono_threads_suspend_policy_name
- mono_threads_suspend_policy_are_safepoints_enabled
- mono_threads_suspend_policy_is_multiphase_stw_enabled
- mono_threads_suspend_policy_is_blocking_transition_enabled
The normal accessors (mono_threads_are_safepoints_enabled, etc) just apply the
policy acessors to the current policy
- Allow creation of JavaScript objects without resorting to json parsing and creating hooks.
- Small cleanup of the bindings routines.
- Modify WasmHttpMessageHandler to use new routines and take out the hackish calls.
* Adds portable version of EncodingTable
Most of the implementation is extracted from CoreRT
* Use string comparer directly
* Remove no longer used COMNlsInfo
* Adds localization support
* Removes FeatureCoreFxGlobalization configuration
* Remove redudant encodings look up from GetEncoding
* Keep Hashtable for nameToCodePage as it does not lock on read
* Replace locked dictionary lookup with short switch
* Include comment with msbuild task link used to generate the data file
Signed-off-by: dotnet-bot <[email protected]>
In the common case where it need to replace a non-empty extension with a non-empty extension, it currently incurs a substring without the original extension prior to then concatenating with the new extension. This PR avoids that.
(As the Path implementation is in corelib, this uses string.FastAllocateString and then formats into it with a span; if we wanted to avoid that, string.Create could also be used.)
* Add internal String.Concat overloads for spans
* Use span-based string.Concat overloads in several places
Signed-off-by: dotnet-bot <[email protected]>
* Fix bug in pulse transition - the suspend count was lost and incorrectly
swapped to 0.
* finish_async_suspend transition - add assertions that the suspend count is
positive. Try to catch incorrect states sooner.
Fixes https://github.com/mono/mono/issues/12235
[interp] Fix resuming into interp frame during EH
During EH, we can have the same frame twice on the stack, the original one and when invoking clauses in the same frame from EH. When having a resume state, we need to check if we should catch it in the current frame, or the original.
<!--
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
-->
Large portion of the current culture handling in the unmanaged runtime inherited from desktop has been no-op. The nativeInitCultureAccessors QCall that it used to depend on desktop got (almost) never called in CoreCLR.
- Delete resetting of current culture on threadpool threads. It was needed in desktop because of a very tricky flow of current culture between appdomains. It is superseded by the flowing the current culture via AsyncLocal in CoreCLR.
- Comment out fetch of managed current culture for unmanaged resource lookup. It has number of problems that are not easy to fix. We are not localizing the unmanaged runtime currently anyway, so it is ok to just comment it out.
- Fix the rest to call CultureInfo directly without going through Thread.CurrentThread
Signed-off-by: dotnet-bot <[email protected]>
We use SR.Format in almost all places where we format resource strings (without a format provider), but there were a few stragglers.
Signed-off-by: dotnet-bot <[email protected]>
When we do need to normalize, we're currently allocating the StringBuilder/char[] for the full path length. As long as the path length is less than the max cacheable size (360), we'll now use a cached builder.
Signed-off-by: dotnet-bot <[email protected]>
The former calls GetLowerBound(0) on both src and dst, which is unnecessary when the arrays are T[] and thus always have a lower bound of 0.
Signed-off-by: dotnet-bot <[email protected]>
* Change array construction with rank>4 to use not use varargs -- localalloc.
This fixes https://github.com/mono/mono/issues/12193.
This is alternative to https://github.com/mono/mono/pull/12200.
They are both pretty good approaches.
12200 uncovered a hash order dependency which should be fixed either way.
* Fix C++.
* Remove unused MONO_ARCH_VARARG_ICALLS and ARCH_VARARG_ICALLS.
```
typedef struct {
.
.
.
MonoMethod *method;
MonoMethod *inlined_method; /* the method which is currently inlined */
MonoMethod *current_method; /* The method currently processed by method_to_ir () */
MonoMethod *method_to_register; /* The method to register in JIT info tables */
} MonoCompile;
```
so at least remove one of them that is not really used.
* Consolidate identical functions type_from_handle and cominterop_type_from_handle
mostly into mono_type_from_handle.
However keep them separate for registration/patching sake, since
will error if register twice, else need to arrange to register once.
* [Coop] Convert {remoting,cominterop}type_from_handle.
* Fix warning about missing icall declaratons.
Typo fix
<!--
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
-->
System.Web.Caching.CacheItemLRU.this[string].get modifies LRU list so it
must be called under write lock. Cache.GetKeyLastChange violates this
constraint by acquiring only a read lock.
Fixes#12218
- In spin-wait loops that are not expected to last too long, Sleep(1) significantly delays threads from completing the operation
- From eliminating Sleep(1) in such spin-wait loops, there can be a tradeoff, better fairness vs worse throughput, because Sleep(1) removes threads from contention and in some cases fewer threads can make faster progress at the cost of delaying the Sleep(1) threads relatively significantly. Eliminating the Sleep(1) in such spin-wait loops seems to be a good tradeoff.
Signed-off-by: dotnet-bot <[email protected]>
* Moves generic comparer to shared CoreLib
* Keep Index/LastIndexOf optimizations in CoreCLR only
* Moved runtime-specific enum helper to runtime-specific partial type
Signed-off-by: dotnet-bot <[email protected]>
* Remove dead checks in Guid parsing
* Minor cleanups in Guid
* Delete unused failureMessageFormatArgument
Signed-off-by: dotnet-bot <[email protected]>
- This will download the most recent version of headless to use.
- Add junit-reporter to output a tests output file to be used for jenkins CI in the future.
ICALL_EXPORT should not be placed on HANDLES() functions.
Only the auto-generated wrappers need it, and they get it from the macro expansion.
And the explicit function declarations are generally redundant - the macro creates declarations, too.
This method doing blind find&replace of "mscorlib" with "System.Private.CoreLib". It is both incorrect (e.g. if the typename happened to contain "mscorlib" string) and inefficient (unnecessary allocations and use of reflection).
Signed-off-by: dotnet-bot <[email protected]>
Synchronized the code as much as possible with CoreCLR. The one major piece that I have excluded is tracing. I will look into doing that separately.
Signed-off-by: dotnet-bot <[email protected]>
* Updating the SIMD intrinsics to check for the `[Intrinsic]` attribute
* Ensure that the existing Vector/Vector<T> intrinsic methods are marked as such.
* Fixing Vector<T>.DotProduct and Vector.AndNot to be treated as intrinsic
* Fixing `SIMDIntrinsicBitwiseAndNot` to swap the operands for XARCH
Signed-off-by: dotnet-bot <[email protected]>
* [Coop] Mostly convert 30+ icalls used via register_icall.
And infrastructure to support that.
The infrastructure is not as ideal as it could be.
In future the C preprocessor wrappers should be marshal-ilgen wrappers,
so the handles are more efficiently created.
Some of the conversion is incomplete and just goes back to raw pointers,
but mostly it is good.
Some of the conversion is by replacing previously manual conversion
with more automatic conversion, but most of it is new.
* Replace `foo_raw` with `foo` and `foo` with `foo_impl` per https://github.com/mono/mono/pull/11941#discussion_r243436712.
* Replace gchandle with no_safepoints in mono_string_builder_to_utf16_impl.
https://github.com/mono/mono/pull/11941#discussion_r243438706
at least the one loop.
* Fix windows build: mono_string_to_utf8str vs. mono_string_to_utf8str_impl.
* Fix boehm ves_icall_string_alloc vs. ves_icall_string_alloc_raw.
* Reduce apparent or actual diff.
* Add link to GitHub issue.
* Fix merge.
* Reduce another apparent but probably not actual diff.
* FIXME missing error
* Reduce diff in comment.
* Reduce diff in comment.
This commit ensures that CVE 2018-8292 is fixed by not setting
auto-redirect in the first request done by CFNetwork. CFNetwork has the
same bug, but we can work around it by performing the first request,
checking the response and, if it is a rediret, follow it without the
Authorization headers.
I noticed that some controls do not dispose tooltips and timers. Depending on the underlying implementation these may use native resources. Therefore I'd suggest to dispose these with the parent control to not rely on the garbage collector to eventually release the resources.
Additionally, in the case of `ToolStrip.cs` `CloseToolTip` would first create the objects before turning them off.
* [Coop] Mostly convert System.String icalls. But do not pin due to perf/profiler.
* Use MONO_ENTER_NO_SAFEPOINTS / MONO_EXIT_NO_SAFEPOINTS
* Add FIXME to MONO_HANDLE_RAW (mono_ldstr_metadata_sig ()), looks like a reasonable place to temporarily suspend the coop conversion graph walk.
* Restore MonoObjectHandleOut to mono_handle_assign_raw (was mono_handle_assign).
* [runtime] Convert TypedReference icalls to handles, return the result using an out argument since wasm doesn't support TypedReference returns from icalls.
* Bump corlib version.
* [runtime] Change ArgIterator icalls to return typedref results using an out argument since wasm doesn't support typedref returns from icalls.
* Use MONO_HANDLE_RAW () only at the end.
Forward port of #10139
Needed for arm64_32 (#11691): We still need to build AOT compilers that are 32bit, which is only possible with Xcode9. However, arm64_32 needs Xcode10.
Relax HttpMessageRequest url scheme validation for wasm so that urls with a blob scheme make it to the host backend. Fixes#11681
note: the browser tests fail when running chrome 71 in headless mode, they work in chrome 70 and 72
* Bump to latest SQLite for Mac bundle
* Explicitly disable editline support.
SQLite assumes that if editline is enabled (the default), then NCurses was compiled with TermInfo support, which is not true on Mac
ystem.Exception: Generic Error [GDI+ status: GenericError]
at System.Drawing.GDIPlus.CheckStatus (System.Drawing.Status status) [0x00079] in <bb99ab19679c4cf79f4136bd0faf8b5e>:0
at System.Drawing.Graphics.FillRectangle (System.Drawing.Brush brush, System.Int32 x, System.Int32 y, System.Int32 width, System.Int32 height) [0x00025] in <bb99ab19679c4cf79f4136bd0faf8b5e>:0
at System.Drawing.Graphics.FillRectangle (System.Drawing.Brush brush, System.Drawing.Rectangle rect) [0x0002c] in <bb99ab19679c4cf79f4136bd0faf8b5e>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Graphics.FillRectangle(System.Drawing.Brush,System.Drawing.Rectangle)
at System.Windows.Forms.Control.PaintControlBackground (System.Windows.Forms.PaintEventArgs pevent) [0x002ff] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.Control.OnPaintBackground (System.Windows.Forms.PaintEventArgs pevent) [0x00000] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.Control.WmPaint (System.Windows.Forms.Message& m) [0x0005f] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x001a4] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.ScrollBar.WndProc (System.Windows.Forms.Message& m) [0x00000] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <69ecb40f27a1431a99620933ba9a8b39>:0
at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <69ecb40f27a1431a99620933ba9a8b39>:0
* [wasm] Add the fix for https://github.com/kripken/emscripten/issues/7399 as a patch for emscripten.
* [wasm] Factor out some flags from the makefile targets.
* [wasm] Enable EMULATED_FUNCTION_POINTERS.
G_BEGIN_DECLS is almost never needed. Esp. around entire files.
It is for "the OS" and interoperation with some code that is still C, like profilers.
MONO_BEGIN_DECLS is often used in internal headers, in which case the same, but
not addressed here.
MONO_BEGIN_DECLS is often used in public headers, along with comprehensive
MONO_API, in which case it is redundant. This would be useful if/when mono
goes back to using .def files, which are a good idea for multiple reasons.
Probably unused since a0c6e79318 in 2004.
Certainly unused since cc9c53a109 in 2008.
Except for use by MERP, replace with its implementation -- MONO_LOCALE_INVARIANT.
* [jit] Call mono_register_jit_icall_full () in more places so most jit icalls can be called directly during AOT.
* Fix a c++-ism.
* Fix a c++-ism.
* Fix a c++-ism.
This is a subset of https://github.com/mono/mono/pull/12023, maybe easier to review
in smaller pieces.
Alternatives:
1. Move more to managed.
2. Remove the feature.
* Add support for LLVM asserts in internal LLVM build on Windows.
* Only build LLVM using MSVC if not cross compiling.
If not cross compiling, building runtime where host/target is Windows, only
build and use LLVM as part of msvc build (only supported configuration),
disabled on gcc build.
Enforce 64-bit LLVM support when building using Visual Studio solution file.
* Disable Windows LLVM Visual Studio build on unsupported configurations.
Automatically disable Windows LLVM build in Visual Studio. This enables
the option to configure using --enable-llvm but still build all runtime
configurations from within Visual Studio. A warning will be issued into
build logs when LLVM support is disabled for a specific build configuration.
* Fix so build-init always have cygconf.h available when needed.
* The problem with this flaky issue was the timing of processing of the async tasks, as it was executed in background threads it was not possible to reach the end of execution because all the foreground threads exit earlier.
The solution creates a TaskScheduler that ensure that the thread that will execute the task will be a foreground thread and then the test always works.
Fixes#6997
Exposes a race condition in CoreFX when gensources tries to enumerate Cecil sources. Run it without `--trace=all`, 86 sources found. Run it with, even if redirected to `/dev/null`, 132 sources found. Eeeeeek.
[runtime] Remove duplicate merp invoke line
Looks like this broke when it got squashed down, or we overlooked it. We've got two calls where we expected one.
...of importing it at linux/macOS
this unbreaks the build on "unix" platforms like FreeBSD and AIX
(is this all needed files, and am I doing this right?)
if (klass = m_class_get_parent (klass))
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
icall.c:4408:12: note: place parentheses around the assignment to silence this warning
if (klass = m_class_get_parent (klass))
^
( )
icall.c:4408:12: note: use '==' to turn this assignment into an equality comparison
if (klass = m_class_get_parent (klass))
* [corlib] Import System.IO.TextWriter/StreamWriter from CoreFX
* Adjust a Mono test. According to CoreFX TextWriter sources, CoreNewLine should only be used for read-only purposes.
* Bump CoreCLR for bug fix on test which becomes much flakier apparently with this patch
* Bump corefx
* Bump API snapshot submodule
* [csproj] Update project files
- Reduce length computations of string builders.
- Handle zero sized StringBuilder correctly (initialize the first
not just the second character).
- Check for overflow correctly in StringBuilder -- include offset.
- Fix prototype of mono_string_to_byvalstr (gpointer vs. char*)
- Fix prototype of mono_string_to_byvalwstr (gpionter vs. gunichar2*).
- Single point of exit in mono_string_builder_to_utf8.
Includes the following from System.IO:
* FileSystemInfo
* FileInfo
* DirectoryInfo
* Directory
* FileSystem
* Path `Join()` Span API
and all of System.IO.Enumeration namespace.
Adds about 1600 System.IO tests
Behavior changes:
* `File.Replace` now replaces files even if they are read-only (using the `rename` syscall on Unix)
* Directory enumeration is no longer stable in the way that many Mono tests expect
* Some changes in when/whether some representations of directories contain a trailing separator character
* Changes in which exceptions are thrown (sometimes these are platform-dependent on CoreFX)
Issues:
* https://github.com/dotnet/corefx/issues/33486
* https://github.com/dotnet/corefx/issues/33490
Part of #7246
CC libtest_la-libtest.lo
<inline asm>:37:2: error: instruction requires: Not 64-bit mode
popl %eax
^
... same error many times
Fix ThisCall tests.
Libtest.c needs to be C++ for Visual C+++ to accept __thiscall.
gcc accepts __thiscall in C.
Visual C++ only accepts __thiscall on member functions and function pointers,
not globals. Gcc accepts on globals also.
So test what we can.
add extern C
Limit thiscall testing to Win32, even if gcc has more support.
Fix CHECK_CANARY_FOR_OBJECT.
..\mono\metadata\sgen-mono.c(1443): warning C4390: ';': empty controlled statement found; is this the intent?
(Why is this not a function?)
* [crash] Switch merp dumper to no-allocate file writer
- Pass merp directory to backend (optional)
- Adds tests that needed the named change
* [crash] Make mono-state use non-allocating format strings
* [crash] Add json formatting validators to mono/tests
* [crash] Make crash-sending icalls use const strings
* [crash] Use fork+exec for merp
* [crash] Throw exception when unable to contact merp
* [crash] Disable merp-json-valid test on non-OSX
* Elimination of mgreg_t in favor of target_mgreg_t and host_mgreg_t.
* [mips] Fix one host vs. target size.
* easier to read in narrow screen
* For posterity.
* Fix regression with building PPC JIT
d5547b1929 made an incorrect change
to `mini-ppc.c` that wouldn't build; revert that file.
* Switch to fixing mini-ops.h instead
Fixes https://github.com/mono/mono/issues/11317
(I guess I need to update culture-info-tables.h via make but it doesn't work on Windows, I have to switch to macOS).
CC libtest_la-libtest.lo
<inline asm>:37:2: error: instruction requires: Not 64-bit mode
popl %eax
^
... same error many times
Fix ThisCall tests.
Libtest.c needs to be C++ for Visual C+++ to accept __thiscall.
gcc accepts __thiscall in C.
Visual C++ only accepts __thiscall on member functions and function pointers,
not globals. Gcc accepts on globals also.
So test what we can.
add extern C
Limit thiscall testing to Win32, even if gcc has more support.
mono_class_init_internal is what mono_class_init was.
mono_class_init *adds* missing GC mode transitions and calls mono_class_init_internal.
Replace mono_class_init with mono_class_init_internal.
/s/mono/mono/mini/interp/interp.c: In function 'interp_entry_from_trampoline':
/s/mono/mono/mini/interp/interp.c:2422:3: warning: 'orig_domain' may be used uninitialized in this function [-Wmaybe-uninitialized]
mono_threads_detach_coop (orig_domain, &attach_cookie);
^
/s/mono/mono/mini/interp/interp.c: In function 'interp_exec_method_full':
/s/mono/mono/mini/interp/interp.c:2695:4: warning: 'locals' may be used uninitialized in this function [-Wmaybe-uninitialized]
memset (locals, 0, rtm->locals_size);
^
/s/mono/mono/mini/method-to-ir.c: In function 'mini_handle_enum_has_flag':
/s/mono/mono/mini/method-to-ir.c:3416:9: warning: 'load' may be used uninitialized in this function [-Wmaybe-uninitialized]
load = mono_decompose_opcode (cfg, load);
^
At least the first two seem to be compiler weakness.
2b029b3df4 broke ppc JIT tracing by
moving it into mini and changing the arguments. Since the mini IR
emitter handles tracing now, rip out the tracing code from the JIT.
(Looks like SPARC will need a similar change, but someone needs to
love SPARC first.)
The existing tests work with JavaScript Engines and do not have any way to test code that works only in the browser. The JavaScript Engines do not have access to any browser API’s so functionality like the WasmHttpMessageHandler can not be tested.
- Add test suite that uses Headless Chrome and Node.js with Karma.
- Allows testing the browser API.
Alternatively, safer, since it never worked, remove it.
/s/mono/mono/utils/mono-error.c:124:28: warning: comparison of constant 'MONO_ERROR_CLEANUP_CALLED_SENTINEL' (65535) with expression of type 'short' is always true [-Wtautological-constant-out-of-range-compare]
g_assert (orig_error_code != MONO_ERROR_CLEANUP_CALLED_SENTINEL);
~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixing this reveals problems in ves_icall_System_Threading_Thread_GetAbortExceptionState,
i.e. the repaired assert fails, so this depends on https://github.com/mono/mono/pull/11889.
Also cleanup and optimize nearby.
This isn't correct for Win64 but that should be ok.
It is correct for all other platforms.
/s/mono/mono/sgen/sgen-memory-governor.c:309:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->promoted_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:310:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->major_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:311:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->major_size_in_use / 1024,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:312:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:313:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size_in_use / 1024);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:321:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:322:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size_in_use / 1024);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:332:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:333:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->los_size_in_use / 1024);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:337:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->major_size / 1024,
^~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/sgen/sgen-memory-governor.c:338:5: warning: format specifies type 'ssize_t' (aka 'long') but the argument has type 'unsigned int' [-Wformat]
entry->major_size_in_use / 1024);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/s/mono/mono/metadata/w32file-unix.c:4688:1: warning: no previous prototype for function 'ves_icall_System_IO_DriveInfo_GetDriveType' [-Wmissing-prototypes]
ves_icall_System_IO_DriveInfo_GetDriveType (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error)
^
/s/mono/mono/metadata/remoting.c:2143:1: warning: no previous prototype for function 'mono_context_set_icall' [-Wmissing-prototypes]
mono_context_set_icall (MonoAppContext *new_context_raw)
^
/s/mono/mono/mini/mini-posix.c:229:2: warning: unused variable 'ctx' [-Wunused-variable]
MONO_SIG_HANDLER_GET_CONTEXT;
And beware icall-decl.h + Boehm producing:
w32file-unix.c:4905:16: error: implicit declaration of function 'GC_dlopen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
libc_handle = dlopen ("/usr/lib/libc.dylib", 0);
^
or, if you fix that, unreferenced symbol _GC_dlopen.
* [corlib] Make by-ref struct actually ref now C# supports them.
This is technically breaking change but the types are already specialized
in C# compiler to be ref structs therefore the breaking change is more
theoretical than practical
* [mcs] Improves error reporting for special runtime types
* Bump API snapshot submodule
While working on PR #11829 I stress-tested the tests by running multiple test
runs in parallel, and it turned out that many tests were not parallel-safe,
because they used the same temporary file names and ended up stomping on
eachother.
So I implemented a helper method that creates a guaranteed unique temporary
directory, and I've changed all tests to use this new helper method.
Fix order of parameter processing.
New parameter addition was put in wrong spot in the parameter list. Also the offsets on the stack were incorrect as 32-bit values are placed in 64-bit aligned slots on s390x. Therefore, even though these are gbooleans the appear to be treated as gulongs.
<!--
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
-->
* [bcl] add fullaotinterp_llvm preset
That is, the AOT compiler uses the LLVM backend for BCL. AOT+LLVM is
used in the 'Release' configuration on Xamarin.iOS.
* [aot_full_interp_llvm] enable corlib tests
* More mgreg_t to host_mgreg_t or target_mgreg_t conversion.
Mostly target_mgreg_t.
Note that this is all optional, in the sense that cross compilers
never run their runtime. So mgreg_t is always target_mgreg_t, or
they are the same.
But agreement is to ban mgreg_t.
* [bcl] Disable some tests under WASM.
* [bcl] Pass a stack mark through TypeSpec.Resolve ().
* [runtime] Avoid freeing an error which gets passed back from an icall.
* [wasm] Make Environment.GetCommandLineArgs () work. Allow excluding tests on the command line.
* Fix some stackframe tests.
* [wasm] Add a missing dependency to the ninja files.
Fix https://github.com/mono/mono/issues/11898
This regressed six months ago at https://github.com/mono/mono/pull/9503/files#r238093574.
There are two identical sounding functions:
mono_string_handle_to_utf8:
What we usually use. Sounds reasonable. Usually is reasonable.
Allocates with malloc.
mono_string_to_utf8str_handle:
What should be used here. Allocates with CoTaskMemAlloc.
So it can be freed with marshal_free => CoTaskMemFree.
i.e. The allocator and the freeer need to agree.
It's only available in automake 1.13+. Since we only use it for tests
we can just make it optional on systems with earlier automake.
Fixes https://github.com/mono/mono/issues/11809
Removing BindingFlags checks from native code to instead
trust the checks made in managed code. This fixes the case
when events were incorrectly returned from types that
have overridden private or static events.
This might invalidate all existing data however and perhaps 32bits is enough.
/s/mono/mono/utils/mono-merp.c:227:63: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
g_string_append_printf (output, "BlameModuleOffset: 0x%x\n", merp->moduleOffset);
~~ ^~~~~~~~~~~~~~~~~~
%zx
/s/mono/mono/utils/mono-merp.c:231:59: warning: format specifies type 'unsigned int' but the argument has type 'guint64' (aka 'unsigned long long')
[-Wformat]
g_string_append_printf (output, "StackChecksum: 0x%x\n", merp->hashes.offset_free_hash);
~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%llx
/s/mono/mono/utils/mono-merp.c:232:55: warning: format specifies type 'unsigned int' but the argument has type 'guint64' (aka 'unsigned long long')
[-Wformat]
g_string_append_printf (output, "StackHash: 0x%x\n", merp->hashes.offset_rich_hash);
~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%llx
The first one isn't really a truncation but fix the warning.
Or use guint32 for module offsets instead of size_t.
* [interp] Remove some useless code
* [interp] Remove useless variable
When unwinding, we get the last interp frame that was executing from the LMF marker.
* [interp] Rethrow from the actual ip
Before we would rethrow from ip - 1 which could be part of another clause, screwing up EH.
* [interp] Enable all bcl disabled tests
* [tests] Include corlib suite on fullaotinterp
Disable more appdomain tests on fullaotinterp
* [interp] Bump again trampoline number for fullaotinterp
It wasn't enough for corlib and System.Core suites
Sync `X509Certificate2` implementation with CoreFX, similar to how we did for `X509Certificate` in "Blue" (#9650).
* Introducing `X509Certificate2ImplUnix` as new common base class for `X509CertificateImplApple`, `X509CertificateImplBtls` and `X509Certificate2ImplMono`. This uses the internal `CertificateData` class from CoreFX instead of the old "fallback" implementation from "Mono.Security".
* `MonoBtlsProvider`, `X509CertificateImplBtls`: the "fallback" option has been removed since we now always provide this functionality via the managed `CertificateData`.
* `X509CertificateImplMono`: This has been largely stripped down to use the new `X509CertificateImplUnix`.
```
abcremoval.c: In function 'process_block':
abcremoval.c:1061:6: warning: variable 'inst_index' set but not used [-Wunused-but-set-variable]
int inst_index;
^
driver.c: In function 'mini_regression_step':
driver.c:514:12: warning: 'func' may be used uninitialized in this function [-Wmaybe-uninitialized]
result = func ();
^
aot-compiler.c: In function 'emit_method_info':
aot-compiler.c:6388:10: warning: variable 'method_index' set but not used [-Wunused-but-set-variable]
guint32 method_index;
^
mini-codegen.c: In function 'mono_print_ins_index_strbuf':
mini-codegen.c:727:3: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'gpointer' [-Wformat=]
g_string_append_printf (sbuf, " %s", ins->inst_p1);
^
CC libmini_la-mini-exceptions.lo
mini-exceptions.c: In function 'summarize_frame':
mini-exceptions.c:1556:25: warning: unused variable 'ud' [-Wunused-variable]
MonoSummarizeUserData *ud = (MonoSummarizeUserData *) data;
```
Probably from:
https://jenkins.mono-project.com/job/build-package-dpkg-mono-pullrequest/label=ubuntu-1404-amd64/326/console
As of https://github.com/mono/mono/pull/11342 the regression tests (builtin-types.cs) call into System.Native incidentally as part of Interop.Sys type initialization. The --regression command line option was causing the --config part of the mono invocation to be ignored, resulting in a buried 'System.DllNotFoundException: System.Native' during the test run,
* [sdks] Reduce android provisioning to minimum
It's not in use by XA anymore, so we only care about what we require
* [sdks] Rework targets generation
* [jit] Refactor the constrained call handling code into a separate function. NFC.
* [jit] Move the low level call related code to calls.c. NFC.
* [jit] Use mini_emit_get_rgctx_klass () in a few more places.
* [jit] Add calls.c to common_sources.
* Fix some c++-isms.
* Fix the windows build.
Refactor tests to use system-assigned ports whenever possible, so that we
avoid the potential race condition in NetworkHelpers.FindFreePort.
This should make it much less probable to run into spurious "Address already
in use" exceptions.
In some cases I kept the call to NetworkHelpers.FindFreePort:
* When the test is not binding/listening on a port, but instead trying to
connect to an inexistent port (for tests that verifies error handling /
exceptions). In this case there is still a race condition (if a test tries
to verify that a connection fails, it may unexpectedly succeed instead).
* Sometimes the test doesn't actually use the port (the test is verifying
something very different, for instance a ArgumentNullExceptions, which are
thrown before the port is used).
* Some API doesn't allow for requesting a system assigned port:
* HttpListener: in this case I elected to re-try a few times in case of
"Address already in use" exceptions.
* The 'UdpClient (string, port)' constructor (other constructors work
fine): these turned out a bit complicated to work around (or would
modify the test more than would be reasonable), so for these we still
have to hope for the best.
Hopefully fixes https://github.com/xamarin/maccore/issues/604.
This is a no-op on gcc ppc for AIX, Linux, and FreeBSD, and should
not be used until gcc implements this. (It *does* on ARM, RISC-V,
Alpha, and MIPS, however - but not PowerPC or x86, based on a skim
of gcc source.)
Should fix#11527.
While working on PR #11829 I stress-tested the tests by running multiple test
runs in parallel, and it turned out that the X509StoreTest is not parallel-safe.
This fixes the X509StoreTest test to parallel-safe.
- Adds the ability for the packager to search in additional folders when resolving assemblies.
- Ignore missing symbols when resolving assemblies, which can happen for facade assemblies.
[interp] Fix interp inline
<!--
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
-->
This reverts commit e15b8c53ff.
It broke other builds.
Revert "[bench] Revert hardcoding of microbenchmarks to run-jenkins (#11787)"
This reverts commit 7a81ac67a2.
* [interp] Check for exception if we always catch it in coop case
* [interp] Enable more fullaotinterp tests
billions and billions
* [interp] Reorganize tests for fullaotinterp
* [interp] Don't include internal frames in stack trace
For handled exceptions. On unhandled exceptions we leave them for debugging purposes.
Fixes exception18.cs
When doing AOT build of builtin-types.exe using a debug compiled LLVM build the
following assert occurs:
Assertion failed: C1->getType() == C2->getType() &&
"Operand types in binary constant expression should match",
file C:\github\mono\external\llvm\lib\IR\Constants.cpp, line 1717.
This happens due to an optimization in cfold.c that removes the widening
done to a const variable in C:\github\mono\mono\mini\mini-native-types.c@224
and when that variable is later used in 64-bit LLVM lowering of OP_LNEG, OP_LNOT
they mismatch the static const 64-bit int used as operands triggering the assert.
Fix is to make sure the operand used when lowering these opcodes are converted
to matching operands.
Incorrect calculation of start of nullable buffer caused stack corruption.
Currently this was only identified on Windows x64 due to use of alternative
ABI register storage types. Fix resolves crash in test_0_dyncall_nullable.
* [runtime] Add a mono_runtime_get_caller_from_stack_mark () function, use it in a few places. NFC.
* [bcl] Add a stackMark argument to AppDomain.Load () calls.
[mini] use AOT trampolines in interp mixed mode
Fixes this on mscorlib/mixed mode on Xamarin.iOS:
```
[FAIL] NonExceptional.Serialization_Deserialization : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] NonExceptional.Serialize_Deserialize_FixedDateRule : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] NonExceptional.Serialize_Deserialize_FloatingDateRule : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] SerializationTests.Serialization_Deserialization : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] TimeZoneTest.CurrentTimeZone_SerializationRoundtrip : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
```
* [corlib] Refactor Type:GetName () to reduce differences with refsources and make it easier to add support for
stack marks later.
Move the icall to RuntimeTypeHandle. Pass a unused stack mark and a unused reflectionOnly parameter.
* Bump API snapshot submodule
[interp] Add inlining of small methods
Avoid call overhead by inlining small methods. We replace stinarg opcodes with storing of the arguments in locals allocated in the parent frame (for each argument).
TODO
- support for methods with locals
- maybe add inline costs to prevent over inlining
On microbenchmark inlining can improve up to 3.5x (less than the 5x that I observed with jit).
Contributes to #11531
Yes, I do know of a possible refactor, but why not get this working? This will enable `System.Net.Sockets.Socket` to depend IPv4/IPv6 are working, and thus, fix a LOT of issues on CI; a bunch of test suites have one or two things that depend on loopback, which is currently busted unless you nop out Socket's protocol check.
Also made a note that the Mac version of the backend is actually likelier to work under other OSes. Structures are kinda ugly, but they work; it took a whole morning and night beating them into submission.
Untested under PASE, though I've marked notes for self to what's different. (My guess: it works, but not as well as it should - but good enough so that Socket starts working again.)
And hey, the Mac backend can't do this!
```
csharp> NetworkInterface.GetAllNetworkInterfaces().Select(x => $"The MTU of {x.Name} is {x.GetIPProperties().GetIPv4Properties().Mtu}");
{ "The MTU of en0 is 1500", "The MTU of lo0 is 16896" }
```
We weren't checking whether the runtime returned a zero exit code which
means if the compilation failed we still reported success.
Now the exit code is propagated all the way up and we report an error
both to make and to the xml result file.
Since iltests.exe contains a test with expected invalid IL this would
now cause a failure. The easiest fix is to just move that test from
mono/mini to mono/tests since all other tests are fine.
Fixes https://github.com/mono/mono/issues/11091
Try to make all entry points into the loader look more uniform by taking a request
struct instead of a big pile of arguments. Where it makes sense, make the
structs subtypes of each other so that more general arguments are shared.
- Pass assembly load arguments in a struct
- Pass assembly open arguments in a struct
- Push MonoAssemblyOpenRequest creation to some callers
- Drop is_private argument to try_load_from
It's been dead code for ten years since c9e8bac0c3
- Get rid of mono_assembly_open_a_lot
- Drop dead static function
- Replace mono_assembly_load_full_nosearch by mono_assembly_request_byname_nosearch
- replace mono_assembly_load_full_internal by mono_assembly_request_byname
- Make mono_assembly_request_byname the internal API
pass a no_postload_search flag in MonoAssemblyByNameRequest, usually FALSE.
Pass TRUE in the one caller of the old mono_assembly_request_byname_nosearch.
- Pass the requesting assembly via MonoAssemblyByNameRequest
- Prepare loader Requests with an initialization function
prevent endless recursion in ListView.ToString()
do not access the Items[] in ListView.ToString() in VirtualMode
as this might cause an endless recursion if ToString() is called
from within the RetrieveVirtualItem event handler
Fixes#11049
* [runtime] Initialize MethodBody objects by calling a ctor instead of accessing the object directly. This allows the MethodBody type to be removed by the linker.
* [bcl] Preserve CustomAttributeData and related types using PreserveDependency attributes on the GetCustomAttributesDataInternal () icall.
* Fix a test.
* Fix C++ build failures.
* Bump API snapshot submodule
* [wasm] Add the declaring types assembly name to the mangled name for instances during dedup. Fixes failures when two assemblies have a generic type with the same name.
* [runtime] Rename MONO_WRAPPER_UNKNOWN to MONO_WRAPPER_OTHER.
* [aot] Make the aot name mangling a little denser.
* [wasm] Don't emulate lojg shifts/multiplications.
* [runtime] Fix warnings.
* [aot] Small cleanups to the dedup code:
* Fix the dedup logging in llvmonly mode.
* Split mono_compile_assembly () into 2 functions, the second one doing the emission.
* Split the setting of cfg->skip from emit_code ().
* Skip more code and some logging for the other assemblies in the dedup-include case.
* [jit] Do the conversion to JIT intrinsics somewhat earlier.
This is needed to avoid emitting the code for passing the mrgctx etc. for
generic intrinsics like RuntimeHelpers.IsReferenceOrContainsReferences ().
* [aot] Implement sharing of gsharedvt wrappers passing/receiving
valuetype arguments based on their layout.
This is done by replacing valuetypes with instances of the
newly added Mono.ValueTuple generic structures inside the
wrappers. For example, for the type:
struct FooStruct {
int i; object o;
}
and the gsharedvt out wrapper:
gsharedvt_out (ref FooStruct v);
This will be replaced by:
gsharedvt_out (ref ValueTuple<int, object> v);
The two structures have the same layout so as far as the JIT is
concerned, they are identical.
* [aot] Share native int/native uint with int32/uint32 in gsharedvt wrappers on 32 bit platforms.
* [bcl] Make the Mono.ValueType structs internal.
Can either have a multi-dimensional array type or an array with a lower
bound, not both. (eg `System.Int32[,,]` vs `System.Int32[*]`, but not `System.Int32[*,]`)
Fixes https://github.com/mono/mono/issues/11684
* Revert "[wasm][binding] Allow the cleanup of transparent/bridged marshalled objects causing leaks. (#11660)"
This reverts commit 75741eb68d.
* Revert "[wasm] Add the declaring types assembly name to the mangled name for instances during dedup (#11724)"
This reverts commit 63fb96c61a.
* Revert "[runtime] Skip sentry upload when tool fails to build (#11726)"
This reverts commit cb690285fb.
* Revert "[sdks] Add mac-{mac32,mac64} and ios-tools64 targets (#10964)"
This reverts commit 6f1537ef58.
- Example: When a delegate is marshalled to JS it is allocated so that it is not GC'd. Since we do not know when JS is finished with the delegate we need a way, for right now, to tell the Runtime to de-allocate the object and remove the transparent/bridged instance from JS as well. The side-effect of not doing this is that any local that is captured (used) by a lambda became heap memory and were allocated as fields on the object. Since the delegate is never a candidate for GC the local that was captured was never released either.
- Fix an error with Windows Edge and Windows IE that threw an exception `Object doesn't support this action` on certain host objects. This only affected Windows Edge and IE when using the JavaScript delete operator to clean up an object after being disposed.
- Cleanup marshalled Tasks after completion. The marshalled tasks and their continuation objects were never un-allocated thus not allowing them to be GC'd.
## Problem
Even after #10942, menus and toolstrips still look awful with a dark theme:

## Previous attempt
#10942 was a first stab in the dark at what was going on here, before I managed to get mono to compile for testing. I was hopeful that it would address this, but the problem was different.
## Another red herring
Later I thought the problem might be that `SystemColors.ButtonFace.IsSystemColor` was `false`. It looked like this might have caused the runtime to interpret `ButtonFace`'s special 168 value as an RGB code instead of a system color marker.
This fix had no effect (see below for true cause), but I'll include it anyway; the lower bound of the upper system colors block needs to decrease from 170 to 168 to allow `ButtonFace` and `ButtonHighlight` to be considered system colors:
https://github.com/mono/mono/blob/44db64c620c2c957a49b3f5a69cb09c19c1c8c1a/mcs/class/System.Drawing/System.Drawing/KnownColor.cs#L200-L203
## Actual cause
The toolstrip color comes from `ProfessionalColorTable.ToolStripGradientBegin` and `ProfessionalColorTable.ToolStripGradientEnd`. The latter color is hard coded to a light shade, but the former defaults to `SystemColors.ButtonFace`.
These are the colors that are loaded from the GTK system theme:
https://github.com/mono/mono/blob/b104565ccfde477fc7b6308f2d3e4efff0af5848/mcs/class/System.Windows.Forms/System.Windows.Forms/X11DesktopColors.cs#L111-L116
Note that `ButtonFace` is not among them. This means that it uses a compile time default, and is not a good choice for the background of a control. `ToolStrip` is using it anyway, but other controls use `SystemColors.Control` instead.
## Changes
There are two obvious ways to fix this:
1. Use `SystemColors.Control` instead of `SystemColors.ButtonFace` in `ProfessionalColorTable`
2. Load `SystemColors.ButtonFace` from the system theme
This pull request does both. In addition, it also sets the other end of the toolstrip gradients to `SystemColors.ControlLight` instead of a hard coded value. The choice of `ControlLight` was made because in those cases where alternate hard coded values were available for both sides of the gradient, the "other" side was consistently lighter. Now it looks better:

* [threading] Add `pulse` transition and begin_pulse_resume_and_request_suspension operation.
A `pulse` atomically resumes a preemptively suspended GC Safe thread and
requests that it suspend again.
If the thread reaches a GC Safe -> GC Unsafe transition, it will self-suspend.
If it doesn't, another iteration of the 'mop up' STW phase will async suspend
it again.
* [threading] Use pulse_resume_and_request_suspension in STW
With non-hybrid suspend, a pulse is just a resume.
With hybrid suspend, a `pulse` is a combination of a resume of a preemptively
suspended GC Unsafe thread and a request that it suspend again - as if we
atomically resumed the thread and then applied the initial phase of two-phase
suspend again. If the now-running thread comes to a GC Safe -> GC Unsafe
transition it will suspend. If not, we will preemptively suspend it again
during the mop-up phase.
The important thing is that we don't want the thread to transition to GC Unsafe
again: if it does so, it may try to take a lock that some other
async-suspended thread is holding, and it will never reach a safepoint ---
exactly the situation that two-phase suspend is supposed to solve.
* [threads] Add mono_threads_is_multiphase_stw_enabled
Flip the logic in mono_thread_info_begin_pulse_resume_and_request_suspension
The previous code read all the .dll and .exe files even when there actually wasn't any mono_crash.*.json file to process.
In the happy case of no crash file this cuts the time from 60s to 5s.
We can also use more efficient patterns in Directory.GetFiles() instead of getting _all_ files and filtering in-memory.
Lastly we also ignore printing a message when a debug symbols file wasn't found for an assembly, this is an expected case for a lot of our assemblies.
Using InMemory Cecil reading shaves another 20s off.
PASE is the Unix subsystem of IBM i, and is binary compatible with AIX. Since IBM i is not a Unix, there are some subtle differences between both environments.
There is an issue with the way PASE on IBM i 7.2 behaves differently than AIX with regards to the POWER_n_ANDUP defines for CPU compatibility. When trying to build on i as opposed to AIX, the following errors appear which break the build:
```
make[5]: Entering directory '/home/YVANJ/mono-on-i/mono/mono/utils'
CC libmonoutils_la-mono-hwcap-ppc.lo
mono-hwcap-ppc.c: In function 'mono_hwcap_arch_init':
mono-hwcap-ppc.c:67:6: error: implicit declaration of function '__power_4_andup' [-Werror=implicit-function-declaration] if (__power_4_andup())
^~~~~~~~~~~~~~~
mono-hwcap-ppc.c:67:2: warning: nested extern declaration of '__power_4_andup' [-Wnested-externs]
if (__power_4_andup())
^~
mono-hwcap-ppc.c:69:6: error: implicit declaration of function '__power_5_andup' [-Werror=implicit-function-declaration] if (__power_5_andup())
^~~~~~~~~~~~~~~
mono-hwcap-ppc.c:69:2: warning: nested extern declaration of '__power_5_andup' [-Wnested-externs]
if (__power_5_andup())
```
This commit adds `#ifdef`s to handle this condition so the build works on IBM i 7.2 now. The resulting application code should not differ from the AIX output, however, this patch fixes the build failure.
test_lib_dir is only defined after the library.make include so we need
to move the logic further down.
Additionally we don't even need to build this assembly ourselves since
corefx already contains a prebuilt binary.
Currently, setting IsWrapped=false on a MessageContract leads to an error in serialization due to an empty element being present where the wrapper element would have been, instead of it being gone entirely.
The serialization then fails because the empty string is not valid localName (which of course is fine).
The helix binaries weren't getting included so the uploader tool failed to build.
While we don't need them for a tarball build it's easier to just include them.
[configure] Pass -stdlib=libc++ to clang on darwin to build C++ code
On iOS 6.0 (`-miphoneos-version-min=6.0`), this is needed to get modern C++11
headers like `<type_traits>`. It does not seem to harm anything to
over-approximate and pass it to clang always when building on Darwin.
This pull request fixes starting a process with an empty environment variable collection in `ProcessStartInfo`. As per the issue it fixes a regression that it used to work but currently an empty environment variable collection works like it was never touched.
I also made a minor fix to remove the `StringBuilder` because a simple `string.Concat` does the job without the `StringBuilder` allocation and overhead.
I've included unit tests. Please let me know if you'd like any changes.
Fixes#8766
* [metadata] Compute interface offsets of ginst by inflating the GTD instead of doing it from the grounds up. Fixes#10837
Say you have;
```
interface Bar<T> { T Bla(); }
class Foo<A,B>: IBar<A>, IBar<B> {
int IBar<int>.Bla)() { ... }
}
```
The GTD of Foo will have the following interface offsets table:
```
4: IBar<A>
5: IBar<B>
```
With the existing code, if you have Foo<int,int> the interface offsets table will look like this:
```
4: IBar<int>
```
The problem with that is it will produce a hole in the vtable and subclasses of Foo<int,int> will have not on slot 5.
That would be just wasteful, unless you have this:
```
class Sub: Foo<int,int>, IBar<int> {
int IBar<int>.Bla)() { ... }
}
```
IOW, a subclass that overrides the interface implementation in Foo. The problem is that it's not always reliable to which iface offset
calls to `IBar<int>` will go through and thus it's possible to have calls made against instances of `Sub` to execute the code from its base
class.
The solution is to inflate the interface offsets table from the gtd as that will preserve the number of entries and will cause the
rest of the vtable layout code to fill the duplicated slots correctly.
* Add regression test for #10837.
* [sre] Replace assert with proper error handling.
* [metadata] Don't mono_class_init ifaces, just have offsets setup.
* [metadata] Make setup_interface_offsets not depend on mono_class_init and fix lazy iid computation.
All that interface offset setup needs are iid as the output in interfaces_packed is sorted by it. Remove
the need to use mono_class_init by properly extracting and making iid setup lazy.
Beyond that, make mono_get_unique_iid not return 0 as a valid iid.
Otherwise we don't have a proper sentinel value when lazily computing iid.
* [metadata] Keep interfaces in the same relative order when computing offsets
qsort() is not guaranteed to be a stable sort (one that keeps elements with the
same key in the same order). For example, the msvc qsort isn't stable.
Add an insertion_order field to ClassAndOffset to keep interfaces with the same
interface_id in the same relative order.
This is all relevant because in setup_interface_offsets we could see the same
interface multiple times (for example, with generics) at different offsets.
* [sdks] Compile support/{zlib-helper,nl}.c so XA doesn't have to cherry-pick it.
* [sdks] Fix ios and android compilation and use of tests
The tests are already built as part of the archive, so there is no need to recompile them. We just need to pick them from the right folder.
[interp] Small fixes
<!--
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
-->
Some jobs pre-clone repositories into acceptance-tests/external, those
would be removed. We don't need to do that, all we want is to have
clean submodule repos so just cd into the repos and clean them.
Right now we create a separate FileSystemWatcher for each file in
CacheDependency. On systems where inotify handles are limited this
leads to problems. As a workaround we can share the FSW which watches
the same directory. Since this wasn't extensively tested, hide it behind
and environment variable.
We enable this in the Helix environment only for now.
The test-bundle target copies all assets needed for test execution
to a specified directory. We upload this directory to Helix and use it
to run our mainline tests.
build. LLVM build follows similar pattern as BTLS build and will be build
as part of regular Visual Studio build Mono runtime if LLVM has been enabled
through the autogen.sh, --enable-llvm or –with-llvm argument. It is also
supports msbuild properties MONO_ENABLE_LLVM, MONO_EXTERNAL_LLVM_CONFIG,
if Visual Studio Mono runtime has been built without using autogen.sh.
When just using –enable-llvm, LLVM build will try to build internal LLVM
branch under external/llvm or if override has been set in props file
(using MONO_INTERNAL_LLVM_SOURCE_DIR), an alternative LLVM source
directory path. If –with-llvm has been used pointing to an llvm-config.exe,
no internal LLVM will be build, but the external LLVM build will be used.
Needed LLVM executables (opt.exe, llc.exe) will be installed into regular
Visual Studio Mono runtime build output directory.
The internal Mono LLVM 6.0 release will build as part of changes to this
commit, but it has not yet been fixed to work as expected during runtime.
That work will be done in different commit. The Mono LLVM 3.6 branch will
however work as expected for Windows x64 and can be setup and used using
–with-llvm argument or build as part of Visual Studio build Mono runtime
by enabling msbuild properties, MONO_ENABLE_LLVM and
MONO_INTERNAL_LLVM_SOURCE_DIR.
* Clean up leaks in the WasmHttpMessageHandler.
- Most of the leaks present themselves during a Cancel of a streaming request.
* Make WasmHttpMessageHandler the default handler for WebAssembly
- Required libraries WebAssembly.Net.Http.dll and WebAssembly.Bindings.dll.
* Clean up spacing
So this is possible now:
```console
$ REGRESSION_FILTER_METHOD=test_0_return ./mono/mini/mono-sgen --single-method=inline ./mono/mini/basic.exe
$ # or
$ REGRESSION_FILTER_METHOD=test_0_return ./mono/mini/mono-sgen --regression --interp ./mono/mini/basic.exe
```
* [corlib] Move Stack and Queue to mscorlib as we want to used them by
implementation code in mscorlib
* Bump API snapshot submodule
* [csproj] Update project files
.NET resource assemblies live in subdirectories named after the culture
of the resource. We need to package these assemblies too.
Follow up to https://github.com/mono/mono/pull/11575
[icalls] remove DISABLE_POLICY_EVIDENCE
Originally it was introduced with https://github.com/mono/mono/commit/db3591bb93dfe913c39ff73b95194effb88c880a . It seems like only the icall definitions were disabled for device runtimes (which aren't shipped there anyway), however the icalls themselves are _included_ in the device runtime. Note that the definitions are available to the AOT compiler.
Not sure what the rationale was behind this. Since the original change is very old, I think it just happened to be like that today. When running with the interpreter we need the icalls definitions at run-time available too (via the optional icall table that is linked in, so no additional cost for the fullAOT runtime due to this change).
Also remove `HANDLES_MAYBE` since it isn't needed anymore.
I think eventually we want to have `--enable-minimal=policy_evidence` that _also_ excludes the actual icalls, but this will need changes on the BCL side as well.
Don't override default LLVM's opt & llc args via llvmopts-add and llvmllc-add commands
Currently we can pass custom arguments to LLVM's `opt` and `llc` via:
```
mono --aot=llvm,llvmopts="...",llvmllc="..."
```
but those completely override the default arguments mono uses (some of them are required).
E.g. lets say I need to add `-foo` to both opt and llc, I should do:
```
mono --aot=llvm,llvmllc="**-foo** -march=x86-64 -mattr=sse4.1 -asm-verbose=false
-disable-gnu-eh-frame -enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_p_eh_frame
-disable-tail-calls -no-x86-call-frame-opt -relocation-model=pic
-filetype=obj,llvmopts="**-foo** -O2 -disable-tail-calls"
```
So this PR introduces new commands `llvmopts-add` and `llvmllc-add` to be able to simply do:
`mono --aot=llvm,llvmopts-add="-foo",llvmllc-add="-foo"`
PS: let me know if you don't like the `-add` suffix
/cc: @migueldeicaza
[mini] do not emit safepoints for methods without calls and loops
with this optimization, running Roslyn with mono on
`mono/tests/pinvoke11.cs` compiles:
* 2019 methods without safepoints, and
* 9443 methods with safepoints.
1) We try to include every source in .sources but that doesn't work
for generic _test.sources since we'd need to prepend the Test/ path.
2) MonoNativeConfig.cs.in was removed in 273f120c52
In preparation of the upcoming FSW support, `Mono.Native` now supports icall registration
and has a test added for this. This doesn't actually hook up FSW yet on iOS, but all the
preparations have been made as well as some tests for it.
* When using Bitcode (iOS only), we now link against the Mono runtime because we cannot have
any undefined symbols. Without Bitcode, the `mtouch` tool will do the linking for us.
* Add `-framework GSS` if needed.
* Removed `common/MonoNativeConfig.cs` - the test harness in `xamarin-macios/tests/xharness`
now takes care of that.
* Include a few more `System.Native` files on IOS.
* `mono_native_initialize()`: New native method to initialize the module and register any
necessary icalls. We register a new `Mono.MonoNativePlatform::IncrementInternalCounter`
icall for testing purposes.
* `mono_native_is_initialized()`: New native method for testing.
* `MonoNativePlatform.Initialize()`, `IsInitialized()`: Managed side of these.
* `MonoNativePlatform.IncrementInternalCounter()`: New icall, which is registered by
`mono_native_initialize()` - this is used by the test suite to make sure the icall
registration works.
* `NativePlatformTest`: Removed compat / unified check, see above. Add tests to call
the other managed APIs via reflection.
* Reduce TLS accesses.
Functions with HANDLE_FUNCTION_ENTER, only call mono_thread_info_current once,
instead of 1 + per-MONO_HANDL_NEW.
This can be extended in future in multiple potential ways.
1 Macro split from HANDLE_FUNCTION_ENTER.
This is easiest/no downside, i.e. for functions that do not HANDLE_FUNCTION_ENTER
but that do multiple MONO_HANDLE_NEW, call other macro
just to mono_thread_info_current () into local.
2 Pass TLS as seperate parameter. Probably not actually, see 4.
3 Store TLS in handles -- too large? Probably not actually, see next.
4 Store TLS in MonoError. i.e. MonoError is "call context", chained
up to "thread context".
* [threads] Add a no_safepoints bit to the thread state machine.
Only valid on RUNNING or ASYNC_SUSPEND_REQUESTED.
Currently no transitions set the bit, but the expectation is that it can only
be set/unset by the current thread on itself and only in RUNNING or
ASYNC_SUSPEND_REQUESTED.
Transitions to suspended states or to GC Safe states are forbidden if
wont_safept is set.
The intention is that this is used by a thread to mark a scope where it will
not safepoint (perhaps because it wants to manipulate a raw ptr to a managed
object).
The wont_safept bit only makes sense for cooperative suspension. For async, we
have the critical regions (which should be much more rarely needed).
* [threads] Add state machine funcs to query/set/uniset wont_safept
* [threads] add MONO_ENTER_NO_SAFEPOINTS/MONO_EXIT_NO_SAFEPOINTS macros
A region between MONO_ENTER_NO_SAFEPOINTS/MONO_EXIT_NO_SAFEPOINTS must not call
any function that could: reach a safepoint (and suspend the current thread),
allocate memory from the managed heap, or transition to GC Safe. In such a
region it is safe to dereference a pointer to managed memory and use read/write
from it (an alternative to avoid the no safepoints region is to pin the memory
with a global GC handle before manipulating it). GC Write barriers still need
to be used.
The current design doesn't allow nesting - the underlying thread state
transitions check that the flag isn't already set - keep the regions short and simple.
* [sgen] Don't initiate STW from a thread in a NO_SAFEPOINTS region
In other words, if you were in
MONO_ENTER_NO_SAFEPOINTS/MONO_EXIT_NO_SAFEPOINTS, you shouldn't be calling
anything that would start the GC
Move the allocation of got offsets for calls to a separate pass after all methods have been compiled. This means
that got offsets do not need to be allocated for calls which can be turned into direct calls.
Upcoming changes to monolinker will make additional optimizations when no instance ctors are marked.
To be safe, add preservations for the ctor's of types that are created in the runtime.
The change to preserve the .ctor() of`System.Runtime.Remoting.Messaging.AsyncResult` was made for more than out of caution. We have a simple delegate test that hung without this.
* Modification to allow deserialization of derrived types
* white space correction
* second attempt
* third attempt
* fourth
* whitespace
* maybe fix null ref exception
* missed same condition in other method
* fixing condition
* hopefully correcting the test failure in AOT
* Modification to allow deserialization of derrived types
white space correction
second attempt
third attempt
fourth
whitespace
maybe fix null ref exception
missed same condition in other method
fixing condition
hopefully correcting the test failure in AOT
formatting
missed some formatting
* adding a test for PR #11194
* fixing a few exceptions
* adding ref
We aot only the bcl (--aot=full,interp) while the tests code is interpreted.
<!--
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
-->
The change which made the handler return (rather than crashing the
runtime) did not consider this control flow path that causes the sigterm
signal handler to trigger the merp dumper if we return.
We now always return.
This was previously so that a random sigterm could be used to trigger a
dump. This isn't really used, and won't work right now anyways
(we don't register it until right before we dump). My fix is to remove
it, and to make the signal handler only work as part of the dumper
machinery.
[interp] Optimise method execution start
This can lead to 4% general speedup
<!--
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
-->
* [metadata] Fix strict prototype warning.
* [metadata] Remove unused variable.
* [metadata] Fix unused function warning.
* [metadata] Fix unused function warning for swap_with_size().
* [metadata] Fix "may be uninitialized" warnings.
* [metadata] Simplify missing ICustomMarshaler exception throwing case.
With current code there is no reason to have explicit jump label.
* [llvm] Rewrite the bitcode get_method () generated method to load the result from a table on wasm instead of a huge
switch statement.
This might be usable on other platforms in the future but having a table full of function pointers might lead to linking
problems.
* [llvm] Make direct calls to jit icalls without wrappers as well.
* [llvm] Export mono_llvm_clear_exception () with G_EXTERN_C, its called from llvm generated code.
* [wasm] Emit target layout/target triple into bitcode files.
* [aot] Allow the decoding of references to icall wrappers, so compiled code can reference them directly using a MONO_PATCH_INFO_METHOD.
* [llvm] Call icall wrappers directly from corlib code in llvmonly mode instead of going through the GOT.
* [llvm] Instance methods without got accesses don't need initialization in llvmonly mode.
- Adds support for HttpCompletionOption.ResponseHeadersRead by delaying reading of the response body into HttpContent
- Adds optional support for streaming responses in supported browsers
- Adds support for canceling in flight fetch requests
Create docs directory and update sample documentation.
- Add getting started docs directory
- Add section of obtaining the mono distribution.
resolves: https://github.com/mono/mono/issues/11346
Fix distribution package from wasm build to have the same structure as `packager.exe` is expecting.
resolves: https://github.com/mono/mono/issues/11344
* Integrate msvc build into make build system.
Add support to perform msvc build as part of regular make build. By default
msvc build will not automatically be done and needs to be enabled using
--with-msvc argument passed to ./autogen.sh. Doing msvc build as part of
regular make will automatically set MONO_EXECUTABLE to build msvc build
Mono runtime used in BCL and Test build as well as runtime used when running
tests.
* Add support to install msvc build mono runtime.
* Disable --with-msvc argument for none Windows builds.
* Fix VS2015 Build Tools build environment.
* Updated with review feedback switching to --enable-msvc.
On all platforms, mono_w32file_get_volume_information is only asked for its last parameter.
So replace mono_w32file_get_volume_information with mono_w32file_get_file_system_type that
only takes that parameter.
* [reflection] Implement RuntimeType.IsByRefLike
* [runtime] Add MonoClass:is_byreflike bit
Not set anywhere yet.
* [custom_attrs] Add mono_class_metadata_foreach_custom_attr
Unlike mono_custom_attrs_from_class_checked, this iterator function iterates
over the metadata without taking the loader lock or constructing class
instances, so it is safe to use during assembly loading or class initialization.
* [class-init] Set is_byreflike from attributes in mono_class_create_from_typedef
* [class-init] Set is_byreflike for generic instances
* [class-init] fail arrays of IsByRefLike elements
* [class-init] Check for ByRefLike struct fields
ByRefLike types only allowed as instance fields of structs that are
themselves ByRefLike.
* [runtime] Disallow instantiating generics with ByRefLike types
Instantiating a generic with a `ref struct` is not allowed.
* [runtime] Disallow instantiating generics with TypedReference
Reverts f457a01416. That was a hack to support
gsharedvt (gsharedvt worked by hijacking TypedReference to instantiate generic
vars since it's a lightly used class) that we no longer rely on (we now
instantiate generic vars by types that are synthesized for purpose).
* [mini] Don't box IsByRefLike types
* [runtime] Disallow boxing IsByRefLike types
* Bump corlib version
* [tests] Test that JIT won't box or instantiate IsByRefLike types
* [metadata] Don't inflate methods with invalid generic arguments
* [metadata] Make mono_is_valid_generic_argument non-static
Make it callable from other translation units.
* [class-init] Check for invalid generic instantiations
Disallow instantiations that contain void, TypedReference or IsByRefLike structs.
* [interp] Don't box IsByRefLike structs
We need xunit xml output for Helix.
The new mode which doesn't rely on build tree paths can be enabled by passing the special value "out-of-tree" as the build dir.
Respects the MONO_EXECUTABLE env variable and bases everything off of that.
Also unified run_test and run_test_sgen since we only have sgen nowadays and we only need one.
[marshal] Delete unused locals in emit_managed_wrapper_ilgen
`ex_local` and `e_local` were used prior to
https://github.com/mono/mono/commit/b20d5ce1e5d69512242dd42ae6ff1afc2483c16d
in order to store an exception raised by the managed method before passing it
to `ftnptr_eh_callback`. After that commit, we invoke the callback from the
stack unwinder, rather than from the method wrapper. As a result both of the
locals are now dead code.
Adding .NET 4.7.2 reference assemblies by updating submodule reference and adding new framework to mcs/tools/xbuild/frameworks and update Makefile to ship as described in #8657.
* [wasm] Handle the /dev/random problems by defining 'crypto' in runtime-tests.js instead of in the runtime/library_mono.js.
Print a stack trace if runtime_invoke () throws a JS exception.
* [wasm] Add a mono_wasm_setenv () function to the MONO module.
* [wasm] Mark some corlib tests as MultiThreaded/NotWasm.
Remove ICALL_EXPORT on all implementations.
Add ICALL_EXPORT on two declarations.
ICALL_EXPORT is on declarations, correctly,
and either isn't needed on implementations, or is incorrect.
On non-handles() implementations, it isn't needed but is ok.
On handles() implementations, it is incorrect.
Add ICALL_EXPORT on mono_object_hash_internal and mono_monitor_exit_internal.
Previously many declarations were missing, which was a reason we put it on implementations.
* [build] Enable netstandard facade in the "build" profile
It is necessary for a helix tool which I'm building in this profile
and it relies on NS2.0.
Adding full NS2.0 would require building System.Transactions.dll,
System.Runtime.Serialization.dll and System.Data.dll too but those
in turn rely on a whole bunch of other junk that I don't want to bring
into the build profile. Therefore I just added stubs for the types
directly into netstandard.dll.
* [csproj] Update project files
A couple of missing mono_class_from_mono_type_internal changes
Two instances were missed when mono_class_from_mono_type was changed to mono_class_from_mono_type_internal
* [System.Core]: Stub out `Interop.Sys.GetEUid` and `SetEUid`.
This is a temporary fix; the native side still needs to be ported from c++
and tested.
* [csproj] Update project files
* [aot] add unbox_arbitrary_trampoline for fullaot/interp mixed mode
On a virtual call where the receiver is a value type, the value type is
boxed at the caller's site, but must be unboxed before passed to the
callee. In FullAOT this happens with the help of the `unbox_trampoline`,
which is attached to the AOT'd assembly for every virtual method with a
value type as receiver, so we have a specific `unbox_trampoline` for
each such `MonoMethod`.
In mixed mode it can happen that an FullAOT'd method is calling such a
method which is _not_ FullAOT compiled, therefore it has to be executed
by the interpreter. We have to insert a trampoline between AOT caller
and interp callee (being a native-to-interp entry), that does the
unboxing and has a configurable target address at run-time. So that:
AOT caller -> unbox_arbitrary_trampoline -> native-to-interp entry
Note on testing: Tested on three different configurations
* amd64/macos with --full-aot-interp and `make -C mcs/class/corlib TESTNAME=MonoTests.System.ArrayTest.BinarySearch_ArgPassingOrder`. This will be covered soon by https://github.com/mono/mono/pull/11307.
* arm64/linux, same as above.
* arm64/iOS which has a different code path due to trampoline pages being used. Tested with `monotouch-tests` mixed mode (i.e. mscorlib.dll FullAOT, rest is interpreter).
armv7 isn't implemented yet.
* fix llvm aot compiler
* unbox_arbitrary_trampoline support for ARM
Comment out code to convert NSUrlError to WebExceptionStatus, because the
result isn't used. Looking through git history it seems the resulting
WebExceptionStatus was never used.
Fixes this warning:
HttpClientEx.cs(83,8): warning CS0219: The variable 'webExceptionStatus' is assigned but its value is never used
Mono doesn't use libxml2 and neither do the LLVM bits used by Mono when building
the AOT cross-compilers. Presence of `-lxml2` on the command line breaks 32-bit
builds on 64-bit Linux hosts:
libtool: link: cc -shared -fPIC -DPIC -Wl,--whole-archive ./.libs/libmini.a ./.libs/libmono-ee-interp.a ./.libs/libmono-dbg.a ../../mono/metadata/.libs/libmonoruntimesgen.a ../../mono/sgen/.libs/libmonosgen.a ../../mono/utils/.libs/libmonoutils.a ../../mono/eglib/.libs/libeglib.a -Wl,--no-whole-archive -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -L$HOME/xamarin-android/external/mono/sdks/out/llvm-llvm32/lib -lz -ltinfo -lxml2 -lstdc++ -lm -lrt -ldl -lpthread -O0 -ggdb3 -m32 -g -mno-tls-direct-seg-refs -Wl,-export-dynamic -Wl,-soname -Wl,libmonosgen-2.0.so.1 -o .libs/libmonosgen-2.0.so.1.0.0
mv -f .deps/libmini_la-aot-runtime-wasm.Tpo .deps/libmini_la-aot-runtime-wasm.Plo
/usr/bin/ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libxml2.so when searching for -lxml2
/usr/bin/ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libxml2.a when searching for -lxml2
/usr/bin/ld: cannot find -lxml2
collect2: error: ld returned 1 exit status
make[7]: *** [Makefile:1495: libmonosgen-2.0.la] Error 1
Installation of `libxml2-dev` (on Ubuntu/Debian + friends) for the x86
architecture (or x86_64 architecture on 32-bit host) would be possible but then
it would break the 64-bit build because the 64-bit version of the library would
be absent. It would be a problem if Mono+LLVM actually used xml2, but since it
doesn't we can just disable the feature completely.
Handles for icall parameters allocated in managed (but not native), can just be pointers to locals or parameters.
Currently the managed stack is scanned conservatively.
When this changes, there will be metadata provided to find these, so this approach will just keep working and should still be ideal (aside from nohandles or staying in managed).
For ObjIn, use pointer to parameter.
For ObjOut/ObjInOut, the parameter might, though it is far fetched, point to a native frame, which isn't convincing. Therefore for those, use a pointer to a managed volatile local, closer to how handles looked like.
For ValueTypeRef, make the parameter volatile so it is sure to survive.
We use volatile instead of merely address-taken because 1. a hypothetical aggressive whole program compiler/optimizer could see through address-taken (runtime and wrappers and corlib compiled together). 2. ValuetypeRef is even easier to optimize/break because the address-taken is dead.
FIXME: Tests that exercise every icall, coop and otherwise.
FIXME: Gcstress.
Collateral damage: The one rarely run assert that handles are not out of scope
cannot be so easily implemented so is removed. It might come back though, if we type tag the handles.
Furthermore, the handle stack setup/cleanup can be done in native instead of managed.
Furthermore, the error check can either be done in native instead of managed, or the fast path inlined in the JIT. Here we just move it to native (and inline the fast path in native).
Therefore coop icalls go from 3 + handle-count managed/native transitions, to just always one, *and* at least some of their handle allocation is exceedingly fast and free of TLS.
The typed handle wrappers change from returning a handle to returning a raw pointer.
Because previously the handle would be allocated in the handle frame setup by the JIT.
Now the JIT doesn't setup a handle frame.
There is a weakreference test that is seemingly very sensitive to stack layout.
For this reason at least, the MonoError is still allocated on the managed side.
Moving it to native broke the test.
This might also be preferable for the public interface.
Coop icalls retain some costs:
- The volatile might cost a little -- lack of enregistration.
- Native code allocating handles.
- Still TLS access.
- JIT icalls (vs. metadata-driven) still native-only handle allocation, and still fully manual conversion.
- Coop icalls that return an object always allocate a handle -- could be more efficient out or inout handle instead, though inout is currently very rare.
Some of this can be further mitigated.
Mainly, the metadata icall signatures could move the "local" handles to be out parameters, in order for managed to allocate them.
The JIT icalls could have richer signatures than just "ptr" and gain these wrappers, or previous (ref parameters, retyped as handles).
* [Reflection] Reverse custom modifiers order in ParameterInfo's GetRequiredCustomModifiers and GetOptionalCustomModifiers methods to follow NetFX/CoreFX behavior.
* Move reversing custom modifiers from managed code to native one.
* Small refactoring
* Disable System.Reflection.Emit related test on Full AOT mode.
* [threads] Make mono_add_internal_call external only
The runtime should use mono_add_internal_call_internal or
mono_add_internal_call_with_flags.
The thread suspend mechanism needs to know if an icall is added via the legacy
mono_add_internal_call API (which is not coop-aware, and so the registered
icalls must run in GC Safe mode), or if it is added by the runtime or by a
cooperative client (currently either the profiler or the System.Native PAL)
which knows to add GC transitions and safepoints and not to block indefinitely.
* [marshal] Factor out GCSafeTransitionBuilder
Make a local builder for creating the GC Safe transition calls for a method wraper.
* [sgen] Add coop GC transitions in mono_gc_toggleref_add
Also mark it external only. It's not used inside the runtime.
* [marshal] Emit GC Safe transitions around foreign icalls.
A foreign icall is added using mono_add_internal_call and that is not coop GC
aware. (The runtime uses mono_add_internal_call_with_flags or
mono_add_internal_call_internal)
Under hybrid suspend, foreign icalls will run in GC Safe mode and transition to
GC Unsafe only when the call back into the runtime or invoke managed code.
Fixes https://github.com/mono/mono/issues/11138
* [cxx] function type overloads for mono_add_internal_call_internal
and mono_add_internal_call_with_flags
* [runtime] Add new API call mono_dangerous_add_raw_internal_call
Under hybrid suspend, this adds an icall that is assumed to run in GC Unsafe
mode. As such it has additional requirements for correct operation: it must
not run loops without periodically polling the runtime, and it must not perform
blocking operations such as blocking I/O or taking locks without manually
switching to GC Safe mode.
In general this is achieved by renaming mono_foo to mono_foo_internal,
and mono_foo_bar calls mono_foo_bar_internal, possibly adding a GC mode change
to mono_foo_bar and removing from mono_foo_bar_internal.
We can also consider other names like m_foo_bar, mi_foo_bar, m.foo_bar, m->foo_bar, m::foo_bar, using mi = mono_internal; mi::foo, foo.bar(), etc.
* [test] Report dlsym failure with an assertion failure and give the symbol.
* Compilation of external-only.c/.o needs special care.
Because it is dead code, except for exports, the linker does not necessarily eagerly look into it (.o within .a), and export anything. This is the usual behavior of Windows linker. Unix linker I guess it varies between programs and shared libraries, but it was observed and broke a test, and a small case was constructed to demonstrate the behavior (i.e. where the dlsym assert is added), even though I assumed the opposite -- so must be program vs. sharedlibrary.
Therefore, we `#include external-only.c` in object.c.
Longer term we should probably use Windows .def files and their Unix equivalent, and/or be sure to list external-only.o directly on the link command line, instead of burying it in a static library.
.def files were used in the past and have other advantages/differences.
Other than guaranteeably reaching into .a/.lib files to find exports, they also export on NT/x86 as plain "mono_foo" instead of "_mono_foo", easing portability of LoadLibrary / GetProcAddress.
The loss of the x86 C name mangling *could* be viewed as a loss, of a tiny amount of safety.
They also make declspec(dllimport) and declspec(dllexport) both pointless, at least for C functions -- dllimport remains significant for data and C++ (no need to list mangled names in .def file), and to microoptimize one instruction out of some calls on non-LTCG builds.
* Add support for BTLS assembler build on Windows (cygwin/msvc).
Building BTLS with assembler support on Windows requires several
additional build tools (except cmake) for both cygwin/msvc builds.
On cygwin, perl and yasm will be needed and on msvc, ninja, perl
and yasm. On msvc builds BTLS doesn’t support Visual Studio generator
when building with assembler support, so this commit adds support for
ninja build system covering that scenario. This commit adds support for
auto detection of needed build tools and enable assembler builds if all
needed tools have been identified as available. Commit also fixes the
execution of msbuild on CI to just use the original PATH variable instead
of the cygwin PATH to make sure correct version of identified build tools
gets used (Windows version of git, ninja, perl and yasm). Both cygwin and
msvc build will use nasm compiler (through use of yasm) since generated
assembler won’t compile with mingw’s gcc version.
* Bump BTLS commit.
* Fix a couple of warnings on BTLS build.
* Fix failing certificate import test using BTLS on Windows.
Mono BTLS library assumes all passwords are ANSI encoded strings since
SafePasswordHandle gets passed directly through pinvokes. This is only true for
SafePasswordHandle implemented on Unix:es. On Windows, SafePasswordHandle stores
passwords as Unicode, most likely due to Windows Crypto API accepting Unicode
passwords. When using BTLS on Windows this difference submerged since passwords
passed to BTLS will be Unicode encoded failing the decryption of PCKS12 structure.
Keeping the pattern already in place, passing SafePasswordHandler all the way
through pinvokes, the needed conversion will be done just before calling into OpenSSL
library as part of mono's BTLS library adapter.
* [class] Ensure 'cast_class' is initialized for array type classes.
Fixes https://github.com/mono/mono/issues/9507
Background: Monoclass:cast_class is used internally to allow for some interfaces to be assignable to each other if they share a "storage class" instead of the class's element class. This is used to i.e. implement IList<ulong> being assignable from IList<long> (IList<ulong> has cast_class=long)
Consider a GenericClass<T> with a T[] field. On instantiation with e.g. GenericClass<ulong> , the ulong[] array class will be generated. As above, ulong[] has cast_class=long
When mono_class_init() is called on an array class, its element_class is also initialized.
If GenericClass<T>:Method() uses any type/subtype checking (e.g. if (field is double[]) ), those may attempt to use cast_class, which is not ensured as initialized.
* Fix typo
Co-Authored-By: alexischr <[email protected]>
* [jit] Add support for accessing method arguments in the profiler in llvmonly mode, by generating code to store them into the MonoProfilerCallContext.args array.
* [jit] Use ctx->args instead of ctx->context for accessing arguments in the profiler.
* Update after review comments.
* [jit] Switch --trace to use the profiler infrastructure.
* Fix a rebase problem.
* Fix c++ failures.
* [wasm] Fix the creation of runtime.js in ninja mode.
* [wasm] Exit with an error code if the emscripten runtime hits an abort.
* [wasm] Error out when mono_wasm_load_runtime () fails too.
* [wasm] Wrap some code in ENVIRONMENT_IS_SHELL.
* [aot] Emit runtime invoke wrappers for up to 40 parameters for bitcode, newly added tests depend on it.
* [aot] Fix a buffer overflow in mini_get_gsharedvt_out_sig_wrapper_signature ().
* [wasm] Remove some filesystem code which is no longer needed.
* [wasm] Disable coop gc on the cross compiler, it effects the generated code.
* [wasm] Use a different random device under wasm so we can override its behavior. This is needed because /dev/random no longer works in emscripten 1.38.13 in JS shells.
* [wasm] Bump emscripten to 1.38.13.
* [wasm] Print a stack in one more abort case.
* [wasm] Add putchar to EXPORTED_FUNCTIONS, llvm-lto seems to create references to it after linking.
Since we've started embedding test resources inside of the test assembly
we've sometimes seen a strange error on Jenkins during the test run:
```
Msg: Error initializing task StringTestTask: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Msg: Error initializing task StringTestTask: System.TypeLoadException: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
at (wrapper managed-to-native) System.RuntimeType.GetConstructors_native(System.RuntimeType,System.Reflection.BindingFlags)
...
```
However this was from an xbuild_12 run so how come it tried to load xbuild 14 stuff?
The reason is there's a race condition between when TestTasks.dll gets
built and when it's embedded inside of the test assembly.
If we're building the xbuild_12 and xbuild_14 profile at the same time
we could end up embedding the xbuild_14 version of TestTasks.dll instead
of the correct one since we're copying it to the same file name.
The fix is to remove the unnecessary copying logic since we can just tell
the compiler to embed the file under the correct name.
This is an alternative or precursor to https://github.com/mono/mono/pull/10212.
- Removes the dependency of some ABIs passing a pointer and a pointer in a struct the same.
- Therefore gives all platforms the same type safety.
- *If* we move to C++, allows us to have member functions in coop handles.
- Having the coop signatures available in C can provide benefits, though we should
probably generate them from reading metadata -- though they won't match w/o more changes,
since we mixup types in several places, like IntPtr vs. pointers.
JIT now traffics in old type-unsafe handles, and wrappers are generated with C preprocessor to trivially convert.
This way the JIT doesn't have to pass structs by value here, which was tried/failed.
The C preprocessor machinery can/should be extended for additional gains.
In particular driving managed/native coop icall transitions from 3+ per call to 1 (like https://github.com/mono/mono/pull/10212).
That will require better verification of the signatures in icall-def.h, either automated and en masses or gradually manually. Embedders will likely do something else, or at least have to independently invent similar.
Whereever a native function was exposed via multiple managed names, wrappers are reused.
* [wasm] Sample program in wasm sdks does not run.
- Add `mono-config.js` reference to html file.
resolves: https://github.com/mono/mono/issues/11239
* Fix `runtime.js` to reference `mono-config.js` variables.
* Fix packager.exe where it deletes the `runtime.js`.
- Replaced the File Delete and Copy with a Copy if new call.
- re-add the generation of a skeleton `runtime.js` file if one can not be found.
Flags to DrawText never reached MeasureText therefore strings with '&' were measured incorrect when drawn with flag TextFormatFlags.NoPrefix.
Fixes#6352
* [System] Don't throw NIE for ServicePoint.ConnectionLeaseTimeout and .ReceiveBufferSize
Instead return a no-op value. This is the same behavior as .NET Core.
Fixes https://github.com/dotnet/standard/issues/642
* Bump API snapshot submodule
* [tests] Renumber duplicate return codes
* [metadata] Fix crash related to custom attributes (#10737)
When a class doesn't contain the desired custom attribute we used
to return the last available attribute. This prevented
`cominterop_ccw_queryinterface()` to detect that the interface
isn't implemented and lead to a crash.
This change fixes#10737.
* [cominterop] Switch to GC Unsafe in IUnknown and IDispatch impls
These methods can be called directly from embedding APIs.
They require the additional files:
- mono/eglib/eglib-config.h: that's to build `libmonodroid`
- mcs/build/Consts.cs: that's to build `Mono.Posix` and `Mono.Data.Sqlite`
This should help get information on native crashes that happen in hard-to-debug environments.
To quote https://github.com/mono/mono/issues/10157 :
When a mono runtime is attached to a managed debugger and the debugged runtime is induced to cause a crash, the state of that crash is not communicated to the managed debugger. This, combined with the difficulty in having the debugged runtime both attached to the managed debugger and lldb, makes this type of crash difficult to interactively debug.
When the managed debugger is the only connection someone has with the runtime because it is embedded in a way that is resistant to unmanaged debugging (watchOS application on-device, for instance), this is an even more difficult problem.
By adding an SDB protocol event that sends a type of "runtime death" and a blob of opaque json (version dependent, no protocol guarantees), people can report these crashes without having to assist a mono runtime engineer in observing a crash on device.
In the case that spurious bugs in this manner are submitted, it will require less effort as well to spot stack frames that indicate misuse of mixed managed-unmanaged APIs (which offer the ability to drive a segfault or g_assert
* [arm64] Remove the limitation on the number of nullable arguments for dyncalls.
Fixes https://github.com/xamarin/xamarin-macios/issues/4984.
* [amd64] Remove the limitation on the number of nullable arguments for dyncalls.
* [jit] Add tests for dyncalls with lots of nullable arguments.
* Mark AddRefInternal as NOHANDLES(). Its signature was incorrect.
* Change ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal to NOHANDLES.
* Mark ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal NOHANDLES.
* ves_icall_System_Runtime_InteropServices_Marshal_BufferToBSTR to nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR to nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem nohandles().
* Fix the signature of ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMemSize.
* [coop] Remove most uses of out_of_memory_ex.
We only build it if we're explicitly building the monodroid profile and for the
monodroid_tools profile we only build the test assembly but not dtest-app.exe
## Problem
`MessageBox` displays as black-on-dark in a dark theme:

This can be difficult to read.
## Cause
The text is drawn with a hard coded color of `Color.Black`. This assumes that the background under the text will be light to contrast with black.
## Changes
Now the color is `SystemColors.ControlText` instead, to match the background of the popup.
In a normal theme this will still be black.
* [bcl] Run System.Windows.Forms.DataVisualization tests
* [bcl] Run Mono.Messaging.* tests
* [bcl] Use correct label for mdoc tests
* [runtime] Skip verifying an xunit-binaries assembly
* [corlib] Import System.IO.IOException/FileLoadException from CoreFX
* [corlib] Remove unused string
* [corlib] Remove another test assert for BadImageFormatException
Exception message no longer includes the file name
During the code refactoring this summer, support for native apple certificates
has been dropped on watchOS.
* add `apple-certificates.sources` and move all certificate-related code from
`appletls.sources`.
* move non-network related code from `MacProxy` into a new `AppleTypes`.
* add the `MONO_FEATURE_APPLE_X509` magic to `System/Makefile` where it was missing from.
* [sdks] Build BCL profiles without configure flags
* [sdks] Add BclTemplate to build BCL profiles
This is to avoid building all the profiles in a single `sdks/out/bcl` directory which will be shared between android, ios and wasm.
* [sdks] Simplify call to BclTemplate
* [mcs] Make directory dependency as order-only
We would otherwise always rebuild the target since the directory is updated whenever something is added to the directory. This is a common Makefile technique.
* [sdks] Build tests for BCL targets
* [runtime] Fix the signature of some native type tests.
* [runtime] Add stubs for the ves_icall_System_Net_NetworkInformation_MacOsIPInterfaceProperties_ParseRouteInfo_internal () icall, needed for AOT.
* [wasm] Print a native stack trace on asserts.
* [wasm] Avoid mmaps with zero length, it leads to an exception under emscripten.
* [bcl] Preserve CustomAttributeData:.ctor (), its called from the runtime.
* [wasm] Print out full test names in the test runner.
* [wasm] Preserve System.Threading.WasmRuntim.
* [wasm] Rename config.js to mono-config.js
* [wasm] Add targets to build aot versions of the test suites.
* [wasm] Exit with a nonzero exit code in case of a failure.
* [wasm] Disable crash reporting.
* [wasm] Use mono headers for public functions.
* [wasm] Enable building AOT tests on CI.
* [wasm] Run some AOT test suites on CI.
* [runtime] Make MonoBundledAssembly.size non-const.
* [wasm] Add a --setenv=VARIABLE=VALUE argument to runtime-tests.js which allows the setting of environment variables.
* [wasm] Update cross compiler executable name.
* [wasm] Remove unused aot-driver.js file, runtime-tests.js has the same functionality.
* [wasm] Run mini tests with AOT on CI.
* [wasm] Error out if the linker fails.
* [wasm] Fix building the AOT tests from another directory.
* [wasm] Use a matching Mono.Cecil.dll for the linker.
* [wasm] Fix running aot tests on CI.
* Revert "[sdks] Switch the invocation of the offsets too to 64 bit on osx. (#10903)"
This reverts commit 2989a83f23.
This seems to cause failures on linux+webassembly.
The VS4M team is making a tool that makes a symbolication lookup table. This enables symbolication without access to the relevant binary.
For unmanaged, it's much harder to precompute things because we were presenting the instruction address. From the address, any lookup needs to find the function enclosing this interior pointer.
To make it easier, this reports the address of the native method as well as the offset. A lookup table can simply key on the function start address with this now.
ie:
```
{
"native_address" : "0x1003a6340",
"native_offset" : "0x00046",
"native_module" : "mono"
}
```
```
$ nm mini/mono-sgen | grep '1003a6340'
00000001003a6340 t _mono_runtime_run_main_checked
```
```
$ nm mini/mono-sgen | grep ' t ' | sort -n
00000001000a4e90 t _alloc_ireg
00000001000a4eb0 t _decompose_long_opcode
00000001000aae90 t _mono_decompose_long_opts
00000001000aaea0 t _mono_decompose_vtype_opts
00000001000ae130 t _m_class_get_byval_arg
00000001000ae150 t _alloc_dreg
............
```
Note:
- This memory isn't accessed until we're crashing
- On any modern machine, unused static memory is lazily allocated. When
we access it, the fault will trigger the MMU to map memory for us.
- This is guaranteed to be reentrant and safe. mmap (the alternative) is
surely fairly stable on many systems, but this is not guaranteed. The
documentation pages for mmap specifically claim it as not safe in these async
contexts.
`Mono.Native` is the new name for both `System.Native` and `System.Security.Cryptography.Apple`.
It is built as a stand-alone shared library and not bundled with the runtime because we
may need to build two different versions of it.
Starting with macOS 10.12+ and iOS 10+, Apple introduced a new Unified API for some of the
crypto primitives that we're using as part of System.Security.Cryptography.Apple.
On Desktop, we can check at runtime whether the OS version is recent enough and switch
implementation accordingly. We build a single `libmono_native` shared library.
However, on Mobile we cannot have any undefined symbols as this would break Bitcode.
During the mobile build, we are called with `CC` containing an explicit minium version flag,
which is either `-mmacosx-version-min=`, `-mios-simulator-version-min=` or `-miphoneos-version-min=`
depending on platform.
We build two versions of the shared library:
- `libmono_native_compat` is built with whichever minimum version is passed to us via `CC`.
- `libmono_native_unifed` is built with the minimum version set to macOS 10.12+ / iOS 10+.
For testing purposes, there is a function called `mono_native_get_platform_type ()`
(see mono/native/mono-native-platform.c), which returns a `MonoNativePlatformType` enum value.
There is also `Mono.MonoNativePlatform.GetPlatformType ()` (see mcs/class/corlib/Mono/MonoNativePlatform.cs).
This can be called by automated tests both to ensure that the library has been correctly installed and also
to verify that it's the correct version of it.
* `configure.ac`: add new configure checks for Mono.Native.
* `mono/native/`: new directory - this replaces the `System.Native` code that was previously in `mono/metadata`.
* `mcs/class/corlib/Mono`: New internal `MonoNativePlatformType` and `MonoNativePlatform` classes.
* `-s` removes all symbols.
* `-x` removes non-global symbols.
This is needed in order to get human readable output with `MONO_VERBOSE_METHOD=method`, so instead of:
```
Disassembly of section .text:
00000000 <.text>:
0: e92d4900 .word 0xe92d4900
4: e24dd05c .word 0xe24dd05c
8: e1a0b00d .word 0xe1a0b00d
c: e58b0030 .word 0xe58b0030
10: e58b1034 .word 0xe58b1034
[...]
```
It is this now:
```
Disassembly of section .text:
00000000 <.text>:
0: e92d4900 push {r8, fp, lr}
4: e24dd05c sub sp, sp, #92 ; 0x5c
8: e1a0b00d mov fp, sp
c: e58b0030 str r0, [fp, #48] ; 0x30
10: e58b1034 str r1, [fp, #52] ; 0x34
[...]
```
This is needed due to a newer toolchain on our ARM bots. Tested on armv7 and aarch64.
* [wasm] Fix the build.
* [wasm] Add --copy parameter to packager
- copy parameter
```
--copy=always|ifnewer Set the type of copy to perform
'always' overwrites the file if it exists.
'ifnew' copies or overwrites the file if modified or size is different.
```
- Fix wasm build target in do-runtime target.
* [wasm] Add support for Module.locateFile to runtime loading
See issue https://github.com/mono/mono/issues/11099 for more information.
resolves issue: https://github.com/mono/mono/issues/11099
* Fix spelling of option `ifnew` to `ifnewer`
* Build BTLS on Windows.
* Quote more cmake paths
Should fix issue on Windows build where cmake is installed in C:\Program Files
* Fix btls cygwin x86, x64 Windows build.
NOTE, cygwin btls build depends on cygwin installed cmake, update cygwin
install to include cmake before building.
* Disable BTLS as default for Windows builds.
* [interp] Avoid unnecessary allocations when pinvoke void functions
* [amd64] Refactor interp pinvoke context computation
* [amd64] Interp trampoline for interpreter entry
* [aot] Don't include interp_in_wrapper when we use entry trampoline
These wrappers take a lot of space in the image.
* [exceptions] continue program execution when mapping of stack overflow guard page fails
Related: https://github.com/mono/mono/issues/10415
* turn comment into warning
* fix mono_gc_register_altstack call when no guard page is mapped
I don't know what the specific code is or what changed, etc.
This addresses Mac/x86:
https://jenkins.mono-project.com/job/test-mono-pull-request-i386-osx/15364/parsed_console/log.html
```Unable to compile method 'int Tests:calli_sig_check_2 ()' due to: 'Invalid IL code in Tests:calli_sig_check_2 (): IL_000b: calli 0x11000044```
which then fails an assert and fails overall.
CI goes deep into bash w/o echoing commands but a repro is:
cd mono/mini
MONO_PATH=./../../mcs/class/lib/net_4_x lldb -- ./mono --aot iltests.exe
The code is meant to be invalid, and meant to raise an exception,
which is catchable/resumable (at least in the JIT case where
executing IL the first time, can raise an exception while caller is
running, vs. AOT where the codegen all happens offline -- leaving what?
A note made at AOT time that calling the code should raise an exception?).
It isn't meant to fail an assert in either case.
This change set represents a major set of changes to the crash reporting mechanism.
1) Coordination involving mandatory timeouts and signals have been changed greatly, to instead use semaphores and to end waiting as soon as possible.
2) Dumping of unmanaged symbols outside of mono has been made possible. Embedders that want to get information on frames outside of mono-sgen can register the library with an icall. This carefully preserves both privacy (opt-in) and resiliency (can't crash/lose more info when misused).
3) The dumper has moved from a workflow that kills the runtime after a long delay into one that can dump individual threads or the entire runtime in a prompt manner. The runtime doesn't die at the end of the dump, but allows threads to resume what they were doing and returns to the caller.
4) This has allowed for the addition of a number of tests that stress both parallel and concurrent dumping of threads. These run fairly quickly, and leave the runtime in a state to continue testing.
5) With this lightweight testing setup created, a long burn-in testing period was done. Places we were using locks or trying to malloc resulted in crashes or hangs. After making the needed changes, it managed to run the dumping tests in a loop for a whole weekend on a Linux x64 configuration without any problems.
This has resulted in a dumper with dramatically improved stability and performance.
* [runtime] Fix mismatched parenthesis on exc-s390x
* [runtime] Fix mismatched static function type declaration on s390x
* [runtime] Fixup b7c18caf0c for s390x
The makefile uses $(dir $<) which has `../` and so refers to `llvm/external/llvm` rather than `external/llvm` now that we're using llvm from a submodule in external/
[interp] Optimize static field access
Do most of the work on transform side and include the field address in the instruction stream. We need to run cctor at runtime to preserve expected order. This makes static field access 4 times faster.
<!--
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
-->
* [build] Unify bootstrap profiles
We can now rely on build only as we have reliable monolite and package
compilers
* Fixes genproj dependencies
* [csproj] Update project files
It is hacky to have to avoid includes in order to have conflicting/incorrect declarations.
And hacky to use extern "C" when the reason is to have incorrect prototypes.
It is arguably hacky to suppress the gcc warning -- granted, the functions are never called, and merely their addresses taken and put into void* -- arguably gcc's warning is too strict and should only trigger for calls or taking address into a non-void*.
Arguably the declarations should be moved around the tree.
Perhaps we should omit the prototypes from C++.
* [llvm] Fix the icall signature of a few llvm EH icalls.
* [wasm] Disable com/remoting in the linker.
* [wasm] Enable direct icalls.
* [wasm] Generate the configuration into a config.js file instead of rewriting the runtime.js file.
* [wasm] Enable icall symbol map in the cross compiler, compile the device runtime with -fexceptions.
* [wasm] Rename runtime-tests.g.js -> runtime-tests.js.
* [wasm] Add mono_wasm_assembly_get_entry_point () function to obtain the entry point of an assembly.
* [wasm] Add profiler support to the packager.
* [wasm] Add support for running a normal .net executable to the test runner.
Do most of the work on transform side and include the field address in the instruction stream. We need to run cctor at runtime to preserve expected order. This makes static field access 4 times faster.
* [wasm] Harden the debugger against invalid breakpoints.
This happens when you reload a page and the old BPs land in now invalid code regions.
* Add node support to library_mono.js
* [wasm] Correctly register pdb files.
* [sdks] Build Android SDKs archive in Debug configuration on master builds
* [sdks] Drop `product-` prefix from Android and iOS SDKs CI_TAGS parameters
* Mitigation for spawn FD closing taking forever with a big FD limit
On systems with a large file descriptor limit, Mono takes a very
long time to spawn a new process; with informal testing on the AIX
CI builder, (with a POWER7) it took ~30 minutes. This is obviously
very undesirable, but hand our is forced - libraries the user might
be calling could be creating non-CLOEXEC files we're unaware of. As
such, we started from the FD limit and worked our way down until we
hit stdio. Using APIs such as posix_spawn aren't desirable as we do
some fiddling with the child before we exec; and even then, closing
FDs with posix_spawn relies on non-standard file actions like
Solaris' addclosefrom not present on many systems. (All of this is
unnecessary on Windows, of course.)
This presents an alternative way (currently only implemented on AIX
but with notes how for other platforms) to try to close the child's
loose FDs before exec; by trying to get the highest number FD in
use, then work our way down. In the event we can't, we simply fall
back to the old logic.
See #6555 for a discussion and the initial problem being mitigated.
* Use an another strategy of closing only known to be open handles
...on FreeBSD and AIX.
Use the kinfo_getfiles library call on FreeBSD and only close what's
safe to close. On AIX, use the third and fourth arguments to getprocs
to check what's open. However, the array to get all the handles takes
1 MB, so allocate it on the heap; like what kinfo_getfiles does. We
don't need to free these as the child will exec or exit, which blows
it all away.
The previous strategy from previous commit is still used and on AIX,
enhanced.
* Add Linux strategy to fork FD close
Tested on WSL, shows benefits with big FD ulimit.
initialization, but rather code that is portable to C89 and C++98.
The alternative is also ok, just costs typically a pointer and a relocation per array element,
things most people wouldn't notice but was presumably the point here.
* [aot] Add clangxx option to --aot that removes the hardcoded clang++ in our aot compiler.
* [mini] Make --aot addictive.
* Update CI script for bitcode.
The makes the following classes optional to the runtime:
System.Reflection.CustomAttributeData
System.Text.StringBuilder
System.Math
System.Console
System.Diagnostics.StackTrace
Those are all types that can be clearly made optional. There are a lot of other types
we could, but there are deeper dependencies in places as threadpool or marshal.
* [runtime] Kill mono_defaults.console_class.
* [runtime] Kill mono_defaults.asyncresult_class. Doesn't help much as it's still needed by the TP.
* [runtime] Remove mono_defaults.stack_trace_class.
* [runtime] Remove dead field.
* [runtime] Remove mono_defaults.math_class
* [runtime] Cleanup handleref resolution to use the access macros.
* [runtime] Remove mono_defaults.stribuilder_class.
* [runtime] Remove System.Reflection.CustomAttributeData
* [corlib] Update linker description.
* [runtime] Fix compilation of the iOS SDK.
When passing FIXTURE or TESTNAME to "make run-test" we automatically
prepended `MonoTests.` to the value since all of our NUnit tests
start with that to save you from typing a few chars.
Now that we have xUnit tests as well this is confusing since it doesn't
happen there. Better to remove it for consistency.
Right now if anything goes wrong in the security stack you get a message like this:
```
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
```
This is confusing since SSPI is a Windows-only thing and is not used on Mono.
We inherited this error message string from referencesource.
Change the string to something more generic which also aligns us with CoreFX:
https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.Net.Security/src/Resources/Strings.resx#L210-L212
Before we only did this for PR builds but it turns out it's needed for
normal master/branch builds too.
In situations where there are two Mac builds at roughly the same time
the downstream Windows builds would otherwise both refer to the same/latest
commit since they just checkout the latest ref on the branch.
Now we reset the Windows build to the sha1 which is passed to it.
* Add support for strongly typed marshalling of C# enums.
JavaScript does not have the concept of Enums like TypeScript. Strings are used to represent enums. This PR allows a strongly type contract between C# values and the string representations used by a lot of the JavaScript API's.
Example:
DOM InputElement type -> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type#Form_<input>_types
The InputElement types are represented by strings. button, checkbox, color, date, datetime-local etc....
These string can be represented and marshalled back and forth by defining an enum as shown below with an `Export` data contract attribute.
```
public enum InputElementType
{
[Export(EnumValue = ConvertEnum.ToLower)]
Button,
[Export(EnumValue = ConvertEnum.ToLower)]
CheckBox,
[Export(EnumValue = ConvertEnum.ToLower)]
Color,
[Export(EnumValue = ConvertEnum.ToLower)]
Date,
[Export("datetime-local")]
DateTimeLocal,
}
```
The enum conversion allows controlling the marshalling:
- Default - Marshals the enum name as is
- ToLower - Marshals the enum name to lower case string
- ToUpper - Marshals the enum name to upper case string
- Numeric - Marshals the enum numeric values.
Marshalling from C# to JavaScript using the SDK Bindings should be made as easy and pain free as possible.
Marshalling the string values from JavaScript to C# will need a little help. The SDK Bindings Runtime provides a method to transport the string value to a strongly typed enum.
```
WebAssembly.Runtime.EnumFromExportContract(typeof(InputElementType), inputElementType);
```
* Add marshalling of C# Enums to method calls.
* Add tests to bindings-test harness for testing marshalling of C# enum values.
* Modify test for marshalling enum value without Export contract.
[interp] fixes for native types
please look at single commits.
------------------------
[interp] fix op_implicit/op_explicit conversions for native types
Conversion operators have been mostly broken in the interpreter, for example conversion from nint to float didn't work. While some conversions are easy to intrinsify (like nint -> I8), there are harder cases like nint -> decimal. The JIT actually falls back to the managed implementation, so let's do this in the interpreter as well.
However the managed implementation expects a pointer to the value type, i.e. the container type System.nfloat instead of float/double primitives. In such cases the value is going to be stored in a local and then the address of its storage is pushed on the stack before invoking the managed implementation of the conversion.
Added test cases for scenarios observed in Xamarin.iOS.
-----------------------
[interp] support ntype.CompareTo ()
-----------------------
[interp] support ntype.Equals ()
-----------------------
[interp] support nfloat.*Infinity
-----------------------
[interp] support ntype.ToString ()
-----------------------
The conversion issue creeped everywhere in Xamarin.iOS since it heavily relies on nint/nuint/nfloat. With this PR we are getting close to a green monotouch tests 😁
<img width="874" alt="screen shot 2018-09-21 at 23 24 36" src="https://user-images.githubusercontent.com/75403/45907566-b457eb80-bdf8-11e8-9cc7-b8cf311dd269.png">
needs backporting to 2018-06 and 2018-08
* bump external/binary-reference-assemblies
* use Mono.Android for netstandard
* use API_BIN_REFS
* move ifeq monodroid upper
* use Mono.Android in System.Drawing.Primitives instead of ns
* fix typo
* Add Mono.Android back to ns as API_BIN_REFS
* Bump API snapshot submodule
* [csproj] Update project files
We didn't include cmods when inflating var/mvar cuz we'd mono_metadata_type_dup' the inflated type
and not the (m)var MonoType.
The solution is to add a variant of mono_metadata_type_dup that takes the source of cmods to use.
Conversion operators have been mostly broken in the interpreter, for
example conversion from nint to float didn't work. While some
conversions are easy to intrinsify (like nint -> I8), there are harder
cases like nint -> decimal. The JIT actually falls back to the managed
implementation, so let's do this in the interpreter as well.
However the managed implementation expects a pointer to the value type,
i.e. the container type System.nfloat instead of float/double primitives.
In such cases the value is going to be stored in a local and then the
address of its storage is pushed on the stack before invoking the
managed implementation of the conversion.
Added test cases for scenarios observed in Xamarin.iOS.
xamarin-macios currently builds zlib-helper.o using mono's source code.
It would be preferrable to use a version built by mono, and since
zlib-helper.o is a byproduct of building libMonoPosixHelper, we need to build
libMonoPosixHelper (we already build it for simulator architectures), even
though we don't need/use libMonoPosixHelper itself.
So they are next to their NUnit counterparts.
Move xunit remote executor app to tests dir too and compile it when
compiling the test assembly instead of doing it before running the test.
We need to use an absolute path for the xunit remote executor and it
needs to be in Windows format on Windows since we pass it as an env var
to the xunit tests.
When building the SDKs on CI, the output is very scrambled. There are simultaneously outputs from making multiple runtimes, uncompressing some tar archives, cloning some repos, building various BCL profiles, etc. This makes it quite hard to easily understand what's going wrong when the build fails.
By using `--output-sync=recurse`, we make sure that even if many targets are executed in parallel, the output is still as if it was executed sequentially.
If another thread locked at least one of the other handles, and there is a
cooperative GC STW happening, this function will loop forever.
Add GC Safe transitions around the call to sleep to give this thread a chance
to suspend.
Fixes https://github.com/mono/mono/issues/10863
The `X509Certificate(byte[])` constructor should call `CertificateProvider.Import(byte[])`
to use the native apple implementation if possible.
Add temporary hack to `X509Certificate2(byte[])` to ensure that we always get an
`X509Certificate2Impl`.
* Fix problem with HttpClientHandler not returning the response status text if available when there is an http error.
resolves: https://github.com/mono/mono/issues/10842
* Extend C# sample to include:
- Calling JavaScript functions from C#
- Calling C# functions from JavaScript.
- Referencing JavaScript objects
- Getting and Setting JavaScrip object properties.
- Invoking JavaScript object functions.
- Setting up the default HttpClientHandler
- Instantiating a default WasmHttpMessageHandler.
- Setting up HttpClient calls
- Parsing and testing the correct results returned from the HtppClient.
- Obtaining a byte array and string array from response.
- Obtaining a reference to a global script function defined in the .html file and calling it.
- Working with DOM objects using the SDK's WebAssembly.Bindings.dll
resolves: https://github.com/mono/mono/issues/7548
* Update sample usage docs
* [cxx] Do not define C++ keywords: bool, inline, final, it can break things.
https://jenkins.mono-project.com/job/d/421/parsed_console/log.html
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(250): fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro. [d:\j\workspace\d\msvc\libmonoruntime.vcxproj]
* PR: Leave profiler defining C++ keywords (define bool char).
* PR: Restore libgc. (mainline removed the code in 2011).
* [sdks] Remove redundant --enable-cxx
* [sdks] Shorten `-m32`/`-m64` parameters detection for runtimes
* [sdks] Build BCL profiles without configure flags
* [sdks] Add BclTemplate to build BCL profiles
This is to avoid building all the profiles in a single `sdks/out/bcl` directory which will be shared between android, ios and wasm.
* [sdks] Create archive targets for pre-building on CI
* [sdks] Use archive-{android,ios,wasm} on CI
* [sdks] Run archive-llvm-llvm{,win}{32,64} on CI
thread-suspend-suspended and thread-suspend-selfsuspended tests has showed long
execution times on low core Windows machines running wow64. It looks like an OS
related issue where ResumeThread Win32 API takes a lot longer time to complete
when running a test scenario like thread-suspend-suspended and this additional
time adds up over many iterations pushing it over to timeout. NOTE, the same behavior
has been identified running on .NET framework, so it's not a mono specific issue and
only reproduce under wow64 on low core machines (probably when one core is busy
just leaving us with one core for most of the test).
Since the purpose of the test is to run GC when t1 is suspended, doing this more
deterministic will fix the ResumeThread issue under wow64 on low core count as
well as making the tests more deterministic, always having t1 in a suspended state
when running GC (that will test the suspend suspended scenario).
Full investigation can be found in, https://github.com/mono/mono/issues/10508.
On cooperative suspend, the wrapper frames capture the exception
in a MonoError, which then must be thrown. The problem with treating
it as a CIL THROW opcode is that every time you THROW, you completely
reset the stacktrace's collectin of saved frames.
The RETHROW opcode will force the JIT to rely on an in-flight exception,
that in our case has been taken our of the in-flight context.
By relying on the new MONO_RETHROW, we will take an explicit exception
and put it back in-flight without clearing the stored stacktrace.
mono/mini/mini-runtime.c so it can use the correct ifdefs
which should fix WebAssembly compilation and let it work on
Mac and Win32 also. This means we no longer need HOST_LINUX in configure.ac either.
Note that for Win32 we don't have the same sort of execution
of a debugger for this to help, but you can see it works
if you run in a debugger and break on mono_sigsegv_signal_handler_debug.
SUBDIRS= mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests
ifENABLE_MSVC
build_with_msvc= msvc
build_without_msvc=
else
build_with_msvc=
build_without_msvc= msvc
endif
SUBDIRS=$(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir)$(build_without_msvc)$(docs_dir) acceptance-tests
# Keep in sync with SUBDIRS
DIST_SUBDIRS= m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools msvc docs acceptance-tests
DIST_SUBDIRS=$(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests
all:update_submodules
SUBMODULE_ERROR='Could not recursively update all git submodules. You may experience compilation problems if some submodules are out of date'
# FIXME: URL should be http://xamjenkinsartifact.blob.core.windows.net/build-package-osx-llvm-$(NEEDED_LLVM_BRANCH)/llvm-osx64-$(NEEDED_LLVM_VERSION).tar.gz
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; \
Loaded 100 of 3850 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.