* [merp] Put thread into async context before running summarizer
[merp] Put thread into async context before running summarizer
Followup work for https://github.com/mono/mono/pull/17090
In order to get managed method info for unmanaged stacktraces, we call
`mini_jit_info_table_find_ext` which calls `decode_exception_debug_info` which may
allocate if it's not in async context.
Do the switch in `mono_threads_summarize_execute` so that non-supervising threads
all switch when they run the `sigterm_signal_handler`. `mono_threads_summarize`
already does it for the supervisor thread.
Fixes https://github.com/mono/mono/issues/17180
Backport of #17194.
/cc @lambdageek
* [merp] Don't call install_state_summarizer in EnableMicrosoftTelemetry
install_state_summarizer installs a SIGTERM handler. Unfortunately
sigterm_signal_handler assumes that it will only be called when a crash is
already in progress (it assumes it won't be the supervisor, and so it doesn't
setup the memory for capturing a crash report among other things).
* [merp] Register SIGTERM handler in dump_native_stacktrace
Previously it was installed by EnableMicrosoftTelemetry, which is too early.
Now we get here without a handler installed even when mono_merp_enabled returns true.
There is an issue with jumping into DST for some time zones when the incorrect date-time offset is returned for date-time in UTC (which comes from DateTime.Now). The fix is to just check if the incoming date-time is in UTC
Also I added set of tests for some time zones but they verify jumping into DST in general.
Fixes https://github.com/mono/mono/issues/16395
Backport of https://github.com/mono/mono/pull/16430
* [2019-06] Bump msbuild and sdk versions to 3.0.1xx latest
* Bump msbuild again to pull in the build updates
* pull in roslyn-binaries fix
* One more bump
* Fix the roslyn hash
* [msbuild] Bump to pick up a build fix from https://github.com/mono/msbuild/pull/138
* Pull in final update from msbuild of nuget and sdk
NuGet 5.3.0-rtm.6251
Sdk 3.0.100-rc2.19467.3
* Pick up packaging fix in https://github.com/mono/msbuild/pull/141
We sometimes saw the following build error in Mono SDKs builds on Jenkins:
```
[2019-09-16T01:03:30.709Z] CSC [xammac] nunit-lite-console.exe
[2019-09-16T01:03:30.709Z] error CS0009: Metadata file '/Users/builder/jenkins/workspace/archive-mono/2019-08/mac/release/mcs/class/lib/xammac/nunitlite.dll' could not be opened -- PE image doesn't contain managed metadata.
```
Taking a closer look we found out that nunit-lite was trying to be built twice for the same profile which caused a race where the file was corrupted.
The reason for this is that the corlib Makefile defines two test assemblies: the normal PROFILE_corlib_test.dll and BinarySerializationOverVersionsTest.dll and
integrating the BinarySerializationOverVersionsTest.dll via the `test-vts` target incorrectly overwrote the `test` target instead of using `test-local`.
Backport of #16894.
Callers of mono_reflection_create_custom_attr_data_args_noalloc were leaking some of the returned information. Accessed attributes are FixedBufferAttribute and UnmanagedFunctionPointerAttribute.
Add RenamedEvent* to FSW sources from CoreFX
Fixes#16486 - This was only partially fixed until now
* [csproj] Update project files
* Add test files which test these code paths on corefx
* Revert "[aot] partial revert of #14043 (#14135)"
This reverts commit 223e0bd78d.
* Revert "[aot] change method table generation so that it works for larger assemblies on ARM (#14043)"
This reverts commit 9ff3b0d65e.
* 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 https://github.com/mono/mono/issues/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 https://github.com/mono/mono/pull/16523.
* [w32socket] Translate some errno codes to WSA_ errors imprecisely.
These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.
Addresses part of https://github.com/mono/mono/issues/16024
* [w32error] Add WSA_INVALID_PARAMETER and WSA_INVALID_HANDLE
Backport of #16331.
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
* Bump msbuild to track mono-2019-06
.. to get changes from https://github.com/mono/msbuild/pull/130
which tracks dotnet `release/3.0.100-preview9`.
Also, bump Roslyn to 3.3.1-beta3-19421-04 .
* Bump the roslyn reference
Using the CoreCLR version of this line fixed the problem and my investigations
also revealed why.
The `SafePipeHandle` contains a reference to both the Socket as well as the
`SafeSocketHandle`, taking ownership of them. If there are no additional
references to either of them, so that both are collected in the same GC pass,
their finalizer may be invoked in any order.
If the Socket gets finalized first, it's `SafeSocketHandle` will have a `_mstate`
of 8 (two references) at the beginning of `DangerousReleaseInternal()` - which
will set it to 6 (one reference plus disposed flag).
Then when the `SafePipeHandle` gets collected, it will call `DangerousRelease ()`
on it's `SafeSocketHandle`. As mentioned above, it's `_mstate` will be 6.
Now we own the handle, so we'll decrease it's reference count by one and set the
`Closed` flag - the new `_mstate` should thus be 3.
However, using
new_state = (old_state & RefCount_Mask) - RefCount_One;
would set it to 1 - thus effectively clearing the `Disposed' flag. And since it's
reference count is now also zero, the next finalize pass will then throw.
The CoreCLR version of this class uses
new_state = old_state - RefCount_One;
which fixes this.
Backport of #16244.
The intention of calling `g_file_test (file, G_FILE_TEST_EXISTS)` where file is
the name of a shared library we want to open is to speed up probing for
non-existent libraries.
See https://github.com/mono/mono/pull/12074
The problem is that if file is just a simple "libdl.so" then `dlopen (file)`
doesn't just look for it in the current working directory, it will probe some
other paths too. (For example on desktop linux you'd also look in all the
directories in LD_LIBRARY_PATH). So the g_file_test() call is not a robust way
to avoid calling dlopen if the filename is relative.
But it actually broke more things: https://github.com/xamarin/xamarin-android/issues/3388
When probing for "libdl.so" on Android mono_lookup_pinvoke_call will first try
prepending some paths that it knows about and we end up calling
`dlopen ("/system/lib/libdl.so")` which will fail because Bionic has security
restrictions on what code can dlopen something from /system/lib with an
absolute path. Eventually mono_lookup_pinvoke_call will go back to trying the
bare "libdl.so" which hits `g_file_test` and returns NULL.
The new code only does the file test if we pass it an absolute path, which
gives Bionic's dlopen a chance to deal with relative paths however it needs to.
* Add missing `Dispose()` call on error in `MonoTlsStream.CreateStream()`.
* Remove the `finally` block to make it more easy to read.
Backport of #16233.
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.
This will allow the interpreter to use System.Reflection.Emit.
Note: There is a small size increase (about 50kb) for an application
built in release mode with the LLVM backend (even if the interpreter
is now used).
Backport of https://github.com/mono/mono/pull/16151
* Fixed RuntimeType.GetConstructorCandidates("") to return 0 elements.
https://github.com/mono/mono/issues/16010
The current behavior for GetConstructorCandidates when the name is null, "",
or "*" is to return the set of constructors for the type. For "", .NET Core and
.NET Framework return 0 elements. This PR adds a check for "" to match that
behavior.
* Removed unncessary changes
* Unnecessary spaces
* Made the if check a bit more readable
Prompted by mono/msbuild#123 :
This includes:
Update to upstream vs16.3 branch
SDK update to track dotnet release/3.0.100-preview8
Roslyn updated to 3.3.0-beta2-19381-14
* Work around remoting1.exe test issue with new Roslyn
* [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
Backport of #15935.
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.
[2019-06] [threads] Enter GC Unsafe before pumping HP queue in unregister_thread
If the thread info TLS key dtor runs `unregister_thread` from a foreign thread and we have work in the hazard pointer queue, we need to first switch to GC Unsafe mode because some of the free methods passed to `mono_thread_hazardous_try_free` need to be coop-aware.
Also, added checked mode assertions that `conc_table_free` and `jit_info_table_free` are called from GC Unsafe mode.
Fixes https://github.com/mono/mono/issues/15878
Backport of #15890.
/cc @lambdageek
[2019-06][sre] Make creation of dynamic method synchronized
Before, reflection_create_dynamic_method could end up being called by two threads simultaneously. At the end of the method the ilgen field of the MonoReflectionDynamicMethod object is cleared, to enable its collection since it is no longer needed. The problem with this is that it can confuse the other thread compiling the dynamic method, making it see that there is no body.
We could either bother making this clearing work with multiple threads (and I'm not 100% convinced that the rest of the code is thread safe), disable the clearing of ilgen (which would make us use more memory) or go with the simple approach of locking on this DynamicMethod so only one thread is compiling it at one time.
Backport of https://github.com/mono/mono/pull/15803
The C# version doesn't work on 64bit. It would require to update its dependencies, but Zoltan already added a Python version for WebAssembly which works fine.
Some notes:
* changed the semantics of `--xcode-path` in order to match the output of `xcode-select -p`
* switched to python3/pip3
* removed hack for arm64_32, it works properly now because the Python version uses stock `clang`
* removed some leftover usages of `XCODE32_DIR`.
Manually verified by comparing output with the C# version.
This will unblock the iOS team when building on Catalina/Xcode11, as they can't consume SDK archives there. See xamarin/xamarin-macios#6603 (comment)
Contributes to #9621
master (#15744)
In some jobs we use throttle() logic which would mean only one job can execute on master, blocking other jobs in the meantime.
We don't really care which node executes this so let Jenkins pick one.
(cherry picked from commit 7784f20a26)
Before the code
(a, b) = (b, a);
was the equivalent of
a = b;
b = a;
now, it evaluates it to so something like
tmp1 = a;
tmp2 = b;
a = tmp2;
b = tmp1;
Signed-off-by: Bijan Tabatabai <[email protected]>
This is to handle the following example. The issue is that in Check() we have
a constrained call where the called method is IAdder`1<!!U>::PlusPlus() which
is a default interface method, and we need to determine at runtime whether to
box the this argument.
```
using System;
public interface IAdder<T> {
int Add (int x);
int PlusPlus () {
return Add (1);
}
}
interface IGen3<T> { }
struct Adder<T> : IAdder<IGen3<T>> {
int _field;
public int Add (int x) {
_field = x + _field;
return _field;
}
}
public class P {
public static int Check<T, U>(T t) where T : IAdder<U> {
return t.PlusPlus () + t.PlusPlus ();
}
public static void Main () {
var x = new Adder<object> ();
int y = Check<Adder<object>, IGen3<object>> (x);
Console.WriteLine ("expect 2, got {0}", y);
}
}
```
1) Copied changes from corefx for System.Data (also mono/corefx#310)
2) New Tracing api is left empty (because the current API is empty too)
3) New AES types throw PNSE
Bump netstandard.dll AssemblyVersion to 2.1 (fixes#13412)
Backport of #15696.
This reverts commit d732cef5fc.
The github commit status setter step requires a node context so we now just use on on master instead.
(cherry picked from commit 0509ceccb6)
For some reason when using a separate file and loading the function
from there Jenkins still requires us to have a node() context when
calling the function which is not what we want.
In preparation for notarizing our .pkg with Apple we need to bump the timeout
since it can take up to an hour for Apple's server to return a result.
(cherry picked from commit 7480830b36)
* The example that reproduces the bug does this: var thread = vm.GetThreads()[0]; greetingValue = program.InvokeMethod(thread, greeting, new Value[0]) as StringMirror;
But sometimes the Thread[0] was the MainThread of the program and it works, and other times was the GC Finalizer, but when it tries to run something on GC Finalizer thread, the thread is not suspended and throws an exception.
In the fix I removed the Finalizer thread of the list that is returned when CMD_VM_ALL_THREADS is called.
Fix#13311
* The example that reproduces the bug does this: var thread = vm.GetThreads()[0]; greetingValue = program.InvokeMethod(thread, greeting, new Value[0]) as StringMirror;
But sometimes the Thread[0] was the MainThread of the program and it works, and other times was the GC Finalizer, but when it tries to run something on GC Finalizer thread, the thread is not suspended and throws an exception.
In the fix I removed the Finalizer thread if ti's not executing a managed code of the list that is returned when CMD_VM_ALL_THREADS is called.
Fix#13311
* Changing what was suggested by Aleksey.
* Removing unused attribute.
Fixes#15366 and #15306.
- Fixes NULL termination of `StringBuilder` to UTF-16 marshalling. Additionally an extra NULL is added as defense-in-depth protection for incorrect handling in native calls. This extra NULL adds protection when trying to marshal the NULL-terminated string back and the native function doesn't null-terminate at the size of the buffer.
- Fixes marshalling back from UTF-16/UTF-8 buffers into chunked `StringBuilder`.
- Fixes missing `mono_marshal_free` call causing a memory leak when marshalling `StringBuilder` to UTF-16 and back.
- Skips marshalling back to `StringBuilder` when the parameter doesn't have `[Out]` attribute.
Unit tests are still TBD. Not sure where to put them and how to structure them. Any help would be appreciated. /cc @vargaz @EgorBo
Backport of #15392.
* Fixes https://github.com/mono/mono/issues/14839
The local timezone name was not known and defaulted to "Local".
This change adds an sdk function that returns the local name.
Backport of #15667.
* Permit DYLD mangling, so p/invokes work from non-system paths
* Add com.apple.security.cs.disable-library-validation
This is required for the .dylibs used in p/invokes to work.
* Use adhoc signing
(cherry picked from commit 202dca075b)
Android NDK r20 contains a header file (`ioctl.h`) with this code:
int ioctl(int __fd, int __request, ...);
#if !defined(BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD)
/* enable_if(1) just exists to break overloading ties. */
int ioctl(int __fd, unsigned __request, ...) __overloadable __enable_if(1, "") __RENAME(ioctl);
#endif
The `_RENAME` macro is defined as `__asm__(x)` and serves the purpose of
replacing an existing symbol with the new one, decorated with the keyword.
Unfortunately, Mono's `offsets-tool` doesn't parse the header properly as
`CppSharp` doesn't understand `__asm__`:
Processing triple: armv7-none-linux-androideabi
Error parsing '/Users/rodo/git/xa2/external/mono/mono/metadata/metadata-cross-helpers.c'
/Users/rodo/android-toolchain/ndk/sysroot/usr/include/bits/ioctl.h(60,5): error: conflicting types for 'ioctl'
Error parsing '/Users/rodo/git/xa2/external/mono/mono/mini/mini-cross-helpers.c'
/Users/rodo/android-toolchain/ndk/sysroot/usr/include/bits/ioctl.h(60,5): error: conflicting types for 'ioctl'
make: *** [/Users/rodo/git/xa2/external/mono/sdks/builds/android-cross-arm-release/armv7-linux-android.h] Error 1
The workaround, implemented in this commit, is to define the
`BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD` macro thus removing the "conflicting"
declaration from the picture, which changes nothing from the offset tool's point
of view and lets us process the headers in NDK r20 properly.
* Add TypeForwards for:
* System.IO.Enumeration.FileSystemName
* System.Security.Cryptography.CryptographicOperations
Since these were removed in NS 2.1
* Bump API snapshot submodule
[System]: Allow reading fully buffered `HttpWebResponse` body after close.
If we have already read the entire response body, then we should allow the
user to read it even after the request has been aborted.
* `WebConnectionStream.Read ()`: Move `Operation.ThrowIfClosedOrDisposed ()`
call down after argument checks and call a new protected abstract method
called `TryReadFromBufferedContent ()` prior to it.
* `WebResponseStream.TryReadFromBufferedContent ()`: Implement it here.
If the entire response body has been buffered, then `bufferedEntireContent`
is true and `innerStream is BufferedReadStream` and we can call the new
`BufferedReadStream.TryReadFromBuffer ()`.
* `WebResponseStream.ReadAllAsync ()`: Set `bufferedEntireContent = true`
after reading the entire response body.
* `BufferedReadStream.TryReadFromBuffer ()`: New internal method.
Fixes#10645.
Backport of #15220.
* [sdks] Use @loader_path for mono and libmonosgen
This way we are able to dynamically load libmonosgen and also use host
mono binary.
The library dependencies look like this after the change:
```
otool -L /Users/rodo/git/mono/sdks/out/android-host-Darwin-release/bin/mono
/Users/rodo/git/mono/sdks/out/android-host-Darwin-release/bin/mono:
@loader_path/libmonosgen-2.0.dylib (compatibility version 2.0.0, current version 2.0.0)
...
otool -L /Users/rodo/git/mono/sdks/out/android-host-Darwin-release/lib/libmonosgen-2.0.dylib
/Users/rodo/git/mono/sdks/out/android-host-Darwin-release/lib/libmonosgen-2.0.dylib:
@loader_path/libmonosgen-2.0.dylib (compatibility version 2.0.0, current version 2.0.0)
...
```
This test was checking a broken Mono-specific behavior, which has been
removed after we switched to the new corefx-based handler. It also does
not make much sense to use a `Transfer-Encoding` header with a GET request.
In managed, these functions are used as `static external IntPtr`. This means that previously on arm64 the top bits of the return value were garbage. A comparison with 64-bit -1 like in LinuxNetworkChange.EnsureSocket would never be true, which was causing us to hit other assertions in the runtime.
Co-authored-by: Aleksey Kliger <[email protected]>
* 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
CADMessages are passed directly between appdomains. When using contained data, we need to make sure we don't create any cross domain references.
When domains are unloaded, all threads executing code in that appdomain are aborted and the entire heap is traversed and objects in that appdomain are cleared. If any objects in other domains are directly referencing objects in the unloaded domain, they will reference junk. If any, cross domain refs should only be allowed when the referenced object is in the root domain which is never unloaded.
We have seen sporadic failures in thread pool tests on CI related to
test case:
System.Threading.ThreadPools.Tests.ThreadPoolTests.QueueRegisterPositiveAndFlowTest [FAIL]
Assert.Equal() Failure
Expected: 0
Actual: 1
Stack Trace:
at System.Threading.ThreadPools.Tests.ThreadPoolTests.QueueRegisterPositiveAndFlowTest () [0x00143] in D:\j\workspace\z3\label\w64\external\corefx\src\System.Threading.ThreadPool\tests\ThreadPoolTests.cs:337
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in D:\j\workspace\z3\label\w64\mcs\class\corlib\System.Reflection\RuntimeMethodInfo.cs:395
Finally managed to track down the issue to a race when using the same final
event in sequential calls to RegisterWaitForSingleObject. The event could, depending on
timing, get signaled multiple times for the same RegisterWaitHandle instance
causing a thread waiting for completion on another RegisterWaitHandle using same event
to be signaled before that callback was completed. That will cause the race seen in the
failing test above.
Fix make sure we only signal the final event one time per RegisterWaitHandle
instance.
* [jit] Throw exception if casting fails for special array interface
After the standard interface check (mini_emit_iface_cast), for special interfaces we need to do additional checks. We were skipping these checks if the object was not an array, without throwing a cast exception. This code path is reached for configurations where remoting is disabled.
Fixes https://github.com/mono/mono/issues/14729
* [tests] Add test for interface casting case
This test would have failed on fullaot lane for example.
We recently switched the AOT compiler for iOS armv7 from 32bit host to 64bit host. At the same time we _also_ switched from LLVM 3.6 to the newer LLVM 6.0 fork we support.
In a Xamarin.iOS Release build for iOS armv7 exception handling would crash. Specifically the problem was that the exception object wasn't properly injected into the handler block. The way it works is, that the exception handler machinery passes the pointer to the exception object via `r0`.
With the newer LLVM the generated code of the exception handling block
looks like this:
```
LBB1_15: @ %EH_CLAUSE0_BB3
Ltmp8:
ldr r0, [sp, #24]
str r0, [sp, #4]
ldr r0, [sp, #28]
ldr r0, [sp, #12]
ldr r0, [r0]
cmp r0, #0
beq LBB1_17
```
thus overwriting `r0`, so that the pointer to the exception object is lost. With the older LLVM 3.6 the generated code looks like this:
```
LBB1_8: @ %EH_CLAUSE0_BB3
Ltmp8:
str r0, [sp, #4]
ldr r0, [r6]
cmp r0, #0
beq LBB1_10
```
correctly storing the exception object into a stack slot for later usage.
After some time I figured out that there are _different_ exception handling models. Depending on the model, the exception pointer is passed in `r0` or not:
https://github.com/mono/llvm/blob/2bd2f1db1803f7b36687e5abf912c69baa848305/lib/Target/ARM/ARMISelLowering.cpp#L14416-L14428
`SjLj` stands for "SetJump / LongJump" and means that exception handling is implemented with this. On iOS this is the default model that is used. We want `dwarf` instead, so we tell this `llc` now and the generated code handles it correctly.
So why was it working before? In our older LLVM 3.6 fork we hardcoded it:
https://github.com/mono/llvm/blob/f80899cb3eb75f7f5640b4519e83bd96991bffb8/lib/Target/ARM/ARMISelLowering.cpp#L756-L762
The `-exception-model=` option is also not available in LLVM 3.6.
Contributes to https://github.com/mono/mono/issues/15058 and https://github.com/mono/mono/issues/9621
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.
Git mailing list bug report: https://public-inbox.org/git/[email protected]/
* 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.
Alias analysis attempts to remove indirection when using OP_LDADDR (which fetches the address of a variable). For example :
ldaddr r1 <- r0
load_mem r2 <- r1
is equivalent to
mov r2 <- r0
The remembered r1 alias needs to be forgotten in case r1 is changed. We were handling this for direct assignment with MOV, but not for the more subtle case where an alias to r1 would be passed to a call, which could lead to changing r1.
https://github.com/mono/mono/issues/14872
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.
* Implementing reabstraction of default interface methods.
* Fixing side effect on unit tests. Tested with another example and changed the implementation: using System; public interface I1 { void M1(); /*void M2(){ System.Console.WriteLine("I1.M2"); }*/ }
public interface I2 : I1
{
abstract void I1.M1();
/* void M2(){
System.Console.WriteLine("I2.M2");
}*/
}
class Test1 : I2
{
static void Main()
{
I1 i1 = new Test1();
i1.M1();
//i1.M2();
}
void I1.M1()
{
System.Console.WriteLine("Test1.M1");
}
}
* Fixing side effect on unit tests.
* Fixing side effect on unit tests.
* Implementing unit test. Fixing side effect.
* Fix unit test.
* Fixing reabstraction.il coreclr test.
* Changing comments.
* Changing things pointed by Aleksey.
* Changing things pointed by Aleksey. Implementing generics test.
* Changing things pointed by Aleksey.
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
```
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).
* [llvm] Enable disabling inlining on llvm
* [llvm] Fix disabling direct calls on llvm
* [llvm] Rename mono_inited even when doing self_init (generated init functions refer to it)
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).
* 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`).
* [AppDomain] Cross-appdomain wrapper throws NIE for methods with ref struct arguments
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).
* [corlib] Add back Serializable attribute on some reflection classes
Tests that use https://www.nuget.org/packages/NUnit.ApplicationDomain/
need to serialize MethodInfo (and hence MethodBase).
* [corlib] Add test for transparent proxies for classes with methods that take ref struct args
Regression test for https://github.com/mono/mono/issues/14809
* Bump API snapshot submodule
Contributes to https://github.com/mono/mono/issues/9621
Fixes https://github.com/mono/mono/issues/14841
Note that it breaks iOS 32bit on devices. The Apple Watch _might_ still works (only tested on `2019-02`). It unblocks some build related issues on the Xamarin.iOS `2019-06` integration, and we have to do it anyway. I'll come back to it to fix device related issues.
It is important to provide this, otherwise the `opt` command will make modifications of every GC safepoint load. For the SmartHotel360 Android app, this can result in `opt` taking 19 minutes and 20 seconds to finish the optimization of the Mono.Android.dll AOT modules.
### IR Example:
Before Opt:
```
> %GC_SAFE_POINT_FLAG_7 = load i64*, i64** getelementptr inbounds ([166068 x i64*], [166068 x i64*]* @mono_aot_Mono_Android_llvm_got, i32 0, i32 7), !invariant.load !139597
> %4 = load volatile i64, i64* %GC_SAFE_POINT_FLAG_7
> %5 = icmp eq i64 %4, 0
> br i1 %5, label %CONT_BB2, label %POLL_BB1
```
After Opt:
```
< %GC_SAFE_POINT_FLAG_7 = load i64*, i64** getelementptr inbounds ([166068 x i64*], [166068 x i64*]* @mono_aot_Mono_Android_llvm_got, i64 0, i64 7), align 8, !invariant.load !139597
< %3 = load volatile i64, i64* %GC_SAFE_POINT_FLAG_7, align 4
< %4 = icmp eq i64 %3, 0
< br i1 %4, label %BB2, label %POLL_BB1
```
This has a huge impact on build time, giving InstCombine a huge slowdown. This change removes the need for opt to rewrite all of these basic blocks.
Backport of #14714.
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].
Due to few recent updates to dotnet/standard (NETStandard 2.1) we had 40 apicompat issues.
Mostly copy-pasted from dotnet/corefx.
Didn't implement Cryptography stuff yet.
Checked all profiles.
Implements #14609
Backport of #14679.
[2019-06] [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
* Add a warning to the gensources Makefile so it's not confusing when it fails to compile in non-build profiles
* Add CI test script that verifies the compiler server functions
* Fix bugs
* Add compiler server tag to jenkins script
* Add +x
* Rename compiler server test tag
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.
* [corlib]: Move sre dependency into their own method in `System.RuntimeType`.
Move call to `TypeBuilderInstantiation.MakeGenericType` into a new
`System.RuntimeType.MakeTypeBuilderInstantiation` method to allow the
linker to remove it.
Requires linker PR https://github.com/mono/linker/pull/590.
* Bump linker.
* Bump cecil as well.
* Fix the build.
* Really fix the build.
* Bump API snapshot submodule
* [csproj] Update project files
when the allocation does not fit, i.e. when it is >= MONO_MEMPOOL_PREFER_INDIVIDUAL_ALLOCATION_SIZE.
Or at least make the code clearer and smaller.
"fixes" https://github.com/mono/mono/issues/14669.
It's a private helper that's always directly awaited. No need to allocate a task each time it's called and data is synchronously available.
Signed-off-by: dotnet-bot <[email protected]>
* Just use `new T[]` when elements are not pointer-free
* reduce zeroing out when not necessary.
* use AllocateUninitializedArray in ArrayPool
Signed-off-by: dotnet-bot <[email protected]>
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.
It makes sense to pass --interp (--interp=-inline) while having another execution mode previously set up (like --full-aot-interp).
Cleanup code a little bit by killing mono_enable_interp which doesn't do much.
* Fix enabling the compiler server using autogen, and force it off if mcs is being used
* autogen updates
* Formatting fixes
* Fix vbcs getting turned on if unspecified even if mcs was selected
* Dynamically evaluate ENABLE_COMPILER_SERVER each time we compile instead of evaluating it once at some arbitrary point during makefile evaluation
* More detailed comment based on testing
* Handle the /shared option in genproj so it doesn't fail
* Raise basic profile check requirement to 6.2 and hopefully assert that named pipes work
* Default compiler server to off for now.
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.
[interp] Share more wrappers for different interp in signatures
The passed arguments are already considered to be gpointer in interp_entry and the real value is obtained using stackval_from_data. For types that are passed by value in a register the wrappers will be identical and we can share them.
This commit reduces the size used by interp_in wrappers (in fullaot-interp) by half. These wrappers still take a fair amount of size, which comes mainly from signatures including value types, which aren't shared.
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
Reduce stack size used by interpreter frame on Windows MSVC.
Interpreter frame was 1248 bytes in size under Windows MSVC. This was almost double the size of other platforms ~670 bytes. After investigating different constructs in interpreter switch statement in interp_exec_method_full, it turns out that local declared errors couldn't be reused over different case statements and added ~100 bytes each. Switching local declared errors to shared one, reduce the stack size down to ~670 bytes under Windows MSVC.
ifdef __cplusplus
define g_static_assert(x) static_assert (x, "")
else
define g_static_assert(x) g_assert (x)
endif
It is, granted, C++11, not C++98, and some C variations.
I myself am bumping for ODBC fixes. This includes a change to SslProtocols to include the Tls13 entry required by the CoreFX changes. (It doesn't wire it up to anything, including BTLS.)
* Fix CollectionTest.UnusableSyncLockTest test
The test checked whether the SyncRoot is of type object, but the corefx implementation switched to returning `this`.
* Bump API snapshot submodule
SemaphoreSlim.Dispose nulls out its lock object, and that's then used as an indication in other methods whether they should throw ObjectDisposedException. But nulling out an object used for synchronization in other methods is a bad practice, and while SemaphoreSlim.Dispose is not thread-safe to be used concurrently with other usage of the instance, it's still confusing when such usage leads to NullReferenceExceptions due to trying to lock on a null lock object. This change just changes the lock to be readonly, always set, and then whether the instance has been disposed is just a value set on that object (such that it's no larger than it used to be).
Signed-off-by: dotnet-bot <[email protected]>
* [System.Net.NetworkInformation] Fork FreeBSD from MacOs
They are related, but not identical. In particular, MacOS AF_INET6 is wrong
on FreeBSD and breaks IPv6 networking on FreeBSD. Establish an inheritence
relationship with overrides for now; it's possible more differences will be
needed in the future.
This change is released under the MIT license.
* [csproj] Update project files
* [jit] Also allow System.Runtime.CompilerServices.Unsafe intrinsics from the System.Runtime.CompilerServices assembly, not just corlib.
* [jit] Fix Unsafe.RefIsAddressLessThan()/RefIsAddressGreaterThan().
Relevant issue: #14376
There are potentially more functions this can apply to, but this covers the ones listed in the issue and an extra one I found in the process.
Functions were either broken off into an external-only and internal version, or such a pair already existed and the internal version was moved from the source file to a separate `-internals` header, similarly to in 3c74df5667.
This gets slightly complicated with `mono_domain_set` and `mono_domain_set_internal`, both of which are currently public (thanks to 4beada2892) and have different signatures. Additionally, the latter does not actually include the gc-unsafe transition despite being public.
I've opted to introduce `mono_domain_set_fast` as the 'internal' version of `mono_domain_set`, to add the proper gc-unsafe transition to `mono_domain_set_internal`, and then to migrate internal usage to `mono_domain_set_internal_with_options`. As part of that I've marked `mono_domain_set_internal` as external only, which is unfortunate naming-wise but I believe the best option here without introducing API breakage.
[llvm] Use CoreCLR GC interop configuration
Since they're identical right now, we can use the coreclr configuration
to make our IR more easily analyzed by tools built around LLVM.
```
class CoreCLRGC : public GCStrategy {
public:
CoreCLRGC() {
UseStatepoints = true;
// These options are all gc.root specific, we specify them so that the
// gc.root lowering code doesn't run.
InitRoots = false;
NeededSafePoints = 0;
UsesMetadata = false;
CustomRoots = false;
}
Optional<bool> isGCManagedPointer(const Type *Ty) const override {
// Method is only valid on pointer typed values.
const PointerType *PT = cast<PointerType>(Ty);
// We pick addrspace(1) as our GC managed heap.
return (1 == PT->getAddressSpace());
}
};
/// A GCStrategy for the Mono Runtime.
class MonoGC : public GCStrategy {
public:
MonoGC() {
UseStatepoints = true;
// These options are all gc.root specific, we specify them so that the
// gc.root lowering code doesn't run.
InitRoots = false;
NeededSafePoints = 0;
UsesMetadata = false;
CustomRoots = false;
}
};
```
Source: https://github.com/mono/llvm/blob/64c0343537016c153894dc60316bd7b316b812c8/lib/CodeGen/BuiltinGCs.cpp#L105-L137
On the stage of the initialization of the SqliteMembershipProvider the existed code always produced an error "Failed to map path '/'" in case if the ASP.NET application is placed not at the root path. Detailed step by step description of the problem is provided in the issue description.
The bug was that was implemented the call of the function with wrong parameters list. So the fix was in changing the function call. The same function call is also used in SqlMembershipProvider.cs.
Fixes#14234
[merp] Don't leak g_getenv return value
Coverity said:
```
CID 1445100: Resource leaks (RESOURCE_LEAK)
Failing to save or free storage allocated by "monoeg_g_getenv("MONO_CRASH_NOFILE")" leaks it.
```
First set of fixes to get the following tests working under interpreter
on Windows x64:
* mono/mini richeck
* mono/mini mixedcheck
* mono/mini fullaotmixedcheck
* mono/tests winx64structs.exe
Fixes are primarily related to Windows x64 ABI support in interpreter. Fixes
also makes sure our interpreter trampolines get unwind info making it possible
to debug through the trampolines on Windows x64.
Several fixes related to value types was needed, also fixed support for return
value types not fitting into registers, current implementation didn't return
passed in value type address in return register as mandated by both
System V and Win x64 ABI's.
Identified and fixed memory leak on every pinvoke from interpreter that needs stack.
Since Windows x64 ABI always use 32 bytes of stack allocated by caller, the
memory leak was hit on every pinvoke call.
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
* 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
* [llvm] Remove unused default_mono_llvm_unhandled_exception.
It references mono_gchandle_get_target_internal which is not marked MONO_LLVM_INTERNAL
so attempts to run it will fail.
This is caught by linking wit -z now (https://github.com/mono/mono/pull/14562).
* [loaded LLVM] mono_debug_get_seq_points and mono_class_enum_basetype_internak MONO_LLVM_INTERNAL
* Mark mono_debug_method_lookup_location MONO_LLVM_INTERNAL.
Found by linking with -z now (https://github.com/mono/mono/pull/14562)
which we should probably do for this and other reasons.
* #include mono-compiler.h for MONO_LLVM_INTERNAL.
* [loaded LLVM] Mark mini_is_gsharedvt_variable_signature as MONO_LLVM_INTERNAL.
Found by https://github.com/mono/mono/pull/14562.
* Mark mono_print_ins MONO_LLVM_INTERNAL.
* mono_rgctx_info_type_to_str MONO_LLVM_INTERNAL
* [loaded LLVM] mono_compile_create_var MONO_LLVM_INTERNAL
* ifdef around use of MONO_LLVM_INTERNAL and hope
* remove include mono-compiler.h from public header to internal header
* MONO_API_NO_EXTERN_C mono_debug_method_lookup_location() instead of mono_debug_method_lookup_location() MONO_LLVM_INTERNAL to workaround possible lack of MONO_LLVM_INTERNAL.
Rework use of marshalling for RuntimeTypeHandle, RuntimeModule, RuntimeAssembly, and IRuntimeMethodInfo as used by QCalls
- Remove special QCall only used marshallers for RuntimeAssembly, RuntimeModule and IRuntimeMethodInfo
- Following the pattern of ObjectHandleOnStack, implement QCall handle types for RuntimeAssembly/Module/TypeHandle. Use these in all QCalls that once passed the types directly.
- For uses of IRuntimeMethodInfo, follow the existing RuntimeMethodHandleInternal pattern
Also perform some replacement of bool marshalling with use of Interop.BOOL, and a few cases of using pointers instead of byref arguments.
Fix delivers a relatively small win on startup, and small throughput gains around reflection as IL stubs are no longer necessary for many functions in reflection that once needed them.
Reduces methods jitted on powershell startup from 422 to 399, (About 5%) but performance win is only about 5ms on ~400ms as the methods removed are simple.
Signed-off-by: dotnet-bot <[email protected]>
* [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
[interp] set correct stack type on op_Implicit/op_Explicit intrinsics for native types
Needs some additional conversions which happen to be included by accident previously.
This fixes those warnings on amd64:
```
Test run:
image=/Users/lewurm/work/mono-dim-call/mono/mini/builtin-types.exe
BuiltinTests.test_0_nuint_fieldload: Store local stack type mismatch 0 1
BuiltinTests.test_0_much_casting: Store local stack type mismatch 0 1
Results: total tests: 84, all pass
Elapsed time: 0.026546 secs (0.026546, 0.000000)
```
and those warnings on armv7:
```
Test run: image=/mono/mono/mini/builtin-types.exe
BuiltinTests.test_0_nint_inc: 0011 arith type mismatch add.i4 0 1
BuiltinTests.test_0_nint_dec: 0011 arith type mismatch sub.i4 0 1
BuiltinTests.test_0_nint_implicit_decimal: 0034 arith type mismatch
add.i4 0 1
BuiltinTests.test_0_nuint_inc: 0011 arith type mismatch add.i4 0 1
BuiltinTests.test_0_nuint_dec: 0011 arith type mismatch sub.i4 0 1
BuiltinTests.test_0_nuint_implicit_decimal: 0034 arith type mismatch
add.i4 0 1
Results: total tests: 84, all pass
Elapsed time: 0.039214 secs (0.039214, 0.000000)
```
[Android] Fix runtime loading of DSOs for 64-bit processes
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.
<!--
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 #13281.
/cc @lambdageek @grendello
Use example.com and example.org instead.
Fixes https://github.com/mono/mono/issues/14585
Note that not all of the things I replaced make an actual network request but I thought it'd be nice to be consistent.
* Plug leak of CustomAttribute initializer name
All the CustomAttribute initializer names (fields, property) except the last were leaked. Ensure all names are freed.
Fixes#14543
* Apply suggestions from code review
Co-Authored-By: Martin Baulig <[email protected]>
* [driver] add --version-number
Useful for third parties consuming the version number of mono.
* s/--version-number/--version=number/g
* add man page entry
* Implement AppDomain.MonitoringTotalAllocatedMemorySize
* Change precise:true back to precise:false in GetTotalAllocatedBytes
Signed-off-by: dotnet-bot <[email protected]>
* Modified format logic so that braces are not allowed in custom format specifiers.
* Disabled failing test temporarily and fixed code style issue.
PR needed to pass test: https://github.com/dotnet/corefx/pull/35820
* Slight changes to logic to better align the diff.
* Fixed counting error.
* Fix nullable
* Move exclusion near related test
* Add skip to new issue file
* Delete CoreFX.issues.json
Signed-off-by: dotnet-bot <[email protected]>
This affects the case where SemaphoreSlim.WaitAsync is invoked, the operation completes asynchronously because there's no count available in the semaphore, and where a timeout and/or a cancellation token is passed to WaitAsync. In that case, we need to wait for the underlying wait task to complete, for cancellation to be requested, or for the timeout to elapse.
There's currently one code path that handles this. This change improves that slightly by avoiding a defensive array copy. However, we can do much better when we get a cancelable token but no timeout, in which case we can avoid operations like Task.Delay, can register with the original cancellation token rather than a new one (which means we avoid forcing a new CancellationTokenSource's lazily-allocated partitions into existence), etc.
Signed-off-by: dotnet-bot <[email protected]>
The most important point of the "temporary" aspect, esp. given
the complete conversion, is renaming MONO_PATCH_INFO_JIT_ICALL to MONO_PATCH_INFO_JIT_ICALL_ID.
Any accidental or merged MONO_PATCH_INFO_JIT_ICALL will fail to compile.
* Copy icall-def.h to icall-def-core.h.
* Manually preprocess icall-def.h vs. icall-def-core.h.
The only common part in this construction is the JIT icalls at the end.
There much overlap, now duplicated.
* Remove JIT icalls fro icall-def-core.h.
* Merge icall-def-core.h with master.
* Merge icall-def.h with master.
* Rename icall-def-core.h to icall-def-netcore.h.
* Remove more unused icalls
Fixes#24663 by calling `Write(ReadOnlySpan<char>)` instead of `Write(object)` with a boxed `Memory<char>`.
Signed-off-by: dotnet-bot <[email protected]>
Currently if calling GetSystemTimeZones, will return a list which in include Utc object created from the enumeration. But when calling FindSystemTimeZoneById("UTC") will return the cached Utc object which is different than the one returned from the enumeration. This in general could be not a problem but it is better to ensure returned the same object from both APIs. The reason is in our internal code, we use some reference equality for the perf reason. Ensure the usage of Utc object will make it more reliable.
Signed-off-by: dotnet-bot <[email protected]>
We encountered some cultures have a time patterns with single quotes which we should handle keeping the parts between quotes as fixed text inside the pattern and not treat it as any of the time specifiers
Signed-off-by: dotnet-bot <[email protected]>
Build / profile changes:
------------------------
* `build/profiles/testing_aot_common.make`: define `DISABLE_REMOTING = yes` and
`NO_MULTIPLE_APPDOMAINS = yes`.
* `mcs/class/corlib/Makefile`: check `DISABLE_REMOTING` when setting
`REFERENCE_SOURCES_FLAGS` (and don't define `FEATURE_REMOTING`, `MONO_COM`
and `FEATURE_COMINTEROP`).
* added new `testing_aot_common_corlib.dll.exclude.sources`. Several types in
the `System.Runtime.Remoting.Messaging` namespace are used by the runtime in
non-remoting scenarios, so those need to be preserved.
For all other remoting namespaces, we only need a few stripped down stub versions
of the some of the types; those have been added to a new `legacy` directory, so
we can wildcard-exclude all the files here.
* added new `testing_aot_common_corlib.dll.sources`; this currently only contains
`legacy/*.cs` to list above mentioned stub versions.
* added new `testing_aot_common_corlib_test.dll.exclude.sources` as a common test
excludes file.
API Changes (conditional to `DISABLE_REMOTING`):
------------------------------------------------
* `mcs/class/corlib/legacy/`: add stub-versions for some of the remoting-related
classes that are used by the runtime (so we can't completely remove those types):
- `System.MarshalByRefObject`.
- `System.Runtime.Remoting.IRemotingTypeInfo`.
- `System.Runtime.Remoting.ObjectHandle`.
- `System.Runtime.Remoting.RemotingServices`.
- `System.Runtime.Remoting.Activation.ActivationServices`.
- `System.Runtime.Remoting.Contexts.Context`.
- `System.Runtime.Remoting.Messaging.ILogicalThreadAffinative`.
- `System.Runtime.Remoting.Messaging.LogicalCallContext`.
- `System.Runtime.Remoting.Proxies.TransparentProxy`.
- `System.Runtime.Remoting.Proxies.RealProxy`.
some of these have fields that need to be preserved; these are marked with
appropriate `#region` pragmas.
All changes below are conditional to `DISABLE_REMOTING`.
* `System.Runtime.Remoting.Messaging.AsyncResult`: this class is used by some of
the async code, so we can't completely remove it. However, we can remove the
`MonoMethodMessage call_message` field when `DISABLE_REMOTING`.
* `System.Runtime.Remoting.Messaging.MonoMethodMessage`: this class is also used
by some runtime code and thus needs to be preserved. However, when `DISABLE_REMOTING`
is defined, then we make some changes to it:
- remove all iterfaces (`IMethodCallMessage`, `IMethodReturnMessage`, and `IInternalMessage`).
- `Properties` throws `PlatformNotSupportedException`.
* `System.Runtime.InteropServices.Marshal`: disable some COM-related code.
* `System.Threading.Thread`: remove `CurrentContext` property.
* `System.Threading.ExecutionContext`: adjust conditional logic; don't define
`FEATURE_REMOTING` if `DISABLE_REMOTING`.
* `System.Activator`: add `DISABLE_REMOTING` to the existing
`#if FEATURE_REMOTING || MOBILE_LEGACY` conditional in this class.
* `System.AppDomain`: since we only have one domain, `DefaultDomain` will always
return the root domain; comment out the call to `RemotingServices.GetDomainProxy`
as well as some internal methods.
* `System.__ComObject`: stub out on `DISABLE_REMOTING` as well as `!FULL_AOT_RUNTIME`.
* `System.Runtime.Serialization.Formatters.Binary.BinaryFormatter`: adjust `IFormatter`
versus `IRemotingFormatter` interface logic to use the former when `DISABLE_REMOTING`.
* `System.Runtime.Serialization.Formatters.Binary.BinaryObjectReader`: adjust existing
`#if FEATURE_REMOTING || MOBILE_LEGACY` conditional to add `DISABLE_REMOTING` to it.
* `System.Diagnostics.CorrelationManager`: comment out some `CallContext.LogicalGetData()`
and `CallContext.LogicalSetData`.
* `System.Diagnostics.TraceEventCache`: likewise.
Test changes:
-------------
* `mono/tests/Makefile.am`: conditionally disable some remoting tests.
* `corlib/Test/System.Runtime.Serialization/SerializationTest.cs`: conditionally
disable all tests requiring remoting.
* `corlib/Test/System/ActivatorTest.cs`: same; trying to preserve as much as possible
in this test.
* added some `DISABLE_REMOTING` and `DISABLE_SECURITY` conditionals to some of the tests.
Fix leak in mono_parse_options
When MONO_ENV_OPTIONS is null, we would leak the array and buffer
<!--
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
-->
* [runtime] Fix mono_icall_get_wrapper_full () to always compile the wrapper even if a trampoline was created previously.
* [jit] Add a mini_patch_llvm_jit_callees () function to patch callsite variables for LLVM JIT.
* [llvm] Patch LLVM JIT callees in trampolines as well. Patching after a method is compiled is not enough, since new callsites can be created after a method has been compiled.
* [llvm] Cleanup calls from JITted code. Compile referenced jit icall wrappers immediately, since the calls will not be patched.
* Add a missing MONO_LLVM_INTERNAL.
* [arm] one more attempt to fix slotsize issue on llvmonly
Regression of https://github.com/mono/mono/pull/12992 & https://github.com/mono/mono/pull/14362
In the end, the actual fix boils down to:
```patch
--- a/mono/mini/mini-arm.c
+++ b/mono/mini/mini-arm.c
@@ -2374,7 +2374,7 @@ mono_arch_get_llvm_call_info (MonoCompile *cfg, MonoMethodSignature *sig)
lainfo->nslots = ALIGN_TO (ainfo->struct_size, 8) / 8;
lainfo->esize = 8;
} else {
- lainfo->nslots = ainfo->struct_size / sizeof (target_mgreg_t);
+ lainfo->nslots = ALIGN_TO (ainfo->struct_size, sizeof (target_mgreg_t)) / sizeof (target_mgreg_t);
lainfo->esize = 4;
}
break;
```
Tested on `xamarin-macios/arm64_32-v3` branch:
* mscorlib
* mini
* dont link
* monotouch tests
* and a modified version of https://github.com/mono/mono/issues/8486#issuecomment-414365860 (added larger structs too)
with each device, Watch Series 3 (`armv7k`) and Watch Series 4 (`arm64_32`).
I hope that is the last iteration on this.
* remove arm64_32_abi
* Reduce JIT icall hash use.
* PR: Rename mono_jit_icall_info_at to mono_find_jit_icall_info.
* Use enum instead of int, and update comment to reality (the assert is arguably leniently off by one.)
* Cast integer to enum for C++.
* More int vs. enum, and use two variables, and const.
* Undo a little fishing for CI failure.
* [netcore] Use bash explicitly for Arcade things
* [netcore] Work around https://github.com/dotnet/cli/issues/10014
* [netcore] Try forcing powershell Arcade on Windows
* [netcore] Switch build properties from /p: to -p: due to MSYS2/dotnet bug
* [netcore] Switch from nuget pack to dotnet pack
* [netcore] Add Windows x64 build
* [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
* [csproj] Update project files
* [netcore] Exclude unused native locale icalls
* Fix builds with mono_feature_disable_sockets, currently not enabled by configure script
* [netcore] Don't compile in System.IO icall in netcore profile
* Make genmdesc output better typed and more readable -- almost hand-maintainable
but no clear route to actually hand-maintainable.
* Replace != with < and undo debug code.
* Changing EnableDefaultCompileItems=false to EnableDefaultItems=false
* Taking the VS auto-fixes for the solution and corelib csproj
* Removing the duplicated T4 file includes in the main csproj
* Regenerating the included T4 templates
* Fixing S.P.Corelib to properly list available platforms/configurations
* Add a comment on the T4 template service
Signed-off-by: dotnet-bot <[email protected]>
- Assembly.ToString() won't return null
- Several attributes have the intent that their arguments are non-nullable, even though they don't check and throw; the annotations should match the intent in such cases.
Signed-off-by: dotnet-bot <[email protected]>
Since commit d8af775, c++ compiler is required to compile.
This patch checks if the c++ compiler is available as soon as possible
and returns an error in case it is not found.
Fixes: https://github.com/mono/mono/issues/14195
Signed-off-by: Angelo Compagnucci <[email protected]>
Modify the sdks/builds/ infrastructure to support compiling the Android SDK on Windows.
The initial goal of this commit is to build only the monodroid BCL on Windows. Compilation of the host and cross-compiler mono binaries is future work.
There's one kind of hacky bit in here. Had to make sure that scripts/ci/run-jenkins.sh does _not_ set MONO_EXECUTABLE. Normally windows builds use the msvc in-tree compiled mono binary to build the BCL. In the case of the SDKs, we don't build that msvc binary, and we just use the usual (cygwin) mono to build the BCL.
* [sdks] allow building on cygwin
* [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
[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
* Revert "[System] Add FSEvent FileSystemWatcher to 'monotouch' BCL profile"
This reverts commit 46fc5352f3dfe0027e684a0f61e71130fccd559f.
While iOS FileSystemWatcher works, we now find that it is using unofficially-available symbols and cannot publish apps using those.
Fixes https://github.com/mono/mono/issues/14290
* [csproj] Update project files
* Enable nullable at the project level
* Remove `#nullable enable` from individual files
Removes `#nullable enable` from almost all .cs files in System.Private.CoreLib. I left it only in the ~30 files (out of ~1480 that had it) that are mirrored to corefx, that are built into projects by corefx that don't yet set NullableContextOptions at the project level, and that use nullable annotations; otherwise, they'd break the corefx build.
Signed-off-by: dotnet-bot <[email protected]>
* Enable MSVC builds of Mono w/ ENABLE_NETCORE
* Fix non-netcore build
* Move the ENABLE_NETCORE definition to config.h where it belongs
* Replace .def with linker #pragmas
* TARGET_WIN32 -> HOST_WIN32 && HOST_X86
* Pick up MONO_ENABLE_NETCORE from cygconfig.h
* Make `./configure --with-core=only` MSVC builds working
* Include netcore sources unconditionally, move the condition into the .c file
* Fix MSVC C++ netcore build on Win32
* [corlib] Change the RuntimeModule.GetGuid and RuntimeAssembly.GetAotId icalls to return a byte array instead of a string, so it doesn't have to be parsed by the Guid ctor. Also allocate the arrays in the c# code and pass them to the icalls.
* Do not allocate handles in ReleaseMutex.
Take advantage of thread/internal_thread maturity/pinning.
There are arguments for and against this.
It is arguably better to use handles everywhere.
But it is dubious to require an allocation to release a lock.
Releasing a lock should be infallible.
And surviving low memory shouldn't be a lost cause, imho..
This diff could also be viewed as an opportunistic cycle/size optimization
and be placed under ifdef -- ifdef THREAD_ALWAYS_PINNED orsuch.
This is an alternative to https://github.com/mono/mono/pull/14397.
* PR: Move comments.
Several fixes to the log profiler in order to work on Windows.
* Add new dynamic library project to build log profiler on Windows MSVC.
* Fix dependecy between log profiler and Mono.
* Rewrite command pipe logic on Windows since it's not supported to select
on both sockets and pipes.
* Several additional socket fixes needed for log profiler to work on Windows.
The less mechical parts:
- spell out monoeg_g_free
- register_dyn_icall not used, remove
- register_icall_no_wrapper only used once, spell it out instead
This is nice cosmetically on its own and will help remove JIT icall hashing.
* Introduce enum and static data for JIT icalls, that are currently hashed
by string and address and use dynamic allocation.
These will be used shortly.
* PR: Move MONO_JIT_ICALLS content from class-internals.h to jit-icall-reg.h.
Not clear what is the best name but moving along.
[gitignore] Add crash dump files, .dylib.dSYM directories, and test-path
Wasn't sure where in the file to best put the .dylib.dSYM stuff, so suggestions are welcome
* Mechanism strings to register_dyn_icall in mini-runtime.c.
That is both, generate them kinda, and make them available for some later manipulation.
* Mechanize strings for JIT icall registration in mini-runtime.c.
Generate them slightly and make them amenable to crude preprocessor transforms later.
* Try to improve github diff presentation.
The constructor for mono_error_set_argument lacks a `const char *msg_format`
so clearly we shouldn't be applying formatting from an entirely
unrelated parameter.
This was flagged by `-Werror=format-security`
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.
* Make mono_fmod extern "C and not static, to simplify later
removal of JIT icall hashing. Making it more consistent with other icalls.
Costing maybe one instruction in some slow paths.
* Move mono_fmod from mini-runtime.c to jit-icalls.c.
* Fix declaratoin of mono_fmod.
Convert managed product binary to use SDK project system.
- Uses Arcade for versions strings
- Overrides Arcade defined output paths - should change in the future
Signed-off-by: dotnet-bot <[email protected]>
* [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.
* match the parameter
* Removed special handling.
Removed special handling of TypedReference and RuntimeArgumentHandle
* Remove the whole special casing block
* Revert part of last commit
Restored the check for IsByRefLikeAttribute
* Corrected the function name
I accidentally left these MICROSOFT_BCL_ASYNCINTERFACES_PACKAGE references in as part of some recent churn. This compilation constant isn't set anywhere.
And the CORERT ifdef is no longer needed now that we've consolidated the code to shared.
Signed-off-by: dotnet-bot <[email protected]>
* Add ManualResetValueTaskSourceCore / AsyncIterateMethodBuilder to Microsoft.Bcl.AsyncInterfaces
These two types needed modifications to target .NET Standard 2.0 and are the necessary pieces to enable the compiler to compile async iterators.
- Copied ManualResetValueTaskSourceCore.cs from coreclr and tweaked it. I opted to do this rather than ifdef because the changes are not localized and I didn't want to significantly perturb the primary implementation.
- Added a few ifdefs to the shared AsyncIteratorMethodBuilder. It already had ifdefs, so I just added to it.
- Added a test project, and included the existing ManualResetValueTaskSourceCore tests. I had to disable two of the tests because of some of the optimization differences.
- Augmented those tests to validate that the compiler is able to successfully generate iterators and await foreach them.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* Implement GC.RegisterMemoryLoadChangeNotification
This allows users to register a callback to be called whenever the
memory load is between a low and high thresholds. The idea is to allow
them to tweak their memory usage based on the available memory.
It is only internal for now because we are not confident on the shape of
the API and if it's the best we can provide users. This needs to go
through a few iterations with first party users like ASP.NET or corefx.
WIP for https://github.com/dotnet/coreclr/issues/18619
* fixup! Implement GC.RegisterMemoryLoadChangeNotification
* fixup! Implement GC.RegisterMemoryLoadChangeNotification
* fixup! Implement GC.RegisterMemoryLoadChangeNotification
Signed-off-by: dotnet-bot <[email protected]>
* Added overloads to Path.Join
* Refactor Path.Join and Path.Combine to use ValueStringBuilder
* Use proper defined const for empty string
* Fix Windows-specific const
Signed-off-by: dotnet-bot <[email protected]>
We decided after all to put these on a different type, TaskAsyncEnumerableExtensions. This commit adds the new type. We can delete the methods in the old location once corefx consumes an updated build and switches over to using the new ones.
Signed-off-by: dotnet-bot <[email protected]>
The previous attempt ( https://github.com/mono/mono/pull/14078 ) only fixed it for ABIs where the stack pointer alignment is 8 bytes. ABIs, such as watchOS, require 16 byte alignment.
* [llvm] Widen vector equality (OP_PCMPEQx)
Fixes https://github.com/mono/mono/issues/14261
Fixes https://github.com/mono/mono/issues/14143
This was causing an issue when trying to inline
System.Numerics.Vectors.Vector`1<byte>:Equals into System.Span.IndexOf
from System.Memory.dll as provided by nuget. I believe that it is
comparing the result of a SIMD operation on two SIMD registers there with a
SIMD register full of zero bytes.
When we produce the Equals call (no inline), we spill the SIMD <4 x i32>
vector to the stack in the caller, and we then later load it
with the widened type used here <16 x i8>.
When we inline, we end up making the args into XMOV opcodes,
and then doing the "pcmpeqb" mini opcode with the return values
from those operations. This becomes a register to register no-op
copy, and the original <4 x i32> gets compared against the <16 x i8>
type:
```
%116 = icmp eq <16 x i8> zeroinitializer, <4 x i32> %115
```
This does not go the way we want it to. It reliably leads to IndexOf
breaking and only finding the desired byte in the portion not processed
by the SIMD code (in the last few elements of the array).
This fix checks if the input dimensions differ, and does a conversion.
This produces the following IR:
```
%114 = bitcast <4 x i32> %99 to <16 x i8>
%115 = icmp eq <16 x i8> %114, %113
%116 = sext <16 x i1> %115 to <16 x i8>
%117 = icmp eq <16 x i8> zeroinitializer, %116
```
* [llvm] Widen vector greater-than
Here we do the same trick used in the above fix, but for the parallel greater-than operation.
Technologies like SharpDX uses a minimal set of COM support from runtime
and System.Runtime.InteropServices.Marshal:
AddRef
Release
QueryInterface
All these are low level wrappers around methods in IUknown interface and
doesn't need any of the additional runtime COM support enabled to work.
Technologies like CoreRT includes these methods in their full AOT
profile, meaning that SharpDX can run on CoreRT on Windows platforms. Mono's
WinAOT profile and runtime currently don't, making it impossible to use
SharpDX.
This PR adds the needed methods into WinAOT profile and also make
sure corresponding icalls always gets included on Windows build Mono runtime.
I'm taking the LibraryNameVariation helper from System.Runtime.Loader for the ride as well because it's a general purpose probing logic that is useful in a managed implementation of NativeLibrary.
Signed-off-by: dotnet-bot <[email protected]>
Applies changes to `Array.IndexOf()` and `Array.LastIndexOf()` similar
to the changes made in #20855, so that types other than `byte` and
`char` can use use the fast vectorized path.
Also allows 32-bit and 64-bit types for which
`RuntimeHelpers.IsBitwiseEquatable<T>()` returns `true` to use the
faster implementation of `IndexOf` and `LastIndexOf` from
`MemoryExtensions`.
Signed-off-by: dotnet-bot <[email protected]>
* Workaround memset alignment sensitivity
memset is up to 2x slower on misaligned block on some types of hardware. The problem is uneven performance of "rep stosb"
used to implement the memset in some cases. The exact matrix on when it is slower and by how much is very complex.
This change workarounds the issue by aligning the memory block before it is passed to memset and filling in the potential misaligned
part manually. This workaround will regress performance by a few percent (<10%) in some cases, but we will gain up to 2x improvement
in other cases.
Fixes#24300
Signed-off-by: dotnet-bot <[email protected]>
* Increasing precision properly and leaving the rounding of to casting operator
* disabling corefx tests in coreclr and addressing feedback
* correcting test project name
* Fix json
Signed-off-by: dotnet-bot <[email protected]>
The --pinvoke-libs=x argument to packager.exe can be used to generate pinvoke linking tables.
'x' is a list of library names used in DllImport declarations, i.e. --pinvoke-libs=libtest is used
to link with [DllImport ("libtest")].
* Fix Satellite Assembly loading
When loading satellite assemblies, we should probe next to the parent
assembly and load into the same AssemblyLoadContext as the parent
assembly.
Disable fallback probing for satellite assemblies.
Add AssemblyLoadContext.Resolving handler to probe for satellite
assemblies next to parent
Fixes#20979
* Call ResolveSatelliteAssembly from native
Only call ResolveSatelliteAssembly from native when
resolving a satellite assembly
* PR Feedback
Minimize string creation
Remove unnecessary if null checks
Eliminate corner cases by only allowing one case insensitive matching directory.
* ResolveSatelliteAssembly should ...
ResolveSatelliteAssembly should always be called on the ALC which loaded parentAssembly
Simplify code.
Add Debug.Assert
* Remove case insensitive culture search
* PR Feedback
* Fix parentAssembly logic
* Fixes from initial testing
* Add probe for lower case culture name
* PR feedback
Signed-off-by: dotnet-bot <[email protected]>
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.
* [interp] Optimize enum.HasFlag for csc pattern
Avoid boxing and slow call. Makes it 100x faster.
* [interp] Optimize enum.HasFlag for mcs pattern
* [interp] Transform ldc.i4 + conv.i8 into ldc.i8
Simplifies code, making enum.HasFlag optimization work for long enums.
* Refactor WebAssembly.Core object instantiation.
- Move the supported Core object identification into javascript.
- Runtime the core object type is now passed into the Runtime from javascript binding support instead of being housed in managed code.
* Address review comments.
* Fix indentation
* Implement suggestion by Katelyn Gadd to use Symbol instead of a Map or WeakMap.
- This removes the previous mono_wasm_core_map used for type mapping.
- Attach a special named symbol for `wasm type` to the prototype property for the Core objects that we have bound.
- The Managed Type is stored in the symbol property that will be passed to the managed side.
* [interp] Optimize special static field access
3x faster. For value types 10x.
* [interp] Remove duplicated code
* [interp] Further optimize thread static field access
Provides an additional 50% perf gain.
This field is used by the internal hash table to link nodes and it can be changed during hash table insertion of other imethods. Copying this field back was leading to random hangs in hash table lookup.
* [runtime] Add a python version of the offsets tool.
This version only depends on python and libclang. It currently only
works on osx.
* [runtime] Add a dummy structure needed by the python version of the offsets tool.
* [offsets-tool-py] Change some argument names for compatibility.
* [wasm] Use the python offsets tool on osx, the c# version is 32 bit, and the 64 bit version doesn't work.
* [wasm] Fix the ordering of mono libraries on the link line.
- The routine specifically will escape path separators when needed for instance on windows instead of using the simplified `.Replace ("\\", "\\\\")` as previously implemented.
- The routine will also add quoting when necessary.
The version number in version.h only shows e.g. "6.3.0", and we
want full version numbers ideally, to match what our Mac pkg files
show. This logic calculates that version number.
* Revert "[Tailcall] [arm] [jit] Fix moving tailcall parameters. (#12701)"
This reverts commit 257efc6374.
* 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.
* Restore Roslyn compilers from NuGet to allow up-to-date version to be used
* Move the Roslyn version to makefile, ensure that it is updated before building System.Private.CoreLib
* Pass the whole path to Roslyn props file instead of just Roslyn version to dotnet build
* Make the Roslyn restore compatible with .NET Core 2.2 SDK
Under hybrid suspend a thread can be cooperative suspended but still
checked for a platform critical region under wow64. Since thread is
not preemptive suspended we can't reliably call GetThreadContext and
doing so could also (even correctly) return a context flagged as critical
triggering an assert in stw for cooperative suspended threads.
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.
* [netcore] Convert netcore/Makefile.am to a normal makefile, get the configure variables from config.make.
* [netcore] Convert mcs/class/System.Private.CoreLib/Makefile.am to a normal makefile.
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
* Bump CoreFX version, include few more packages
* Add exclusions for System.Collections.NonGeneric.Tests
* Exclude tests that crash runtime
* Add more exclusions for known failures
* Exclude System.Utf8String.Experimental.Tests, it is CoreCLR specific
Exclude System.ComponentModel.Composition.Registration.Tests, the published version throws PNSE for all methods
Please enter the commit message for your changes. Lines starting
* Make a list of known non-passing tests and establish baseline for 'make xtestpass'
* Add exclusions
* Reenable System.Net.NameResolution.Functional.Tests
* Reenable System.Net.Sockets.Tests
* Reenable System.Diagnostics.Tracing.Tests
* Reenable System.Net.Http.Functional.Tests
* Reenable System.Net.HttpListener.Tests
* Reenable System.CodeDom.Tests
* Reenable System.Linq.Expressions.Tests
* Reenable System.Threading.ThreadPool.Tests
* Reenable System.Runtime.Tests
* Reenable System.Collections.Tests
* Reenable System.Threading.ThreadPool.Tests
* Reenable System.Memory.Tests
* Reenable System.Linq.Parallel.Tests
* Update exclusions for System.Diagnostics.Process.Tests
* Reenable System.Dynamic.Runtime.Tests
* Reenable System.Runtime.Numerics.Tests
* Sort excluded tests
* Reenable System.Reflection.Tests
* Reenable System.Reflection.Emit.Tests
* Reenable System.Linq.Parallel.Tests
* Reenable System.Diagnostics.TraceSource.Tests
* Reenable System.Threading.Tests
* Disable tests that trigger UI on macOS
* Update System.Runtime.Tests exclusion list
* Update line numbers
e.g. whenever underlying representation is nul terminated string.
MONO_PATCH_INFO_LDSTR_LIT
MONO_PATCH_INFO_OBJC_SELECTOR_REF
almost the same as
MONO_PATCH_INFO_JIT_ICALL
MONO_PATCH_INFO_JIT_ICALL_ADDR
MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL
MONO_PATCH_INFO_LDSTR_LIT no longer allocate
and copy the string from the AOT image into image_pool.
g_str_equal check pointer equality first.
While obviously correct, not obviously faster,
as it adds cost when strings are unequal.
Uninline g_str_equal, seems cleaner, but perhaps less efficient.
Combine the switch-exit and default: paths,
as only one case other than default exited the switch.
Lift out other common subexpressions.
* Package the wasm and wasm Facades correctly.
* Move the build props and targets file to netstandard2.0 build directory.
* Place framework .props file properly for build
* Place runtime .props file properly for build
* A little cleanup and add escaping windows path separator.
- There are problems executing mononlinker.exe on windows if the windows path separators are not escaped.
* [image] Create MonoImageStorage to own the image raw data
Create a new data structure: MonoImageStorage.
It is an object that will have the responsibility for the raw data of a
MonoImage. It has a string key and a refcount that is used to share a
MonoImageStorage between multiple MonoImage objects.
The reason we need this is because the current MonoAssembly/MonoImage design is
broken for multiple domains and (more evidently) it will be broken when we add
AssemblyLoadContext support. The issue is that a MonoImage may be shared
between multiple domains (or ALCs), but it has a 'references' field which
points to a single other MonoAssembly.
This is a problem because the references of an image may be resolved
differently in different domains (or ALCs).
The eventual solution will be to stop sharing MonoImages based on path name (or
in the case of in-memory images based on a name made up from the address of the
byte blob).
However we still don't want to open the same data more than once (if we're on a
config where we don't have mmap, we malloc some memory and dump the data in
there - we don't want to do that multiple times for the same file).
So the solution is to create this MonoImageStorage object and make it possible
to share it based on path name, but don't give it any responsibilities except
for owning the memory. It doesn't know anything about metadata or assemblies
or any of that stuff - it just owns a chunk of memory and knows when and how to
free it.
This commit just adds the MonoImageStorage object and wires it up in MonoImage
loading. There should be no observable behavioral changes from this commit.
* [win32] call FreeLibrary from MonoImageStorage dtor, not mono_image_close_except_pools
If we're sharing a MonoImageStorage, only call FreeLibrary when the storage is
finally destroyed, not every time one of the images is closed.
* Update dependencies from https://github.com/dotnet/corefx build 20190419.5
- Microsoft.NETCore.Platforms - 3.0.0-preview5.19219.5
- Microsoft.Private.CoreFx.NETCoreApp - 4.6.0-preview5.19219.5
* Removing the Sse2.StoreLow(long/ulong*, ...) methods that have been replaced
* Moving the Sse2.StoreLow(long/ulong*, ...) tests to be Sse2.StoreScalar tests
* Fixing some existing usages of Sse2.StoreLow(long/ulong*, ...)
Signed-off-by: dotnet-bot <[email protected]>
* removing using systems and adding nullability for System.Diagnostics.SymbolStore
* annotating the class that implements the internal interface
* adding bang to fix failure
* correcting the byte array declarations
Signed-off-by: dotnet-bot <[email protected]>
* Nullable: shared\System (most of it)
And some other things it touches.
* Nullable: src\System (most of it)
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* Nullable: System.IO
Everything exception StreamReader, StreamWriter, BinaryReader, BinaryWriter, which are waiting for some changes in master to propagate over to the feature branch.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* Nullable: System.Runtime.InteropServices.Marshal
* Fixing the nullable annotations for BindToMoniker and GetObjectForIUnknown
* Fixing the nullability of PtrToStringAuto(IntPtr, int)
Signed-off-by: dotnet-bot <[email protected]>
Ultimate goal is to significantly reduce or maybe completely
eliminate the hashing of JIT icalls.
It is not a small change.
This is a small digestable albeit tedious step toward that.
The "names" of opcode emulation icalls are needed for
token pasting and/or struct fields. They are needed without quotes.
This PR removes the quotes.
And then for now, just always restores them.
This is extracted from https://github.com/mono/mono/pull/14047
as a step toward making it easier to review.
* [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.
* Cut down on strlen calls.
But keep the shared memory format unchanged to match .NET. (i.e. don't
put string lengths in it).
* PR: MONO_ENTER_NO_SAFEPOINTS instead of gchandle.
Push/pop frames in loops and mind the return/goto/break/continue carefully, instead of using assignment.
*PR: Reduce gsize to adequate int, move multiple int declarations to same line.
* PR: Fix prototypes in disabled code.
* PR: Spell out `int` as `gint32`.
Use an uppercase guid to workaround Windows problem.
* A bit more true to the previous version.
* Reduce diff a little.
* if (is_ok()) around one line instead of goto around it.
* Restore some old code.
* Restore more verbosity, that used to have a point but no longer does.
* [aot] Add a depfile= argument which causes the AOT compiler to write out a gcc style dep file listing the dependencies between the output file and all referenced assemblies.
* Add a manpage entry.
* Update after comments.
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.
[interp] Simplify cpobj.vt
[interp] Optimize stelem.vt/ldelem.vt
[interp] Avoid unnecessary write barrier for ldobj.vt
Write barriers are only required for stores in the major heap/los.
[interp] Simplify ldfld.vt/stfld.vt
* [interp] Remove redundant check
It can't be an enum if it is stored on the vtstack
* [interp] Optimize boxing
Makes boxing of primitives 4x faster and boxing of vt 3x faster.
* [interp] Remove unneccessary check in unbox
We do the same check as jit. Makes unboxing 10x faster.
* [interp] Extract some duplicate code for boxing
* [interp] Fix boxing of nullable with constrained calls
Before the box opcode optimization, it was handling nullable. When normally boxing a nullable we call the Box method, but this is awkward when doing a constrained call, so we just add a separate opcode. This is slightly slower than calling Box, but much faster than the old code using the generic mono_value_box_checked.
Now all custom attribute related tests pass in System.Runtime.Tests.
Also this PR fixes broken acceptance tests for regular mono introduced in https://github.com/mono/mono/pull/13809
* Move most of EventSource to shared CoreLib partition
* Reenable some code that can be shared with Microsoft.Diagnostics.Tracing.EventSource.Redist in CoreFX
* Remove unused functions
* Fix placement of #endregion
* Clean up P/Invoke prototypes
* Move remaining code from EventSource_CoreCLR to shared partition (guarded by !CORERT)
* Remove more unnecessary marshalling attributes
* Move remaining CoreRT/ProjectN code to shared partition
* Avoid using Windows errors on non-Windows platforms
Signed-off-by: dotnet-bot <[email protected]>
* [netcore] Add linker descriptor. This is just a copy of the mscorlib descriptor.
* [netcore] Update linker descriptor for netcore.
* Remove com/remoting related classes.
* Other smaller changes.
* [netcore] Allow loading corlib from MONO_PATH.
* Update System.Private.CoreLib.xml
[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)
* Check for lower bounds on non-zero-based arrays
* Grab correct version of System.Reflection.Context
* Move Attribute type validation to fix checking for custom attributes using interface types
* Fix parameter checks
* [interp] Further optimize static vt field access
We don't require any write barrier checking since we always copy between interpreter vt_stack and static data. We can also include the vt size in the code stream. Makes it over 1.5x times faster.
* [interp] Fix static field access using ldfld/stfld
Static field access using the ldfld/stfld instructions was not updated when stsfld/ldsfld were optimized.
* [interp] Fix special static vtype field access
* Switch to msbuild nuget which is available for all platforms
* Remove check-env rule dependency
* Add missing reference to System.Composition.TypedParts
* Sort references by name
* Fix Windows builds of CLR hosting API
* Make System.Private.CoreLib compilable on Windows
* Remove accidental change
* Fix Unix build
* Update GlobalizationMode.cs
* Update GlobalizationMode.Unix.cs
* Move DateTime Windows implementation to shared CoreLib
* Make all the BOOL/struct marshalling explicit
* internal -> private
* Use unsafe code on all layers, remove unnecessary fixed blocks
Signed-off-by: dotnet-bot <[email protected]>
This compat quirk is increasingly more broken since the framework is generally not compatible with, and we have not heard anybody actually using it.
Changed Environment.HasShutdownStarted to unconditionally return false. It does not make sense for it to ever return true with shutdown finalization disabled.
Signed-off-by: dotnet-bot <[email protected]>
* Update dependencies from https://github.com/dotnet/corefx build 20190411.2
- Microsoft.NETCore.Platforms - 3.0.0-preview5.19211.2
- Microsoft.Private.CoreFx.NETCoreApp - 4.6.0-preview5.19211.2
* Update dependencies from https://github.com/dotnet/corefx build 20190411.22
- Microsoft.NETCore.Platforms - 3.0.0-preview5.19211.22
- Microsoft.Private.CoreFx.NETCoreApp - 4.6.0-preview5.19211.22
* Removing renamed HWIntrinsic APIs from S.P.Corelib
* Updating the hwintrinsiclistxarch to match the new intrinsic API names
* Updating the HWIntrinsic generated tests to use the new API names
Signed-off-by: dotnet-bot <[email protected]>
* Make GC.GetGCMemoryInfo public
This is to be used to allow users to optimize memory consumption based
on what's available to the GC and on the system.
This is based on https://github.com/dotnet/corefx/issues/34631
* Address reviews
- Pass GCMemoryInfo struct to native in place of many arguments
- Make GCMemoryInfo.HeapSize and GCMemoryInfo.Fragmentation long in place of IntPtr
* Address reviews
- Mark GCMemoryInfo readonly
* Rearrange fields and match managed/native names
* Fix compilation
* Use getter shorthand
* Address API Design Review
https://github.com/dotnet/corefx/issues/34631#issuecomment-481358549
* Fix comments
* Fix comments
* Do everything in managed
* Address review
- Remove unecessary [StructLayout.Sequential]
- Remove "_" prefix for parameters variables
Signed-off-by: dotnet-bot <[email protected]>
* Update Range.GetOffsetAndLength
Make it return offset and length tuple instead of the old Type Range.OffsetAndLength
* Fix the return Tuple fields names
Signed-off-by: dotnet-bot <[email protected]>
* Updating the Avx2.ConvertToVector256UInt APIs to return a signed type (matching the native signature and Sse41 APIs).
* Adding explicit overloads for `Sse41.ConvertToVector128Int*` and `Avx2.ConvertToVector256Int*` that take a pointer
* Updating the word ordering for the Compare/CompareScalar methods.
Signed-off-by: dotnet-bot <[email protected]>
* rename BaseCounter to DiagnosticCounter
* Change MetaData->Metadata
* Make EventSource and Name a property for counter classes
* Make the counter APIs public
* fix build errors
* Change float to double
* Few cleanups, fix test
* fix GetMetadataString
* PR feedback
* More PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* [interp] Remove dead code
It doesn't make sense to dereference a value type
* [interp] Emit faster instructions for ldobj
* [interp] Emit faster instructions for stobj
* [interp] Simply ldobj vt
This makes it 10x faster
* [interp] Make ldind.r8 unaligned friendly
Assembly.LoadFromPartialName(string) should not throw FileNotFoundException, but
should rather return null.
ArgumentException should use nameof(partialName)
Fixes#19817
Signed-off-by: dotnet-bot <[email protected]>
Previously for `<`/`<=` it would throw if `v1` argument was null, but for `>`/`>=` would throw if the `v1` argument was null, albeit using `v1` in the exception parameter name. It's also not expected for comparisons like this to throw, in general.
Signed-off-by: dotnet-bot <[email protected]>
Symlinks on TVOS run into sandboxing restrictions. We've already disabled a similar test.
This test was added recently as part of 26e0b1deec.
(cherry picked from commit b85fdbdb10)
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.
`make dist` stopped erroring in #13961 but didn't actually work, because
the relevant Makefile.am was not distributed, causing configure to fail
(because the Makefile.am was cited as an input, unconditionally).
We can't rely on the dist-recusrive from library.make or build.make because
this lib is in a weirdo format which doesn't comply with the requirements
of those helpers, so craft a simple handwritten replacement for our special
case
Cleaning exceptions during static constructor loading
Reset the stack_trace and trace_ips because the type initialization exception is reused.
Fixes#13714
* 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)
Currently we have two nullable API's that will have value in the public
embedding API (already requestsed by users), eliminating the needs to go
from native->managed and back to get nullable information about a type.
mono_class_is_nullable
mono_class_get_nullable_param
This PR moves them from class-internals.h into class.h and mark them
with MONO_API and when needed include GC UNSAFE/SAFE transition.
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.
uses_handles parameter is a gboolean -> int32_t in Mono but was uint8_t
in WASM implementation. This triggered a problem when a uninitialized
gboolean was used and only parts of it got set and method still returns
an address, indicating success. This is a different behavior compared to
Mono's default implementation. Fix to this particular problem was to init
the gboolean variable before calling, but good to make sure the signatures are in
sync anyways.
icalls registered with mono_add_internal_call, mono_add_internal_call_with_flags
or mono_add_internal_call_internal ended up in two different hash tables
depending if they were "foreign" or not. This caused double lookups in
mono_lookup_internal_call_full. There are also use cases where it could be
interesting to keep additional flags related to the icall, that could be
used by codegen for various optimization.
This PR merge the two hash tables into one and add a flag describing icall
details. The flag could later be extended with additional behaviors going
forward if needed.
* Improve RuntimeHelpers.GetSubArray
This change does three things.
First, it fixes `GetSubArray` to work when the supplied array is actually a `U[]` where `U : T`. Currently this case ends up throwing an exception inside of span, which doesn't like working with arrays covariantly.
Second, it fixes argument validation so that we throw an ArgumentNullException if the input array is null rather than NullReferenceException.
Third, it improves the performance of `GetSubArray` for the 95% common case where either `T` is a value type or the type of the array matches the `T` type specified.
* Only use `Array.Empty<T>` when `typeof(T[]) == array.GetType()`
Signed-off-by: dotnet-bot <[email protected]>
* Match PtrToStringUTF8 to the other PtrToString* families.
* Make PtrToString*(IntPtr,int) exceptions consistent.
* Exclude out-of-date tests in CoreFX.
* Update exclusions to cover tests that are now throwing ArgumentOutOfRangeExceptions instead of ArgumentExceptions.
* Fix parameter order for exception.
* Pass value to exception.
Signed-off-by: dotnet-bot <[email protected]>
* Moving some JITDUMP calls into Compiler::lookupNamedIntrinsic
* Marking the IsSupported methods as Intrinsic for all HWIntrinsic ISAs
* Updating the hwintrinsic importation to more generally handle IsSupported and ThrowPNSE
* Applying formatting patch.
* Adding using System.Runtime.CompilerServices to the various x86 PlatformNotSupported HWIntrinsic files
Signed-off-by: dotnet-bot <[email protected]>
These types null out some fields on Dispose, and some of those fields are accessible directly via exposed properties, which means that nulling them out would either force us to annotate those properties as being nullable or would require us to lie about them being nullable. Nulling them out also makes it easier to accidentally null ref in the implementation, and prevents us from making the fields readonly.
It should be exceedingly rare that you dispose of one of these objects and then keep it alive while also being concerned about keeping alive the other helper objects the type uses. So this change just uses a separate flag to track disposal, and avoids nulling out the fields, which is not a common practice elsewhere in the framework.
This will be a visible change in that after Dispose, properties like StreamWriter.BaseStream/Encoding will now return the stream/encoding rather than null. In theory that could break someone if they were using those properties to determine whether the writer had been disposed, but that seems unlikely / similar fallout from most any bug fix, and objects generally aren't supposed to be touched after Dispose, anyway.
Signed-off-by: dotnet-bot <[email protected]>
[aot] use g_malloc () instead of malloc ()
Unbreaks jemalloc support as it hooks into `g_malloc ()` instead of replacing `malloc ()`.
```
%4 0x000055ee6af0d27b in sigabrt_signal_handler (_dummy=6, _info=0x7ffc7b0c4ff0, context=0x7ffc7b0c4ec0) at mini-posix.c:232
%5 <signal handler called>
%6 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
%7 0x00007f4ae0d73801 in __GI_abort () at abort.c:79
%8 0x000055ee6b2ab6ed in rtree_child_leaf_tryread (elm=0x55ee6b75b028 <je_extents_rtree+704104>, dependent=true) at src/rtree.c:205
%9 0x000055ee6b2ab95f in je_rtree_leaf_elm_lookup_hard (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, init_missing=false) at src/rtree.c:292
%10 0x000055ee6b242f70 in rtree_leaf_elm_lookup (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, init_missing=false) at include/jemalloc/internal/rtree.h:369
%11 0x000055ee6b242fb5 in rtree_read (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true) at include/jemalloc/internal/rtree.h:394
%12 0x000055ee6b2431ee in rtree_szind_slab_read (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, r_szind=0x7ffc7b0c6000, r_slab=0x7ffc7b0c6004) at include/jemalloc/internal/rtree.h:446
%13 0x000055ee6b24d468 in ifree (tsd=0x7f4ae1f05738, ptr=0x55ee6c7dfad0, tcache=0x7f4ae1f058f0, slow_path=true) at src/jemalloc.c:2126
%14 0x000055ee6b24de06 in mono_jefree (ptr=0x55ee6c7dfad0) at src/jemalloc.c:2290
%15 0x000055ee6b2c6c68 in monoeg_g_free (ptr=0x55ee6c7dfad0) at gmem.c:83
%16 0x000055ee6adefafa in emit_method_code (acfg=0x7f4ae0986000, cfg=0x7f4ae0ad4e00) at aot-compiler.c:6243
%17 0x000055ee6adf9534 in emit_code (acfg=0x7f4ae0986000) at aot-compiler.c:9704
%18 0x000055ee6ae04a9d in emit_aot_image (acfg=0x7f4ae0986000) at aot-compiler.c:13535
%19 0x000055ee6ae03b7c in mono_compile_assembly (ass=0x7f4ae09a9300, opts=374434303, aot_options=0x7f4ae093c000 "bind-to-runtime-version,outfile=./../../class/lib/build-linux//Microsoft.CodeAnalysis.CSharp.dll.so", global_aot_state=0x7ffc7b0c6438) at aot-compiler.c:13357
```
* Nullable: remainder of globalization
* annotate windows specific files
* add TODO-NULLABLE next to TODO suggesting comments
* fixes after merging other globalization annotations, apply feedback
* fix windows
* address feedback
* fix windows
* fixes
* apply feedback
* remove workaround
* s_Invariant?, couple of Debug.Asserts
Signed-off-by: dotnet-bot <[email protected]>
* Nullable: NumberFormatInfo, CultureInfo
* fix build
* fix windows
* fix APPX issue
* another appx failure
* get rid of line split
* mark retVal as nullable
Signed-off-by: dotnet-bot <[email protected]>
We can now build `--with-core=only` on Linux or Mac with the same makefile, and have a functional `make nupkg` rule which attempts to produce a .nupkg of the runtime in the format consumed by core-setup.
* [corlib] Make NSLogWriter thread-safe.
* [corlib] Simplify newline checking in NSLogWriter.
Checking the StringBuilder buffer after writing to it instead of the input
string/char[] makes the code somewhat simpler.
* [corlib] Fix NSLogWriter.Write to take into account the index and count parameters.
CoreCLR allows reflection on methods with ByRef return types under certain conditions. The PR implementing it is https://github.com/dotnet/coreclr/pull/17639.
Mono already implemented most of it in the marshalling code but artificially blocked it in `ves_icall_InternalInvoke`. I changed the condition for the exception to match the condition in `emit_invoke_call` (marshal-ilgen.c). It's similar to the condition in CoreCLR, but it may not handle byref-like types correctly. It would have to fixed on both places if it turns out to be the case.
The remaining issue is that null references returned in ByRef are not checked and converted to correct exception. It should result in `NullReferenceException` with special message that doesn't get wrapped in `TargetInvocationException`. I put a TODO marker at a place where I think it should be handled, but it's a bit over my head to implement it.
/cc @vargaz
An icall declaration can now use the following attribute:
MonoDirectICallSymbolNameAttribute("MyNativeCFunction")
and if not already defined in icall-def.h and direct-icalls are used when
AOT compile the assembly, a direct call will use symbol defined in attribute
as the symbol for direct call. Using this attribute will also enable inlining
for the specific icall wrapper generating inlined direct icalls to external
defined native methods.
This feature is valuable when embedding the runtime and extend with icalls
added using mono_add_internal_call. By applying the above attribute, it is
possible to do AOT with direct-icalls and get static linked icalls without
the need to extend and rebuild cross compiler in the process.
* Add support for core SharedArrayBuffer.
- Add SharedArrayBuffer implementation
- Add SharedArrayBuffer constructors to TypedArray implemenations
* Add tests for SharedArrayBuffer.
- Refactored the test code to add specific test files for Core Bindings. This separates the tests into specific test regions.
- Moved bindings tests from the http tests to the core bindings tests.
* Cleanup debugging code.
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.
* Add JavaScript Core support for Function
* Fix compile
* Fix bindings tests
* Add Core Function tests
- TestFunctionSum
- Create a new Function with a body that returns the sum of two numbers
- call method `Call` on the sum Function
- TestFunctionApply
- Return the Math.min function from the Global Math space
- Call method `Apply` on the min Function to return the minimum value from an array.
* Use Core Function to determine streaming instead of calling InvokeJS which uses javascript Eval.
* Move nested array checking to managed code as per review comments.
- This removes the icall as per review suggestion.
* [wasm] Generate the pinvoke tables.
Put the default non-linked version of the table into version control, usable by the interpreter only build.
* Add a comment to the generated file.
Create a new data structure: MonoImageStorage.
It is an object that will have the responsibility for the raw data of a
MonoImage. It has a string key and a refcount that is used to share a
MonoImageStorage between multiple MonoImage objects.
The reason we need this is because the current MonoAssembly/MonoImage design is
broken for multiple domains and (more evidently) it will be broken when we add
AssemblyLoadContext support. The issue is that a MonoImage may be shared
between multiple domains (or ALCs), but it has a 'references' field which
points to a single other MonoAssembly.
This is a problem because the references of an image may be resolved
differently in different domains (or ALCs).
The eventual solution will be to stop sharing MonoImages based on path name (or
in the case of in-memory images based on a name made up from the address of the
byte blob).
However we still don't want to open the same data more than once (if we're on a
config where we don't have mmap, we malloc some memory and dump the data in
there - we don't want to do that multiple times for the same file).
So the solution is to create this MonoImageStorage object and make it possible
to share it based on path name, but don't give it any responsibilities except
for owning the memory. It doesn't know anything about metadata or assemblies
or any of that stuff - it just owns a chunk of memory and knows when and how to
free it.
This commit just adds the MonoImageStorage object and wires it up in MonoImage
loading. There should be no observable behavioral changes from this commit.
* [netcore] Implement RuntimeImports.RhBulkMoveWithWriteBarrier
* Add the actual write barrier to RhBulkMoveWithWriteBarrier
* Rename ves_icall_System_Runtime_RuntimeImports_Memmove_wbarrier to ves_icall_System_Runtime_RuntimeImports_RhBulkMoveWithWriteBarrier
Fixes 15 failures in System.Memory.Tests.
From: https://llvm.org/docs/LangRef.html
```
Furthermore, the semantics of the noalias attribute on return values are stronger than the semantics of the attribute when used on function arguments. On function return values, the noalias attribute indicates that the function acts like a system memory allocation function, returning a pointer to allocated storage disjoint from the storage for any other object accessible to the caller.
```
Think this probably helps LLVM reorder the method calls, telling it that allocating won't return a pointer to something else on the stack.
The aggregate modifiers container is owned by a MonoImageSet. The aggregate
modifiers may be shared by more than one MonoType that happen to need the same
modifiers. (Similar to how generic instantiations are shared)
When the image set is cleaned up the aggregate modifier cleanup will free the
types in the aggregate modifiers container (the call to
free_aggregate_modifiers in mono_metadata_clean_for_image).
With this extra call to free_aggregate_modifiers in mono_metadata_free_type may
cause the same memory to be freed twice.
Fixes https://github.com/mono/mono/issues/13775
* Add MONO_PATCH_INFO_LAZY_FETCH_ADDR and MONO_PATCH_INFO_TRAMP_ADDR.
These are int-based alternatives to MONO_PATCH_INFO_JIT_ICALL_ADDR + sprintf.
This clarifies work to remove the JIT icall hash tables that are used with:
MONO_PATCH_INFO_JIT_ICALL
MONO_PATCH_INFO_JIT_ICALL_ADDR
MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL
making it easier to make those enum-based, indexing a fixed size dense array.
As a related side effect, that could be achieved otherwise,
this fixes apparent leaks.
And clarify MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL slightly, by making
searches for it find one more hit.
That is, those three enums are mostly used with a fixed set of strings.
Except for as in this PR where they are used with indefinite strings.
The removal of the indefinite strings eases replacement of the fixed
set of strings with an enum.
* Bump MONO_AOT_FILE_VERSION.
* PR feedback: Remove unused code and historical commentary.
Also updated PR title with more verbose actual names of the new symbols:
`MONO_PATCH_INFO_TRAMPOLINE_FUNC_ADDR`
`MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR`
* Add missing break.
* [netcore] Fix Marshal test failures.
* [netcore] Add exclusions for System.Runtime.InteropServices.Tests.
* [netcore] Make an icall internal.
* Add more test exclusions.
* Address review comments.
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).
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
This test https://github.com/dotnet/coreclr/blob/1649da12db73c8c07513c9168cb30ec70c310063/tests/src/Regressions/coreclr/20452/twopassvariance.il
On mono we were ordering the list of implemented interfaces and shouldn't do this as it's described on ECMA-335 Section II.12.2.1 and II.12.2.2.
The ordering was removed on ilasm and some changes were needed on metadata either because it's not ordered anymore.
There were two bugs, one on ilasm and other on class initialization on mono.
### ILAsm ###
If we get the .exe generated by .net Framework it doesn't execute on mono without modifications because we ordered the implemented interfaces list by id. And doing that the order defined on source code is ignored.
If we get the .exe generated by Mono it doesn't execute on .net Framework because on IlAsm we order the list and loose the order defined on source code.
The interfaces on metadata before these changes on IlAsm were like this:
```
1: Fooer1 implements class IFoo<class Derived>
2: Fooer1 implements class IFoo<class Base>
3: Fooer2 implements class IFoo<class Base>
4: Fooer2 implements class IFoo<class Derived>
5: Fooer3 implements class IFoo<object>
6: Fooer3 implements class IBar<class Derived>
7: Fooer3 implements class IBaz<class Base>
8: IBar implements class IFoo<!0>
9: IBaz implements class IFoo<!0>
10: Fooer4 implements IQux
11: Fooer4 implements class IBar<class Derived>
12: IQux implements class IFoo<class Base>
13: IQux implements class IFoo<class Derived>
14: Fooer5 implements IQux
15: Fooer5 implements class IBar<class Derived>
16: Fooer6 implements class IBar<class Base>
17: Fooer6 implements class IFoo<class Base>
18: Fooer7 implements class IFoo<class Base>
19: Fooer7 implements class IBar<class Base>
```
And After the changes they follow the definition order which is the same order of IlAsm for .net framework and .net core.
```
1: IBar implements class IFoo<!0>
2: IBaz implements class IFoo<!0>
3: IQux implements class IFoo<class Base>
4: IQux implements class IFoo<class Derived>
5: Fooer1 implements class IFoo<class Base>
6: Fooer1 implements class IFoo<class Derived>
7: Fooer2 implements class IFoo<class Derived>
8: Fooer2 implements class IFoo<class Base>
9: Fooer3 implements class IBaz<class Base>
10: Fooer3 implements class IBar<class Derived>
11: Fooer3 implements class IFoo<object>
12: Fooer4 implements IQux
13: Fooer4 implements class IBar<class Derived>
14: Fooer5 implements class IBar<class Derived>
15: Fooer5 implements IQux
16: Fooer6 implements class IFoo<class Base>
17: Fooer6 implements class IBar<class Base>
18: Fooer7 implements class IBar<class Base>
19: Fooer7 implements class IFoo<class Base>
```
### Mono vtable layout ###
Internally when Mono computes the interface table for each class, it would previously sort the interfaces by `MonoClass:interface_id` which is a unique id assigned (roughly) in load order. This was incorrect because the order of the interfaces determines the final vtable for the class. This PR changes the interface table computation so that the interfaces of a single class are ordered in declaration order, following ECMA.
One consequence is that we can no longer use binary search with the interface id as the key to find out if a class implements an interface. We have to do a linear scan. On the other hand, we expect that the number of interfaces implemented by a single class is small in practice.
This is how the Vtable for Fooer1 and Fooer2 looks like after the changes:
```
*** Vtable for class 'Fooer1' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fd78681db20]
[O][001][INDEX 001] object:GetHashCode () [0x7fd78681daf8]
[O][002][INDEX 002] object:Finalize () [0x7fd78681dad0]
[O][003][INDEX 003] object:Equals (object) [0x7fd78681daa8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fd786503800]
[I][005][INDEX 000] IFoo:Gimme () [0x7fd7865038c0]
Packed interface table for class Fooer1 has size 2
[000][UUID 078][SLOT 004][SIZE 001] interface IFoo[Base]
[001][UUID 079][SLOT 005][SIZE 001] interface IFoo[Derived]
```
and
```
*** Vtable for class 'Fooer2' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fd78681db20]
[O][001][INDEX 001] object:GetHashCode () [0x7fd78681daf8]
[O][002][INDEX 002] object:Finalize () [0x7fd78681dad0]
[O][003][INDEX 003] object:Equals (object) [0x7fd78681daa8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fd7865038c0]
[I][005][INDEX 000] IFoo:Gimme () [0x7fd786503800]
Packed interface table for class Fooer2 has size 2
[000][UUID 079][SLOT 004][SIZE 001] interface IFoo[Derived]
[001][UUID 078][SLOT 005][SIZE 001] interface IFoo[Base]
```
This is how the VTable for Fooer1 and Fooer2 looks like before the changes, as you can see Packed interface table are the same in Fooer1 and Fooer2, so the behavior of both classes was the same:
```
Vtable for class 'Fooer1' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fcf3801d920]
[O][001][INDEX 001] object:GetHashCode () [0x7fcf3801d8f8]
[O][002][INDEX 002] object:Finalize () [0x7fcf3801d8d0]
[O][003][INDEX 003] object:Equals (object) [0x7fcf3801d8a8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fcf37c29880]
[I][005][INDEX 000] IFoo:Gimme () [0x7fcf37c29940]
Packed interface table for class Fooer1 has size 2
[000][UUID 076][SLOT 004][SIZE 001] interface IFoo[Base]
[001][UUID 077][SLOT 005][SIZE 001] interface IFoo[Derived]
```
```
Vtable for class 'Fooer2' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fcf3801d920]
[O][001][INDEX 001] object:GetHashCode () [0x7fcf3801d8f8]
[O][002][INDEX 002] object:Finalize () [0x7fcf3801d8d0]
[O][003][INDEX 003] object:Equals (object) [0x7fcf3801d8a8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fcf37c29940]
[I][005][INDEX 000] IFoo:Gimme () [0x7fcf37c29880]
Packed interface table for class Fooer2 has size 2
[000][UUID 076][SLOT 005][SIZE 001] interface IFoo[Base]
[001][UUID 077][SLOT 004][SIZE 001] interface IFoo[Derived]
```
[llvm] Fix llvm JIT.
<!--
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
-->
* Add cpu counter
* Fix windows build
* Make the counter just return current CPU usage as %
* Add Unix
* Fix unix build
* Some cleanup
* rename
* fixing some build errors
* some cleanup
* remove unused using
* more cleanup
* newline
* Address PR feedback
* more pr feedback
* More feedback
Signed-off-by: dotnet-bot <[email protected]>
Match Mono's behavior by changing the Auto character set to mean UTF-8 on non-Windows platforms (new behavior) and UCS-2/UTF-16 on Windows (current behavior).
Fixes#23464Fixesdotnet/corefx#32442
Impact of breaking change: It is highly unlikely that anyone is actively using current behavior since it is inconsistent with Mono and doesn't match any native system APIs on non-Windows platforms (they're all UTF-8 based).
We will need to update our documentation to reflect this updated behavior.
Signed-off-by: dotnet-bot <[email protected]>
The OnProcessExit was iterating over the s_contextsToUnload and calling
Unload on each of the contexts. However the s_contextsToUnload is a
misnomer, it contains all the contexts, both collectible and
non-collectible ones. So we were calling Unload on non-collectible
contexts too there. That resulted in InvalidOperationException being
thrown from the OnProcessExit.
This change fixes that by calling unload only on ALCs whose
IsCollectible returns true. It also renames the s_contextsToUnload to
s_allContexts.
Close#22902
Signed-off-by: dotnet-bot <[email protected]>
We want to avoid calling stackval_to/from methods. Also include the field address in the instruction stream. This makes static vtype field access 10x faster.
Refactor the code a bit.
[gsharedvt] Fix sizeof opcode
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.
Adds 5 quick checks, on prefix-tests tag:
* Build a basic file with mcs
* Build a basic file with Roslyn
* AOT an assembly
* LLVM AOT an assembly (loadedllvm)
* LLVM JIT an assembly (loadedllvm)
This should let us spot regressions affecting installed prefixes sooner
These console PInvokes are used in nearly every app. Omitting unnecessary SetLastError
will save us from generating marshalling stub for them.
Signed-off-by: dotnet-bot <[email protected]>
Also make cimag/creal macros for guaranteed inlining -- instead of passing structs by value.
And add spaces before parens to follow coding convention (which is designed
to ease low tech searches for entire words).
This was agreed to when the code was first ported to C++ but got dropped.
The compromise though was to put the defines relatively late to limit their impact.
In this case we relied on nunitlite to be compiled when the parent profile is compiled. That doesn't work however if we compile the child profile first (e.g. during a parallel make) since it'll
complain about missing nunitlite.dll.
We now compile nunitlite in the child profiles too even though we don't use it.
This is an alternative solution to what I tried in https://github.com/mono/mono/pull/5357 since I couldn't get it to work and this should be the easier fix.
It allows us to finally remove the `-i` (ignore errors) from the CI scripts and catch test assembly breakages in mobile profiles which we ignored before.
* fix test
* fix tests
* Fix ArgumentNullException empty ParamName
* System.Text.Tests.StringBuilderTests are fine
* fix BlockCopy test
* enable more tests
* Enable more tests
* address feedback
* [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
* [netcore] Add error checking for assembly version parsing, pass the full 32 bit value to managed code.
* [netcore] Implement RuntimeType.StructLayoutAttribute.
* [runtime] Implement RuntimeFieldHandle.GetValueDirect (), convert SetValueDirect () to handles.
* [netcore] Implement Assembly.GetFiles ()/GetForwardedTypes ().
* [runtime] Handle 'ARM' as a valid architecture in assembly name parsing.
* [netcore] Implement ParameterInfo.MarshalAsAttribute, AssemblyName.EscapedCodeBase.
* [netcore] Add exclusions for System.Reflection.Tests.
* [netcore] Update test exclusions.
* [netcore] Fix CustomAttributeExtensions.
* [netcore] Add a list of passing test suites.
* [netcore] Add a missing argument check.
* Update Object.cs
* Fix a few deficiencies in mono_path_filename_in_basedir.
The main one is that strstr is too loose.
Add tests.
Make it case insensitive on Win32 and allow some denormal input.
Note that case sensitivity is a function of file system, not
operating system, but a lot of code gets it wrong, so here does too.
Add more data to asserts.
Account for test reality -- filename is not absolute.
The Win32 code paths can be tested on Unix and vice versa
w/o compromise. See https://github.com/mono/mono/pull/13707
* Reduce testing per PR feedback.
* Edit/add comments.
This is an attempt to clarify and hopefully doesn't backfire.
* Try to make tests clearer, and stop skipping some oops.
* PR: Restore case insensitivity testing on Windows. Tweak a little bit.
* Include the .c file instead of .h to fix some builds.
It turns out that homebrew now has a package for the MinGW gcc-based windows
cross compiler which is awesome as it allows us to skip building MXE and use the
latest version of the GCC suite pre-packaged for Mac. This commit removes almost
all traces of MXE (except for `mxe.mk` itself, because I don't know if any bot
or external tool, whatever, use targets in it) and adds the following brew
packages to SDK bot provisioning as well as to the `provision-mxe` target of
Mono SDKs:
* mingw-w64
* xamarin/xamarin-android-windeps/mingw-zlib
The latter package builds a Windows version of zlib using MinGW and it comes
from Xamarin's own homebrew tap at https://github.com/xamarin/homebrew-xamarin-android-windeps/blob/f4cc90845ff1953800d8d71035566a12d9b7aa24/mingw-zlib.rb
Additionally, this commit adds a new `configure` flag: `--with-static-zlib=PATH`
which allows one to specify the static zlib archive to use when linking Mono.
The static archive supersedes the otherwise indicated or detected zlib. This is
the recommended mode of operation for MinGW builds as it avoids problems with
`zlib.dll` versions on the target machine.
* The `SimpleCollator` class now implements a new internal interface `ISimpleCollator`.
In `CompareInfo`, we reference it by that interface everywhere except `GetCollator ()`,
so we can `#if`-def it out.
Later on, we will use the linker to do this dynamically with some sort of conditional,
but even then the interface is required to limit references to the `SimpleCollator` type
to one single method.
* Add `Mono.Globalization.Unicode/SimpleCollator.cs` to `wasm_corlib.dll.exclude.sources`.
* `corlib/Makefile`: remove collation resources on WASM.
* Added new `[Category ("ManagedCollator")]` to the relevant tests.
* Revert "[System.Net.Http] Move NSUrlSessionHandler from xamarin-macios to mono (#13229)"
This reverts commit 5bf74a9954.
* [System.Net.Http] Move Mac/iOS specific HttpMessageHandler's to Xamarin.*.dll
We decided to move these types into Xamarin products since they can't be
used without the underlying infrastructure anyway.
* Bump API snapshot submodule
* [csproj] Update project files
* Add missing roslyn assemblies to mcs package makefile
* Remove deploy step for dynamic interface methods prototype since current roslyn has DIM
Roslyn picked up some new dependencies that I failed to add to a Makefile containing a list of its dependencies. This may fix some scenarios (not covered by CI) that result in csc and/or msbuild not working.
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).
* Removing FeedTasksPackageVersion from dependencies.props
* The corresponding metadata was removed in https://github.com/dotnet/coreclr/pull/22884
* Updating BuildTools, CoreCLR to preview4-03828-01, preview4-27528-71, respectively
* Adding a ! in String.Searching.cs
Signed-off-by: dotnet-bot <[email protected]>
* Add test for IncrementingPollingCounter
* Fix a bug in Increment calculation in IncrementingPollingCounter
* Remove setting DisplayName property since that's a private property for now
* fix comment
* Remove unused variables
Signed-off-by: dotnet-bot <[email protected]>
The python script now also extracts downloaded zips and `make xtest-%` is now able to consume these artifacts.
E.g.
```
make xtest-System.Collections.Tests COREFX_ROOT=/prj/corefx-repo
```
We still need COREFX_ROOT because of two missing files:
`CoreFx.Private.TestUtilities.dll` and `xunit.console.deps.json`
maybe I should just add them to our repo?
Also this PR fixes `RemoteExecutorConsoleApp` problems for `make xtest-%`
* [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
* Nullable: Int32
* remove restore and move nullable up front
* remove trailing \n after #nullable to make it easier to remove later
Signed-off-by: dotnet-bot <[email protected]>
* Initial implementatation of ALC enhancements
Add public constructor with name
Add Name property
Add Assemblies property
Add All property
Override ToString
Name Default and Assembly.Load(...) ALCs
Add AssemblyLoadContext30Extensions test
Signed-off-by: dotnet-bot <[email protected]>
* [interp] Extract the code pushing lmf in separate function
There is no reason to not optimize the code inside do_icall
* [interp] Remove dead code
Trace ips are filled in mono_handle_exception_internal
* In mono_threadpool_enqueue_work_item, if mono_runtime_invoke_checked fails,
still restore domain.
In mono_threadpool_enqueue_work_item, acknowledge with a comment but do not change
that mono_domain_set failing leads to returning success.
In mono_threadpool_enqueue_work_item, refactor for sharing code without loss
of efficiency or hopefully clarity.
* Keep this line duplicated:
`mono_runtime_invoke_checked (unsafe_queue_custom_work_item_method, NULL, args, error);`
Every caller was consistently forming the same name based on callinfo->name
and passing callinfo->func and callinfo->sig.
Pass callinfo instead and do the common work in mono_marshal_get_icall_wrapper.
This has the following side effects:
Do not form and free name when there is a cache hit. This seems like a nice optimization.
Allow name when there is a cache hit. This is unintended. We could assert if it is a problem.
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.
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 at `#C6` 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.
We cannot presume more than just "linux" or "osx" in our RIDs, because
if we want to enable --host vs --build, we can't detect the OS from
the runtime environment.
This is an okay compromise for now.
* Cleaning up the P/Invoke signatures for QPF and QPC to avoid marshalling and pinning
* Responding to PR feedback.
* Dropping support for low resolution stopwatch
* Removing BestFitMapping=false
* Removing unneeded unsafe declarations
* Addressing more PR feedback
* Fixing the pal_time header file
* Fixing the Unix P/Invoke signatures for GetTimestamp and GetTimestampResolution to return ulong.
* Fixing GetTimestampResolution to scale the result for HAVE_CLOCK_MONOTONIC
Signed-off-by: dotnet-bot <[email protected]>
When we switched to using the corefx System.IO.File implementation we also switched to an implementation that 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.
* Reconfigure bump for PR test
* Actually bump submodule this time probably
* Bump submodule
* Revert "Bump submodule"
This reverts commit b47679be10d3c38d40673cf73e0dc48a300318bc.
* Bump submodule
* Modify csi-test.csx to manually reference netstandard 2.0, because this is required for some reason
* Checkpoint: Test modifying csi.rsp instead of csi-test
* Git
* Update submodule
* Update submodule compiler path
* Remove binaries-new submodule
* Update to latest roslyn-binaries revision and update path in configure.ac
* Instead of having one `AppDomain.DoTypeResolve(object)` that checks at runtime whether
the argument is a `string` or a `TypeBuilder`, use two strongly-typed methods
`DoTypeResolve(string)` and `DoTypeBuilderResolve(TypeBuilder)`.
* Add both to the `corlib/LinkerDescriptor/mscorlib.xml`.
* Adjust the code in `appdomain.c` accordingly.
* Bump corlib version.
This is part of a larger on-going project to improve the linker logic.
The rationale behind this is that the new `AppDomain.DoTypeResolve(string)`
that is being called from `mono_domain_try_type_resolve_name()` should not
reference `TypeBuilder`, to allow the linker to remove some of the
`System.Reflection.Emit` types.
* [intrinsics] sync implementation with IL code
Before the intrinsic implemented
```
ldarg.0
ldarg.1
sizeof !!T
mul
conv.i
add
ret
```
now it implements
```
ldarg.0
ldarg.1
sizeof !!T
conv.i
mul
add
ret
```
`conv.i` and `mul` have been swapped. Also see https://github.com/mono/mono/pull/13609
* fix op_sext_i4 usage
[amd64] use 32bit variant of lea_membase for 32bit operations
Consider
```
xor %r15, %r15 // %r15 = 0x0
dec %r15d // %r15 = 0xffff_ffff
lea 0x1(%r15), %rdx // %rdx = 0x1_0000_0000 but should be 0x0
```
instead `lea 0x1(%r15), %edx` should be generated.
Fixes#13452Fixes#13597
* Remove the parsing, hashing, locking, allocations associated with JIT icall signatures.
Make them statically allocated, single-instanced at compile time, and almost
statically initialized.
Fix C++ and x86.
More x86 fix.
Fix ARMv5.
Undo tedious work to be redone instead of merged from old.
Put all signatures back, prepare for automated conversion.
Replace all the register_icall strings with:
my @a = ("double double",
"long long long",
"long long int32",
"double double double",
"ulong float",
"ulong double",
"long float",
"double int32",
"float float float",
"long double",
"object ptr int int32",
"double ptr",
"int int int ptr ptr ptr",
"int obj ptr",
"int obj",
"int ptr int int ptr object",
"int32 double",
"int32 int32 int32",
"int32 int32 ptr",
"int32 obj",
"int32 object ptr ptr ptr",
"int32 object",
"int32 ptr ptr ptr ptr ptr int32",
"int32 ptr ptr",
"obj ptr int",
"obj ptr",
"object int object object",
"object int object",
"object int",
"object int32",
"object object ptr ptr",
"object object ptr",
"object object",
"object ptr int int int int",
"object ptr int int int",
"object ptr int int",
"object ptr int ptr",
"object ptr int",
"object ptr int32",
"object ptr ptr int32",
"object ptr ptr ptr ptr ptr",
"object ptr ptr",
"object ptr",
"object",
"ptr int",
"ptr obj",
"ptr object int ptr ptr",
"ptr object int32 int32",
"ptr object ptr ptr",
"ptr object ptr",
"ptr object",
"ptr ptr int ptr",
"ptr ptr int",
"ptr ptr int32",
"ptr ptr ptr ptr",
"ptr ptr ptr",
"ptr ptr",
"ptr",
"uint32 double",
"uint32 ptr int32",
"void double ptr",
"void int",
"void int32",
"void obj ptr",
"void object object ptr",
"void object object",
"void object ptr int32 int32",
"void object ptr int32",
"void object ptr",
"void object",
"void ptr int int object",
"void ptr int object",
"void ptr int ptr",
"void ptr int",
"void ptr int32",
"void ptr object int32",
"void ptr ptr int",
"void ptr ptr int32",
"void ptr ptr ptr",
"void ptr ptr",
"void ptr",
"void ptr object",
"void",
);
while (my $line = <>)
{
if ($line =~ /register|mono_create_icall_signature/ && $line =~ /"/)
{
for my $from (@a)
{
my $to = "mono_icall_sig_$from";
$to =~ s/ /_/g;
$to =~ s/"//g;
$to =~ s/"//g;
$to =~ s/"//g;
$line =~ s/\Q"$from"\E/$to/;
}
}
print($line);
}
Remove whitespace from end of line.
Convert the strings to smaller arrays, of chars now,
that are scaled offsets into MonoDefaults, or -1 for ptrref.
Use smaller encoding.
fix merge
cleanup
* Larger representation that handles alignment.
* Try to undo external changel.
* Fix AOT.
* Fix code search and comments
* Restore warning in this PR.
* More ARM signatures.
* Change representation from pointer to offset.
Use sizeof for the special case ptrref.
Comments. Perhaps too much.
asserts. Perhaps too much.
A little bit more verbose/readable but essentially the same thing otherwise.
Perhaps too verbose.
* The initializer all-but-must be pointer-sized.
Even if the values fit in much smaller.
Add comments.
On obscure systems size_t is smaller than a pointer so
gsize or uintptr_t is required. Use gsize.
* Spaces before parens.
* PR: Use enum instead of offsetof.
Use may_alias some.
mono builds with -fno-strict-aliasing, but we had recent
aliasing problem (the enum operators with older g++)
and this looks a little hazardous
We could also have a separate integer or array of byte or array of integer or perhaps string
to resolve the aliasing.
integer: 16 values, 8 max -- could just use an int instead of this array business,
but the representation would be full with no room for expansion.
We are not wasting any/much memory here -- maybe one word per the 200 signatures,
because of sloppyness around any_size_array.
Work a little on dealiasing.
Comment some aliases and make obj/object, int/ptr, bool/boolean share values.
* tweak: Compute all the values once and then directly index small local array.
* Adjust comments to new reality.
Add comments explaining aliasing.
* Add casts to attempt to abide by strict aliasing rules.
* Updated Argument Helper param from list->collection since the parameter name is collection
* Updated exception message to use an out of range exception that doesn't explicitly reference a list
* Simplified if statements that verify if the index is out of range
* Updated if logic to be simplified using (uint)
* Updated exception handling to throw ThrowHelper.ThrowArgumentOutOfRange_IndexException() when the ExceptionArgument was 'Index'
Signed-off-by: dotnet-bot <[email protected]>
* Unexpected System.MethodAccessException is thrown for a method call of a class that implements a protected interface inside another interface.
```
public interface I1
{
protected interface T1
{
void M1();
}
protected class T2
{}
protected struct T3
{}
protected enum T4
{
B
}
}
class Test1 : I1
{
static void Main()
{
I1.T1 a = new Test2();
a.M1();
System.Console.WriteLine(new I1.T2());
System.Console.WriteLine(new I1.T3());
System.Console.WriteLine(I1.T4.B);
}
class Test2 : I1.T1
{
public void M1()
{
System.Console.WriteLine("M1");
}
}
}
``
Fixing this case Test1 implements I1<int> but can access methods from I1<object>
public interface I1<X>
{
protected interface T1
{
void M1();
}
protected class T2
{}
protected struct T3
{}
protected enum T4
{
B
}
}
class Test1 : I1<int>
{
static void Main()
{
I1<object>.T1 a = new Test2();
a.M1();
System.Console.WriteLine(new I1<object>.T2());
System.Console.WriteLine(new I1<object>.T3());
System.Console.WriteLine(I1<object>.T4.B);
}
class Test2 : I1<object>.T1
{
public void M1()
{
System.Console.WriteLine("M1");
}
}
}
* [interp] Fix instruction length
* [interp] Don't generate directly into linear code stream
Allocate each instruction into the mempool and link them together. At the end of code generation and after all potential optimisation passes, we will compact this code into its final form.
* [interp] Add support for branch relocations
For each branch instruction, we store in its data field the il offset that we are branching to. During the final code generation, we resolve all backward branches and add relocs for forward branches. These relocs are then resolved after all instructions have been emitted in the final code stream.
* [interp] Extract vararg call code in separate instruction
It requires a different instruction size and is extremely rare code.
* [interp] Fix backwards branch with large offset
We were adding an unsigned instead of subtracting.
* [interp] Fix line numbers
For each il offset that generated interpreter instructions we store the native offset, during the compaction phase.
* [interp] Fix seq points
We have to defer SeqPoint data creation during the compact generation phase, because that's when we have native offset information. We add a flags field to the interpreter instruction to store any relevant information coming from the compilation phase.
* [interp] Make verbose logging a bit nicer
We no longer have the native offset during the first IL instruction interation. Maybe we should bring back logging for the IL -> IR mapping during the compaction phase.
* [interp] Remove some dead code
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 #12940.
- Disable other failing tests (they are tests that are newly added, not regressions)
- Look for mono_pal_init() directly in the System.Native library
- [configure] Have libmono-native depend on libmono(-sgen) for the Android build
If this is not done, Android is not able to resolve mono symbols that are used in mono-native (e.g. mono_add_internal_call_with_flags), and will refuse to load the library with 'cannot locate symbol' errors
[llvmonly] Add gsharedvt in wrappers to calls which could go to the interpreter.
Fixes https://github.com/mono/mono/issues/13463.
<!--
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
-->
* Enable MSVC objects on LLVM >= 6.00
* Always used PIC relocation-model on Windows x64 due to LLVM problem with
static triggering incorrect ADDR32 relocation entries in 64-bit objects.
* Add CodeView symbol format instead of DWARF for Windows x64.
* Fix LLVM outfile when doing static link to not end up in temp directory.
* Only add /DEFAULTLIB when using MSVC and not doing static compile. For
static compile the needed libraries must be added when objects get's linked
and since the needed libraries are c-runtime libraries, should be transparent
for most applications consuming the object files.
When logic moved from winsetup.bat into an msbuild task that changed the
console output of winsetup.bat causing problems for genconst to find
MONO_VERSION and MONO_CORLIB_VERSION. There was also a potential problem
where winsetup.bat couldn't find msbuild.exe if not included in PATH.
This fix makes sure winsetup.bat detect and setup a full msbuild environment
before running msbuild.exe. It also change genconsts to look at the generated
config.h for the correct values of MONO_VERSION and MONO_CORLIB_VERSION that
will be used by the runtime builds.
[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
* ```
interface I1<T>
{
sealed protected void M1()
{
System.Console.WriteLine("M1");
}
}
interface I3<T> : I1<T>
{}
interface I2<T> : I3<T>
{
static void Test(I2<int> x)
{
x.M1();
}
}
class A : I2<int>
{
static void Main()
{
I2<byte>.Test(new A());
}
}
```
When a interface implements another interface and they are generics, we don't need to check the datatypes of generics, we only need to check the inheritance.
Fixes 13467
* Adding test.
* Using the getter functions
* Initializing klass->interfaces/interfaces_count.
* Update mono/metadata/class.c
Co-Authored-By: thaystg <[email protected]>
* Fixing side effect on dim-simple.il
1. aot-compiler: don't leak `MonoCustomAttrInfo`
2. aot-runtime: don't leak sigs when decoding wrapper references. All of these cases we decode a sig (which uses malloc), and then call some method that immediately calls `mini_get_underlying_signature` which dups the sig, so the one from the decode isn't needed anymore.
* namespace Application
{
public interface I1 { void M1() { System.Console.WriteLine("Unexpected!!!"); }}
public interface I2 : I1 { void I1.M1() { System.Console.WriteLine("I2.I1.M1"); }}
public interface I3 : I1 { void I1.M1() { System.Console.WriteLine("I3.I1.M1"); }}
public interface I4 : I1 { void I1.M1() { System.Console.WriteLine("I4.I1.M1"); }}
class Test10 : I1, I2, I3, I4 { public void M1() { System.Console.WriteLine("Test10.M1"); } }
class MainClass {
public static void Main(string[] args)
{
I1 var = new Test10();
var.M1();
}
}
}
The interface method M1 is overridden at I1, at I2, at I3, at I4. The class Test10 overrides method M1 so regardless of having methods overriden in interface, the method of the class should be priority in this case. And then I remove the conflicts because there is not a conflict anymore.
[aot] force v7 on arm when using LLVM on iOS
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
* [runtime] Default llvm to self-init
Now the init code is behind llvm_plt_init. Setting
--aot=llvm-plt will bring back the legacy llvm+plt behavior
* [llvm] Mark managed methods no-inline by llvm
* [runtime] Clean up self-disabling machinery
* [llvm] Skip self-init on cctors
* [runtime] Always make ctors call their cctors
* [runtime] Improve mono_print_unwind_info, add cases
* [runtime] Fix too-early eager calling of cctors
We emitted all of the lazy checks and init around a specific static
method, but still were initializing it when we initialized methods
that access it. This made static cctors run before they were supposed
to.
The problem was that the call site here has method == NULL, because
we don't compute it. That's expected, as we don't compute the method
along this path.
This initial "&&" looks like it was supposed to avoid calling the method
on a null MonoMethod reference. This preserves that, while fixing the
control flow issues.
* [runtime] Associate init_method native code with MonoMethod
* [runtime] Future-proof against aot init wrapper subtype mixups
* [runtime] Fix goto in AOT-init change for c++
* [runtime] Move docs for llvm-disable-self-init into runtime
* [runtime] Fix bitcode, remove unneeded wrapper around init icall
* [llvm] Include global prefix in init name
* [comment] Describe debugging usage of llvm self-init disable flag
* [aot] Consolidate mangler string append lines
* [llvm] Make self-init documentation changes
* [llvm] Rename self-init funcs, mini_llvmonly_ to mini_llvm_
* [runtime] Enable inlining for methods without init
* [netcore] Avoid casting to generic parameters in gen-xunit-runner.
* [netcore] Make the build-/run- targets more generic, add support for more test suites.
* remove NIE from Exception
* [netcore] Convert gen-xunit-runner to use roslyn for code generation instead of codedom.
* [netcore] Add check target to run all test suites.
* Reduce number of classes in winaot mscorlib.
Winaot profile should be a Windows AOT friendly profile close to mobile
and consoles. At some point it was set to include the full net_4_x that
cause problems on none desktop platforms. This fix reduce the set to only
include classes similar to mobile and console profiles.
* Reverting changes to TimeZoneInfo test when reducing classes in corlib winaot.
* Move SafePasswordHandle to win32_build_corlib profile.
* Excluded some additional none Windows sources from win32_build/winaot profile.
Utf8String is an experimental type that is string-like (heap-allocated, immutable, variable-length, null-terminated) but whose inner representation is UTF-8, not UTF-16.
This is a skeleton implementation of the basic API shape. The ecosystem of APIs has not yet been built around it. All Utf8String-related code is currently surrounded by ifdefs to allow easy identification and removal from release branches.
Signed-off-by: dotnet-bot <[email protected]>
* '''
interface I1
{
sealed void M1()
{
System.Console.WriteLine(“M1”);
}
}
interface I2 : I1
{
static void Test<T>(T x) where T : I2
{
x.M1();
}
}
class A : I2
{
static void Main()
{
I2.Test(new A());
}
}
'''
When an interface implements a Sealed method, this method is not virtual, so it will not be available at vtable. But in the IL the call is a virtual call, but in this case we don't need to search at vtable.
Fixes#13466
* Change IL test.
Types like sbyte, ushort, and other 8-bit / 16-bit elemental types are now directed down the fast vectorized code paths that previously only byte and char were eligible for.
Signed-off-by: dotnet-bot <[email protected]>
* [Coop] Convert ves_icall_System_Globalization_CultureData_fill_number_data.
Tested by running this program:
```
class A
{
public static void Main()
{
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.CompareInfo);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.AMDesignator);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.DateSeparator);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.DisplayName);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.EnglishName);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.IsNeutralCulture);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.IsReadOnly);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.LCID);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.Name);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.NativeName);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalDigits);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.Parent);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.TextInfo);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName);
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName);
}
}
```
which covers some but not all of the data.
* - Use gint32 instead of int when interfacing directly with managed code.
Indirectly would be passing the parameter off to additional native code; compiler
can often silently convert.
int will always be 32 bits.
- Expand tedious error-prone code instead of using preprocessor to automate.
- Add comments that the native and managed types must match.
- Rename the managed type to match the native type (not necessary,
but might as well have them grep perfectly coincidentally.).
- Sort the fields and some of their uses for easier reading.
It might be infinitesimally faster to line up the order
with the native structure, to synchronize access order (i.e. sequential access to all).
- Restore parameter name to number_index.
- Validate, with assert, number_index maximum not just minimum.
* Restore the group_sizes logic.
group_sizes is an array of up to two integers, -1 terminated.
* restore const
* Add comment explaining the ordered -- sorted alphabetically.
I was looking over the new Range methods on `Collection<T>` and it occurred to me that for all existing methods, parameter validation is done in the *public* methods before calling the *protected virtual* methods. This changes the new Range methods to do the same.
Signed-off-by: dotnet-bot <[email protected]>
* Only do clean/rebuild when an assembly changed.
* Add wrappers for different full AOT build configurations.
* Make scripts callable from different working directory.
Winaot profile should be a Windows AOT friendly profile close to mobile
and consoles. At some point it was set to include the full net_4_x that
cause problems on none desktop platforms. This fix reduce the set to only
include classes similar to mobile and console profiles.
This all stems from ECMA 335, 7.1.1:
> The CLI itself shall treat required and optional modifiers in the same
> manner. Two signatures that differ only by the addition of a custom
> modifier (required or optional) shall not be considered to match. Custom
> modifiers have no other effect on the operation of the VES.
This rule means that when comparing signatures, we have to treat two types that
differ only in their custom modifiers as distinct. In particular, we have to do
this when comparing signatures in order to fill in the vtable for a class. And
moreover, we have to concatenate custom modifiers when doing generic
instantiation. If a method in a generic type has signature `T modopt(IsConst)
Method()` and we instantiate T with `int32 modopt(IsLong)`, we are expected to
produce the signature `int32 modopt(IsConst) modopt(IsLong) Method()` (with the
custom modifiers on `int32` in that order).
So this PR implements the following operations:
1. custom modifier appending during `mono_metadata_type_dup_with_cmods`
2. custom modifier-respecting comparison in `do_mono_metadata_type_equal`
To do this, we actually have to introduce a second representation of custom
modifiers: in the normal representation, all the cmod type specs come from a
single image. Whereas now, due to inflation of signatures, we can have a mix
of modifiers from different images. So in the MonoAggregateModContainer
representation, we pair each typespec token with the image in which it is to be
resolved.
We keep the old representation (a single image to resolve the entire set of
typespec tokens) because it's natural when you're just reading from a single
image. Also this representation is part of the embedding API.
---
### But that's not all ###
It is possible for generic parameters of a generic class to appear in the
_custom modifiers_ of a type in a method signature. For example:
```
T modopt(Nullable`1<T>) Method ()
```
In this case, when we inflate this signature, we need to inflate not only the
return type, but also the modifiers on a return type.
That means our old aggregate representation (where each modifier is a pair of a
MonoImage and a typespec token) is inadequate: we can inflate a signature and
get a custom modifier that doesn't appear as a typespec in any table of any
existing image.
This is the same situation as generic instances: as a program runs, it creates
generic instances that are not part of the source code. So we solve it the
same way as with generic instances.
Our new `MonoAggregateModContainer` representation is a pointer into memory owned
by a MonoImageSet that contains an entire MonoType for each custom modifier.
The invariant is that the aggregate modifier container is allocated from a
mempool of a `MonoImageSet` that includes the images of all the modifiers.
In general, when inflating, we first create a provisional candidate
MonoAggregateModContainer on the stack and then look it up the image set that
should own it and then look for a "canonical" mod container in the
`MonoImageSet:aggergate_modifiers_cache`
---
Also had to bump the AOT image format, which now always reads back in using the aggregate representation.
---
This should address #10564, #10565, #12422, #10945 (again), #6936, and the parts of #11350 that **don't** deal with arrays.
---
TODO:
- [x] Add some representative test cases to this PR.
- [ ] Modify our acceptance tests to run the various disabled Roslyn tests.
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
```
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
-->
* Refactor EventCounter and add PollingCounter
* Add PollingCounter
* Add IncrementingEventCounter and IncrementingPollingCounter
* Add MetaData API to Counters
* Some more refactoring
* removing commented out code
* some more cleanup
* build fix and addressing some PR comments
* Addressing PR feedback
* use StringBuilder to generate metadata string
Signed-off-by: dotnet-bot <[email protected]>
* Move drawing types for XI/XM/wasm/orbis/unreal to System.Drawing.Common
For XI/XM they were in Xamarin.iOS.dll/OpenTK-1.0.dll before.
For wasm/orbis/unreal we remove System.Drawing.dll from the profiles and
add the types to System.Drawing.Common.dll instead to align with the other
mobile profiles (only "net_4_x" and "build" still have System.Drawing.dll).
* Bump API snapshot submodule
* [csproj] Update project files
Replacing this with a pattern that is easier to statically analyze. We use the GetType/GetMethod/CreateDelegate pattern in several places already.
Signed-off-by: dotnet-bot <[email protected]>
When the configure checks were ported from configure.cmake in corefx
a couple of mistakes happened:
- Using AC_TRY_COMPILE instead of AC_TRY_LINK:
CMake's check_c_source_compiles() function compiles *and* links while
AC_TRY_COMPILE only does the former. This hides potential linking issues
which should fail the configure check.
- Using CFLAGS="-Werror -W....":
This works in CMake but autoconf always appends the previously defined
CFLAGS and since we set e.g. `-Wno-undefined` some configure checks
would fail due to an unrelated warning being treated as an error.
We need to only promot specific warnings to errors instead.
While looking at this I also found that we were setting CFLAGS after
we already AC_SUBST() it, we need to do this very close to the end of configure.ac.
Moved some code into that last block.
Finally, Android has special cases for sendfile and arc4random_buf where
they're defined in the header but aren't actually there for certain API profiles.
For now we disable arc4random_buf on Android and add a special check for sendfile.
* Fix sendfile with 6 parameters being misdetected
We need to make sure to actually prevent the implicit prototype since
in this case sendfile with different set of parameters actually exists
so the linker wouldn't fail.
Also fixed a few other cases of wrong configure checks due to missing headers.
* Move GSS checks into the Mono.Native checks section
This allows us to have a 1:1 mapping of the checks from configure.cmake
* [debugger] Fixing two crashes while debugging an Android app.
-> 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
This PR adds missing System.Drawing converters thus it completes NS2.1 support (as of today) for all profiles except macOS\IOS specific ones: monotouch, tv, watch, xammac, xammac_net_4_5.
* [runtime] Add a few new m_class inline functions.
* [netcore] Implement Array.IndexOf ().
* [netcore] Implement RuntimeHelpers.PrepareMethod ().
* Add error checks to RuntimeHelpers.GetUninitializedObject ().
* Fix some type attributes.
* Fix some TypedReference special cases.
Upstream must have rewritten, because the runtime checks were
replaced with the (not good for Mono) ifdefs.
Not throughly tested, but unbreaks build locally; waiting for CI
to come back with more results.
If it works, could someone get this upstream?
* DynamicRoleClaimProvider to help with legacy role management in web forms
* Added AppDomainManagerAssembly, AppDomainManagerType, and PartialTrustVisibleAssemblies
properties to AppDomainSetup. They don't do anything, but having them there
helps lessen the amount of change in refsrc System.Web.
This refactoring is limited to ASCIIEncoding at the moment, but it can easily be applied to UTF-8 / UTF-16 / UTF-32.
High-level changes:
- Fallback logic has been split from the fast-path, improving performance of GetBytes and similar routines.
- All of the plumbing of when to invoke the fallback logic and how to manage leftover data has been moved into the base class.
- Almost all of the logic except for the fast-path is now written in terms of verifiable code (Span and ReadOnlySpan).
- Minor bug fixes in EncoderNLS.Convert (see https://github.com/dotnet/coreclr/issues/23020).
Signed-off-by: dotnet-bot <[email protected]>
threads: set mutex PRIO_INHERIT in attribute
When running multiple threads on a linux-rt kernel, with different priorities, the lack of priority-inheritance
makes the kernel make wrong scheduling choices.
This commit changes the system-wide mutex initializers.
This change protects our system against unexpected latencies in higher priority threads.
<!--
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
-->
Currently Task has a stack depth check that avoids stack overflows on very deep stack continuation chains, but it only applies to Task.ContinueWith, not to other kinds of continuations. This changes that to have it apply to all.
As part of this, this also deletes the current StackGuard type used to achieve the check. The type was meant to avoid expensive calls to check where we are on the stack, but now that we're using TryEnsureSufficientExecutionStack, it's actually faster to just call that rather than access the current StackGuard from a ThreadLocal. This then also cleans up the call sites nicely, as they no longer need finally blocks to undo the increment performed on the StackGuard.
Signed-off-by: dotnet-bot <[email protected]>
* [netcore] Implement MethodBody using internal Runtime* classes. Use the mono version for ModuleHandle.
* [netcore] Reflection fixes.
* Address review comments.
* [netcore] Implement RuntimeHelpers:GetUninitializedObject ().
* [netcore] Implement the Type::GetMethod () overload which has a genericParameterCount parameter.
* [netcore] Implement Thread.OptimalMaxSpinWaitsPerSpinIteration.
* Revert a change to fix a test failure.
* [netcore] Implement Marshal:GetExceptionForHRInternal ().
* [netcore] Implement GC:GetSegmentSize ().
* [runtime] Allow pointer type members in typed references.
* Added new Range Manipulation APIs for Collection<T> which propogate up to ObservableCollection<T>. AddRange, InsertRange, RemoveRange and Replace Range
Signed-off-by: dotnet-bot <[email protected]>
* Updated index out of range exception check to be a single comparison
Signed-off-by: dotnet-bot <[email protected]>
* Updated foreach to use T instead of var
Signed-off-by: dotnet-bot <[email protected]>
* Adding braces on for loop
Signed-off-by: dotnet-bot <[email protected]>
* Added ReplaceItemsRange API and updated ReplaceRange to invoke the protected method
Signed-off-by: dotnet-bot <[email protected]>
* Remove ternary operator from invocation as it is the same as inputing items.Count
Signed-off-by: dotnet-bot <[email protected]>
* Updated RemoveItemsRange to prevent int.MaxValue overflow errors
Signed-off-by: dotnet-bot <[email protected]>
* Updated RemoveItemsRange to properly remove each item and not just the index items
Signed-off-by: dotnet-bot <[email protected]>
* Added ArgumentOutOfRangeException exception in RemoveRange if the count is less than 0
Signed-off-by: dotnet-bot <[email protected]>
* Updated RemoveRange invocation of RemoveAt to use index instead of i, because the array changes with each iteration of the for loop and will cause side-effects which may include index out of range exceptions. This needs to be index because as the array shrinks the index is always at the correct position.
Signed-off-by: dotnet-bot <[email protected]>
* Updated RemoveAt->RemoveItem. This change removes redundent validation checks that happen using the RemoveAt API. RemoveItem gives us direct access to invoke the command
Signed-off-by: dotnet-bot <[email protected]>
* Updated InsertItemsRange to simplify the expression and added performance improvements. If the underlying `items` is using List<T> we should use it's InsertRange method since it is optimized, othersie we use InsertItem
Signed-off-by: dotnet-bot <[email protected]>
* Added new RemoveRange validation check to see if the resulting range (index + count) > items.Count and if it is true throw ArgumentException
Signed-off-by: dotnet-bot <[email protected]>
* Removed (Int64) cast statements from RemoveItemsRange when checking for overflow errors
Signed-off-by: dotnet-bot <[email protected]>
* InsertItemsRange API now checks if the underlying items.IsReadOnly first then collection == null
Signed-off-by: dotnet-bot <[email protected]>
* Simplified the RemoveItem logic since we have more robust validation
Signed-off-by: dotnet-bot <[email protected]>
* Optimized RemoveItemsRange to call the list.RemoveRange if the items is of type List<T>
Signed-off-by: dotnet-bot <[email protected]>
Several of the corefx interop sources uses the Unicode names of Win32 symbols.
Our current probing implementation on Windows will test the given name last
when nomangle is not provided (default). On Windows that will be a large number
of probes due to old stdcall name mangling rules. Fix makes sure we first test
the symbol against its charset and the given symbol, before trying the stdcall
name mangling rules. Will reduce the probing a lot on Windows for corefx Win32
interop classes.
* [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
Warning (at least on Windows) due to unamed struct:
C4201, nonstandard extension used : nameless struct/union
Since the header can be consumed by embedders this warning should be
disabled.
* Use platform specific implementation of GetCurrentProcessId
directly in shared location instead of relying on runtime export
* Move GetCurrentProcessId to Interop class
* Update ES_BUILD_STANDALONE build
Signed-off-by: dotnet-bot <[email protected]>
* Created SR and Strings helpers as refsrc resources are
missing / incomplete
* Moved existing tests into the Test folder
* Moved old DBLinq code into tools/sqlmetal as there are no other
alternatives.
* Fixing the float/double parsing logic to handle exponents that are too large/small
* Fixing the debug assert to use >= and <=
* Fixing the max exponents to be +1 to match what scale uses.
Signed-off-by: dotnet-bot <[email protected]>
* Clean up some string.Format usage
Mainly changes some string.Format usage to be SR.Format when working with resource strings. Also cleans up a few asserts that were using string.Format.
* Address PR feedback and clean up src
* Address more feedback
* Update src/System.Private.CoreLib/shared/System/Type.Enum.cs
Thanks.
Co-Authored-By: stephentoub <[email protected]>
Signed-off-by: dotnet-bot <[email protected]>
* Fix ValueStringBuilder.EnsureCapacity to call Grow correctly (#35746)
Call to EnsureCapacity may result in invalid buffer size being
allocated.
* Update ValueStringBuilder.Grow to prevent misuse (#35746)
Updated name of the argument to make it clearer on the call-site also
added summary co clearly state the behavior of Grow.
Signed-off-by: dotnet-bot <[email protected]>
* Update dependencies from https://github.com/dotnet/core-setup build 20190301.13
This change updates the following dependencies
- Microsoft.NETCore.App - 3.0.0-preview4-27501-13
- Microsoft.NETCore.DotNetHost - 3.0.0-preview4-27501-13
- Microsoft.NETCore.DotNetHostPolicy - 3.0.0-preview4-27501-13
* Remove workaround for System.Runtime.CompilerServices.Unsafe
* Update dependencies from https://github.com/dotnet/core-setup build 20190302.8
This change updates the following dependencies
- Microsoft.NETCore.App - 3.0.0-preview4-27502-8
- Microsoft.NETCore.DotNetHost - 3.0.0-preview4-27502-8
- Microsoft.NETCore.DotNetHostPolicy - 3.0.0-preview4-27502-8
* Update dependencies from https://github.com/dotnet/core-setup build 20190303.9
This change updates the following dependencies
- Microsoft.NETCore.App - 3.0.0-preview4-27503-9
- Microsoft.NETCore.DotNetHost - 3.0.0-preview4-27503-9
- Microsoft.NETCore.DotNetHostPolicy - 3.0.0-preview4-27503-9
* Update dependencies from https://github.com/dotnet/core-setup build 20190304.10
This change updates the following dependencies
- Microsoft.NETCore.App - 3.0.0-preview4-27504-10
- Microsoft.NETCore.DotNetHost - 3.0.0-preview4-27504-10
- Microsoft.NETCore.DotNetHostPolicy - 3.0.0-preview4-27504-10
* Don't include EventRegistrationToken on Unix
This type was accidentally duplicated between CoreLib and contracts.
Suppress that for now since we're detecting the duplication in the shared framework.
Make a fix in the shared items to restore the condition on this type.
Signed-off-by: dotnet-bot <[email protected]>
* The default `HttpClient` constructor now calls a static method `CreateDefaultHandler()`;
we provide a platform-specific implementation of it.
* Replaced `HeaderUtils` with `PlatformHelper` and removed the `LEGACY_HTTPCLIENT` conditional.
* Added a new `socketshandler.sources` file to keep the sources in one place.
* Use a reflection check in the tests instead of the `LEGACY_HTTPCLIENT` conditional.
* This allows us to also get rid of the `SOCKETSHTTPHANDLER` define.
* [safepoint] Use LLVM pass to insert safepoint
This is to avoid safepoints to stop optimizations from happening.
* [safepoint] Use LLVM pass to insert safepoint
This is to avoid safepoints to stop optimizations from happening.
* fix error: emit_gc_safepoint_poll does not return anything
* Revert partial 4150f06f8621f2f2918e3bd747bf80a0f0f8c9c6
* Fix build
* [runtime] Add mono_threads_state_poll to preinited icalls
* [runtime] Adding back in safepoint icall skip code
* Revert mini.c to 100f422
* [runtime] Add missing deref to safepoint poll
* [runtime] Make safepoint functions have WeakODR linkage
They can be used with native line endings.
We now have a shared folder with the dotnet repos and they have CRLF normalization enabled.
This difference leads to conflicts while applying changes from the dotnet repos to mono.
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.
- The purpose of this is to be able to respond to CI incidents faster for instance specific engine versions when JavaScript engines do not update/install correctly.
- This will install from a forked version of the jsvu repo: https://github.com/GoogleChromeLabs/jsvu
- Forked version rests here: https://github.com/kjpou1/jsvu/tree/mono-wasm
- The forked version removes the Node >= 10.0 dependency but brings in the newest 1.4.0 version modifications.
- This should be temporary until we get another solution i.e. a managed version of the engine updater.
* 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
* [interp] avoid multiple transformations
* [interp] remove delegate hack for method_ptr=imethod case
it isn't needed anymore
* [interp] ensure initialized fields of a class retrieved from wrapper data
* [fullaot mixed] add test for specific mixed mode scenario
* [interp] remove assertion, it does not take into account multiple threads transforming the same method
* [interp] avoid non-lazy compilation of delegate if interpreter is involved
* [fullaot-mixed] disable on i386
* [interp] propagate errors on delegate init
* fix c++ build
* [tests] improve return codes
* error only for dynamic methods
* [fullaot-mixed] disable test on coop
* Fix System.Math regressions brought on by PowerPC JIT optimizations
* While frin[.] does do rounding, the semantics are slightly
different enough from the BCL that it subtly breaks, as
seen by some tests. Ceil/Floor/Trunc are fine, however.
Perhaps the sysmath.c version can be translated to asma.
* Fix typo where signed long comparison for isel was using
an unsigned comparison.
Add a test for this in the JIT regression check.
* Link against (not fd.o) libbsd for System.Native on AIX
The way we link the library by default will allow some unresolved
symbols. These will get resolved to the runtime when loaded by it.
However, flock isn't in AIX libc, and the native library needs it.
This doesn't seem to be a problem on AIX, but on i libbsd doesn't
seem to be in the dependency chain, so it errors out when you use
it. The workaround is to link libbsd (not the freedesktop.org one)
into the library. According to dump, it seems it has its own copy
of ioctl and fnctl, but they seem benign according to objdump and
don't seem to affect System and corlib tests I've ran to check it.
* [runtime] Add unmanaged fast-path for mono_class_is_assignable_from
Our managed code has a fast path for this that checks if the two types
are the same. The unmanaged calls here always falls back on the slow path.
This leads to a latency that is pretty observable during
array_set_value_impl calls.
* [runtime] Make faster already-pinned nullable init path
* [runtime] Expose non-handle-allocating object_handle_isinst_mbyref
* [runtime] Use MONO_ENTER_NO_SAFEPOINTS for array_set_value_impl
* [interp] Remove some duplicated code
* [interp] Optimize type checking for interfaces
Mainly to avoiding handles for common scenarios. Makes type checking for common interfaces 10x faster.
* [interp] Optimize type checking for common classes
Mainly to avoiding handles for common scenarios. Makes type checking for common classes 10x faster.
This reverts commit b740313aa5.
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.
* [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
* [csproj] Update project files
* Removing the InsertVector128 and ExtractVector128 overloads that take an address from S.P.Corelib
* Removing the ExtractStore and InsertLoad tests.
* Fixing the PacketTracer test to use the appropriate Extract/InsertVector128 overloads
* Removing the JIT support for the Extract/InsertVector128 overloads that take an address.
Signed-off-by: dotnet-bot <[email protected]>
* [monodroid] Use CoreFX to fill in reference stubs for System.Drawing types that are currently 'forked' from Mono into Mono.Android.dll
The list of localy implemented System.Drawing types: https://github.com/xamarin/xamarin-android/blob/e0da1f152de84c4cc39983f2fda775ec98c08250/src/Mono.Android/Mono.Android.csproj#L311-L325
* [netstandard] Update for Mono.Android change
* Bump reference assemblies to include Mono.Android update
* Use System.Drawing.Common to find moved types in monodroid case for netstandard facade
* Bump API snapshot submodule
* [csproj] Update project files
a IDispatch class interface. this is being done
to ensure WinForms consumers can interact with
COM based controls.
Signed-off-by: dotnet-bot <[email protected]>
Continuations created while the debugger is attached or certain EventSource events are enabled end up getting wrapped in an extra ContinuationWrapper object that carries some additional information. DumpAsync currently isn't unwrapping these but should. This just teaches it to look for a known field name so that it can "see through" these wrappers while following async "stacks".
Signed-off-by: dotnet-bot <[email protected]>
- Thread.ExecutionContext needs to return ExecutionContext.Capture() to public callers.
- Fix restoring of culture to be inside of the ExecutionContext callback where applicable
Signed-off-by: dotnet-bot <[email protected]>
* Move Thread to shared CoreLib
* Remove all local variables from Thread in shared code
* Remove duplicate checks
* Port back CoreRT changes needed for shared code
* Fix missing culture initialization in ThreadStart()
* Adjust for shared WaitHandle
Signed-off-by: dotnet-bot <[email protected]>
* Cancel sync IO on Windows when aborting thread.
Using CancelIO/CancelIOEx or CancelSynchronousIo on a thread that is moving
into a suspended state can cause these calls to hang (they shouldn’t but
have been observed to be the case). Fix does the cancel of sync IO after
the aborted thread has been resumed, but before releasing suspend locks
making sure thread won't be suspend again until after cancel IO call has
completed.
* Add tests aborting blocking socket and file IO on Windows.
* Fixed the Attach() test which required a free port to attach.
* Added test for incorrect events behavior when VM is started with suspend
* Bump API snapshot submodule
* [ppc] Optimize floating point performance in the JIT sqrt/sqrtf/abs
* [ppc] Integer Min/Max inlining wiht POWER5 isel instruction
Compresses a function call down to two instruction, for both signed
and unsigned, long and int. Needs to check for POWE5 though, and I
don't know the effects of this on ppc32. FP version using fsel is
also desirable, but not in the scope of this commit.
* [ppc] Check for POWER5 compatible CPU before using isel
* [ppc] Don't use long min/max inlining for ppc32
Other 64-bit operations are marked for ppc64 only.
* [ppc] also ifdef that out for ppc32 too
* [ppc] Rounding function optimizations
* [corlib]: Use `Guid.NewGuid()` implementation from CoreFx.
The corefx implementation of `Guid.NewGuid()` uses the internal
`Interop.GetRandomBytes(byte*, int)`, which uses `RNGCryptoServiceProvider`
directly without using `CryptoConfig`.
* [csproj] Update project files
* Rename Guid.MonoTouch.cs -> CommonCrypto/Guid.cs.
* Initial support for Fuchsia
Compile like this:
if you have Zircon installed, with the prebuilts on "../zircon", use this to compile:
CC="`pwd`/../zircon/prebuilt/downloads/clang/bin/clang-9 -nostdlib -O2 -g -fdebug-prefix-map=/cvs/fuchsia/zircon=. -finline -fno-common -ffunction-sections -fdata-sections -no-canonical-prefixes -march=x86-64 -mcx16 --target=x86_64-fuchsia -fPIC -D_ALL_SOURCE=1 -DENABLE_DRIVER_TRACING=1 -fasynchronous-unwind-tables -fno-omit-frame-pointer -std=c11 -I`pwd`/../zircon/build-x64-clang/sysroot/include/ -I`pwd`/../zircon/system/public" LDFLAGS="-L`pwd`/../zircon/build-x64-clang/sysroot/lib/ -L`pwd`/../zircon/build-x64-clang/sysroot/debug" ./configure --host=x86_64-google-fuchsia
* Use HOST_FUCHSIA rather than TARGET_FUCHSIA
We can get the the OS name similar to the architecture from the value that is used by the runtime for DllMaps.
Cached the values into static fields so we only need to do the runtime icall once.
Added all the existing OS names recognized by DllMap to RuntimeInformation.
This also allows us to mark some corlib/System tests that hang the runtime on AIX as non-working.
* Make BitOps public
* Update name to BitOperations
* Change namespace to System.Numerics
* Fix file name
* Alphabetical
Signed-off-by: dotnet-bot <[email protected]>
Current output from console-output test is just Error and Out (indicating)
the different console output streams. When seen in log files the error output
string can be misleading. Fix makes it clearer that the output is originating
from a test and not an “error”.
* Add new internal `CryptoConvert.TryImportCapiPrivateKeyBlob()` method that's using `RSAManaged` directly to make it more linker-friendly.
* Also add new internal `CryptoConvert.TryImportCapiPublicKeyBlob()`.
* Use it in `AssemblyName.IsPublicKeyValid`.
* [runtime] Inflate overridden methods properly during vtable construction when using default interface methods.
* [jit] Handle default interface methods in constrained calls, they need to box if the constrained type is a valuetype which doesn't override the default method.
* [runtime] Update Default Interface Methods tests from coreclr.
* [jit] Fix interp support.
* [nuget-hash-extractor] Make the order for denied lists deterministic and
.. stable. We were not sorting the list of assemblies with the same
version, causing irrelevant changes in updates.
* Update denied assembly list to fix order
.. to be deterministic. Generated with the updated
nuget-hash-extractor.cs .
* [nuget-hash-extractor] Make the order of assemblies deterministic
The .nupkgs were being processed in arbitrary order, causing unncessary
diffs when updating them which required manual work to check and fix
them.
It's very common for an assembly to have only one module, in which case we can avoid unnecessary allocations and copies in Assembly.GetTypes() and Assembly.DefinedTypes.
Signed-off-by: dotnet-bot <[email protected]>
* [ci] Add new mode of execution for nunit tests on Android
This makes it possible to run the `nunit-lite-console.exe` on the host, while the tests still run on the device. This makes it transparent wherever the tests are running, giving us a seamless integration with the existing infrastructure based around nunit.
* [android] Fix System.Net.Http test suite
* [android] Fix System.ServiceModel.Web test suite
* [android] Fix Mono.Security test suite
* fixup! [ci] Add new mode of execution for nunit tests on Android
* [ci] Disable failing tests
* [csproj] Update project files
Compile like this:
if you have Zircon installed, with the prebuilts on "../zircon", use this to compile:
CC="`pwd`/../zircon/prebuilt/downloads/clang/bin/clang-9 -nostdlib -O2 -g -fdebug-prefix-map=/cvs/fuchsia/zircon=. -finline -fno-common -ffunction-sections -fdata-sections -no-canonical-prefixes -march=x86-64 -mcx16 --target=x86_64-fuchsia -fPIC -D_ALL_SOURCE=1 -DENABLE_DRIVER_TRACING=1 -fasynchronous-unwind-tables -fno-omit-frame-pointer -std=c11 -I`pwd`/../zircon/build-x64-clang/sysroot/include/ -I`pwd`/../zircon/system/public" LDFLAGS="-L`pwd`/../zircon/build-x64-clang/sysroot/lib/ -L`pwd`/../zircon/build-x64-clang/sysroot/debug" ./configure --host=x86_64-google-fuchsia
* [interp] Move special case initialisation of frame->ip
* [interp] Properly init locals
When we have locals that need to be initialized.
* [interp] Load the entire enum value
When calling calling method on constrained type for enums with long storage.
* [interp] Avoid clearing the stack with each call
Reducing overhead for each call, this can give an overall performance improvement of 5%.
* Consider unknown GB18030 characters as invalid to enforce use of replacement character instead of throwing SystemException.
* Return negative result for unknown character instead of throwing SystemException in GB18030Source.FromUCS
* Add new internal `CryptoConvert.TryImportCapiPrivateKeyBlob()`
method that's using `RSAManaged` directly to make it more
linker-friendly.
* Use it in `AssemblyName.IsPublicKeyValid`.
* [wasm] Add browser test suite.
- Runs a series of tests against the HttpClientHandler and blob tests.
* Setup custom browser launcher to pass `--no-sandbox` to work on CI
* Remove auto client config that caused async errors on tests.
[aot] abort lookup early when a method isn't 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
* https://github.com/mono/mono/issues/11643 mkbundle problem - Illegal byte sequence
The size of the mapping is the maximum file offset to map.
See https://docs.microsoft.com/en-us/windows/desktop/Memory/creating-a-file-mapping-object.
When I tried it, I got a different error.
If in the debugger you simulate this fix, it gets further.
Here is a small program to exercise and see the behavior:
```
// include <windows.h>
// include <stdio.h>
// include <stdlib.h>
//
// int main()
// {
// // Create a 128K file.
//
// HANDLE file = CreateFile("1", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
// printf("createfile %p %d\n", file, GetLastError());
//
// HANDLE map = CreateFileMapping(file, 0, PAGE_READWRITE, 0, 1 << 17, 0);
// printf("createmap %p %d\n", map, GetLastError());
//
// CloseHandle(map);
// CloseHandle(file);
// system("dir");
//
// // Attempt to map the second 64K of the 128K file, with a 64K mapping.
//
// file = CreateFile("1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
// printf("createfile %p %d\n", file, GetLastError());
//
// map = CreateFileMapping(file, 0, PAGE_READWRITE, 0, 1 << 16, 0);
// printf("createmap %p %d\n", map, GetLastError());
//
// // This fails.
//
// PVOID view = MapViewOfFile(map, FILE_MAP_WRITE, 0, 1 << 16, 1 << 16);
// printf("view %p %d\n", view, GetLastError());
//
// CloseHandle(map);
//
// // Use a 128K mapping instead. It works.
//
// map = CreateFileMapping(file, 0, PAGE_READWRITE, 0, 1 << 17, 0);
// printf("createmap %p %d\n", map, GetLastError());
//
// view = MapViewOfFile(map, FILE_MAP_WRITE, 0, 1 << 16, 1 << 16);
// printf("view %p %d\n", view, GetLastError());
// }
```
Here is debugging mono and simulating the fix in the debugger (I did not build or test
the fix):
```
\bin\amd64\cdb C:\Users\jaykrell\Downloads\output\output.exe
0:000> bm kernel*!*createfilemap*
0:000> g
Breakpoint 2 hit
KERNELBASE!CreateFileMappingW:
00007ffd`0a449de0 4883ec48 sub rsp,48h
0:000> dv
hFile = 0x00000000`00000200
lpFileMappingAttributes = 0x00000000`00000000
flProtect = 2
dwMaximumSizeHigh = 0
dwMaximumSizeLow = 0x477000
lpName = 0x00000000`00000000 ""
0:000> bm kern*!*mapviewoffile*
0:000> g
Breakpoint 38 hit
KERNEL32!MapViewOfFileStub:
00007ffd`0b09bfa0 48ff2591c10500 jmp qword ptr [KERNEL32!_imp_MapViewOfFile (00007ffd`0b0f8138)] ds:00007ffd`0b0f8138={KERNELBASE!MapViewOfFile (00007ffd`0a465ad0)}
0:000> dv
hFileMappingObject = 0x00000000`00000204
dwDesiredAccess = 4
dwFileOffsetHigh = 0
dwFileOffsetLow = 0x30000
dwNumberOfBytesToMap = 0x477000
0:000> gu
0:000> r rax
rax=0000000000000000
0:000> !gle
LastErrorValue: (Win32) 0x5 (5) - Access is denied.
LastStatusValue: (NTSTATUS) 0xc000001f - {Invalid Mapping} An attempt was made to create a view for a section which is bigger than the section.
0:000> .restart
0:000> bm kernel*!*createfilemap*
0:000> g
0:000> dv
hFile = 0x00000000`00000220
lpFileMappingAttributes = 0x00000000`00000000
flProtect = 2
dwMaximumSizeHigh = 0
dwMaximumSizeLow = 0x477000
lpName = 0x00000000`00000000 ""
0:000> ?? dwMaximumSizeLow += 0x30000
unsigned long 0x4a7000
0:000> bc *
0:000> g
Corlib not in sync with this runtime: The runtime did not find the mscorlib.dll it expected. Expected interface version CA4932AE-2294-4ECD-B863-BF98FDD84F33 but found 0CC970F6-6F25-4218-9427-3E4C3DC8DE33. Check that your runtime and class libraries are matching.
Loaded from: mscorlib.dll
Download a newer corlib or a newer runtime at http://www.mono-project.com/download.
```
* Restore useful part of comment.
* Restore dead code.
* Add to comment the other possibility that is being countered.
* Additional explanation.
* 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).
* Add support to handle new lines in response file on Windows.
[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.
* [wasm] Update to emscripten 1.38.28.
The emscripten patch is no longer needed.
* [wasm] Disable optimizations in SHA1Transform (), the normal version seems to cause stack overflows in binaryen's asm2wasm tool.
* Make System.Runtime.CompilerServices.Unsafe inbox
Fix a couple places where we wanted to use it from other inbox assemblies but couldn't.
Unsafe remains as a package and newer versions of Unsafe will replace the inbox Version,
permitting us to add API over time.
* Update Rune tests to use TryEncodeToUtf8Bytes directly
* Add temporary suppression to package tests
Signed-off-by: dotnet-bot <[email protected]>
* Change Environment.Version to return product version
- Contributes to https://github.com/dotnet/corefx/issues/31099
- Use AssemblyInformationalVersion attribute as fallback
* Add sanity test for Environment.Version
* Disable CodeDom tests
* Fix test assembly name
Signed-off-by: dotnet-bot <[email protected]>
- 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
```
@/external/bockbuild/builds/fsharp-fsharp-6624925/src/scripts/fssrgen.fsx(334,28): error FS0041: A unique overload for method 'GetFileNameWithoutExtension' could not be determined based on type information prior to this program point.
A type annotation may be needed. Candidates: System.IO.Path.GetFileNameWithoutExtension(path: System.ReadOnlySpan<char>) : System.ReadOnlySpan<char>, System.IO.Path.GetFileNameWithoutExtension(path: string) : string
[@/external/bockbuild/builds/fsharp-fsharp-6624925/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj]
```
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.
* [wasm] [debugger] Add test suite.
* [wasm] [debugger] Add test suite.
* [wasm] [debugger] Add test suite.
* Changing what Larry suggested and removing some -debug that is not used.
* Adding the DebuggingTestSuite.
* indentation
* Update run-jenkins.sh
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.
It's possible to pass any string as an argument to DriveInfo ctor (e.g. `new DriveInfo(Path.GetTempPath())`). Mono throws ArgumentException if there is no exactly the same drive name in the list of available drives.
I tried to handle this case by extracting any valid drive name from the array of available drives sorted by path in descending order.
Fixes https://github.com/mono/mono/issues/12157
* Add server-side Server-Name-Indication (SNI) support (both AppleTls and BTLS).
* Support the new `SslServerAuthenticationOptions.ServerCertificateSelectionCallback`.
* Server certificate selection is now compatible with CoreFx behavior; first
checking the new `ServerCertSelectionDelegate` then `LocalCertSelectionCallback`
and finally using an explicitly provided certificate.
* Misc exception checks and fixes to make behavior consistent with CoreFx;
any exception thrown by reading / writing the underlying stream will now be
propagated verbatim (and not wrapped in an `AuthenticationException`);
exceptions thrown by the handshake / TLS stack itself will still be wrapped.
* Added `System.Net.Security` xUnit tests from CoreFx.
* Misc test cleanups; moved certificate test files from `System.Net.Http` into
`System` and embed them in the test assembly as resources, adjusting
`test-helpers/Configuration.Certificates.cs` accordingly.
* Removing various S.R.I.Vector instance method APIs, since they should now be exposed as extension methods
* Updating the JIT to recognize the S.R.I.Vector extension methods.
* Updating various S.R.I.Vector test templates
* Regenerating the S.R.I tests that are created from a template.
* Fixing the numArgs for Base_Vector256_GetLower
* Fixing the handling for `Base_VectorXXX_As` to normalize the struct type.
* Adding the Base_Vector128_As intrinsics back for arm64
Signed-off-by: dotnet-bot <[email protected]>
[loader] Fix off by 1 (netstandard is a framework facade)
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
https://github.com/mono/mono/blob/f8094319132d2d40f37e8cac6058e783b5648260/mono/metadata/assembly.c#L345
* Fix for runtime mcs-compileall test on Windows x64 full AOT.
Test picked up full AOT:ed libraries as well as managed libraries failing
the test. Full AOT:ed shared libraries on Windows has .dll.dll prefix and
full AOT:ed executables on Windows has .exe.dll prefix.
Fix makes sure to filter out any files ending with dll.dll or exe.dll.
* Fix build errors in System.Web.Services test under winaot profile.
* Fix errors in System.Core test under winaot profile.
* Fix build error in linker tests on Windows under winaot profile.
Build fails since profile build mscorlib is used as well as default
triggering build error. Fix is to build linker tests using -nostdlib flag.
Should not be part of the package and cause issues on Windows 32-bit
cygwin build since it's not using makefile generated by autotools. When
make install is run it will build jay one more time, but picking up
cygwin default gcc compiler instead of the one used in configure step, mingw.
That cause link errors since the object files are not rebuild, only relinked
with different linker, causing errors.
Apple's make doesn't support the --output-sync option and Homebrew's make is installed as gmake.
Also fixed a few places in the repo where we directly invoked make instead of $(MAKE).
* Fix race condition in ManualResetValueTaskSourceCore
ManualResetValueTaskSourceCore.GetStatus is used from ValueTaskAwaiter.IsCompleted. If GetStatus returns Success too early, then IsCompleted will also return true too early, which will result in GetResult being called too early. This doesn't happen today when an MRVTSC is used sequentially. But if an instance is pooled by the object its stored on getting put back into a pool as part of a call to the wrapper's GetResult, then we can end up in the following situation:
- Thread 1 starts an await on an instance containing an MRVTSC. It calls IsCompleted.
- Thread 2 starts to complete that instance, getting as far as calling SignalCompletion and setting _completed to true but not yet setting _continuation.
- Thread 1 sees _completed == true and returns true from IsCompleted. It calls GetResult, and the wrapper extracts the result from the instance, resets it, and puts it back into the pool.
- Thread 3 takes the object out of the pool and starts using it.
- Thread 2 continues SignalCompletion on that instance, and sets _continuation to the sentinel.
- Now Thread 3's instance's _continuation is the sentinel when it should be null. If it calls SignalCompletion, it'll erroneously find that _continuation is not null and will queue _continuation/_continuationState for execution, resulting in the sentinel getting executed. If it calls OnCompleted, it'll find that the _continuation is not null, and will queue the supplied continuation/state to execute immediately even though the operation may not yet actually be done.
The fix is simply to check not just _completed but also _continuation. The operation is considered pending if either _completed is false, meaning SignalCompletion has not yet been called, or if _continuation is still null, meaning it's neither been set to the supplied delegate nor to the sentinel. We can't just rely on _completed for the above outlined reasons, and we can't just rely on _continuation because it can be non-null if OnCompleted was called to hook up a callback (if we only cared about the await pattern, then we could just check _continuation and wouldn't need _completed, but we also need to support non-await access).
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
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.
SemaphoreSlim.Release shouldn't invoke arbitrary continuations as part of its invocation, so when it dequeues a task waiter and goes to complete it, rather than just calling TrySetResult, it queues the task to the thread pool to have TrySetResult invoked there. Now that we have RunContinuationsAsynchronously, though, we can just use that functionality instead. This has two main benefits:
1. We avoid queueing a work item entirely if there are no continuations from the task. This might happen, for example, if the semaphore is released so quickly after waiting on it that the WaitAsync caller hasn't yet hooked up a continuation, in which case the await on the WaitAsync task will just see IsCompleted as true and continue running.
2. We avoid queueing a work item when the task represents a synchronous Wait, which happens if there's already a pending WaitAsync when Wait goes to block. The main benefit here is avoiding potential thread pool starvation, if threads in the pool are blocked in such Waits, and previously another thread pool thread would have been needed to run the queued work item to complete the synchronous Wait.
Signed-off-by: dotnet-bot <[email protected]>
* [interp] Extract some duplicated code
* [interp] Kill stinarg opcodes
Before we were reallocating the arguments in the current frame and had a stinarg opcode for copying each argument there. Access the arguments directly from the parent frame, to reduce call overhead. This can give up to 5-10% general speedup.
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
```
* [netcore] Switch to Debugger class from corlib.
* [netcore] Implement exception stack trace support.
* Address review comments.
* [netcore] Create a netcore specific version of Exception based on the refsource version.
* [interp] Fix unaligned access crashes on arm
strd instruction fails if the memory address is not word aligned.
Fixes corlib-xunit suite on arm.
* [interp] Fix warning
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.
* [tests] Add the BitcodeNotSupported category to tests exercising non-bitcode-compatible API.
We have APIs that use exception filter clauses, and we don't support that when
compiling to bitcode.
So mark any tests exercising such API accordingly, so that we can skip those
tests when running tests on targets that use bitcode (watchOS).
* [tests] Use BitcodeNotSupported on applying profiles
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.
* [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.
* Move SafeHandle to managed code and shared
This moves the implementation of SafeHandle from native code in the runtime to managed. I used corert's implementation as a base, and reviewed it again against the existing native implementation, making a few tweaks to better match the existing semantics.
This should be a valid move because of the reduced goals around CERs, thread aborts, etc.
However, there are places in the runtime that access SafeHandle functionality via its native counterpart, so I kept the relevant pieces of the native code intact. Most code will continue to use the managed APIs, but the runtime can continue calling into the native versions when needed.
* Address PR feedback
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
- Conditional include of bindings depending on if --nobindings is specified.
- Packager: AOT ninja build modifications.
- Add corebindings build dependency
- Add bindings_support.j build dependency
- Remove dependency to add Bindings initialisation to build and mono_config.js
- Modify runtime.js and runtime-tests.js to remove the bindings initialisation code.
* Index and Range updates
* Address @mikedn feedback
* Address Feedback
* more feedback
* Use Deconstruct in Range.GetOffsetAndLength
* Rename GetArrayRange to GetSubArray
* Temporary disable the old Corefx Range tests
* Return back the TimeSpan test disabling
* Fix Range jit test
* Exclude the jit test
* revert the changes in the jit Range test
* Address Suggested Feedback
Signed-off-by: dotnet-bot <[email protected]>
* Move GCHandle to shared
* Cache the handle in a local to make it easier for JIT to generate good code
* Rename m_handle to _handle to match the coding conventions
* Delete isPinned argument for GCHandleInternalCompareExchange
* Add fast path to GCHandle.Alloc/Free FCalls
* Disable outdated test
Signed-off-by: dotnet-bot <[email protected]>
* Renaming RuntimeEventSource to NativeRuntimeEventSource
* missed a couple of comments and XPlatEventLogger
* rename DotNETRuntimeEventSource.cs to NativeRuntimeEventSource.cs
* use condition= instead of ifdef
* removing ifdef from NativeRuntimeEventSource.cs
* Fix case for 'eventing' directory in csproj
* Fix unix builds
* This should fix unix build...
Signed-off-by: dotnet-bot <[email protected]>
* Moving several of the Vector128<T> instance methods to be extension methods.
* Moving several of the Vector256<T> instance methods to be extension methods.
* Moving several of the Vector64<T> instance methods to be extension methods.
Signed-off-by: dotnet-bot <[email protected]>
* [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
Remove the hack that injected an extra line with the source
location now that we reference local sources when we can and
fix the Match logic so that it corrects for the difference
between pdbs and chrome breakpoints
Unknown schemes (dotnet:) are not well supported by all the
tools that support the chrome DevTools protocol so if the
file exists locally use a file: url rather than a dotnet:
url to reference it.
* add new rounding modes to MidpointRounding.cs
new modes added to enum
implemented ToZero for double in Math.cs
* ToZero implementation
* implement double and float rounding modes
* updating rounding implementation
now round inline with DecCalc internal round implementation
* small bug fix
also replace var to make things obvious
* update implementation - floor/ceil
code review feedback
* review feedback
add comments, update MathF with floor/ceil
* code review feedback
- fix comments
- replace ifelse with switch
- remove RoundingMode enum from DecCalc
* exclude outdated corefx test
Signed-off-by: dotnet-bot <[email protected]>
* Add new String overloads
* Remove some overloads with non-primitive types
* Remove IndexOf overloads with more than 1 argument
* Remove Trim() from TrimTranslator because CanonicalFunctionDefaultTranslator already supports it.
* Trim/TrimStart/TrimEnd: remove Char parameter overloads; add condition to support parameterless overloads.
* Remove unsupported Char overloads of Contains, IndexOf, StartWith and EndWith methods
* Move all icalls to RuntimeModule.
* Make all icalls static and receive the module as an IntPtr.
* Remove some duplicate code between the RuntimeModule and ModuleBuilder classes.
* Make Module partial to allow additional changed for Mono
Signed-off-by: dotnet-bot <[email protected]>
* Move ConditionalWeakTable to shared (dotnet/coreclr#22531)
Leaves DependentHandle as being the runtime PAL
Signed-off-by: dotnet-bot <[email protected]>
Much of the tooling around DevTools expects
actions under /json to return useful data
this adds adds some simple logic to proxy those
so that you can point tooling directly at the
proxied port and get responses you expect
* Move Volatile to shared
This largely takes corert's implementation, which uses Unsafe.As and volatile fields.
We could investigate also removing the JIT's replacements subsequently.
* Add [Intrinsic] attributes
Signed-off-by: dotnet-bot <[email protected]>
* [marshal] Add emit_exception_for_error callback
* [runtime] MonoError-ize mono_lookup_pinvoke_call_internal
Two complications:
1. Marshalling needs to turn a MonoError into MethodBuilder instructions to
emit an exception.
2. The public API uses two string to signal an error. So we have to use
a custom status struct to return the error code.
* [loader] Factor out library path transformations
* [marshal] Copy error msg in mono_mb_emit_exception_for_error
Add new mono_mb_stdrup to make a copy of a given string into the memory that
will live with the MethodBuilder's method.
* [interp] Callvirt of an icall should call the wrapper.
See pinvoke2.cs test_0_missing_virtual_pinvoke_method ()
You can have an icall override a virtual method:
public class T2 : T {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public override extern object MyClone ();
}
When the interpret saw this, it was setting up a child frame with the frame
method being the MonoMethod of the icall itself, not the wrapper. But it was
executing the wrapper. As a result if the wrapper body had a LDSTR in it, we
would hit the assertion in the MINT_LDSTR_TOKEN case where
frame->imethod->method->wrapper_type == MONO_WRAPPER_NONE is not allowed.
With this change the frame method is now the wrapper which has a correct
wrapper type.
* [loader] remove pinvoke_probe_transform_path do{}while(0) construct
take the line damage; make the code easier to understand.
mono_string_utf16_to_builder_copy incorrectly uses MONO_HANDLE_SETRAW to
update the chunkLength field with a string length. Since MONO_HANDLE_SETRAW
assumes the argument is a MonoObject reference this could lead to a dereference
and since the value is a string length, that dereference will lead to a crash.
The problem happens in mono_gc_wbarrier_set_arrayref_internal where vtable
is retrieved from value. The crash happens randomly since it is depending
on the object being moved out of the nursery + sgen_binary_protocol_wbarrier
not being eliminated.
Fix is to use MONO_HANDLE_SETVAL since the value is not a reference so no need
to trigger a write barrier.
Current codegen incorrectly read back last error when doing p/invoke for
full AOT. This caused many failed corlib tests ~600. It also
turns out that the test for set/get last error related to p/invoke that we
have in pinvoke2.exe, is not run for the full AOT profile, due to other tests
depending on none full AOT features. In order to make sure we run the test
and not regress, test has been moved into its own runtime tests, running as
part of full AOT testing.
When using the previous test, some memory unsafety was
observed. It's rather unrecoverable memory unsafety, as
it corrupts heap memory used by the sequence points, registered MERP
paths, jit info internals, and output string.
Crashes seen here: https://github.com/mono/mono/pull/12387 reproduce
with less than 100 iterations of this malloc test run as the stress
test.
```
(MonoJitInfoTable) $2 = {
domain = 0x5050505050505050
num_chunks = 1347440720
num_valid = 1347440720
chunks = {}
}
```
with
```
(lldb) p/x 1347440720
(int) $0 = 0x50505050
```
And sometimes the mono crash
```
(lldb) p *it
(SeqPointIterator) $3 = {
seq_point = (il_offset = 0, native_offset = 0, flags = 0, next_offset = 0, next_len = 0)
ptr = 0x5050505050505050 <no value available>
begin = 0x5050505050505050 <no value available>
end = 0x5050505050505064 <no value available>
has_debug_data = 0
}
```
===
These do not reproduce when doing a double free of legally allocated
memory.
I think that the crash reporting tests aren't the place to check if the
OS allows for wild heap corruption when doing these things. I don't
think it's currently in scope for the runtime to do crash reporting
after it's internal metadata tables have been corrupted. They're the
source of truth for symbolication. We don't have many options to
validate and reparse them, unless we want to make this all very
heavyweight.
* Move Array's SZGenericArrayEnumerator to shared partition
* Remove legacy comment
* Move all array enumerators to a new file
Signed-off-by: dotnet-bot <[email protected]>
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.
Fixes this app startup issue
```
dyld: Library not loaded: /Users/lewurm/work/mono-watch4-ios-sdk/sdks/out/ios-target64-release/lib/libmono-native-unified.0.dylib
Referenced from: /var/containers/Bundle/Application/9697C8F3-811C-4BF3-B1BC-1E6385673984/PublicStaging.app/test-Mono.Runtime.Tests
Reason: image not found
Process 2269 exited with status = 0 (0x00000000) Terminated due to signal 6
```
* [interp] Avoid using MINT_CKNULL
Unnecessary overhead for this tiny instruction.
* [interp] Do null check for this before inlining
Otherwise we miss it.
* [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
* [interp] Move profiler callback when we are actually done
Just in case.
* [corlib] Move the implementations of virtual methods from Assembly to RuntimeAssembly to ease netcore integration.
* [corlib] Move more code to RuntimeAssembly.
* [corlib] Move fields from Assembly to RuntimeAssembly/AssemblyBuilder.cs. Reduce the amount of fields visible to runtime code.
* Update serialization tests.
* Fix the MOBILE build.
* Bump API snapshot submodule
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.
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
* Index and Range updates
* Address @mikedn feedback
* Address Feedback
* more feedback
* Use Deconstruct in Range.GetOffsetAndLength
* Rename GetArrayRange to GetSubArray
* Temporary disable the old Corefx Range tests
* Return back the TimeSpan test disabling
* Fix Range jit test
* Exclude the jit test
* revert the changes in the jit Range test
* Address Suggested Feedback
Signed-off-by: dotnet-bot <[email protected]>
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.
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.
* Fixing Utf8Formatter.Float to support all the same format specifiers as the utf16 formatter.
* Disabling some outdated CoreFX tests.
* Fixing TryFormatFloatingPoint to special-case format.IsDefault
Signed-off-by: dotnet-bot <[email protected]>
* [runtime] Mark mono_lookup_pinvoke_call external only
Runtime should use mono_lookup_pinvoke_call_internal
* [loader] Factor out helper functions from mono_lookup_pinvoke_call
Separate the logic for probing for a dynamic library module from the logic for
looking for a symbol inside the module.
* [loader] Factor out relative directory probing in pinvoke lookup
* An attribute with a content that was a string null was creating two items in result json and it was throwing an exception in client side because it is expected a name and a value and not a name and two values.
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.
* [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
Resolves https://github.com/mono/mono/issues/11431
I put the native impl to Mono.Native, but probably it should be in a separate lib (`libmono-native.0.dylib` before: **81kb**, after: **898kb**) if Linker is not able to trim it if it's not used.
Compiles and works on Windows (however, we don't build Mono.Native for Windows, but we can borrow `clrcompression.dll` from .net core) and macOS but requires changes in mono/corefx,
I disabled xunit tests as those need 50mb of test data.
PS: Brotli could be fully managed 😢https://github.com/dotnet/corefxlab/issues/1673
C# ports:
- https://github.com/master131/BrotliSharpLib
A quick benchmark (Compressing a 5mb file with max compression level=11)
Mono JIT: 25sec
Mono LLVM-AOT: 7.8sec
.NET Core 2.2: 6.8sec
.NET Core 3.0: 5.8sec
.NET Core's BrotliStream (with native lib): 3.5sec
- https://github.com/google/brotli/tree/master/csharp - official C# port. Based on Java sources, slow, outdated (2 years ago).
Due to current order, process togglerefs and then take current threads
stack could cause a problem where toogleref references might be left
in registers after native code process the list and those reference
would then be put into current thread context, incorrectly pinning the
toggleref, preventing it from being GC:ed. The problem was observed on
Windows (in debug build) running sgen-toggleref.exe runtime test since
the native compile of sgen_process_togglerefs used a register when
walking the list of togglerefs that was then not re-used until the
current threads stack was taken, causing incorrect pinning. This problem
could in theory happen on any platform depending on how sgen_process_togglerefs
would been compiled and what register will be used.
Fix is to take 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 native code.
Combination of Windows x64 ABI and the lack of not checking for fault handlers
in OP_START_HANDLER cause a hard to track stack corruption when combined with
tail calls. Fix is to make sure we also handle fault regions in handlers to
handle cases like the one exposed by catchfault_tail.exe test.
When running tests on CI the runtime is configured from autogen.sh script.
When running fullaot there are a couple of features not supported so they are
disabled. The problem is that the MSVC Windows builds have its own winconfig.h
template, losing all the disabled features from configures config.h.
This commit adds support to detect the disable defines from configures config.h
if one exists. Since the complexity of this step increases the work previously
done in winsetup.bat has been moved into a msbuild target that is used from
both within VS build as well as winsetup.bat (there are a couple of other builds
using that bat file, so won't remove it).
The winconfig.h template we had is quite outdated compared to what’s generated
by configure. This commit also updates the winconfig.h to closer match what generated
for corresponding mingw build but keep all the Windows specific configurations
included in current version.
* [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.
Switch NUnit BCL tests to use embedded test resources instead of reading from the repo
Right now a lot of our tests expect to be able to read resources directly from the repository, e.g. `File.Open ("../../resources/some-file.txt")`
In order to run these tests in a standalone, clean environment without access to the source repo we need to change that. The most straightforward way to achieve that is to embed all the resources inside of the test assemblies and extract/read them from there during test execution time.
The new TestResourceHelper helper class extracts all embedded test resources to a temporary directory and cleans them up when the test runner process exits. This allows us to make relatively small changes to the tests as opposed to rewriting them all to read directly from the embedded resource stream (which isn't even possible in all cases).
It turns out some Debian versions identify themselves as `Debian GNU/Linux`, add
this string to the list of distributions which have mingw. This *should* fix the
PR builds (fingers crossed)
Part of #9660.
The changes:
- included corefx version of EventInfo type;
- included related xunit tests from corefx System.Reflection;
- made System.Reflection/EventInfo.cs partial and left some Mono-specific stuff only there.
Some changes will be done in corefx part.
Look like:
https://github.com/mono/mono/commit/e8029e1474b701184840f6e0abea51966d048831
caused issues in the parameters for this test since caller was not updated
accordingly.
This fixes so that the caller pass needed additional argument + simplify the
AOT use case for Windows since different tested versions will need different
toolchain versions that in turn will cause additional complexity. Since the
test doesn't validate the compile/link of AOT module (and don't handle errors)
anyways, Windows versions of this test will just generate assembler output.
Debian and its derivatives include full mingw chain (both 64 and 32-bit) and so
they don't need to build the toolchain at all. However, the current detection of
Linux flavor takes into account only Ubuntu and all other distros are configured
to *require* MXE but they do *not* build them.
This commit fixes detection of distros which provide the mingw toolchain in a
way that makes it easy to extend the set of compatible distributions as needed.
In order to mark a distribution as one with MinGW one has to add the `:Distro:`
string to the `LINUX_WITH_MINGW` make variable in `mxe.mk`. The `Distro` string
is whatever the `determine-linux-flavor.sh` script returns.
MONO_API here was dubious, as all systems have it, except Visual C++ was configured away.
In Visual C++, it is in ucrt, so present in 2015 also.
More information in nearby comments.
This PR cleanups C++SDKs support and gets them all passing for the first time, esp. Android (WebAssembly already was, iOS uncertain before, green here).
* Current Visual C++ has signbit.
* Rework C++ linkage to C99 math-- trunc, isnan, isinf, etc.
Go through mono wrappers that are compiled as C.
Remove support for Visual C++ pre-2015 and non-C99 Solaris.
(Solaris has plenty of other problems compiling.)
Cleanup Windows ssize_t support.
* Remove trunc and aintl autoconfigury.
Use trunc unconditionally. (aintl is a Solaris near equivalent to trunc).
* Replace dis_isnan with mono_isnan.
* Interpreter already assumes presence of isinf and isfinite, so everywhere else might as well too.
A fair amount of cleanup therefore -- autoconf, ifdef, etc.
If this changes back, the mono_isinf, etc. wrappers are likely, but not necessarily, where to handle it for everyone, not sprinkling ifdefs and alternate implementations around -- assuming all users want the same fallback.
As well, we might want to import some good BSD libc versions of all these if there is any remaining question of portability. *Everyone* except old VAX and Cray have always used the same 32bit float and 64bit double representations since circa 1985 so these are all probably about one line of portable C89/C++98 each, maybe with endian sensitivity.
* [wasm] Fix linker changes.
* Revert "[wasm] Enable the mini test suite under AOT. (#10670)"
This reverts commit 9cb832ff2a.
Revert this, it doesn't work yet.
* [wasm] Run AOT tests on CI.
* Fix the CI label.
* [wasm] Disable the aot test on CI, it doesn't yet run on linux.
* [wasm] Fix the computation of code_start/code_end for wasm.
* [llvm] Avoid passing a dummy extra args to wrappers which don't need it.
* [wasm] Enable gshared.
* [llvm] Fix the build.
* [llvm] Avoid passing a dummy arg to string:memcpy/bzero.
* [wasm] Enable exception catching.
* [wasm] Enable explicit division by zero checks.
* [wasm] Patch emscripten with the patch from https://github.com/kripken/emscripten/pull/7182.
* [wasm] Use '.' instead of source in the ninja build scripts since they might be ran with sh/dash instead of bash.
* [wasm] Reenable check-aot on CI.
* [wasm] Run emcc using bash -c since the emsdk_env.sh scripts contains bash-ishms.
* [wasm] Don't error out if the emscripten patch is already applied.
* [wasm] Fix do-aot-sample.
* [wasm] Disable AOT test on CI, it still doesn't work.
* [llvm] Add support for OP_RCNEQ.
* [jit] Make some tests in builtin-types.cs static.
* [wasm] Fix the return value of mono_wasm_exec_regression ().
* [wasm] Make aot-sample uses mini_tests.dll.
* [Coop] Mostly convert appdomain.c.
* Mostly don't convert mono_domain_try_unload at this time -- it was causing failures and maybe the domain swapping needs to be considered carefully with handles.
* Also a few assignments to non-local raw pointers remain, and should probably be suppressed.
See https://jenkins.mono-project.com/view/All/job/test-mono-mainline-staticanalysis-and-code-coverage/Centrinel_Report/
appdomain.c has 34 warnings. This should drop it significantly.
* [runtime] Allow strings when doing alloc-less cattr decoding.
* [runtime] Remove dead define.
* [wasm] Disable broken method under wasm.
* [wasm] Add mono_exec_regression to use mini's regression driver and make it work with WASM interp&AOT.
* [wasm] Remove dead targets. Packager is used for all test suites now.
* [wasm] Cleanup csc flags.
* [wasm] Move aot-sample to use mini_tests_basic again.
* [wasm] We no longer need to exclude FULLAOT from the test suite.
* [wasm] Expose mono_wasm_exec_regression.
* [wasm] Remove dead test driver.
* [wasm] Fix the provisioning step.
* [wasm] Bindings don't link well with the aot sample.
* [wasm] Update the test driver to include --regression support.
* [wasm] Change how regression tests are executed so we exec over aborts.
* [wasm] Appease the C++ typechecker.
* [wasm] Add more casting to make c++ happy.
There is wrong cursor placement after the \t character. Example:
textBox1.Multiline = true;
textBox1.Text = "aa\taa\r\nbb\tbb\r\n";
Point pt = textBox1.GetPositionFromCharIndex(4); //pt.X is wrong for index 4 or any other char after \t in the line.
The default behavior is still to produce an NUnit xml file but we can
now produce xunit format too with the --xunit option.
Slightly refactored the xml reporting into distinct methods for NUnit/xunit.
Roslyn submodule was updated to enable more automated tests. This bumps our submodule revision, and uses roslyn's script to run tests instead of ours.
@monojenkins skip
Part of #6991
* [ci][cxx][sdks] C++ support for SDKs.
* Remove cplusplus support, only cxx.
* [cxx][sdks] Provide isinf and isnan.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/1/parsed_console/log.html
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/jit-icalls.c:994:14: error: 'isinf' was not declared in this scope
if (isinf (v) || isnan (v))
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/jit-icalls.c:994:27: error: 'isnan' was not declared in this scope
if (isinf (v) || isnan (v))
* Change target card mask from gpointer to mgreg_t.
Consider in future target_gsize instead, though if registers are larger than pointers (x32, arm64_32), ok.
Change inst_imm from mgreg_t to target_mgreg_t.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm-cxx/1/parsed_console/log.html
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-runtime.c:3657:24: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
g_assert ((((mgreg_t)arg) & 1) == 0);
^ ^~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-runtime.c:3658:30: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
arg = (gpointer)(((mgreg_t)arg) | 1);
In file included from /mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c:75:0:
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c: In function 'void mini_emit_write_barrier(MonoCompile*, MonoInst*, MonoInst*)':
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/ir-emit.h:703:39: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
inst->inst_imm = (mgreg_t)(imm); \
^
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c:2989:4: note: in expansion of macro 'MONO_EMIT_NEW_BIALU_IMM'
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PAND_IMM, offset_reg, offset_reg, card_table_mask);
^~~~~~~~~~~~~~~~~~~~~~~
* [cxx][sdks] Move include out of extern "C" where it never belongs.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/4/parsed_console/log.html
template<typename _Tp, typename _Up, typename _Vp,
^
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/ext/type_traits.h:205:3: error: template with C linkage
template<typename _Tp, typename _Up, typename _Vp, typename _Wp,
^
In file included from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/mono-compiler.h:31:0,
from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/dlmalloc.h:33,
from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/dlmalloc.c:27:
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/cmath: In function 'constexpr float std::abs(float)':
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/cmath:87:16: error: conflicting declaration of C function 'constexpr float std::abs(float)'
abs(float __x)
* Expand cmath to wasm.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm-cxx/5/parsed_console/log.html
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-llvm.c:4189:6: error: 'isnan' was not declared in this scope
if (isnan (val))
^~~~~
* Provide cmath std::isnan for WebAssembly C++.
* Provide cmath std::isfinite for Android C++.
* Add cmath std::isunordered for Android
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:3282:14: error: use of undeclared identifier 'isunordered'; did you mean 'std::isunordered'?
CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
^~~~~~~~~~~
std::isunordered
* Add cmath std::isinf for Android.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/10/parsed_console/log.html
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:3751:8: error: use of undeclared identifier 'isinf'
if (isinf (sp [-1].data.f))
* "using std::isinf" sometimes breaks on Android, sometimes fixes Android,
because Android sometimes has global isinf.
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:92:12: error: target of using declaration conflicts with declaration already in scope
using std::isinf;
^
/Users/builder/android-toolchain/toolchains/arm64-v8a-clang/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../include/c++/4.9.x/cmath:604:3: note: target of using declaration
isinf(double __x)
^
/Users/builder/android-toolchain/toolchains/arm64-v8a-clang/bin/../sysroot/usr/include/math.h:234:6: note: conflicting declaration
int (isinf)(double) __pure2;
There are still some errors in new lanes (WebAssembly works, Android does not, iOS not sure), to be addressed shortly, possibly by redoing some of the cmath stuff.
* mono_w32handle_wait_multiple: Duplication is ok for WaitAny, exception for WaitAll.
Fixes https://github.com/mono/mono/issues/9089
* Duplicate detection in mono_win32_wait_for_multiple_objects_ex, like mono_w32handle_wait_multiple.
* Move wait duplicate tests from mono/tests to mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs.
Run them with e.g.:
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -test:MonoTests.System.Threading.WaitHandleTest.DuplicateWaitAll`
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -test:MonoTests.System.Threading.WaitHandleTest.DuplicateWaitAny`
Find the full names with:
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -explore`
and look at the resulting .xml file.
I ran them w/ and w/o the fix, verify they both failed w/o and passed w/.
(w/o the fix was a slight hack of the fix)
* Move null checks so other uses can still null dereference.
* Short circuit duplicate search, correct either way.
* Fix windows build -- missing include.
* Add MonoError to mono_win32_wait_for_multiple_objects_ex, probably did this earlier but lost it somewhere in git.
* Add missing include.
* Follow shorter convention of rest of directory.
* Make the code slightly more complicated per PR.
* PR: Split into small used-once functions.
* cleanup
* add static
* PR: sizeof (array [0]) vs. sizeof (type)
* Convert or partially convert mono_domain_try_type_resolve_typebuilder, mono_domain_try_type_resolve, mono_domain_try_type_resolve_name.
In order to use TYPED_HANDLE_DECL, this required splitting handle.h into at least two pieces,
here called handle-decl.h and handle.h.
A fair amount of early returns had to be converted.
* PR: Move mono_domain_try_type_resolve_name from domain-internals.h to reflection-internals.h.
Move mono_domain_try_type_resolve_typebuilder ditto.
Move ves_icall_TypeBuilder_create_runtime_class from object-internals.h to reflection-internals.h.
Move TYPED_HANDLE_DECL (MonoReflectionAssembly) from handle-0.h to reflection-internals.h (previously object-internals.h)
Move TYPED_HANDLE_DECL (MonoReflectionTypeBuilder) ditto.
Add MONO_HANDLE_BOOL to handle.h so we can 1. Stop inverting tests and 2. Prefer
true first in ternary.
x = MONO_HANDLE_BOOL (y) ? z : 0
instead of
x = MONO_HANDLE_IS_NULL (y) ? 0 : z
Add include "reflection-internals.h" to mono-security.c
Add include "reflection-internals.h" to security.h
object-forward.h:
Place MONO_RT_MANAGED_ATTR on MonoReflectionTypeBuilder.
Really it should just be MonoObject, and then implied
by everything that contains it.
Place MONO_RT_MANAGED_ATTR consistently.
Sort by native then managed.
mono_reflection_get_type_with_rootimage: Rename assembly to refection_assembly
and then use assembly to reduce occurences of MONO_HANDLE_GETVAL (assembly, assembly).
mono-security.c: include config.h unconditionally and just once.
* Change mono_class_get_ref_info_raw to return MonoReflectionTypeBuilder* instead of MonoObject*.
Remove casts on mono_class_get_ref_info_raw calls.
Change mono_class_get_ref_info to return MonoReflectionTypeBuilderHandle instead of MonoObjectHandle.
Move mono_class_get_ref_info from object-internals.h to reflection-internals.h.
Use mono_class_get_ref_info instead of mono_class_get_ref_info_raw.
* Cleanup -- MONO_HANDLE_BOOL and contains instead of cast.
* PR: Fix incorrect comment. Fix precise GC hole wrt invoke.
It's assuming a device or emulator is already attached or running. On our CI, a new emulator is automatically started at the beginning of the job and shutdown at the end of it.
When building 32-bit binaries on a 64-bit system and vice versa, it is necessary
to pass the `-m32` or `-m64` compiler flags, respectively. Failure to do so will
result not only in linking problems (different binary architecture) but also in
problems when using some system headers which are sensitive to the architecture.
For instance, `ucontext.h` contains register set definitions for different
architectures and building Mono runtime with a 64-bit compiler targetting 32-bit
architecture results in this error:
.../mono/mono/utils/mono-sigcontext.h:173:74: error: ‘REG_EIP’ undeclared (first use in this function); did you mean ‘REG_RIP’?
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EIP])
The issue here is that the compiler defines the `__x86_64__` macro which causes
`ucontext.h` to choose declarations for amd64 (which does not use `REG_EIP` but
has `REG_RIP` instead) while Mono runtime assumes its building for a 32-bit host
and uses 32-bit register names. Passing `-m32` to the compiler will fix the
issue as now the compiler will define the `__i386__` macro and all parties will
agree where they are and what they want.
This commit uses a rather baroque statement when constructing compiler flags to
build the Mono runtime to check whether the host triple targets 32 or 64-bit
host and adds the appropriate flag.
* [System]: Make sure `HttpWebRequest` observes exceptions on timeout. #10488.
`HttpWebRequest.RunWithTimeoutWorker()` needs to observe the worker task's exception
on timeout to prevent it from being thrown via the `TaskScheduler.UnobservedTaskException`
event. Fixes#10488.
* Add `TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.OnlyOnCanceled` as suggested by Marek.
* Use 'OnlyFaulted' only.
PAL_gssapi.c was converted to C recently in corefx but since our fork is not up to date I copied `PAL_gssapi.c` and `PAL_gssapi.h` into mono/metadata (I guess I should just cherry-pick those files to our fork).
For System.Data it will allow users to connect to sql servers using SSPI (Security Support Provider Interface).
See https://github.com/mono/mono/issues/9028 and https://github.com/mono/mono/issues/9751
on macOS (and iOS) it uses built-in GSS.framework.
on Linux it requires an additional package (`krb`) to be installed (see .NET Core prerequisites, e.g. https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x#ubuntu).
Unfortunately it's not installed on our CI yet.
* Some cleanup in appdomain.c.
- Combine exit paths.
- npaths is always incremented, so remove test against 0 (assuming no overflow).
* Change g_strdelimit first parameter from string to character.
* Fix C++ -- goto around init.
* PR: Restore legacy types gint, gchar.
* [wasm] Add beginnings of linker support in AOT mode.
* Fix the compilation of monolinker.exe.
* Link in libmono-icall-table.a as well.
* Copy monolinker.exe instead of building it.
* [jit] Fix a constant propagation problem on 32 bit with iconst+conv.i8, we would be setting inst_imm even for long opcodes.
* [llvm] Fix the special casing of OP_LCOMPARE_IMM, its not needed.
* Use TARGET_SIZEOF_VOID_P.
* [wasm/gc] It's valid to register for finalization an object without a finalizer. Don't register for fin objects added to refqueues under sgen.
The refqueue change undo part of 87fb34d18a.
This is due to how track resurrection weak refs are implemented under boehm and sgen. Sgen natively supports them so we don't
need to emulated it by registering them for finalization. This produces a lot of useless work for the GC.
* [wasm] Enable SRE.
[interp] Optimize ldtoken + GetTypeFromHandle pair
As we do with jit. Improves speed of typeof operator by 10-15 times.
<!--
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
-->
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.
* Fix outarg_vt processing. Fixes#10549
* Cleanup unused bits and pieces
* Correct the handling of structures being retuned from a call
* Restore vtcopy code etc.
[llvm] Make sure OP_LSHL_IMM is transformed to a 64 bit shift even if the input is 32 bit, which can happen because the JIT IR is not regular. Fixes bug-17590.exe on arm64+fullaot+llvm.
Fixes https://github.com/mono/mono/issues/10527
* mono_aot_get_unbox_trampoline: amd64 compute unbox trampoline size correctly via runtime disassembly.
This fixes: MonoTests.System.Linq.ParallelEnumerableTests.TestGroupBy frequently crashing on FullAOT/LLVM/Linux/amd64 CI.
https://github.com/mono/mono/issues/10441https://github.com/mono/mono/issues/9554https://github.com/mono/mono/issues/9046
Race condition because the code varies in what actually runs.
Sometimes System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT is called,
sometimes not.
FullAOT+LLVM for obvious reasons.
Very sensitive to exact code presumably because the bug depends on whether the first
unbox trampoline has the same size as the unbox trampoline for System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT?
For example, this could be the only unbox trampoline or it could be first.
For example System_Security_Cryptography_ECCurve_get_Oid gets the first unbox trampoline and compiling it with mini or LLVM makes a difference.
Guessing here:
When the first unbox trampoline is 9 bytes in size and
System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
is 6 bytes in size, then System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT's
unbox trampoline, which comes right before System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
is thought to be 9 bytes also, which overlaps System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT.
So the binary search finds that, which goes wrong somehow -- mono_aot_find_jit_info returns NULL (for reasons not debugged).
And then we fail to wrap System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
with a gsharedvt trampoline.
In the normal course when things work, calling System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
goes through both gsharedvt_out_trampoline and gsharedvt_trampoline.
The first turns a byref into a byvalue, the second turns it back into a byref.
When the second is skipped, we end up treating the value as a pointer and SIGSEGV.
This can be seen using https://github.com/mono/mono/pull/10582.
mini amd64 unbox trampolines are always 9 bytes -- 4 byte add, 5 byte jmp
LLVM amd64 unbox trampolines vary 6 or 9 -- 4 byte add, 2 or 5 byte jmp.
There are *many* possible ways to fix this.
1. Runtime disassembly to measure the trampoline size, each trampoline, allowing just two variations. This was written, tested, works. Downside is inhibits breakpoints, at an unlikely time and place, and inhibits execute only memory protection, also unlikely. Looks a little gnarly, but really is not.
2. Get the assembler to output fixed size trampolines.
This is known for GNU assembler -- (disp32) jmp and jmp.d32.
This is not known for Apple assembler, either the older cctools or LLVM, but maybe.
The problem *seemed* to be Linux only, but the underlying causes do not.
If this were looked into more closely and a Linux-specificity actually found, then depending on GNU as is more reasonable.
3. Output object files instead of assembly text. Good and bad idea otherwise. Super non-trivial.
4. Construct the tramp_info at compile time, with compiler/assembler/linker-computed size. This should be possible and otherwise beneficial, but not trivial, and not super beneficial, only mildly.
const static data/code is generally prefer over dynamic.
5. Don't bother with the trampinfo at all. It should not be needed, even for stackwalk, as these are leaf functions (don't change nonvolatiles), so stackwalk is just *rsp++.
Good idea for another day, as it is a simple net reduction in code, pending testing a not easy to test case -- need to make a function that just jmps to self, point a thread at it, wait till it gets there, suspend it, and stackwalk it. A good exercise, for another time.
6. Pad out trampolines to at least 9 bytes by adding 3x 0xcc.
Sometimes 12 bytes.
And hardcoding size as 9 at runtime -- don't use the actual computed size, as it could be 12, apply that to a 9 byter, and back with the same problem.
That is one incorrect solution in there -- just merely adding 3 bytes of padding seemed at first like a good idea, but would not likely work.
7. Or rather, no need to pad, hardcode to 6 at runtime.
8. Or rather, hardcoding to 5 suffices. Interior bytes of last instruction need not be described, pretend it is of size 1. 2 is no more accurate than 1, when some of them are actually 5.
9. Can hardcode in compiler or runtime.
Both developed, easy.
10. Try current assemblers. Maybe the original reason to switch from 0xe9 to jmp is moot.
But continue to work with old assemblers? (in a test-only scenario?)
Not attempted.
11. Use separate source files to help achieve distance or assembler ignorance of distance.
Not attempted.
12. Move all the trampolines adjacent, with 128 bytes of padding on either end.
Not attempted.
13. Asserting the trampolines are 16-aligned would maybe work. And/or following them with a 16-aligned entity.
Here we option 9, hardcode to 5 in the compiler. It is essentially a one line change.
Removing the trampinfo and testing async stack walk is left as a future change.
This is really the best option but has more significant test burden.
* Increment MONO_AOT_FILE_VERSION to invalidate old bad images.
The badness is borderline -- limited to FullAOT+AMD64+LLVM, which is nonexistant outside test environments. This version should probably be a guid also.
It is not clear how this should be represented.
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa
"Note that an ANSI environment block is terminated by two zero bytes: one for the last string,
one more to terminate the block.
A Unicode environment block is terminated by four zero bytes: two for the last string,
two more to terminate the block."
Is unambiguous however.
* Add support for:
- Get global object - This allows developers access to variables of javascripts global space. For example the window object in the Browser.
- Add reference counting to the javascript object registry in the bindings. This can prevent a javascript object that is in the object registry from being removed unexpectedly.
- Add AddRef and ReleaseRef to manage object registry reference counting if it is needed.
* Add support for an HttpMessageHandler that works for WASM.
- Needs real world testing before we decide to make this a default.
- Depends on the delivered bindings.dll and the bindings support built.
- Due to the bindings dependency there is no need to add extra javascript library to the build.
- Works only through a browser session at this time as it works directly with window.fetch.
* Free the Task Completion Source after the promise completes.
* There are some headers that can only be attached to the Content's Headers.
- If the header returned from fetch can not be added to the response header then try to add it to the Content headers.
- Fix misspelling in binding_support.js
* Remove reference counting from bindings.
- Remove object disposal from WasmHttpMessageHandler.
* Add bindings.dll requirement to wasmhttp.dll build.
* Clear the HttpResponseMessage after setting the TaskCompletionSource so it can be garbage collected.
* [interp] move thread attach to interpreter entry
We want to attach a thread before any TLS operation is done by the
interpreter. In the JIT this happens inside the native-to-managed
wrapper via `mono_threads_attach_coop ()`. Unfortunately, this is too
late for the interpreter as it already requires a working TLS before
even calling into the wrapper.
Also, fixup naming of locals in the native-to-managed wrapper.
* [interp] do not propagate uninitialized ThreadContext to JIT TLS
* [interp] fix memory corruption around pinvoke wrapper allocation
* [interp/jit] fix memory leak in pinvoke wrapper allocation
* Make test.js use generated driver and bindings.
- bindings_tests.dll uses the generated bindings.dll.
- Modify packager to accept a template parameter that overrides the default `runtime.g.js`.
- Modify the tests to call runtime.js in the test-suite directory
- The runtime.js is automatically created in the test-suite library so no need to do extra copies.
- resolves https://github.com/mono/mono/issues/10244
* Add -template option to packager
- Part of merge conflict resolution
* Add -asset option that allows an extra asset to be copied to the output directory.
- --asset=x Add specified asset 'x' to list of assets to be copied
- An asset option needs to be specified for each asset to be copied.
Handle ref returns in runtime invoke wrappers.
Indirectly load ref return values in invoke wrappers and return by value.
Don't share wrappers with ref returns since indirect load is used.
Add soft debugger support for methods with ref returns.
* [metadata] Hack - get mono_use_interpreter from metadata
Don't use this, it's a mistake. The granularity is all wrong, for one: in the
future the interpreter may not be an all-or-nothing deal.
* [marshal] Don't emit CEE_MONO_JIT_ATTACH except for interpreter
Always use the mono_threads_coop_attach/mono_threads_coop_detach pair.
* [aot] Drop MONO_PATCH_INFO_JIT_THREAD_ATTACH
We always emit the mono_threads_attach_coop icalls now.
Bump MONO_AOT_FILE_VERSION
* [mini] mark mono_jit_thread_attach external only
It's used by Xamarin.Mac and possibly other embedders.
Interpreter still used mono_jit_thread_attach_interp until it's fixed to work
with coop.
There shouldn't be any other callers.
* [interp] Add a thread attach EE callback
Use it to set the interpreter thread context on the JIT tls value
* [marshal] Always emit mono_threads_attach_coop instead of CEE_MONO_JIT_ATTACH
Use the coop icall for the interpreter, too.
* [interp] Drop MINT_MONO_JIT_ATTACH and detach opcodes
* [metadata] Drop CEE_MONO_JIT_ATTACH and detach opcodes
* Revert "[metadata] Hack - get mono_use_interpreter from metadata"
This reverts commit c3d2f488b824dcdfa261f8292013c805740f353f.
* [mini] Drop unused mini_jit_thread_attach_interp
It was a temporary workaround for the interpreter; no longer needed.
* [coop] Switch to GC Safe in mono_jit_thread_attach.
It's an external-only function that's not called by the runtime on any
threads. So the only calls are explicit uses by Mono API clients. Leave the
thread in GC Safe mode and leave it to the n2m invoke wrappers or MONO_API
entry points to switch to GC Unsafe.
* [interp] Add MINT_MONO_THREADS_ATTACH_COOP opcode
Because this icall can be called from detached threads, don't go through
do_icall () which needs initialized tls keys
* fixup for c++ build
* fixup indentation and comments
* fixup C++ a bit more
* [mini] Bump MONO_EE_API_VERSION
* Revert "[interp] Add a thread attach EE callback"
This reverts commit 8a343d6ce15f0475a62936f28264f638ebf0344f.
* [interp] sync jittls context before entering EH machinery
Indirectly load ref return values in invoke wrappers and return by value.
Don't share wrappers with ref returns since indirect load is used.
Add soft debugger support for methods with ref returns.
* [wasm] Rename 'wasm-aot' to 'wasm-cross' for consistency with the other SDKs.
* [wasm] Use the separate libmono-ee-interp.a library for linking in the interpreter.
* [wasm] Unify interp and aot runtimes.
* [wasm] Avoid cleaning the emscripten toolchain when cleaning the runtime or cross compilers.
* [wasm] Use the sdk llvm targets to build the cross compiler, so it can use a downloaded llvm instead of building its own.
* [offset-tool] Add WASM support.
* [wasm] Generate offsets file for wasm.
* [wasm] Switch packager.exe to use Mono.Options, add a --mono-sdkdir option to specify the path to the mono sdk.
* [wasm] Emit a ninja build file from the packager when the --builddir argument is given.
* [wasm] Auto generate the aot registration code by generating a driver-gen.c file and including it into driver.c.
* [wasm] Add emcc link step to the ninja build script.
* zoltan's changes.
* [wasm] Fix merge conflicts from picking Zoltan's patches.
* [sdks] Fix the wasm build so the package target doesn't build 394839840 llvms.
* [wasm] Fix mono_arch_create_specific_trampoline to work with the AOT compiler reverse lookup of icalls
* [wasm] Don't set minimum memory size, let it dynamically grow.
* [wasm] Remove old aot targets. Now do-aot-sample does the whole magic.
* [wasm] Attept at making the offsets-tool work on linux.
* [wasm] Cleanup the hacks early in this PR.
* [wasm] Fix rebase issue.
* Fix rebase
* Fix rebase
* [llvm] Only emit the dummy arg when targeting wasm.
Part of #9660.
The changes:
- included corefx version of PropertyInfo type;
- included related xunit tests from corefx System.Reflection;
- moved `GetPropertyFromHandle `method to MonoProperty type;
- moved `internal_from_handle_type `extern method and related icall to MonoProperty type;
- fixed some edge cases where exception is expected;
- removed obsolete System.Reflection/PropertyInfo.cs.
<!--
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.IO] Enable CoreFX FilesystemWatcher on Android
This was the last user of the 'InotifyWatcher' Mono implementation, so this is also removed.
* [csproj] Update project files
* Ensure the finalization of SafeHandle and GCHandle in DeflateStreamNative is performed in the correct order.
* Do not access BaseStream from finalizer.
* Fix Mono Windows cross compiler using mono LLVM release_60 branch.
For scenario where llvm-config.exe can't be run (none WSL/CygWin build target)
Build will fallback to hard coded libraries not working with mono LLVM release_60
branch.
Added an exact mirror of what llvm-config.exe is returning for different components
on mono LLVM master and mono LLVM release_60 branch.
The selected codegen libraries (passed in as extra_libs) was not handled in any cases
so added them into the build script as well.
* Split parameter between lvm codegen libs and llvm extra libs.
Need to explicit pass -lz in case where configure have detected zlib availability
and llvm-config.exe can't be executed. In cases where zlib is not available, default
in mingw installs, this check make sure link step won't fail due to missing library.
* Fix inversion of aarch64codegen libs.
* Enable package-android-cross-{arm,arm64,x86,x86_64}-win builds on CI.
* Fix incorrect checks when compiling Windows cross compiler.
Windows cross compiler could have a target that is !TARGET_WIN32 but still
running on a Windows host, so check needs to look at !HOST_WIN32 to determine
if Unix source files can be included or not.
* [metadata] Fix Thread.Yield icall function signature
The signature exposed on the C# side has a boolean return but the actual C implementation used to be marked as void.
This caused an issue with the WASM backend as the interpreter would try to jump to the icall using an `MINT_ICALL_V_P` opcode. Since emscripten does function pointer jumps based on a function signature key and the signature mismatched on the C side, the jump would fail triggering the `nullFunc_i(x)` on the mono.js side.
* [wasm] Add facade resolving to packager tool
* [wasm] Use correct mono_bindings_init syntax to initialize bindings library
* [interp] Remove some duplicated code
* [interp] Don't abort in critical wrappers
Fixes premature exiting of special threads due to aborts (like threadpool threads), instead of catching exception and resuming to native code.
By default, all projects are build using "default" compiler based on source
file extension. There is a property in mono.props, MONO_COMPILE_AS_CPP
that could change this and build selected projects (eglib, libgcmonosgen,
libmini, libmono-dynamic, libmono-static, libmonodac, libmonoruntime,
libmonoutils, mono, monodis, monograph and pedump) using C++ compiler.
MONO_COMPILE_AS_CPP property could be set when calling msbuild
or through VS property manager IDE. Default value is false building using
"default" compiler (current behavior). When setting MONO_COMPILE_AS_CPP=true
the build prefix will be altered to make sure the C++ build gets its own build
folder, parallel to default build folders.
Example of building using C++ compiler from msbuild:
msbuild /p:PlatformToolset=v140 /p:Platform=x64 /p:Configuration=Release /p:MONO_TARGET_GC=sgen /p:MONO_COMPILE_AS_CPP=true msvc/mono.sln
We can't decrement the size on removal as we use tombstones.
When using tombstones, the invariant to keep is on the number of null entries as those
are used as search stop-marks.
Without this change, it's possible that a long series of add/remove operations could leave the array with no null entries,
just tombstones and filled entries. In that case, search would degenerate into a linear search that would look into all array elements.
This change fixes worst-case perf of not-found searches to be bound to the load factor.
Additionally, clear the array to null entries, otherwise we fall into the above trap even more easily.
* gmisc-win32.c(136): error C2664: 'HRESULT SHGetKnownFolderPath(const KNOWNFOLDERID&,DWORD,HANDLE,PWSTR *)': cannot convert argument 1 from 'const GUID *' to 'const KNOWNFOLDERID
REGUID is const GUID& in C++, const GUID* in C*.
It is impossible to have portable C/C++ that deals with this.
This feels like a mistake, but it is ancient and not changing.
* gpath.c(102): error C2440: '=': cannot convert from 'const char *' to 'char *'
Add const, like in the non-Windows case right before.
* sgen-gc.c(1381): error C4576: a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax
A inline function would trivially portably standardly solve this,
but wrap in compiler-specific pragma to suppress.
* [cxx] abi.c(60): error C2059: syntax error: '.'
Remove designated initializer.
[mono] Compiler warnings fixes
This fixes a bunch of warnings in threads.c. Compare-exchange cast is unfortunate because it would do without if we had platform long sized cas helper around - tid is always u32 on Windows (DWORD), and pthread_t is always long int, which could be 32 or 64 bit.
* Adapt typesafe coop handles to be valid standard C++. i.e. valid for Visual
C++, w/o gcc/clang language extension __typeof__. This is not meant to be
long term idiomatic C++, just enough to get us by for now.
The solution does not quite work for type unsafe handles, because
checking for this == NULL is not defined. A non-member function
would be needed.
C++11 decltype could be used instead at the MONO_TYPEOF_CAST level,
but this solution is trivial C++98.
Visual C++ historically was seen to have trouble giving names
to member functions of anonymous types -- an unusual construct.
So the previously anonymous structs are given a name here.
* Go back to anonymous type.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-ios/4408/parsed_console/log.html
CC libmonoruntimesgen_la-method-builder-ilgen.lo
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/marshal-ilgen.c:6403:29: error: use of undeclared identifier 'MONO_OFFSET_MonoObjectHandlePayload___raw'; did you mean 'MONO_OFFSET_MonoObjectHandle___raw'?
mono_mb_emit_ldflda (mb, MONO_HANDLE_PAYLOAD_OFFSET (MonoObject));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MONO_OFFSET_MonoObjectHandle___raw
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/handle.h:426:42: note: expanded from macro 'MONO_HANDLE_PAYLOAD_OFFSET'
^
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/handle.h:425:50: note: expanded from macro 'MONO_HANDLE_PAYLOAD_OFFSET_'
^
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/abi-details.h:56:42: note: expanded from macro 'MONO_STRUCT_OFFSET'
^
<scratch space>:89:1: note: expanded from here
0dbcdd5c28 added CFLAGS etc in front of the
command but that's not something the TESTCMD can execute.
We need to pass those variables to the whole process.
Part of https://github.com/mono/mono/issues/9660
The changes:
- included corert version of CustomAttributeTypedArgument type;
- included related xunit tests from corefx System.Runtime;
- updated corert/Type.cs to have some required properties from corert Type.Internal.cs;
- removed obsolete System.Reflection/CustomAttributeTypedArgument.cs;
- moved back "array case" handling in CustomAttributeTypedArgument ctor (via related PR);
- re-enabled "Arrays" test in CustomAttributeDataTest on mobile.
* [cxx][metadata] Cast from void.
* [cxx][metadata] Casts, mostly from void*.
* [cxx] [metadata] MONO_BEGIN_DECLS / MONO_END_DECLS only in public headers.
G_BEGIN_DECLS / G_END_DECLS are ok in private headers (and .c), but the vast majority of uses are not needed. In this case, every function is MONO_API anyway.
* [cxx] [metadata] Add template for mono_mb_emit_native_call under #ifdef __cplusplus.
* [cxx] [metadata] Loosen the parameter type in mono_vtype_get_field_addr from guint8* to gpointer.
* [cxx][metadata][profiler] Add G_ENUM_FUNCTIONS (MonoProfilerCallInstrumentationFlags), outside of the public header MonoProfilerCallInstrumentationFlags is defined in.
* [cxx][metadata][profiler] Cast void* to function pointer MonoProfilerCallInstrumentationFilterCallback.
* [cxx][metadata] Cast from void*.
* [cxx][metadata][sgen] Change sgen_client_root_registered(source) from int to enum MonoGCRootSource.
* [cxx][metadata][sgen] Change report_conservative_roots(root_report_address) from char* to void*.
* [cxx][metadata][sgen] In mono_gc_register_obj_with_weak_fields, cast parameter from void* to MonoObject*.
* [cxx][metadata][sgen] In sgen_client_gchandle_created and sgen_client_gchandle_destroyed, cast handle_type from int to MonoGCHandleType. This could be better.
* [cxx][metadata][sre] In mono_dynimage_encode_constant, change local box_val from char* to void*.
* [cxx][metadata][sre] Change swap_with_size(dest, val) from {,const}char* to {,const}void*. Move function starting brace to its own line.
* [cxx][metadata][sre] encode_cattr_value(argval) from char* to const void*.
* [cxx][metadata][sre] Add ICALL_EXPORT to ves_icall_TypeBuilder_create_runtime_class.
* [cxx][metadata] Templatize mono_thread_create_internal and mono_thread_create_checked. FIXME: Fix the parameter type and inputs.
* [cxx][metadata][threads] Cast from void* to MonoCoopMutex*.
* [cxx] Fix return type of start_wrapper_internal -- guint32 vs. gulong.
* [cxx][metadata] In start_wrapper_internal, cast function pointer to void*. Later we should get all the types correct.
* [cxx][metadata] Fix return type of start_wrapper from gsize to mono_thread_start_return_t.
* [cxx][metadata] create_thread: Remove cast on first parameter to mono_thread_platform_create_thread.
* [cxx][metadata] Add ICALL_EXPORT on ves_icall_System_Threading_Thread_GetPriority.
* [cxx][metadata] g_cast does not allow for ternary operator though it could with one line; add casts to workaround; remove cycle optimization from error path, favoring smaller code.
* [cxx][metadata] ves_icall_System_IO_MonoIO_Read, ves_icall_System_IO_MonoIO_Write: Change relatively untyped data from char* to void*.
* [cxx][metadata] Add parentheses around define INVALID_HANDLE_VALUE to avoid surprises.
* [cxx][metadata] In mono_w32handle_convert_wait_ret, cast between int and enum MonoW32HandleWaitRet. We could also give up on enums for this type.
* [cxx][metadata]ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal: Add cast to HWND.
* [cxx][metadata] Cast to HMODULE. Add const.
* [cxx] w32process.h: Add missing ICALL_EXPORT.
* [cxx][metadata] w32socket-win32.c: add const on string literals.
* [cxx] mono_w32socket_recvbuffers: cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.
* [cxx] mono_w32socket_send: cast from void* to char*.
* [cxx]mono_w32socket_sendbuffers cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.
* [cxx] mono_w32socket_getsockopt cast from void* to char*.
* [cxx] mono_w32socket_setsockopt cast from const void* to const char*.
* [cxx] mono_w32socket_ioctl fix out parameter written from glong* to DWORD* to avoid casts.
* [cxx] [w32socket] Remove casts on calls to mono_w32socket_getsockopt and mono_w32socket_setsockopt since they nicely accept void* and const void*.
* [cxx][w32socket] Change output_bytes from glong to the correct DWORD to avoid casts.
* [cxx] Add ICALL_EXPORT to ves_icall_cancel_blocking_socket_operation.
* [cxx] Remove keyword 'template'.
* PR: Revert "[cxx] Fix return type of start_wrapper_internal -- guint32 vs. gulong."
This reverts commit 8e02c9cf732a80b77af59b9a11fceaca7490a87c.
https://github.com/mono/mono/pull/10432#discussion_r215009888
This area of thread creation needs work.
1. We have function pointers with almost gratuitous casts,
2. inconsistent return types (motivating function pointer casts)
3. return values ignored
https://github.com/mono/mono/issues/10467https://github.com/mono/mono/issues/10319#issuecomment-417739621
and more.
* [cxx][mini] compile_methods: cast function pointer passed to mono_thread_create_internal to void*. This should be improved in future.
* [cxx][mini] mono_read_method_cache: C++ does not allow goto around initialization.
* [cxx][mini] mono_read_method_cache: C++ does not allow goto around initialization.
* [cxx][mini] decode_exception_debug_info: Use Enum a |= b instead of a = (Enum)(a | b); one of these might be have recent damage.
* [cxx][mini] init_method: C++ does not allow goto around initialization.
* [cxx][mini] get_new_trampoline_from_page: cast twice to guint8* instead of void*.
* [cxx][mini]Strengthen MonoAotFileInfo.runtime_version from void* to char*.
* [cxx][mini] Weaken decode_vtype(addr, buf) from guint8* to void*, but then assign right back to guint8* locals for easy to author and read diff.
* [cxx][mini] Weaken decode_value(addr, buf) from guint8* to void*, but then assign right back to guint8* locals for easy to author and read diff. (like previous but decode_vtype vs. decode_value)
* [cxx][mini] vm_commands: standard C++ has no designated initializers; actual support by compilers varies, but effectively no support and trivial to do without. (current clang++ good support, current g++ some support, g++4.4 no support, msvc presumed no support).
* [cxx][mini] Cast function pointer from void* to correct type.
* [cxx][mini] exceptions-amd64.c: mono_arch_ip_from_context: cast from integer to void*.
* [cxx][mini] exceptions-amd64.c: mono_arch_ip_from_context: cast from void* to MonoContext*.
* [cxx][mini] exceptions-amd64.c: fast_find_range_in_table_no_lock_ex: Cast from void* to DynamicFunctionTableEntry* twice. On the second one, it might be clearer to put the cast further to the left, i.e. just after =.
* [cxx][mini] exceptions-amd64.c: initialize_unwind_info_internal: Cast parameter to mono_arch_unwindinfo_create to void**.
* [cxx][mini] exceptions-arm.c: mono_arm_get_exception_trampolines: Change local variable tramp from guint8* to void*.
* [cxx][mini]exceptions-wasm.c: Cast returned function pointers to void* a few times.
* [cxx][mini] exceptions-x86: Fix win32_handle_stack_overflow(sctx) to be CONTEXT* instead of struct sigcontext *.
* [cxx][mini] exceptions-x86: win32_seh_init: Cast mono_win32_get_handle_stackoverflow() from void* to correct function type.
* [cxx][mini]mono_arch_exceptions_init: Cast GetProcAddress() to correct function pointer type and call through correctly typed function pointers.
* [cxx][mini]exceptions-x86.c: mono_arch_ip_from_context: Cast from integer to void*.
* [cxx][mini]exceptions-x86.c: mono_arch_handle_exception: Cast from void* to struct sigcontext*.
* [cxx][interp] C++ deprecates the register keyword, remove it.
* [cxx][interp] C++ deprecates the register keyword, remove it.
* [cxx][mini] liveness.c: Change MonoPtrSet to a union and then use GHashTable* instead of void* instead of casting from void*.
* [cxx][mini] main.c: probe_embedded: Change local item_size from uint64_t to uint32_t to fix error about it being truncated when initializing MonoBundledAssembly. Could cast instead.
* [cxx][mini] C++ does not allow goto around initialization.
* [cxx][mini]Do not mixup enum types between MONO_CEE_ and CEE_. This fixes an error. We might wanto have the one set of values alias the other, but this wasn't a big problem actually.
* [cxx][mini] C++ does not allow goto around initialization.
* [cxx][mini] Cast from void*.
* [cxx][mini] Cast pointer to pointer-sized integer before casting
to integer or enum. Otherwise errored.
* [cxx][mini] Cast function pointer to void* to mono_arch_instrument_prolog() and mono_arch_instrument_epilog().
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8* -- probably reduced need for additional casts.
* [mini] A field per line (MonoCompileArch.omit_fp, omit_fp_computed).
* [cxx][mini] Cast mono_aot_get_trampoline() to guint8* from void*.
* [cxx][mini] Cast parameters to __builtin___clear_cache from guint8* to char*.
* [cxx][mini] Remove casts on mono_arch_get_seq_point_info().
* [cxx][mini] Cast g_hash_table_lookup() from void* to SeqPointInfo*.
* [cxx][mini] Cast integer to enum MonoJumpInfoType. Could maybe change the incoming type to MonoJumpInfoType.
* [mini] A field per line (MonoCompileArch.omit_fp, omit_fp_computed).
* [cxx][mini] Remove cast to CallInfo*.
* [cxx][mini]mini-arm64.c: Cast pointer to pointer-sized integer before casting to other integer or enum.
* [cxx][mini] Cast from void* to guint8*, though this one is now covered by g_cast.
* [cxx][mini] Change types and add casts due to void*/non-void* mix.
* [cxx][mini] mini-exceptions.c: first_managed change local data from void*** to void**, and likewise the cast on its assignment.
* [cxx][mini][profiler] Cast integer to enum MonoExceptionEnum multiple times.
* [cxx][mini] Weaken mono_handle_exception(obj) from MonoObject* to void*, and then store it right into a local MonoObject*. This alleviates casts elsewhere.
* [cxx][mini] Cast g_hash_table_lookup() from void* a few times.
* [cxx][mini] More pointer casts.
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8* to alleviate casts.
* [cxx][mini] Cast result of mono_arch_instrument_prolog() and mono_arch_instrument_epilog().
* [cxx][mini]Change MagicTypeInfo.{big_stack_type,small_stack_type,stack_type} from short to enum MonoStackType : 16, under #ifdef __cplusplus, to allevate casts and strengthen types.
* [cxx][mini] Cast from integer to enum MonoStackType. This can probably be improved, i.e. by changing the source type to enum.
* [cxx][mini]emit_intrinsics: Change local stack_type from int to MonoStackType to alleviate casts and strengthen types.
* [cxx][mini] Cast from integer to enum MonoStackType. This can probably be improved, i.e. by changing the source type to enum.
* [cxx][mini] Cast pointers g_hash_table_lookup() and profiler input (byte* instead of void*).
* [cxx][mini] Fix the function pointer parameter type to add_signal_handler so avoid casts, but add one cast from function pointer to function pointer for systems lacking MONO_ARCH_USE_SIGACTION.
* [cxx][mini] mini-posix.c: sampling_thread_func: Remove designated initializer.
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8*() to reduce casts at its callers.
* [cxx][mini] Undo g_cast support on mono_arch_instrument_prolog() and mono_arch_instrument_epilog(), probably a mistake from a recent other PR, harmless. i.e. remove parens from around that suppress macro expanstion
* [cxx][mini] Cast return of mono_arch_instrument_prolog and mono_arch_instrument_epilog to guint8*.
* [cxx][mini] Remove a layer from some TLS access -- macro vs. function that might not inline.
* [cxx][mini] Strengthen the parameter to mono_set_lmf_addr() from void* to MonoLMF**.
* [cxx][mini] Provide a typedef MonoAbortFunction for MonoJitTlsData.abort_func.
* [cxx][mini] Strengthen the output of setup_jit_tls_data from void* to MonoJitTlsData* and the input function pointer from void* to MonoAbortFunction, eliminating existing and future casts.
* [cxx][mini] A few pointer and enum/int casts.
* [cxx][mini] Change mini_llvmonly_initial_imt_tramp locals from gpointer* to IMTTrampFunc** to alleviate casts.
* [cxx][mini] Cast some function pointers to void*.
* [cxx][mini] Cast void* to MONO_SIG_HANDLER_INFO_TYPE* for the non-HAVE_SIG_INFO case. We could maybe change the void* local to MONO_SIG_HANDLER_INFO_TYPE*, since we are casting it to that anyway.
* [cxx][mini] Cast function pointer to void*.
* [cxx][mini] Cast void* to GSList* twice.
* [cxx][mini] Cast function pointer to mono_runtime_init_checked. In future we should get all these types and parameters to match.
* [cxx][mini] Cast result of mono_arch_instrument_prolog/mono_arch_instrument_epilog to guint8*.
* [cxx][mini]Change return type of get_delegate_invoke_impl from void* to guint8*.
* [cxx][mini] Cast result of mono_arch_instrument_prolog/mono_arch_instrument_epilog to guint32*.
* [cxx][mini] Cast function pointers to void*.
* [cxx][mini] Cast from void* to non-void*.
* [cxx][mini] Change types and add casts due to void*/non-void* mix.
* [cxx][mini] Pointer casts.
* [cxx][mini] Pointer and int/enum casts, and widen pointer before casting to smaller integer.
* [cxx][mini] Strengthen types from void* to non-void* within x86 MonoCompileArch. (void *cinfo, *ss_tramp_var, *bp_tramp_var; => CallInfo *cinfo; MonoInst *ss_tramp_var; MonoInst *bp_tramp_var;)
* [cxx][mini] int/enum casts
* [cxx][mini] create_jit_info: Use Enum a |= b instead of a = (Enum)(a | b); one of these might be have recent damage.
* [cxx][mini] Pointer/int/enum casts.
* [cxx][mini] Change mono_cfg_set_exception(int) to mono_cfg_set_exception(MonoExceptionType) to reduce casts elsewhere.
* [cxx][mini] Pointer cast.
* [cxx][mini] Change mono_cfg_set_exception(int) to mono_cfg_set_exception(MonoExceptionType) to reduce casts elsewhere.
* [cxx][mini] Pointer casts.
* [cxx][mini] recursively_make_pred_seq_points: Fix parameter to g_array_index from void* to MonoInst*.
* [cxx][mini] Change parameter to decompose_vtype_opt_load_arg from guint32* to gint32*, and assign right back to local guint32*, to avoid casts, and limit diff, and obviously preserve semantics.
* [cxx][tasklets] Add include loader-internals.h.
* [cxx][mini]Fix cast mono_win32_get_handle_stackoverflow() to function pointer restore_stack.
* [cxx][mini] Casts. See https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android/4480/parsed_console/log.html.
* PR: Replace goto up with goto down, and split decl/init instead.
https://jenkins.mono-project.com/job/w/15083/parsed_console/log.html
assembly.obj : error LNK2001: unresolved external symbol "struct _IMAGE_DOS_HEADER __ImageBase" (?__ImageBase@@3U_IMAGE_DOS_HEADER@@A) [d:\j\workspace\w\msvc\libmono-dynamic.vcxproj]
d:\j\workspace\w\msvc/./build/boehm/Win32\bin\ReleaseCxx\mono-2.0-boehm.dll : fatal error LNK1120: 1 unresolved externals [d:\j\workspace\w\msvc\libmono-dynamic.vcxproj]
Since it is data, extern "C" w/o braces is confusing, but maybe valid, so begin/end form is used.
When creating a diff on windows, the lines are split on the `\n` so the `\r\n` results in multiple lines:
**START SNIP**
Obsoleted methods:
```diff
[Obsolete ("Use AddRoundRect instead.")]
public void AddRoundedRect (SKRect rect, float rx, float ry, SKPathDirection dir);
```
**END SNIP**
This PR makes sure to use the platform line endings everywhere. When adding line endings, use the same that `StringBuilder` uses - platform endings. This makes it easy to split - just use the platform as that is what everyone is using.
* Fix mkbundle alignment to work with Windows. See https://github.com/mono/mono/issues/8225.
Consider doing this only for Windows.
* Align only first file at 64K, the rest the previous 4K.
* Ensure strings are nul terminated, if alignment doesn't handle it.
StringPairs already are.
* Save 30K on average on Unix, for an entire bundle (not per file within, but the entire bundle).
* Probe runtime for for MZ signature to determine if target
is Windows. "Style" is about host.
* [sdks] Add CrossRuntimeTemplate
* [sdks] Add cross-{arm,arm64,x86,x86_64}{,-win} runtimes for XA
* [sdks] Use CrossRuntimeTemplate for iOS
* [sdks] Factor various variables for RuntimeTemplate
* [sdks] Use MonoRuntime template for desktop-x86_64
* [sdks] Unify provisioning of LLVM for both Android and iOS.
A global CFLAGS would be set in `run-jenkins.sh`, and that would screw up with LLVM. The global CFLAGS makes sense as long as we are only building Mono, but that's not the case with LLVM anymore.
* [sdks] Remove android-armeabi, it's been removed from XA already and the target has been deprecated in the NDK
* [jit] Add intrinsics for Math.Round/Floor/Cecil () on SSE41.
* Add LLVM support.
* Fix the build.
* Move the code to mono_arch_emit_inst_for_method ().
* Fix the build.
* [Mono.Options] Add `CommandSet.GetCompletions()`
Add a `Mono.Options.CommandSet.GetCompletions()` method, which returns
all possible commands which match a given "completion prefix".
This is intended for e.g. bash completion support.
* Bump API snapshot submodule
Part of #9660.
The changes:
- included FieldInfo type from CoreFX + related xunit tests;
- made Mono-implemented class partial; removed duplicated code;
- moved GetOptionalCustomModifiers and GetRequiredCustomModifiers methods to MonoField type;
- moved GetTypeModifiers extern method and related icall to MonoField type;
- updated ToString method in CustomAttributeTypedArgument type with CoreFX implementation;
* [cxx] Add const, and static while there.
* [cxx] Auto cast in ARM_EMIT
* [cxx] Cast from int to enum.
* [cxx] Cast from void*.
* [cxx] Cast function pointer to void*.
* [cxx] Cast int to GCHandleType.
* [cxx] Cast to GCObject*.
* [cxx] Cast unsigned char* [cxx] to char*.
* [utils] Cast void* [cxx] to function pointer (FIXME) and remove extra parens (former macro?).
* [cxx] Change int parameter to enum MonoGCRootSource.
* [cxx] Do not goto around init.
* [cxx] Fix cast -- void* [cxx] vs. void**, and volatile per error but it is optional.
* [cxx] Fix type for pointer to array element -- void** [cxx] vs. void*.
* [cxx] Remove duplicate line from Makefile.
* [cxx] Remove incorrect cast.
* [cxx] Remove unneeded cast.
* [cxx] Spell out enum values for easier to read headers.
* [cxx] Split up compound initialization with NULL because the types vary, i.e. remove implicit conversion from void* that would need a cast.
* [cxx] Static thread locals fail to link on Linux; make them extern. FIXME?
* [cxx] Strengthen void* [cxx] to SGenFinalizationProc.
* [cxx] Templatize mono_native_thread_create (FIXME).
* [cxx] Use G_BEGIN_DECLS not MONO_BEGIN_DECLS in non-public headers, for brevity and subtle extra annotation.
* [cxx] Widen integer to pointer-size before casting to pointer.
* [cxx] Wordsmith comment.
* [cxx] Wrapping a bunch of includes in extern "C" is generally in poor form and unnecessary.
* [cxx] [sgen] Remove unnecessary cast.
* [cxx] [sgen] casts
* [cxx] [utils] Add const with a string literal.
* [cxx] [utils] Casts from void* [cxx] and between int/enum.
* [cxx] [utils] Clarify empty macros.
* [cxx] [utils] Compile more as C++ if enabled.
* [cxx] [utils] extern "C" mono_file_map_error. (FIXME?)
* [cxx] [utils] Remove autocast from mono_lock_free_alloc.
* [cxx] [utils] ifdef wasm the type in unused mono_pages_not_faulted so it compiles, remove incorrect comment, add FIXME.
* Use typedefs of structs in the usual fashion.
* [cxx] externC to the 'operating system'
* [cxx] Add externC for debugger interop.
* Fix indentation.
* [cxx] externC on chkstk.
* [cxx] externC on sys_icache_invalidate.
* [cxx] externC on __aeabi_read_tp.
* [cxx] externC on sys_icache_invalidate.
* Remove exactly duplicated license.
* __EGLIB_X11 is defined but never used.
* Let compiler decide inline.
* Get ves_icall_System_Environment_GetOSVersionString declaration from environment-internal.h.
* Put ves_icall_System_Reflection_Assembly_GetCallingAssembly at start of line for grep ^foo.
* Remove accidental space.
* Remove casts and error_init.
* Fix warning: sgen-mono.c:959:36: warning: incompatible pointer to integer conversion passing
'void *' to parameter of type 'MonoGCDescriptor'
(aka 'unsigned long long') [-Wint-conversion]
return mono_gc_alloc_fixed (size, NULL, source, key, msg);
* Add a comment and associate comment more closely with code.
* Remove gratuitous pragma -- header is only included once, fix the include.
* [cxx] Just enough extern "C" for profilers, libtest, MonoSupportW, MonoPosixHelper, THREAD_INFO_TYPE, WebAssembly interop.
Some of this is redundant, i.e. in glib.h and mono-threads-coop.h.
But if someone removes otherwise unnecessary header wrappers, these become meaningful.
This is an alternative to:
https://github.com/mono/mono/pull/10160 Remove most G_BEGIN_DECLS but add back to make things work.
https://github.com/mono/mono/pull/10284 Port libtest to C++
https://github.com/mono/mono/pull/10294 Rework mono-threads.h THREAD_INFO_TYPE parameterization to not violate C++ typesafe linkage.
https://github.com/mono/mono/pull/10297 Fix typesafe linkage problem in gc-internals.h THREAD_INFO_TYPE parameterization.
https://github.com/mono/mono/pull/10341 Port all of MonoPosixHelper MonoSupportW to C++, including K&R zlib.
https://github.com/mono/mono/pull/10342 Port profilers to C++
https://github.com/mono/mono/pull/10378 Port all of MonoPosixHelper MonoSupportW to C++, except K&R zlib.
https://github.com/mono/mono/pull/10375 Eliminate THREAD_INFO_TYPE by suggestion, to fix typesafe linkage.
https://github.com/mono/mono/pull/10379 Mark the 14 functions used by MonoPosixHelper as extern "C" (basically this PR)
Most of the alternatives are very reasonable and remain viable, except porting K&R zlib.
Hopefully in future, SgenThreadInfo will derive from MonoThreadInfo, improving the THREAD_INFO_TYPE fixes.
* [cxx] Replace invalid two extern "C" with just one.
* Strengthen MonoImage.aot_module and _MonoJitInfo.aot_info to be MonoAotModule* instead of void*.
* Strengthen thread locals away from void*.
* Strengthen _MonoThreadInfo from void* to HandleStack*.
* Elminate "struct".
Introduce mono-forward.h and mono-forward-internal.h.
Add cast for profiler.
* Strengthen tramp_info; remove struct on JitInfo; remove a cast.
* Tweak and add #includes accordingly.
Any header that was providing a typedef, or forward declaring a struct and now
using typedef instead must include a header to get it.
Internal types must come from internal header.
Internal header may include internal header.
Public header must not include internal header.
foo.c does not have to include what foo.h must include to declare foo.c's functions (mono-tls.c
does not need to include mono-forward-internal.h)
I misssed mono/metadata/metadata-internals.h: void *image_info; do it later.
* Remove use of sln dependencies and use csproj project references instead
* Rewrite jay.vcxproj so it builds correctly even without help from the sln file
* Force pre-build event to run after references are resolved. Change how culevel.exe path is computed to be more resilient.
* [csproj] Update project files
See my comments in https://github.com/mono/mono/pull/10134 for details.
The problem was that
1. It is wrong to assume that `chain != null`. In fact, it likely won't be if `wantsChain == false`.
2. Similarly, the `storeCtx` should only be used if `storeCtx != NULL && wantsChain == true`.
3. It was missing `MonoBtlsX509Error.HOSTNAME_MISMATCH`.
4. I reformatted and re-indented the method to match Mono's style.
Since `mono_raise_exception_deprecated` never returns, the transition won't be
balanced. This fixes a cookie-counting problem (assert on mono shutdown) in
coop and hybrid checked builds using the new test case:
MONO_THREADS_SUSPEND=coop MONO_CHECK_MODE=thread,gc mono mono/tests/install_eh_callback.exe
* [cxx] Port mono main to be in C++.
This allows to remove more extern "C" from glib.
* [cxx] DllMain should be extern "C".
* [cxx] Make OutOfProcessFunctionTableCallback and OutOfProcessFunctionTableCallbackEx externC.
* Remove do-nothing line and change .o to $(OBJEXT).
[sgen] Fix string size inconsistency between alloc/scan
This could lead to crashes when having strings with size at the LOS boundary.
https://github.com/mono/mono/issues/10309
<!--
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
-->
Pass arguments to LLVM's LLC via --aot=llvmllc
Currently we can override arguments passed to llvm's `opt` via `--aot=llvm,llvmopts="some args"`, this PR introduces a similar capability for `llc` - `llvmllc` parameter.
E.g. for my environment Mono uses the following arguments for llc:
```
-march=x86-64 -mattr=sse4.1 -asm-verbose=false -disable-gnu-eh-frame
-enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_fffff_eh_frame
-disable-tail-calls -no-x86-call-frame-opt -relocation-model=pic
-filetype=obj -o "mono_aot_IWvNWm/temp-llvm.o" "mono_aot_IWvNWm/temp.opt.bc"
```
what if I want to test some avx stuff, e.g. `-march=core-avx2 -O2` and test other parameters.
Extracted custom marshaler logic into managed code.
Fixed crash when using mono_verbose_method
Fixed free of zero desc ptr in mini_method_compile when verbose method variable doesn't resolve to a method
If the cfg is in verbose mode emit a brief message on abnormal termination of IR generation
Use CEE_MONO_CLASSCONST to store the type of the custom marshaler since it appears to work with AOT
Handle various error conditions in Marshaler.GetInstance and produce exceptions that roughly match .net framework
Use ValueTuple instead of a custom tuple type. Use LazyInitializer to init dictionary for marshalers on demand.
Add test case for custom marshalers in linker tests (disabled because the linker does not understand custom marshalers yet)
* [cxx] Make some code valid C++, esp. adding casts and esp. not touching allocators.
* [cxx] PR: Update comment on MonoThreadPriority.
* [cxx] PR: Provide templates for register_icall mono_mb_emit_icall
mono_register_jit_icall mono_register_jit_icall_full mono_aot_register_jit_icall
to cast from arbitrary type to gpointer or gconstpointer.
Ideally this would be limited to function pointers but anything is progress here.
* [cxx] Move C++ template mono_add_internal_call from loader.h to new loader-internals.h.
[cxx] Add C++ template register_opcode_emulation.
[cxx] Add C++ template register_icall.
[cxx] Add C++ template register_icall_no_wrapper.
[cxx] Add C++ template register_icall_with_wrapper.
[cxx] Add C++ template mono_emit_jit_icall.
[cxx] Add C++ template mini_register_opcode_emulation.
[cxx] Add #include loader-internals.h.
[cxx] Remove preemptive extern "C++" until/unless needed.
* [cxx] Change preexisting #define register_icall to C++ templates.
- #define HAVE_SGEN_GC in order to get missing prototype of sgen_sort.
- Move main to static libraries, in order to compile as C++ but not link as C++.
Linking pedump as C++ in particular broke running it in Windows x64 CI.
- Some const fix.
- "class" => "klass"
There are advantages and disadvantages here.
adv: No file rename.
dis: Not linking to libc++ -- which broke Windows x64 CI running pedump.
adv: Linking with -xc++ incorrectly treats .o/.a files as C++ text and fails to link; avoids that.
Moving these to C++ enables the runtime to not need extern "C" sprinkled around
on internals -- which was done but not accepted (https://github.com/mono/mono/pull/10160#pullrequestreview-148551783).
Free the thread_info_key and thread_exited_key during unload
Fixes a crash where pthread_key_clean_all will call destructors that should have been freed before unload.
[mini] fix memory dumping on devices
also, guard for `IP == NULL`: I haven't seen it in the wild, but when messing with EH I have seen it happen and then we have a segfault in the signal handler, which is... bad 😄
we should backport this to `2018-06` and `2018-08`.
- Add a private static variable to HttpClient called `Func<HttpMessageHandler> GetHttpMessageHandler` that will be used to obtain the default message handler and can be set for example as follows:
```
var httpMessageHandler = typeof(HttpClient).GetField("GetHttpMessageHandler",
BindingFlags.Static |
BindingFlags.NonPublic);
httpMessageHandler.SetValue(null, (Func<HttpClientHandler>) (() => {
return new MyHttpClientHandler ();
}));
```
- If a handler is not set or returns null the default implementation HttpClientHandler will be returned.
- Add HttpClient.wasm.cs implementation to handle the default HttpClient
- Add simple test to the wasm test harness bindings-test.
- Reference https://github.com/mono/mono/issues/9941
<!--
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
-->
* [cxx] int vs. enum.
There are at least three or so approaches to this.
1. Sprinkle around casts.
2. Overload operators.
2a. Bit-only (| & ^ |= &= ^=) This PR.
2b. Also math (+ - ++ -- == !=)
3. typedef to int instead (https://github.com/mono/mono/pull/10231)
They all have tradeoffs.
1. Casts: The most line damage. Not huge, but the most.
2. Overloads: New idiom to some but an old idiom. Supported in this way by windows.h even.
This is the most "C++y solution".
3. int: Highest level of source compat and semantic compat. Least line damage (just
change the declarations). Least debuggable and least typesafe.
In terms of semantic compat, even in C the guarantees aren't particularly strong.
Some enums will be int, some unsigned, depending on the values and the compiler.
Perhaps even other types, but I doubt it.
I observe C++ compilers don't tend toward unsigned the same way, so switching
to C++ will on some platforms lose unsignedness. Given we didn't have it portably
anyway, should be ok.
A typesafe enum has the properties that enum A cannot be silently assigned to enum B (ok,
there might be a warning), or from an integer.
A typesafe enum, bitfield or otherwise, can/will be shown symbolically by a debugger.
(lldb does not handle bitfields, only strict enums)
A C enum might be debuggable, w/o typesafety.
A C enum can be freely mixed with other enums and integers.
A C++ enum is more restricted.
Using typedef int, is a maybe surprising option, but does provide the closest meaning to C enum.
Per guidance, this PR also changes one enum to #defines + int.
* PR: "mono" => "g"
"T" => "type"
static_cast where it works (not to reference)
Use templatized typedef instead of macro, if it works on g++4.4.
Add test.
Provide to build eglib tests.
Borrow CXXFLAGS_COMMON from https://github.com/mono/mono/pull/10271.
Add some const to test harness.
* g++4.4 compat (not quite C++11) -- use macro, not template typedef.
* Fix real problem with aliasing seen with g++4.4.
Use attribute(may_alias) when casting pointers/references.
* Add mono/eglib/test/enum.cpp.
gcc/clang do have __restrict and/or __restrict__.
On MacOSX, __restrict is preprocessed out of the headers for C++.
On Linux, __restrict is used and preserved for C++.
I didn't check others.
__restrict does not appear to be part of the function signature.
You cannot overload on it.
It is not in the mangled name.
If you declare one way and implement the other, there is no warning or error.
Therefore, remove restrict.
There are alternatives.
One could preserve it for C only.
One could preserve it for C and for Linux/C++.
One could preserve it based on autoconf, and autoconf results on Mac and Linux.
Perhaps as well we will autoconf or ifdef wasm away use of these functions?
If we merely if them away, we still need them.
Needed for TimeZoneInfo.
Imports CoreFX's Registry API for Windows. Other platforms use old mono file-based Registry API implementation because CoreFX doesn't support it yet, see: https://github.com/dotnet/corefx/issues/14896
(however, some basic types such as enums are imported for all platforms)
Part of #8131
When the TLS Handshake fails in `MonoTlsStream.CreateStream()`, then we must dispose
the `SslStream` to avoid a memory leak.
In addition to this, `MonoTlsStream` now implements `IDisposable` and is disposes
in `WebConnection.CloseSocket()`.
Fixes#8689
Part of #9660.
The imported CoreFX types:
- MemberInfo;
The changes:
- used MemberInfo type from CoreFX;
- moved MetadataToken property from MemberInfo to leaf classes; added unit tests.
- updated icall-def.h for related types;
- updated corlib version;
- added overridings for new HasSameMetadataDefinitionAs property to leaf classes;
- included more MemberInfo xunit tests to verify HasSameMetadataDefinitionAs property;
- renamed MemberInfoExtensions class to DbLinqMemberInfoExtensions in System.Data.Linq assembly to avoid a conflict with the class imported to System.Reflection namespace.
- [acceptance-tests] removed AssemblyExtensions class which duplicates the same functionality introduced in System.Reflection.
* Fix layout of scrollbars in combobox.
* Fix TextBox height fixup to work properly inside TableLayout.
* Fix changing TextBox font before the Control handle has been created.
* Add test case.
* Reintroduce fix for TextBoxTest.Bug82749. We need to save the user requested control bounds outside of ExplicitBounds since ExplicitBounds are used by table layout engine.
The issue was that packager.exe was using Mono.Cecil from net_4_x, which is only built/installed if the desktop sdk is built. We replace
Finally, we change the CI script to disable desktop as well to ensure we don't regress in that scenario.
The llvm/llvm_config.mk makefile fragment just includes make (not automake)
variable definitions. So there is no need to regenerate the mini/Makefile.am
file if the fragment updates - the include will pick it up.
* [w32socket] Refactor ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal and ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal into common mono_w32socket_getname.
* [w32socket] Zero consistently. Note that a statically sized struct sockaddr_storage would be appropriate here.
* [cxx] Remove goto around init.
* PR: [w32socket] Use gboolean local instead of function-pointer/string to mono_w32socket_getname.
Restore lost comment.
* [cxx] [w32socket] Remove ternary operator on allocators so that rvalue constructor
can be removed here: https://github.com/mono/mono/pull/10027#issuecomment-414848498
Provide for void* to non-void* conversion on common allocators (g_malloc, etc.) to "just work", via perhaps a bit of a surprising twist ("hack" or "technique"?).
This greatly reduces the churn of C to C++ conversion.
This helps handle.h in 3 places, at least 2 of which could use C++11 `auto` instead.
Ternary operator has reduced functionality as a result.
Either:
1. Put in rvalue constructor, omitted here.
2. Cast both sides of the ternary.
3. Don't ternary.
This impacted only here:
https://github.com/mono/mono/pull/10206/commits/b543f3f0fd71e5801af059663b4d7b01a6390707
Add some explicit casts.
Remove `register`, as it is deprecated (warning or error) and means little (it does prevent taking-address, which helps optimizers).
Add parens missing in macros.
Favor `gssize` over `long` for consistency on Win64.
Implement a two-phase hybrid suspend scheme:
1. In the _entente phase_ put all threads in the suspend request state (either `ASYNC_SUSPEND_REQUESTED` or `BLOCKING_SUSPEND_REQUESTED`). Wait for pending operations (but only wait for the async ones) and let all threads try to self-suspend.
2. In the _aggressive mop-up phase_ - preemptively suspend any threads that are still in `BLOCKING_SUSPEND_REQUESTED`.
* [coop] Check async suspend status in ReqSuspendInitSuspendBlocking case
So the issue is that calling begin_suspend_for_blocking_thread under hybrid
suspend will perform a preemptive suspension of the victim thread.
The preemptive suspend doesn't always succeed.
In particular, thread_state_init_from_sigctx or thread_state_init_from_handle
could return FALSE and into->suspend_can_continue will be set to FALSE.
When the thread_state_init_* functions return FALSE, they also set the
MonoThreadUnwindState:valid to FALSE.
So it is important to check the value of MonoThreadInfo:suspend_can_continue
before proceeding with a suspension.
As a result in suspend_sync in the ReqSuspendInitSuspendRunning case we call
check_async_suspend which checks (for preemptively suspended threads) whethere
suspend_can_continue is true. If it isn't, we resume the victim thread and
loop once more in suspend_sync_nolock and try again.
We didn't have a check_async_suspend call in the ReqSuspendInitSuspendBlocking
case, so a thread could be considered suspended even if we couldn't capture a
valid MonoThreadUnwindState for it.
That breaks the assertion the call to mono_thread_info_get_last_managed in
async_suspend_critical which needs a valid MonoThreadUnwindState.
Fixes https://github.com/mono/mono/issues/10031
* fixup - remove coop assertion in check_async_suspend
result for coop could be iether BeginSuspendOkCooperative or
BeginSuspendOkNoWait depending on whether the thread was running (Ok) or
blocking (OkNoWait)
* [coop] suspend_can_continue if async raced with self-suspend (osx + win32)
Companion to 006d6ce097 from earlier this year
which applied this fix for POSIX signal based suspend. This is the
corresponding OSX and Win32 fix.
In hybrid suspend, in the case where a suspend initiator needs to preemptively
suspend a thread, but the thread self-suspended while after the suspend
initiator put it into the blocking_suspend_requested state, we want to allow
the suspend to continue. We do have to call the syscall to undo the native
async suspend, but after that, we can leave the victim to continue waiting for
a resume.
This should not have any effect on full cooperative or full preemptive suspend
- in the full coop case we never call async suspend, in the full preemptive
case the thread never self-suspends in blocking.
When we execute the certificate verification callback we just don't test for success and set status11. Now we get the error (if any) and map the error code to those defined by ChainStatusFlags and add it to a list of X509ChainStatus objects for that chain. Now when get_ChainStatus is called we convert that list to an array of X509ChainStatus and return it.
Use argv for cli_launcher on OSes that don't return full path for process names; fix mono_w32process_get_path on Free/NetBSD
Should fix process-leak test on AIX, maybe more. Also tested that it fixes the
same behaviour on FreeBSD. Other OSes may be affected; consult and test with the
files `w32process-unix-*.c`.
From comments:
```c
/*
* XXX: verify if other OSes need it; many platforms seem to have it so that
* mono_w32process_get_path -> mono_w32process_get_name, and the name is not
* necessarily a path instead of just the program name
*/
/*
* mono_w32process_get_path on these can only return a name, not a path;
* which may not be good for us if the mono command name isn't on $PATH,
* like in CI scenarios. chances are argv based is fine if we inherited
* the environment variables.
*/
```
There is a small race condition during the completion of a native thread join
call. During that period of time the tid is no longer included on the
internal list tracking joinable threads so a thread that will join on the
tid while another thread (like the finalizer thread) is waiting on native
join to complete for the same tid, will cause the managed Thread.Join call
to complete before the native join call has completed. This race could cause
issues on some OS:es that clear's up some thread resources, like abandoned
mutexes when the thread has exited. This race is hit by WaitAnyWithSecondMutexAbandoned
since the call to Thread.Join will return before the thread owning the mutex
has terminated meaning that it doesn't get ownership of the abandoned mutex
as assumed by the test.
Fix makes sure Thread.Join won't complete until native thread join is complete.
Increasing the join timeouts in the test also eliminates a timeout error making it
harder to hit the problematic code path, primarily during reproduction
in the debugger.
Fix also switch to coop mutex for joinable threads.
And they are not checked in a consistent order, leading to bugs, or at least
somewhat surprises. This incorrect/unintended code fails to compiles as C++.
We should check them in a consistent order.
This favors Win32 over unistd.h but the opposite is probably ok too.
Also fix infinite loop in error path.
See https://jenkins.mono-project.com/job/x/12739/parsed_console/log.html
```
sgen-protocol.c: In function 'void binary_protocol_open_file(gboolean)':
sgen-protocol.c:101:31: error: invalid conversion from 'int' to 'HANDLE {aka void*}' [-fpermissive]
binary_protocol_file = open (filename, O_CREAT | O_WRONLY, 0644);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sgen-protocol.c:102:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (binary_protocol_file == -1) {
^
sgen-protocol.c:114:38: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
ftruncate (binary_protocol_file, 0);
^
In file included from ../../mono/utils/mono-compiler.h:14:0,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:65:18: note: initializing argument 1 of 'int ftruncate(int, off32_t)'
__CRT_INLINE int ftruncate(int __fd, off32_t __length)
^~~~~~~~~
sgen-protocol.c:116:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
} while (binary_protocol_file == -1);
^
sgen-protocol.c: In function 'void close_binary_protocol_file()':
sgen-protocol.c:164:36: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
while (close (binary_protocol_file) == -1 && errno == EINTR)
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:10:0,
from ../../mono/utils/mono-compiler.h:14,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:328:15: note: initializing argument 1 of 'int close(int)'
int __cdecl close(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~
sgen-protocol.c: In function 'void binary_protocol_flush_buffer(BinaryProtocolBuffer*)':
sgen-protocol.c:229:82: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
ret = write (binary_protocol_file, buffer->buffer + written, to_write - written);
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:10:0,
from ../../mono/utils/mono-compiler.h:14,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:344:15: note: initializing argument 1 of 'int write(int, const void*, unsigned int)'
int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~
```
That is, >=0x80000000 does not fit in a signed 32bit long.
Linux manpage acknowledges the mess and says "unsigned int" will work "for most systems".
So let's do that and hope, "most systems" and other C runtimes besides glibc.
http://man7.org/linux/man-pages/man2/statfs.2.html
The __fsword_t type used for various fields in the statfs structure
definition is a glibc internal type, not intended for public use.
This leaves the programmer in a bit of a conundrum when trying to
copy or compare these fields to local variables in a program. Using
unsigned int for such variables suffices on most systems.
Remove excess const and add more meaningful const.
* Truncate MachineName (and UserDomainName) at first period
Unix machines often put their FQDN as the host name, and domain
name is used for things such as yp. As such, truncate the FQDN to
just the hostname, as other Unix utilities seem to do.
Matches the .NET Core and .NET Framework behaviour, and MS seems to
require this for a future project. Fixes#9839.
* Add a unit test for bug
* Formatting tweaks
* For ProcessArchitecture, use the DllMap arch of the runtime.
* For OSArchitecture, make an educated guess combining ProcessArchitecture and Environment.Is64BitOperatingSystem.
* For non-Intel/ARM architectures, (supported by Mono and not on the chopping block are PPC32/64, z, and WebAssembly) please dogpile onto dotnet/corefx#30706.
macOS 10.14 introduces a Network framework, which means Xamarin.Mac now has a Network namespace.
This conflicts with 'using Network = System.Net':
> mono/mcs/class/System.Xml.Linq/Test/System.Xml.Schema/ExtensionsTest.cs(97,27): error CS0576: Namespace '<global namespace>' contains a definition conflicting with alias 'Network'
so just remove the using and use the full 'System.Net' namespace instead.
* [wasm] add wasm-aot and wasm-aot-runtime
* [runtime] Add MONO_STRUCT_SIZE that works similarly to MONO_STRUCT_OFFSET and handles mini types.
* [wasm] Add enough scafold for the AOT compiler.
* [wasm] Make some functions available for the interp to satisfy the linker.
* [wasm] Add aot-sample and link-sample helper targets for AOT development.
* [wasm/sdks] Update documentation.
* Update README.md
broken:
```c
#include <math.h>
void * pmod = fmod;
fmod-broken.cpp:3:15: error: address of overloaded function 'fmod' does not match required type 'void'
void * pmod = fmod;
^~~~
```
fixed:
```c
#include <math.h>
typedef double (*fmod_t)(double, double);
fmod_t pfmod = fmod;
```
A wrapper function would also work:
```c
double mono_fmod (double a, double b)
{
return fmod (a, b);
}
fmod_t pfmod = mono_fmod;
```
This may be advantagous, if the standard allows fmod to be a macro ("cannot take address of macros") or its signature to not match this.
However this would veer even further from apparent C compatibility (if our previous code was portable), so probably not.
* [reflection] Assembly.LoadFile should throw ArgumentException for relative paths
Fixes https://github.com/mono/mono/issues/9943
* [mcs/tests] Use full path in the compiler-tester
Otherwise the call to LoadFile will fail
* [mono/tests] Use full path in LoadFile in test-multi-netmodule-4-exe
* [mono/tests] Use the test runner for a couple of tests
* [fullaot] Disable test-multi-netmodule-4-exe and custom-attr-errors.exe
* [tests] Use Path.GetFullPath and Path.Combine in AssemblyTest
Fix windows test failures
EH still uses the original ip for determining whether there are any abort protected blocks to be exited, once the frame is unwinded.
Fixes delegate2.exe
https://jenkins.mono-project.com/job/x/12802/parsed_console/log.html
ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken(gpointer, MonoError*)':
mono-security-windows.c:214:62: error: invalid conversion from 'int (*)(int)' to 'gpointer {aka void*}' [-fpermissive]
return DuplicateToken (token, SecurityImpersonation, &dupe) ? dup : NULL;
^
The code is confusing the local variable dupe with an 'e' at the end
with the function dup.
* [System.Reflection] CoreFX import for ManifestResourceInfo and ResourceLocation types.
Part of #9660.
* Bump API snapshot submodule
* [csproj] Update project files
Longer term some functions accepting function pointers can/should take
a stronger type, and the parameters match w/o casting.
Also cast int to enum one same line.
One of these is under if 0.
Should fix the following:
attach.c:494:13: error: no matching function for call to 'mono_thread_create_internal'
internal = mono_thread_create_internal (mono_get_root_domain (), receiver_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (void *)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
threadpool-io.c:585:7: error: no matching function for call to 'mono_thread_create_internal'
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, error))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
gc.c:957:14: error: no matching function for call to 'mono_thread_create_internal'
gc_thread = mono_thread_create_internal (mono_domain_get (), finalizer_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
attach.c:494:13: error: no matching function for call to 'mono_thread_create_internal'
internal = mono_thread_create_internal (mono_get_root_domain (), receiver_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (void *)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
threadpool-io.c:585:7: error: no matching function for call to 'mono_thread_create_internal'
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, error))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
:411:24: error: no matching function for call to 'mono_create_ftnptr'
func = (TestMethod)mono_create_ftnptr (mono_get_root_domain (), func);
^~~~~~~~~~~~~~~~~~
../../mono/mini/mini-runtime.h:432:11: note: candidate function not viable: no known conversion from 'TestMethod' (aka 'int (*)()') to 'gpointer' (aka 'void *') for 2nd argument; take the address of the argument with &
gpointer mono_create_ftnptr (MonoDomain *domain, gpointer addr);
driver.c:1170:2: error: no matching function for call to 'mono_thread_create_checked'
mono_thread_create_checked (mono_domain_get (), compile_all_methods_thread_main, &args, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:441:1: note: candidate function not viable: no known conversion from 'void (CompileAllThreadArgs *)' to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_checked (MonoDomain *domain, gpointer func, gpointer arg, MonoError *error);
^
LLVM was using the helper for the abandoned prototype linkonce work that
much predated when I picked up the project.
This is a problem because it can lead to aot-compiler thinking a method
is dedupable, while llvm thinking it's not. When this happens, the
symbol does not have the Assembly baked into it's name to ensure
uniqueness.
We now adopt CoreFX's behavior in `X509Certificate` regarding serialization and immutability.
* All serialization APIs now throws `PlatformNotSupportedException`.
(this was initially part of #9650, but had to be taken out due to problems with Xunit 2.4).
* All `Import()` overloads now throw `PlatformNotSupportedException`.
* The property setter of `X509Certificate2.PrivateKey` now also throws `PlatformNotSupportedException`.
If an AOT library is loaded that was compiled with safepoints, but currently
we're running with preemptive suspend (e.g. MONO_THREADS_SUSPEND=preemptive is
set), don't assert. `mono_polling_required` will always be false, so the
safepoint will be ignored.
Fixes https://github.com/mono/mono/issues/9947
- Remove two unused types from corlib (DecoupledTask is not used since migrating to StreamReader/StreamWriter from referencesources).
- Fix indentation in System.Security.Policy/Site.cs which mixed tabs and spaces.
- Fix comment in Test/System.Diagnostics/DebuggerTypeProxyAttribute.cs (to avoid false results when using grep on the source code).
* Add support for marshalling ArrayBuffer and TypeArrays from JavaScript to C#.
- The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. More Info ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays#ArrayBuffer
- JavaScript typed arrays are array-like objects and provide a mechanism for accessing raw binary data. (...). More Info ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
- Some examples of API's that use these are Fetch, WebGL, Canvas, Web Audio API, XMLHttpRequests, WebSockets, Web Workers, Media Source API and File APIs.
| ArrayBuffer | uint8_t | byte[] | byte or Byte (unsigned byte)
| Int8Array | int8_t | sbyte[] | byte or SByte (signed byte)
| Uint8Array | uint8_t | byte[] | byte or Byte (unsigned byte)
| Uint8ClampedArray| uint8_t | byte[] | byte or Byte (unsigned byte)
| Int16Array | int16_t | short[] | short (signed short)
| Uint16Array | uint16_t | ushort[] | ushort (unsigned short)
| Int32Array | int32_t | int[] | int (signed integer)
| Uint32Array | uint32_t | uint[] | uint (unsigned integer)
| Float32Array | floa t | float[] | float
| Float64Array | double | double[] | double
- Added tests to the bindings-test test harness.
* Add support for marshalling TypeArrays from C# to JavaScript.
- Add tests to test harness.
<!--
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
-->
iconv in eglib was broken due to a broken define. Also fix linking
of iconv when iconv isn't in libc.
Also remove the usage of a GNU libcharset specific function and rely
on a standard POSIX function that outputs the same value on every
modern Unixoid I've tried it on. (Ubuntu/macOS/i/FreeBSD)
This comment explains a lot of things for the latter:
```c
/*
* This function used used to use the "locale_charset" call in
* libiconv's libcharset library. However, this isn't always
* available on some systems, including ones with GNU libc. So,
* instead use a function that's a standard part of POSIX2008.
*
* nl_langinfo is in POSIX2008 and should be on any sane modern
* Unix. With a UTF-8 locale, it should return "UTF-8" - this
* has been verified with Ubuntu 18.04, FreeBSD 11, and i 7.3.
*
* The motivation for using locale_charset was likely due to
* the cruftiness of Unices back in ~2001; where you had to
* manually query environment variables, and the values were
* inconsistent between each other. Nowadays, if Linux, macOS,
* AIX/PASE, and FreeBSD can all return the same values for a
* UTF-8 locale, we can just use the value directly.
*
* It should be noted that by default, this function will give
* values for the "C" locale, unless `setlocale (LC_ALL, "")`
* is ran to init locales - driver.c in mini does this for us.
*/
```
Fix s390x build broken by incorrect specification of the msgfi instruction used in MUL_IMM type operations. The instruction had been encoded as its 32-bit counterpart (msfi).
In addition, the s390x microcode makes the mono_strength_reduction_division unnecessary so this can be bypassed.
The change to basic.make is just to avoid error messages when basic-profile-check.exe hasn't been built yet.
<!--
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 build on AIX
* crash reporting requires dladdr, a function AIX (at least
the version on CI) lacks
* fix build with a powerpc64-*-(aix|os400)* triplet as IBM
wishes to do
* Fix some stuff for Haiku
Some stuff requires CoreFX PAL changes that haven't been merged and
thus one or two more items for configure to detect.
* sigaltstack is broken for haiku
* getifaddrs is available and PAL would like it, so fix it
* Fix detection of flock64
This erroneously detected flock64 on platforms that lacked it.
Fixes the build of CoreFX PAL on FreeBSD and Haiku.
* Fix flock64 define
* Fix define for flock64 in PAL block
* Remove nonsense comment that only applied to an older unreleased version of the patch
Noticed this today when the corlib test which checks for unknown filesystems failed. Turned out it was because of a .dmg I had mounted:
```
$ mount | grep nullfs
/Volumes/Skype Meetings App/Skype Meetings App.app on /private/var/folders/cs/kt8x25p14g9dlk_p192rd7th0000gn/T/AppTranslocation/957CCB05-C113-4897-9C80-700C2CE4809E (nullfs, local, nodev, nosuid, read-only, noowners, quarantine, nobrowse, mounted by alexander)
```
By default ```msbuild bcl.sln``` will fail because of our non-standard platform names and the need to restore nuget packages. Add a default response file so it just works. (Response files can be suppressed)
This imports github.com/kumpera/ws-proxy into mono.
It facilitates distribution and coordination of upstream as there's a clean version connect between the two bits.
The proxy is currently version locked with the runtime.
* [wasm] Call the correct single step trampoline. Fixes some step-into scenarios.
* [wasm] Make the debugging sample a bit more complicated.
* [wasm] Add debugger support for removing breakpoints.
* [cxx] mono-logger.c int vs. enum and casts void* to non-void*
mono-logger.c:18:16: error: cannot initialize a variable of type 'GLogLevelFlags' with an rvalue of type 'int'
GLogLevelFlags mono_internal_current_level = INT_MAX;
^ ~~~~~~~
mono-logger.c:19:16: error: cannot initialize a variable of type 'MonoTraceMask' with an rvalue of type 'int'
MonoTraceMask mono_internal_current_mask = ~((MonoTraceMask)0);
^ ~~~~~~~~~~~~~~~~~~~
mono-logger.c:305:17: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ "io-layer", MONO_TRACE_IO_LAYER_PROCESS
^~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:315:12: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ "all", ~((MonoTraceMask)0) },
^~~~~~~~~~~~~~~~~~~
mono-logger.c:316:11: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ NULL, 0 },
^
mono-logger.c:392:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an lvalue of type 'void *'
UserSuppliedLoggerUserData *ll =logCallback.user_data;
^ ~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:400:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an lvalue of type 'void *'
UserSuppliedLoggerUserData *ll = logCallback.user_data;
^ ~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:451:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an rvalue of type 'gpointer' (aka 'void *')
UserSuppliedLoggerUserData *ll = g_malloc (sizeof (UserSuppliedLoggerUserData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated.
* [cxx] Add missing cast from void* to non-void* in g_renew.
* [cxx] mono-flight-recorder.c:97:22: error: cannot initialize a variable of type 'MonoFlightRecorder *' with an rvalue of type 'gpointer' (aka 'void *')
MonoFlightRecorder *recorder = g_malloc0 (size_of_recorder_prefix + size_of_item_ptrs + size_of_items);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
add cast
* [cxx] mono-error.c:769:18: error: cannot initialize a variable of type 'MonoErrorBoxed *' (aka '_MonoErrorBoxed *') with an rvalue of type 'gpointer' (aka 'void *')
MonoErrorBoxed* box = mono_image_alloc (image, sizeof (MonoErrorBoxed));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cast from void* to non-void*
* [cxx] lock-free-alloc.c:358:27: error: no viable overloaded '='
new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lock-free-alloc.c:90:9: note: candidate function (the implicit copy assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
typedef union {
^
lock-free-alloc.c:90:9: note: candidate function (the implicit move assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
typedef union {
^
lock-free-alloc.c:465:27: error: no viable overloaded '='
new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lock-free-alloc.c:90:9: note: candidate function (the implicit copy assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
C++ does not by default allow copying volatile aggregates (struct, union, class).
This is mostly reasonable because, imagine the struct does not fit in a register. How would it work?
Here, and it is probably common, the struct does fit in a register and the intent and implementation
is pretty obvious.
Anyway, you can provide operator= or copy the constituents (i.e. one integer that unions over the rest).
* [cxx] mono-threads.c strengthen type from gpointer to actual type,
add casts from void* to non-void*, add casts between int and enum,
remove excess GSList type that caused some errors.
mono-threads.c:568:2: error: no matching function for call to 'mono_threads_signal_thread_handle'
mono_threads_signal_thread_handle (handle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:491:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoThreadHandle *' for 1st argument
mono_threads_signal_thread_handle (MonoThreadHandle* thread_handle);
^
mono-threads.c:570:2: error: no matching function for call to 'mono_threads_close_thread_handle'
mono_threads_close_thread_handle (handle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./mono-threads.h:516:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoThreadHandle *' for 1st argument
mono_threads_close_thread_handle (MonoThreadHandle *handle);
^
mono-threads.c:776:12: error: cannot initialize return object of type 'MonoThreadInfoFlags' with an rvalue of type 'gint32' (aka 'int')
return mono_atomic_load_i32 (&info->flags);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:783:22: error: cannot initialize a variable of type 'MonoThreadInfoFlags' with an rvalue of type 'gint32' (aka 'int')
MonoThreadInfoFlags old = mono_atomic_load_i32 (&info->flags);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:794:8: error: definition of type 'GSList' conflicts with typedef of the same name
struct GSList {
^
../../mono/eglib/glib.h:330:24: note: 'GSList' declared here
typedef struct _GSList GSList;
^
mono-threads.c:811:22: error: assigning to 'GSList *' (aka '_GSList *') from incompatible type 'gpointer' (aka 'void *')
wait_request.next = old;
^~~
mono-threads.c:852:10: error: assigning to 'GSList *' (aka '_GSList *') from incompatible type 'gpointer' (aka 'void *')
old = old_read;
^~~~~~~~
mono-threads.c:866:3: error: no matching function for call to 'mono_os_sem_post'
mono_os_sem_post (curr->data);
^~~~~~~~~~~~~~~~
./mono-os-semaphore.h:166:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoSemType *' (aka 'unsigned int *') for 1st argument
mono_os_sem_post (MonoSemType *sem)
^
mono-threads.c:1865:10: error: cannot initialize return object of type 'MonoThreadInfoWaitRet' with an rvalue of type 'int'
return MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 + (res - MONO_OS_EVENT_WAIT_RET_SUCCESS_0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 errors generated.
* [cxx] mono-threads-coop.c In C++, enums are not quite ints.
Their default underlying type (you can change it, per type, nice!), is int,
but they are unique types not automatically interchangable with int.
mono-threads-coop.c:530:9: error: cannot initialize return object of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
return 0; /* unset */
^
mono-threads-coop.c:558:27: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
MonoThreadsSuspendPolicy policy = 0;
^ ~
mono-threads-coop.c:571:27: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
MonoThreadsSuspendPolicy policy = 0;
^ ~
mono-threads-coop.c:590:34: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
static MonoThreadsSuspendPolicy policy = -1;
^ ~~
4 errors generated.
* [cxx] mono-utility-thread.c; cast from void* to non-void*.
mono-utility-thread.c:85:21: error: cannot initialize a variable of type 'MonoUtilityThread *' with an rvalue of type 'gpointer' (aka 'void *')
MonoUtilityThread *thread = g_malloc0 (sizeof (MonoUtilityThread));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-utility-thread.c:128:27: error: cannot initialize a variable of type 'UtilityThreadQueueEntry *' with an rvalue of type 'gpointer' (aka 'void *')
UtilityThreadQueueEntry *entry = mono_lock_free_alloc (&thread->message_allocator);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-utility-thread.c:154:27: error: cannot initialize a variable of type 'UtilityThreadQueueEntry *' with an rvalue of type 'gpointer' (aka 'void *')
UtilityThreadQueueEntry *entry = mono_lock_free_alloc (&thread->message_allocator);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
* [cxx] Fix assignment of volatile aggregate without raising specter of ifdef __cplusplus.
Does this violate the abstraction? i.e. wouldn't it be better to assign entire aggregate
at the caller than to dig into its constituent member data?
All the casts of (x) can be replace with G_CAST (x) that I developed this morning and am working through.
mono_metadata_read_constant_value was extracted from mono_get_constant_value_from_blob
but removing the bits that require GC interaction. This function will be used to read corlib version without allocating strings.
mono_string_from_blob decodes a string from a blob pointer, returns g_malloc'd memory.
* [cxx] Port complex math to small portable C and C++ with the only dependency being hypot and non-complex math, and small preexisting code we already had for msvc.
I.e. we already had two versions, with varying portability.
Use one of them, adding about three lines to it.
There was some debate back and forth about macros/renames here.
This version significantly reduces line damage and is much easier to read.
Doing the rename as a separate step may still be advisable, to erase any doubt as to portable semantics, i.e. namespace isolation.
Mono style divergence is also left unfixed to avoid further line damage.
i.e. consider `double_complex` => `MonoComplex`.
`mono_double_complex_` => `mono_complex_`.
A recent commit revealed that in cases where we select based on a mix of host platform and profile, genproj csproj files can end up with duplicate sources because the existing <ItemGroup Condition= approach could make multiple groups match for a given compile when we really just want one.
This PR changes to generating a cascade of msbuild <Choose> elements, which give if-else selection to ensure that we only ever build a single set of files.
* [cxx] C++ does not allow goto around initialization.
The result would be undefined/uninitialized -- presumably that is what we get in C,
not as safe as it seems. Though, since variable not typically/ever used after goto target, it is ok. A little bit of language requirement for the compiler to do such analysis would have gone a long way, not sophisticated analysis, just used/not-used.
Not a problem in C89 because variables only at top.
Not a problem in idiomatic C++ because, often, early return + destructors.
But definitely a problem with C99, and goto for error handling.
Not a problem with msvc in default permissive mode.
Not likely a problem with gcc due to permissive option.
But a problem with clang.
* [cxx] Split declaration from initialization, instead of go up to within if (0).
* [cxx] mono-merp.c:83:9: error: implicit default constructor for 'MERPStruct' must explicitly initialize the const member 'systemModel'
There are possible other solutions involving initializing up front, and later casting away const for additional initialization. Having public-const private-mutable is a good-seeming interface, but is pretty rare. Maybe in [cxx]future can restore const, add a constructor, etc.
* Remove toplevel const in struct for extremely obscure reasons, again pretty rare pattern.
The obscure reason:
given:
```
typedef struct foo
{
const int i; // remove const to fix
} foo;
foo global = { 1 };
```
compiled as C++, with some recent versions of Visual C++, there is a regression
where it thinks this is a dynamic initialization. Which is usually ok, but can be a problem in unusual cases (true story..delayload implementation..).
The icall was converted to use HANDLES(), so the icall wrapper will set the
pending exception from the MonoError. If the icall does it, too, the second
use (in the wrapper) will assert that the MonoError is being reused after
cleanup without being reinitialized.
Also add an assertion in mono_error_get_message that we're not trying to get a
message from a cleaned up MonoError.
Fixes https://github.com/mono/mono/issues/9935
* console-unix.c:221:21: error: cannot initialize a variable of type 'MonoMethod *' (aka '_MonoMethod *') with an rvalue of type 'gpointer' (aka 'void *')
static MonoMethod *System_Console_DoConsoleCancelEventBackground_method = ((gpointer)-1);
^ ~~~~~~~~~~~~~~
* ../../mono/metadata/opcodes.h:27:14: error: ISO C++ forbids forward references to 'enum' types
typedef enum _MonoOpcodeEnum MonoOpcodeEnum;
* w32socket-unix.c:601:9: error: no matching function for call to 'mono_w32socket_send'
ret = mono_w32socket_send (((MonoFDHandle*) sockethandle)->fd, buffers->Head, buffers->HeadLength, 0, FALSE);
Change parameter from char* to void*.
* In file included from console-unix.c:479:2: error: no matching function for call to 'set_control_chars'
set_control_chars (MONO_ARRAY_HANDLE_PIN (control_chars_arr, gchar, 0, &h), mono_attr.c_cc);
^~~~~~~~~~~~~~~~~
^
console-unix.c:362:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'gchar *' (aka 'char *') for 1st argument
set_control_chars (gchar *control_chars, const guchar *cc)
add cast in MONO_ARRAY_HANDLE_PIN
* w32socket-unix.c:635:11: error: assigning to 'gchar *' (aka 'char *') from incompatible type 'gpointer' (aka 'void *')
buffer = g_malloc (SF_BUFFER_SIZE);
^~~~~~~~~~~~~~~~~~~~~~~~~
Change buffer to gpointer, and another similar.
* w32socket-unix.c:1136:99: error: cannot initialize a member subobject of type 'gpointer' (aka 'void *') with an lvalue of type 'gboolean (SOCKET, OVERLAPPED *, guint32, guint32)' (aka 'int (int, OVERLAPPED *, unsigned int, unsigned int)')
{ {0x7fda2e11,0x8630,0x436f,{0xa0,0x31,0xf5,0x36,0xa6,0xee,0xc1,0x57}} /* WSAID_DISCONNECTEX */, extension_disconect },
^~~~~~~~~~~~~~~~~~~
w32socket-unix.c:1137:99: error: cannot initialize a member subobject of type 'gpointer' (aka 'void *') with an lvalue of type 'gboolean (SOCKET, gpointer, guint32, guint32, OVERLAPPED *, TRANSMIT_FILE_BUFFERS *, guint32)' (aka 'int (int, void *, unsigned int, unsigned int, OVERLAPPED *, TRANSMIT_FILE_BUFFERS *, unsigned int)')
{ {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} /* WSAID_TRANSMITFILE */, extension_transmit_file },
Add cast to gpointer.
Also add const while there.
* w32process-unix.c:2189:14: error: no matching function for call to 'process_wait'
waitret = process_wait (process_info->process_handle, MONO_INFINITE_WAIT, NULL);
Add cast from void* to non-void*.
* w32process-unix.c:2099:3: error: cannot jump from this goto statement to its label
goto done;
^
w32process-unix.c:2111:13: note: jump bypasses variable initialization
gunichar2 *args = utf16_concat (utf16_quote, lpFile, utf16_quote, lpParameters ? utf16_space : NULL, lpParameters, (const gunichar2 *)NULL);
^
w32process-unix.c:2104:19: note: jump bypasses variable initialization
const gunichar2 *lpDirectory = coop.length.working_directory ? coop.working_directory : NULL;
^
w32process-unix.c:2103:19: note: jump bypasses variable initialization
const gunichar2 *lpParameters = coop.arguments;
^
w32process-unix.c:2102:19: note: jump bypasses variable initialization
const gunichar2 *lpFile = coop.filename;
^
w32process-unix.c:2285:3: error: cannot jump from this goto statement to its label
goto exit;
^
w32process-unix.c:2291:13: note: jump bypasses variable initialization
gunichar2 *dir = coop.length.working_directory ? coop.working_directory : NULL;
^
w32process-unix.c1 error generated.
:2288:13: note: jump bypasses variable initialization
gunichar2 *args = coop.length.arguments ? coop.arguments : NULL;
etc.
Separate declaration from initialization.
* appdomain.c:554:22: note: jump bypasses variable initialization
MonoAppDomainHandle ad = mono_domain_create_appdomain_internal (friendly_name, setup, error);
^
appdomain.c:590:2: error: cannot jump from this goto statement to its label
goto_if_nok (error, leave);
^
etc.
Split local declaration from initialization.
* w32process-unix.c:1914:27: error: no matching function for call to 'mono_handle_new'
and error on every typesafe MONO_HANDLE_NEW call
Have MONO_HANDLE_TYPECHECK_FOR return MonoObject* instead of gpointer, by casting.
Could probably also change mono_handle_new to accept gpointer.
* class-accessors.c:247:9: error: cannot initialize return object of type 'MonoMarshalType *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_MARSHAL_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:265:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:273:19: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:279:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'gpointer' (aka 'void *')
Uint32Property *prop = mono_class_alloc (klass, sizeof (Uint32Property));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:294:19: error: cannot initialize a variable of type 'PointerProperty *' with an rvalue of type 'gpointer' (aka 'void *')
PointerProperty *prop = mono_class_alloc (klass, sizeof (PointerProperty));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:334:9: error: cannot initialize return object of type 'MonoClassPropertyInfo *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_PROPERTY_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:347:9: error: cannot initialize return object of type 'MonoClassEventInfo *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_EVENT_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:372:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_DECLSEC_FLAGS);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:379:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'gpointer' (aka 'void *')
Uint32Property *prop = mono_class_alloc (klass, sizeof (Uint32Property));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:412:18: error: cannot initialize a variable of type 'WeakBitmapData *' with an rvalue of type 'gpointer' (aka 'void *')
WeakBitmapData *info = mono_class_alloc (klass, sizeof (WeakBitmapData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:423:18: error: cannot initialize a variable of type 'WeakBitmapData *' with an rvalue of type 'void *'
WeakBitmapData *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_WEAK_BITMAP);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:454:19: error: cannot initialize a variable of type 'DimConflictData *' with an rvalue of type 'gpointer' (aka 'void *')
DimConflictData *info = mono_class_alloc (klass, sizeof (DimConflictData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:469:19: error: cannot initialize a variable of type 'DimConflictData *' with an rvalue of type 'void *'
DimConflictData *info = mono_property_bag_get (&klass->infrequent_data, PROP_DIM_CONFLICTS);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cast from void* to non-void*.
* class.c:3005:16: error: assigning to 'char *' from incompatible type 'const char *'
if ((nested = strchr (name, '/'))) {
^~~~~~~~~~~~~~~~~~
class-init.c:437:11: error: assigning to 'MonoClass *' (aka '_MonoClass *') from incompatible type 'gpointer' (aka 'void *')
klass = mono_image_alloc0 (image, sizeof (MonoClassGtd));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-init.c:442:11: error: assigning to 'MonoClass *' (aka '_MonoClass *') from incompatible type 'gpointer' (aka 'void *')
klass = mono_image_alloc0 (image, sizeof (MonoClassDef));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-init.c:500:5: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:496:5: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:490:4: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:838:14: error: no matching function for call to 'class_kind_may_contain_generic_instances'
image_set = class_kind_may_contain_generic_instances (eclass->class_kind) ? mono_metadata_get_image_set_for_class (eclass) : NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* class.c:3005:16: error: assigning to 'char *' from incompatible type 'const char *'
if ((nested = strchr (name, '/'))) {
^~~~~~~~~~~~~~~~~~
class.c:427:10: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
char *s = strchr (klass_name, '`');
^ ~~~~~~~~~~~~~~~~~~~~~~~~
add const, add cast, and also fix adjacent integer truncation
* assembly.c:2964:8: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
char *eqsign = strchr (pair, '=');
add cast
* cominterop.c:664:2: error: no matching function for call to 'register_icall'
register_icall (cominterop_get_method_interface, "cominterop_get_method_interface", "ptr ptr", FALSE);
^~~~~~~~~~~~~~
repeatedly
Add cast in macro.
Also another need for a cast on a string (error not recorded).
* [cxx] icall.c:
casts
change char* to void*
split local declaration from initialization
add extern "C" around external code (environ -- probably merged to master already)
* image.c:726:8: error: no matching function for call to 'strcmp'
if (strcmp (list_iter->data, name) == 0) {
^~~~~~
image.c:1184:20: error: constant expression evaluates to 2218203019 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
IGNORED_ASSEMBLY (0x8437178B, SYS_NET_HTTP, "C0E04D9C-70CF-48A6-A179-FBFD8CE69FD0", "4.3.0 net46"),
^~~~~~~~~~
repeatedly
add casts
* [cxx] marshal.c
marshal.c:224:3: error: no matching function for call to 'register_icall'
register_icall (mono_marshal_string_to_utf16, "mono_marshal_string_to_utf16", "ptr obj", FALSE);
repeatedly; add cast in macro
Also possible int/enum mixup -- add cast.
* [cxx] property-bag.c
property-bag.c:44:37: error: cannot initialize a variable of type 'MonoPropertyBagItem *' (aka '_MonoPropertyBagItem *') with an lvalue of type 'void *'
MonoPropertyBagItem *cur, **prev, *item = value;
Add cast here, and another.
* [cxx] metadata.c
add casts from void* to non-void*
indicate future enum instead of int
remove designated intitializers
* [cxx] more appdomain.c
* PR: Repatriate orphaned comment.
* PR: include opcodes.h instead of duplicating MonoOpcodeEnum
Otherwise I get consistent access failures for CALLVIRT from mono_method_to_ir().
Stacktrace looks like this:
```
System.InvalidOperationException: WinForms_SeeInnerException ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MethodAccessException: Method `System.__ComObject..ctor()' is inaccessible from method `System.__ComObject..ctor()'
445286 at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_throw_method_access(intptr,intptr)
445287 at System.__ComObject..ctor () [0x00000] in <430892d2beef407ea6b21748b72c1144>:0
445288 at (wrapper cominterop-invoke) System.__ComObject..ctor()
445289 at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
445290 at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445291 --- End of inner exception stack trace ---
445292 at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445293 at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445294 at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <b683bf5ced8643af8ec 2e589dfb23c2b>:0
445295 at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <b683bf5ced86 43af8ec2e589dfb23c2b>:0
445296 at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445297 at System.Activator.CreateInstance (System.Type type) [0x00000] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
```
My understanding is that misleading exception message is due to exact same name used for dynamic type, in fact it means that some type in dummy assembly can't access internal method from corlib.
* [threads] switch to GC Safe around pthread calls in mono_thread_internal_set_priority
Observed pthread_getschedparam taking a lock on OSX
* [win32] Capture GetLastError before MONO_EXIT_GC_SAFE
* Fix Tasks and Promises in bindings.
- Tasks were not being marshalled correctly in some circumstances. The only place that I could reproduce this was in the bindings tests. Running from outside the test harness would not reproduce this error.
- Promises would intermittently throw Exceptions: NullReferenceException, ArrayIndex out of bounds.
- When using Promises from JS to CS there were random Memory access exceptions. Looks like memory was being trampled on. Adding an integer variable to the create_task_completion_source call fixed these problems as the CreateTaskSource is defined as receiving an int variable. This also fixed the NullReferenceExceptions and ArrayIndex out of bounds exceptions.
* Make JSObject disposable
- Add the ability to dispose of a JSObject.
- The dispose will remove the object from the tracked object list and will allow the reference counter to be recycled later.
- By keeping a recycled list of references and reusing those will keep the tracked objects array from growing out of hand.
- Add test to the Test Harness.
- Modifiy the way the bindings init works by passing in of the Assembly and Class `[asm]namespace.class`. Modfiy test.js to use the new format.
* Add support for Get and Set of javascript properties on a JSObject.
* The namespace problem was fixed in https://github.com/mono/mono/pull/9836
* Cleanup unused and duplicate definitions
* [runtime] Add mono_runtime_get_caller_no_system_or_reflection
Exposes an already existing stackwalk that we use to find out who called a corlib API.
* [loader] Consult asmctx of executing assembly for Assembly.Load
if an assembly in LoadFrom context calls Assembly.Load, the given assembly name
should be tried in the basedir of the executing assembly, and the resulting
loaded assembly should be in LoadFrom context.
* [loader] Assemblies in individual asmctx can reference assemblies in application base
If an assembly was loaded with LoadFile, it can reference assemblies from the
application base, the GAC or MONO_PATH.
Fixes https://github.com/mono/mono/issues/8575
* [loader] Pass requesting assembly to mono_assembly_open_predicate
In LoadFrom and LoadFile icalls, pass the currently executing assembly as the
requesting assembly.
* [utils] Add mono_path_filename_in_basedir
* [loader] Add mono_install_asmctx_from_path_hook
Add a hook that can be used to check whether a given path belongs to some
assembly load context.
For example if a given path is in the application base of the current
appdomain, an appdomain hook would set out_asmctx to MONO_ASMCTX_DEFAULT and
return TRUE.
* [loader] Use appdomain base dir and loadfrom asmctx hooks
1. If an assembly filename is in the GAC, always open the assembly in default
context.
2. If an assembly filename is in the appdomain search path (base directory or
private bin path) always open the assembly in default context.
3. If an assembly filename is in the base dir of the requesting assembly and
the requesting assembly was in LoadFrom context, always open the assembly in
LoadFrom context.
Fixes https://github.com/mono/mono/issues/9753
and Fixes https://github.com/mono/mono/issues/9542
* [tests] Test loading references from LoadFrom and LoadFile contexts
The LoadFrom assembly loading context and the individual assembly loading
context (aka LoadFile aka "no context") behave differently when requesting a
referenced assembly - for LoadFile we expect the runtime to probe the appdomain
base, the GAC + MONO_PATH but not the basedir of the requesting assembly. For
LoadFrom the basedir of the requesting assembly _is_ included. So the tests
here try all the possible variations.
* [tests] AOT assembly-load-reference tests
* [metadata] Cache method signature in correct image hash
When freeing dynamic methods in mono_free_method, we remove entries in the method image's hashtables, hashed by the soon to be freed method signature.
* [metadata] Avoid unnecessary alloc
Fixes https://github.com/mono/mono/issues/9869.
<!--
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
-->
* [coop] Turn hybrid suspend on by default on desktop platforms
Use hybrid suspend by default on x86 and amd64 OSX, Windows and Linux
Pass `--disable-hybrid-suspend` to configure to disable at build time, or set the environment variable `MONO_THREADS_SUSPEND=preemptive` when running Mono to use preemptive suspend (the previous default).
Pass `--disable-hybrid-suspend --enable-cooperative-suspend` to configure cooperative suspend at build time.
* [sdks] Disable coop and hybrid suspend for iOS and Android
Only the devices and simulator builds, not the host ones.
* [coop] Add mono_threads_suspend_override_policy ()
Do not use it. It provides a last resort method to ignore configure and environment settings and use a hardcoded threads suspend policy.
* [interp] Override suspend policy - warn and use preemptive
Until the interpreter supports safepoints and performs threads suspend states switches in its trampolines, always use preemptive suspend if the interpreter is used.
* [coop] Enter GC Safe around mono_threads_join_lock ()
Like other uses of mono_threads_join_lock, enter GC Safe before trying to take the lock.
* [interp] Use preemptive suspend with --full-aot-interp
Move safepoint suspend check to mono_runtime_set_execution_mode
* [test] fullaotmixed - force preemptive suspend[test] fullaotmixed - force preemptive suspend
Force preemptive suspend in fullaotmixedcheck. We must compile the AOT images without safepoints.
* [sdks] Run the offset-tool in 64 bit mode.
* [sgen] SgenDescriptor should use the target wordsize.
* [sdks] Fix 'Run the offset-tool in 64 bit mode.'
* Manually add a csproj file for cil-stringreplacer
Adjust trace level for genproj
* Manually add cil-stringreplacer to bcl.sln and set it as a dependency of corlib
* Fix typo
* Add post-build event to corlib that runs cil-stringreplacer on it in mscorlib mode
* [csproj] Update project files
Right now, the set of mono-api-tools only works as console apps. This PR will make them work as normal dlls so they can be consumed by other apps and libraries. They will still work as .exes, so nothing visibly changes for existing users.
The motivation for this is for some build process or third party tool to take an assembly and generate an .xml doc from it. Since the writer is in-memory, the tool can then parse the .xml and do whatever it needs to. The same goes for the diff tools - if the diff happens in-memory, then the tool can process it without having to save and then load from the file system.
## Libraries
- [x] mono-api-info -> `Mono.ApiTools.ApiInfo`
- [x] mono-api-diff -> `Mono.ApiTools.ApiDiff`
- [x] mono-api-html -> `Mono.ApiTools.ApiDiffFormatted`
## Major changes
- the existing `Driver` classes are now just thin wrappers to parse the args and pass it on to the generators
- the "options" are now abstracted into config classes to avoid methods with numerous parameters
- the APIs have new support for reading assembly and info `Stream`s instead of just file paths
- added compiler flags to control the namespace and type visibility to make the library APIs nicer
- added compiler flag to remove the `Driver` class and `Mono.Options` dependencies
- the mono-api-info tool has some more options to allow it to run on libraries, and ignore dependencies that it cannot find - this makes it easier to use so that the entire dependency chain does not have to be loaded just to output the current assembly API
## Compiler defines
- `EXCLUDE_DRIVER` will remove the console entry point and remove the dependency of Mono.Options
- `USE_MONO_API_TOOLS_NAMESPACE` will switch the namespace to `Mono.ApiTools` so that libraries can have a nice API
- `USE_INTERNAL_VISIBILITY` will make any non-essential, `public` APIs turn `internal`
## Review points
- are there any variables/fields that are still static?
- are there any exposed types/members that need to be hidden?
- are the new names for the APIs and config classes OK?
- are my whitespaces according to the guidelines?
- did I go horribly wrong?
- Public headers should be wrapped in it (all but one are).
- MONO_API should include it.
But it is not needed "everywhere".
Placement of "extern" therefore tweaked.
- Remove from functions where it is meaningless and gets in the way.
- Mark data with MONO_API_DATA instead of MONO_API.
[not yet]Sprinkle in a few G_BEGIN_DECLS for monodis and where THREAD_INFO_TYPE makes prototypes incorrect.
include/add prototypes for all icalls. [undone per PR, possibly a misunderstanding]
A problem would be, if embedders manage to use functions that are neither MONO_API nor
in public headers.
Some parts of the larger solution are omited here in the hopes of finding better options.
In particular, compiling all of monodis as C++ so we don't need some extern "C" for it,
and THREAD_INFO_TYPE at least incoming being gpointer so declaration and definition match.
This is based on https://github.com/mono/mono/pull/9812/commits/40315ee475bdf89c40189707a8cca86b3f6d91c8 and is an alternative to https://github.com/mono/mono/pull/9782.
We also can/should prune the preexisting G_BEGIN_DECLS / G_END_DECLS uses.
* [runtime] Add a MONO_ABI_SIZEOF(MonoObject) define, use it instead of sizeof(MonoObject). Add a few helper functions to avoid sizeof(MonoObject) in many places.
* [aot] Add a 'deterministic' testing argument to have the compiler produce deterministic output by turning off the generation of the AOT id.
* [jit] Use target sizes in many places.
* [runtime] Avoid corlib checks in cross compile mode, its not possible to read the field value from corlib.
* [runtime] Fix the arm build.
Every different locale getter in unmanaged attempts to
cache the result from this icall. Some of them fail to do so in a manner
that is correct.
CFLocaleCopyCurrent (); in get_darwin_locale ends up being called
thousands of times. In an app with a few dozen printfs, it's easy to see
18mb of leaked memory through this.
Rather than trying to fix them all in unmanaged in a perfect manner, I
thought it better to also avoid the icall overhead and to cache it in
C#.
Without this fix, a memory traffic stress test (debian shootout's pidigits) leads to 66% of
memory pressure being due to this icall. With this fix, it is 4.3%.
If this caching is wrong for correctness reasons (we expect it to change?),
I would like to point out that we have similar caching done in unmanaged
and that we should then bring both into a correct design.
Right now we have a race condition where parallel make on CI will barge ahead and start building things before monolite+basic-profile-check have completed, which results in some weird behavior - gensources silently fails to run, etc. Testing some possible fixes for this.
* [offsets-tool] Add i386-apple-darwin11.2.0 as an abi target, used only for development.
* [offset-tool] Emit sizes for structures.
* [runtime] Cleanup the cross targets in configure.ac and add more target defines.
Redefine SIZEOF_REGISTER to refer to the target size.
Add TARGET_SIZEOF_VOID_P define and target_mgreg_t type.
* [runtime] Add missing object offsets for x86.
* [runtime] Avoid trying to execute assembly load hooks in aot mode.
* [runtime] Fix the windows build.
* [offset-tool] Fix indentation.
* [runtime] Add a mono_gc_get_target_card_table () function which is the same as mono_gc_get_card_table () but returns information for the target. Use it in the JIT and in places where we generate IL code.
* [aot] Save the card table parameters in the AOT image and check them at load time.
* Fix llvm support.
Using solution dependencies in ```bcl.sln``` seems flaky and seems like it might not establish the full ordering we need to ensure that ```Consts.cs``` exists before we build things that require it. Let's try using project references (where ```corlib.dll``` 'depends' on ```genconsts.exe```) instead. This should also insert the dependency for any project that includes Consts.cs instead of just corlib.
This PR also makes update-solution-files actually fail if ```genconsts.exe``` fails to build because it was driving me mad.
Part of #6886
* Add check for a generic method when invoking in debugger
VSTU will try to invoke a generic (uninflated) method in certain
situations, which was causing the Mono debugger to assert and crash
Unity. Added a check for this situation before the invoke so the
debugger can return an error to the client. Previously, this case
wasn't caught until the method was in JIT compilation, which will
assert when this situation is detected.
* Fixing typo
The version imported and attempted to patch didn't work fully. This
preserves the .NET representation while converting if directives to
runtime checks, which CoreCLR inlines.
Testing was done poking some values in the REPL and running some
test suites (System.Json, System.Decimal) that broke as a result.
mcs should also properly handle constants; again, the "bits" inside
are consistent with amd64, and just converted as needed.
Unless I fucked up, should fix#9772.
Carbon implementation now throws exception instead of crashing in the mismatched p/invoke calls.
Cocoa implementation now support 64-bit mode and uses the handle of `NSView` that is passed in instead of relying on `NSGraphicsContext.CurrentContext`. It also fixes handling of flipped views.
Requires up to date libgdiplus.
* [appdomain] MONO_API mono_domain_set needs GC Unsafe
* [runtime] MONO_API mono_domain_set_config needs GC Unsafe
* [runtime] MONO_API mono_dllmap_insert sometimes needs GC Unsafe
When adding a global mapping, don't do the state transition because the thread may not be attached yet. When adding a per-image mapping, do the transition.
* [runtime] MONO_API mono_g_hash_table_insert needs GC Unsafe
* [runtime] MONO_API mono_g_hash_table_new_type needs GC Unsafe
* [runtime] MONO_API mono_gc_reference_queue_new needs GC Unsafe
* [runtime] mono_thread_detach_if_exiting thread state change
1. Mark it external only, it's unused in the runtime.
2. If detaching, switch to GC Unsafe before detaching
* [metadata] Make mono_class_get_fields external only
- Runtime should use mono_class_get_fields_internal
- MONO_API mono_class_get_fields needs GC Unsafe
* [runtime] MONO_API mono_gc_reference_queue_add needs GC Unsafe
* [metadata] Make mono_class_get_name and namespace external only
- Runtime should use m_class_get_name and m_class_get_name_space
- MONO_API mono_class_get_name and mono_class_get_namespace need GC Unsafe
* [metadata] MONO_API mono_class_get_parent needs GC Unsafe
- mark it external only; runtime should use m_class_get_parent
* [metadata] Make mono_class_is_delegate external only
- runtime should use m_class_is_delegate
- MONO_API mono_class_is_delegate needs GC Unsafe
* [metadata] Make mono_class_is_valuetype external only
- runtime should use m_class_is_valuetype
- MONO_API mono_class_is_valuetype needs GC Unsafe
* [metadata] Make mono_class_is_enum external only
- runtime should use m_class_is_enum_type
- MONO_API mono_class_is_enum needs GC Unsafe
* [metadata] Mark mono_class_get_element_class external only
- runtime should use m_class_get_element_class
- MONO_API mono_class_get_element_class needs GC Unsafe
* Add support for Blazor custom interop support.
This adds additional ability to perform unmarshalled calls for advanced but high-performance shared-memory interop.
* Note: * This is only safe in Blazor's case because of its exact usage patterns.
* Add dotnet_support.js backing file.
Instead of accessing them using the inst_ls_word/inst_ms_word macros which use the union in MonoInst.data, access them normally using
MonoInst.Data.i8const.
It wasn't possible to debug any F# app that contained PInvokes.
The F# compiler omitted MethodDebuginformation for PInvokes which in
turn caused Mono to fail on an assertion.
```
* Assertion at metadata.c:1117, condition `idx < t->rows' not met
```
https://github.com/mono/mono/commit/0f0e31842f1f394c4e95d3726c20af547e706278 added a new pipes_pns.sources file
but we forgot to add it to EXTRA_DISTFILES so it gets included in the tarball.
Given that this happens almost all the time when we add a new .sources file
we should just always include all *.sources
* [cxx] Build/CI support for C++.
configure -enable-cplusplus and CI_TAGS=cplusplus
https://jenkins.mono-project.com//job/test-mono-mainline-linux-cplusplus/
* [cxx] Rename CPLUSPLUS/cplusplus to CXX/cxx.
* [cxx] Add C++ build support to mini.
* [cxx] Jenkins/CI support for cxx not just cplusplus.
* [interp] Fix some conv ovf opcodes
* [interp] Correctly hande a few conv ovf cases
For conversion from unsigned value to i1 and i2.
* [interp] Fix multiplication overflow case
* [interp] Remove some constants from code
* Use System.Security.Policy.Publisher from corefx (they essentially stubbed it out).
Fixes the XUnit 2.4 problem.
* Use `PublisherMembershipCondition` from CoreFX as well (stubbed out in there) and remove the tests.
* Bump API snapshot submodule
* [Coop] System.IO mark all remaining NOHANDLES().
* Functions take no parameters, not any parameters -- () vs. (void).
* [Coop] Mark System.Threading.Interlocked as mostly NOHANDLES().
* [Coop] ves_icall_System_Threading_Thread_MemoryBarrier is NOHANDLES().
* [Coop] System.Threading volatile reads/writes are NOHANDLES().
* Make YieldInternal NOHANDLES and remove two potential layers.
* [Coop] Make ves_icall_System_Threading_Thread_current_lcid NOHANDLES().
* [Coop] mono_100ns_ticks nohandles.
* [Coop] More nohandles volatile reads/writes.
* [Coop] NOHANDLES() System.Security.SecurityManager.
Return objects from load_cattr_value () using an additional out parameter. Add a variant of
mono_reflection_create_custom_attr_data_args () which can only decode a subset of cattr types, but
it doesn't allocate any objects. Use this in marshal.c/marshal-ilgen.c to avoid allocating objects
while decoding FixedBufferAttribute and UnmanagedFunctionPointerAttribute.
* [interp] Refactor MINT_ICALL opcodes
Remove integer versions, since they add unnecessary complexity, and with some signatures we were already implicitly casting int to gpointer.
* [interp] Use fast versions for icalls
* [interp] Include more fast pinvoke/icall signatures
These cover almost all icalls
* [interp] Fix fast icall return value
The returned value needs to be converted to the stackval representation
* [corlib]: Cleanup `X509Certificate` implementation and sync it with CoreFX.
Completely refactored the `X509Certificate` implementation to make it based very closely on CoreFX.
We cannot fully switch to their implementation yet because we are missing things and they also have
a few issues in their implementation. However, this will make it a lot easier to do this at a later time.
The internal `X509CertificateImpl` has been cleaned up as well, using properties instead of methods in
most places and the `ToString()` implementation is now shared between all platforms.
* `X509Certificate.CreateFromSignedFile()`: in CoreFX, this is the same as `CreateFromCertFile()`.
Our old implementation was incomplete and did not verify the signature - we even had a test where
loading a certificate with an invalid signature was supposed to work; this test has been disabled
because we're now throwing an exception.
* `X509CertificateImpl.KeyAlgorithmParameters`: this is supposed to throw `CryptographicException`
on error, see `Certificate13` in `X509CertificateTest.cs`.
* We now match CoreFX's behavior regarding serialization - while the `X509Certificate` type is still
marked as `[Serializable]`, we now throw `PlatformNotSupportedException` when attempting to serialize
or deserialize it.
* Bump API snapshot submodule
* [csproj] Update project files
* Make `corlib` internals visible to `System.Security` on all profiles, not just monotouch watch.
* Moves all generated `SR` files and their generation logic from `System` and `System.Security` into `corlib`. Since `corlib` internals are visible to these assemblies, we don't need to duplicate the resource strings.
* Cleanup the `RESX_RESOURCE_STRING` is `corlib` and sort them alphabetically.
* Add the internal `Internal.Cryptography.Helpers` helper class from CoreFX to `corlib` (currently unused, but "Blue" will need it).
* Fix up behaviour of verbose method with arguments
Given a method spec which looks like:
`MainClass:Do(int,int,int)`
Via f024e820a025aacc1cf80eb82a8aee4552c3ac11 the code would match 3 methods:
`MainClass:Do(int`, `int`, `int)`, crashing the runtime.
Accept the multiple method matches via `;`, rather than `,`.
Now, the behaviour is changed so:
`MainClass:Do(int,int,int);MainClass:Do(int,int)`
Get parsed as:
`MainClass:Do(int,int,int)`
`MainClass:Do(int,int)`
* Add tests
* add test file and make tests actually output something
* Smarter unit test around disassembling methods
* Try single quoting environment variable value
* Try using non-throwing setter
Temporarily switch back to ref-source impl for `CharUnicodeInfo` which contains a few special BE patches while I am trying to upstream them.
Fixes#9684
Both `Certificate_11_Properties` and `Certificate_14_Properties` use an invalid
certificate that violates X.690 11.8.2 (UTCTime under a DER encoding).
This will no longer be supported once we switch to CoreFX's PAL code.
See also https://github.com/dotnet/corefx/pull/31293.
Instead of digging around in the environment for the coop and hybrid suspend
settings, define in terms of mono_threads_suspend_policy (or the
MONO_ENABLE_BLOCKING_TRANSITION env var as before).
Set to one of "preemptive", "coop" or "hybrid".
Unlike the old MONO_ENABLE_COOP, MONO_ENABLE_COOP_SUSPEND,
MONO_ENABLE_HYBRID_SUSPEND, the value of MONO_THREADS_SUSPEND will take
priority over the configure flags default.
For compatability the old environment variables will be respected if neither
MONO_THREADS_SUSPEND nor a configure flag was set. A warning will be emitted
if MONO_THREADS_SUSPEND isn't set. (Rationale: maybe the environment set both
because they're not sure which version of Mono they will be running - so don't
nag them).
Rework of #5448, contributes to #7143.
The anonymous pipes were tested on macOS, build was tested only on few configurations (hoping to solve some issue through Jenkins builds). Named pipe tests get stuck on macOS, but it may be unrelated Xunit issue and needs some proper debugging.
@Therzok, do you know of anything else that is missing for parallel MSBuild? Do you have some test environment for it by chance?
[MacOS] On Mac, use the copyfile API to copy files
Rebase of #9038 with added fix for the failing unit tests. Note that there's a race condition in the check between `source file == destination file` and the `copyfile` call, but a similar race condition already exists there in the current code except the outcome is different.
* `X509Helper`, `X509CertificateImpl`, `X509Certificate2Impl` and `ISystemCertificateProvider` now use `SafePasswordHandle` instead of strings.
* `X509Certificate`: actually implement `SecurePassword` based APIs using `SafePasswordHandle`.
* `mono_btls_pkcs12_import()`: when passed an empty password, try both the empty string and null.
After the dependency injector changes, the `X509Certificate` code in corlib now uses the implementation from `System.dll`, including the platform-specific switch via `MONO_TLS_PROVIDER` / `MonoTlsProviderFactory`.
This adds a new `X509Certificates2` category to the corlib tests and runs them with `MONO_TLS_PROVIDER=btls` on OS X (where the default is applets).
* [interp] fix stack type warning around ldlen instruction
removes this warning in e.g. mcs-tests:
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
* [interp] fix compiler warning around MINT_INTRINS_BYREFERENCE_CTOR
fixes those warnings:
> interp/interp.c:3924:13: warning: unused variable 'valuetype_this' [-Wunused-variable]
> stackval valuetype_this;
> ^
> interp/interp.c:3926:13: warning: unused variable 'retval' [-Wunused-variable]
> stackval retval;
> ^
> 2 warnings generated.
Adds 1192 xunit tests for System.XML from CoreFX
Also, moves common lines from `mobile_System.Xml.sources` and `System.Xml.sources` to `common.sources`
Part of #8132
* Use __declspec(thread) with Visual C++, and __thread with Win32/gcc,
instead of much slower TlsGetValue / TlsSetValue
* Avoid affecting Boehm.
* Replace HAVE_KW_THREAD and USE_KW_THREAD with MONO_KEYWORD_THREAD.
* Refactor the AppleTls Certificate code into a PAL-based approach.
* Added the internal `SafeHandle` based classes from CoreFX's PAL:
`SafeSecCertificateHandle`, `SafeSecIdentityHandle`, `SafeKeychainItemHandle`
and `SafeSecKeyRefHandle`.
* Added a new static internal class `MonoCertificatePal`:
- `Mono.AppleTls/MonoCertificatePal.cs` is shared between OS X and Mobile.
- `Mono.AppleTls/MonoCertificatePal.OSX.cs` contains the OS X specific parts.
- `Mono.AppleTls/MonoCertificatePal.Mobile.cs` contains the Mobile specific parts.
This split allows us to avoid all the `MONOTOUCH` conditionals in the code.
* In the `Mono.AppleTls` directory, all code from `Certificate.cs`, `Items.cs` and
`ImportExport.cs` have all been merged into the new `MonoCertificatePal` class.
* The entire AppleTls code is now using these safe handles instead of the old
Mono-specific types. This allows us to swap out the implementation of the certificate
code with CoreFX's PAL code.
* Cleaned up and removed some ancient dead code.
* `build/profiles/build.make`: Don't set `MONO_FEATURE_APPLETLS` here.
* Add `appletls.sources` and cleanup `MONO_FEATURE_APPLETLS` conditionals.
* [csproj] Update project files
These programs work if you just compile them with g++ and most of the automake/autoconf/libtool
flags, but not if you use all of them. Something to do with search paths perhaps.
* [linker] Add BCL size regression testing
We're now tracking the size of the BCL after it was processed by the linker
across various profiles we care about (currently net_4_x, monotouch and monodroid).
The way it works is that we keep a file with size measurements in the repo
and during CI we run the linker against the current state and compare.
Right now we're simply running the linker tests as they are a good approximation
of various usages (this PR additionally adds more comprehensive linker tests we had in XI).
If changes are found there's a report to check where the increase/decrease came from.
The changes can be applied via `@monojenkins commit sizediff` similar to
existing csproj and apidiff usages.
Fixes https://github.com/mono/mono/issues/6992
* Don't run new linker tests yet, just use for size checking
The mono_load_runtime_and_bcl allows upstream to remap requests and report download progress.
This cb semantics might change in the future when we implement more agressive loading.
The `mono_threads_attach_coop` / `mono_threads_detach_coop` icalls are called
from the wrapper around managed methods that will be called from native code
`emit_managed_wrapper_ilgen`.
If the managed method throws an exception, the mono_threads_detach_coop will
not be called, and the checked build
`mono_threads_enter_gc_unsafe_region_internal`/`mono_threads_exit_gc_unsafe_region_internal`
accounting will be mis-matched which will break later checked mode checks.
(The unbalanced thread state transition is not a problem - the next outermost
exit_gc_unsafe will operate just fine - it's just the checked mode check that's
wrong)
Once we lost the try/finally in b20d5ce1e5 these
should have become unbalanced.
* [Coop] Convert 3 more functions and strengthen some types to be not just gpointer.
i.e. to see in debugger and for static type checking
* ves_* probably shall not call ves_*.
non-ves_* (mono_*) really shall not call ves_*.
Only C#/icall-def.h shall call ves_*, and only ves_*.
Where there is a contradiction, rename ves_* to mono_*,
have ves_* and mono_* call mono_*, and possibly cleanup.
For example, removing MonoError* parameter, and moving asserts
around to preserve or improve semantics.
* Remove incorrect comment.
This adds a simple script for generating Consts.cs that can run on Windows, and makes it a dependency of corlib.csproj in the BCL solution file. From my initial testing this will autogenerate Consts.cs if it's missing and then corlib will successfully build.
This (mostly?) addresses issue https://github.com/mono/mono/issues/6886.
This currently has an awkward dependency on ```winsetup.bat``` and I modified it slightly to make it clearer whether the batch file succeeded.
Rather than always writing to the std out, provide an option to write to a file. This makes things easier for tooling by not requiring `RedirectStandardOutput = true`
* [interp] Check delegates for null this
* [interp] Resolve target method for delegates created with abstract methods
* [interp] Fix delegate invocation
Previously, when first calling the Invoke method on a delegate we would silently transform the delegate invoke wrapper of the delegate on which Invoke is called, after which all calls would go through this method. This is problematic because the same Invoke method can be called on a different delegate afterwards (the delegate_invoke wrapper needs to be tied to the delegate and it's not global for all invokes of same type),
We solve this by storing the invoke method in the delegate, similarly to the JIT.
* [interp] Remove unused argument
[llvm] Avoid using the preserveall calling convention in another plac…
…e on watchos.
Fixes https://github.com/mono/mono/issues/9318.
<!--
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
-->
Generate similar array-coop*.cs files from pieces.
System.Array icall logging/testing tweaks.
Add const, but only in comment.
[Coop] Convert ves_icall_System_Array_CreateInstanceImpl.
PR feedback: Don't have icall call icall, refactor into common helper instead.
Add more disabled printing.
test_get_generic_value fails even CI JIT due to AOT runtime,
but does work with full JIT configuration.
Generic ref/out parameters are not supported by HANDLES(), so
NOHANDLES(SetGenericValueImpl)
NOHANDLES(GetGenericValueImpl)
Also add MONO_REQ_GC_UNSAFE_MODE because of unsafe gpointer value (which reinforces NOHANDLES?)
Remove extra evaluation of arg.
Enable 3 more tailcall tests on x86.
Enable more tailcall AOT tests.
Program to split fsharp-deeptail.il into separate tests.
Split up F# test into individual tests.
Simplify test IL and make it stack overflow upon failure.
Cleanup test code before splitting.
Program to split tailcall-interface-conservestack into separate tests.
Enable split up versions of tailcall-interface-conservestack and F#.
There is a problem in that we use gsharedvt unexpectedly, and gsharedvt
has almost-fundament contradiction with tailcall.
Need to figure out why it used, if that is correct.
Disable some FullAOT tests that are broken by gsharedvt.
Lower apparent memory use.
Move tests into directories and reset disabled lists.
Centralize tailcall debug helpers.
Add comments why test_virt.exe fails on 32bit x86.
Remove tail. prefixes that are besides the point, and add noise to the logging.
Print more in failure.
Better align the stack for x86, so tests pass.
There were already tailcalling and conserving stack, but still using a little stack.
Real world code will use zero or a little. The test self-check is very strict
and wants zero, and prints how much.
Rename duplicate tests, and sort them.
Otherwise we were missing split tests.
Add 96 ARM failures and 30 FullAOT failures, mostly all understood.
ARM cannot pass extra parameter in a tailcall (except bitcode that we do not fix).
FullAOT uses gsharedvt a lot even for statically discovered types created, due to
interface and virtual.
Convert to C++98 and fix warnings about /* in //
Split the tests up in the build instead of ad hoc by developer.
Disable tests on wasm and win32 (and cross) due to build problem.
* [Coop] Convert ves_icall_System_Runtime_InteropServices_Marshal_IsComObject.
* [Coop] cominterop and marshalling partial conversion and cleanup.
* Some refinement/correction/commenting to mono_string_to_utf8str_handle.
* Fix index out of bounds.
* Fix error handling.
* Remove some mono_error_set_pending_exception.
* Fix icall interface -- string vs. ptr/len.
* tweaks
* Restore the corlib interface, and maybe address the apidiff gate.
* cleanup
* Fix PtrToStructure GC assertion failure tests/marshal2 interpreter.
* Fix merge.
* Revert "Restore the corlib interface, and maybe address the apidiff gate."
This reverts commit ca8456a05f75f0fc05f6559e2f075e18a455a362.
* Try harder to support fixed in array copying.
* Allow for overlap.
* Put mono_ in front of type and fix Windows.
* Fix small problems on Windows build.
* Fix Windows and support larger data.
* [arm64] Make OP_CHECK_THIS read only a byte, to prevent unaligned access errors.
* Bump corlib higher.
* Merge with https://github.com/mono/mono/pull/9430/files.
* Bump API snapshot submodule
* cominterop_get_interface(gboolean throw_exception) throw_exception is always true.
* Remove unused cominterop_get_hresult_for_exception.
* Guids are constant.
* Replace g_assert (mono_error_ok (error)) with mono_error_assert_ok (error).
* Move function name to start of line for grep ^foo.
* PR feedback: g_assert(ex)
* Cleanup cominterop_get_interface -- single point of exit, more canonical non-coop form,
assert error indicator equivalence.
* Cleanup cominterop_get_interface_checked: early return and assert equivalent error indicators.
* Combine two versions of mono_cominterop_init.
* g_new0 instead of g_new+memset
* Remove obviously redundantly error_init.
* Inline cominterop_get_idispatch_for_object into its only caller ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal,
and make it a more coop-friendly.
* add const
* Combine forks of some functions and ifdef out more on Win32.
* Initialize with declaration.
* Use integers for sizes, not pointers.
* More asserts though redundant.
* Combine two forks of mono_marshal_safearray_set_value.
Dependency Injector
===================
* `corlib/Mono/DependencyInjector.cs`: this is corlib's entry point.
* `corlib/Mono/ISystemDependencyProvider.cs`: this interface is implemented in `System.dll`.
* `System/Mono/SystemDependencyProvider.cs`: the `System.dll` side of it.
To use this, we need to call `SystemDependencyProvider.Initialize()` during system startup on Mobile
(this is already done for Android, but still needs to be done for XI/XM).
For Desktop, this will be triggered by a few `System.dll` based APIs such as for instance `SslStream`
or `X509Certificate2` - and the corlib side can use reflection if needed.
The corlib side should use `DependencyInjector.GetSystemDependency()`.
X509Certificate - corlib side
=============================
We previously had a mechanic called `INativeCertificateHelper` (which unfortunately was not really
working as intended) to use the BTLS code (which lives in System) in corlib. This has now been
replaced to use the new dependency injector.
The actual implementation as well as all the platform conditionals have now been moved into `System.dll`
where they can take advantage of existing PAL code.
This also removes all `Mono.Security.X509` usage from the `System.Security.Cryptography.X509Certificates`
namespace (it is still used by some of the other crypto classes, so we can't remove it yet).
* `Mono/ISystemCertificateProvider.cs`: this interface is now hooked up via the new
dependency injector and replaces `INativeCertificateHelper`.
* `System.Security.Cryptography.X509Certificates/X509Helper.cs`: this file has been completely
reworked and is now just a tiny stub around `ISystemCertificateProvider` and will eventually go
away completely. The entire implementation has been moved into `System.dll`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplMono.cs`: removed, we now use
`X509Certificate2ImplMono` from System via `ISystemCertificateProvider`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs`: moved into `System.dll`
and slightly reworked there.
* `System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs`: removed, we do not have any
platform-specific code here anymore; the new `ISystemCertificateProvider` provides this for us.
X509Certificate - System side
=============================
The actual implementation as well as all the platform-specific code now lives in `System.dll`.
* `Mono/SystemCertificateProvider.cs`: the `System.dll` implementation of `ISystemCertificateProvider`.
We do the platform / TLS Provider checks in here, then construct a custom PAL class.
* `Mono/X509Pal.cs`: New internal static class.
* `Mono/X509PalImpl.cs`: New abstract internal class. It contains some common code, including the
fallback implementation.
* `Mono/X509PalImpl.Mono.cs`: Fallback PAL, used by platforms without SslStream / MonoTlsProvider.
* `Mono.Btls/X509PalImpl.Btls.cs`: BTLS implementation.
* `Mono.AppleTls/X509PalImpl.Apple.cs`: We are using the `MONO_FEATURE_APPLE_X509` conditional in
here, so it can be used without the actual Apple TLS code.
* `Mono.AppleTls/X509CertificateImplApple.cs`: moved here from corlib.
* `Mono.AppleTls/*.cs`: Use the `X509CertificateImplApple(IntPtr)` constructor everywhere instead of
`X509Certificate(IntPtr)` to make sure we are using the "correct" PAL.
* [System]: Fix `mono_btls_x509_get_public_key()` implementation.
* Copy corlib's `X509CertificateTest.Certificate8` into System, call it
`Corlib_Test_Certificate8` and use `X509Certificate2`.
The test in corlib does not expose the problem because it would use the
fallback implementation.
* Use `[SetCulture ("")]` as suggested by Marek.
[coop] Fix MONO_HANDLE_TRACK_OWNER build
<!--
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
-->
Originated from PR #1283, they now pass because we're using referencesource
code for the hash algorithm classes now.
In RSAPKCS1SignatureDeformatterTest.cs we weren't testing against the
actual `badSignature` (it doesn't make a difference since the referencesource
code or .NET Framework throws NullReferenceException anyway, but is more correct).
Closes#1283
* `HashCode` is now enabled in all profiles.
* Added `RNGCryptoServiceProvider` based fallback implementation.
* Added internal `RNGCryptoServiceProvider.GetRandom(byte*,IntPtr)` overload.
* The fallback implementation is enabled by default in `corlib.dll.sources`,
platforms which provide a native implementation need to add it to their
`.exclude.sources`.
[sdb] Avoid calling vm.GetThread () in the event callback, it could c…
…all into the debuggee leading to a deadlock if the thread mirror object has not been created yet.
<!--
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
-->
[interp] fullaotmixedcheck 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
-->
It is too easily trashed, e.g. by mono_thread_info_uninstall_interrupt.
See https://github.com/mono/mono/pull/9104.
See https://github.com/Unity-Technologies/mono/commit/b6f1ba89f7ab285a0990e696e78798f7cf18dafb
Which this should be an alterate fix for, as discussed in 9104.
This is a small change, but ultimately we should be able to thread
gint32 *win32error around enough, such as to eliminate the thread local on Unix.
It doesn't appear to take much. Thread locals, it turns out, are not a good mechanism.
They are sensitive to loss as addressed here. They are slower to access than regular globals
or locals. They do have the advantage of "automatic threading through a callgraph", as long
as you are very careful with their use (this PR demonstrates that problem).
As well we could/should move the GetLastError calls down one layer on Win32,
from w32file.c to w32file-win32.c.
But this change addresses only ReadFile/WriteFile.
Also remove unnecessary void** vs. void* cast.
Also combine Unix mono_w32file_read and mono_w32file_write.
[mini] make interp work with AOT image generated with aot=interp
[aot-compiler] use mono_aot_mode_is_interp instead of directly using the flag
---------
[interp] add FULL_AOT flags to AOT image when `--aot=interp` is used
fixes regression from 67e995c6e2
---------
partial forward port of https://github.com/mono/mono/pull/9266
needs backporting to `2018-06`
* Fix unit tests to use SERIALNUMBER instead of OID.2.5.4.5 in X.500 names. Modify the code to pass the tests.
* Add SERIALNUMBER for BTLS implementation.
* Fix one more place where SERIALNUMBER was not handled.
[interp] Optimise allocation path
Speeds up allocation by 30-40%
<!--
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
-->
As part of #7589
- CoreFX import only for Windows platform (no support for non-Windows platforms, see https://github.com/dotnet/corefx/issues/22510)
- left Mono managed implementation for non-Windows platforms
- removed DataProtectionScope parameter value check (no such a check in CoreFX and NET Framework, see https://github.com/dotnet/corefx/pull/30726) and couple of related unit tests
- added CoreFX xunit tests
When implementing Windows x64 valuetype ABI mono’s SIMD optimization didn’t
handle the case when passed arguments uses ArgValuetypeAddrInIReg/
ArgValuetypeAddrOnStack so optimization was disabled on Windows x64.
This commit fixes mono SIMD support for ABI’s passing value types using
ArgValuetypeAddrInIReg/ArgValuetypeAddrOnStack on Windows x64. It does this
as part of regular value type decomposition, including a pass decomposing SIMD
intrinsic ending up as arguments of type OP_ARG into correct load/store of the
value type reference before argument can be used by SIMD instructions.
All JIT and full AOT regression tests pass with enabled SIMD optimization
on Windows x64. Running this optimization on some vector intensive applications
showed some great performance increase. Just running this on basic-simd.exe
regression shows:
Elapsed time: 0.040471 secs (no optimizations at all)
Elapsed time: 0.015756 secs (only simd and intrins optimization)
So in this small, isolated test, the optimization indicates a 2.5x performance increase.
* [runtime] Map memory used by code managers with MAP_JIT on osx.
* [runtime] Use MAP_JIT only on osx mojave and later, it seems to cause crashes on earlier versions.
* [runtime] Add a constant for darwin 18.
* [runtime] Fix the race in get_darwin_version ().
* Fix indentation.
When doing full AOT of System.dll on Windows and other platforms building
runtime without HOST_DARWIN or HOST_BSD we will get an ugly error,
but compilation will still succeed leaving the user confused around the result.
The following error is printed:
--------------------------------------
cant resolve internal call to
"System.Net.NetworkInformation.MacOsIPInterfaceProperties::ParseRouteInfo_internal"
(tested without signature also)
Your mono runtime and class libraries are out of sync.
The out of sync library is: C:\github\mono\msvc\build\fullaot\winaot\system.dll
When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first.
cant resolve internal call to
"System.Net.NetworkInformation.MacOsIPInterfaceProperties::ParseRouteInfo_internal"
(tested without signature also)
Your mono runtime and class libraries are out of sync.
The out of sync library is: C:\github\mono\msvc\build\fullaot\winaot\system.dll
When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first.
--------------------------------------
The problem is that MacOs/BSD specific NetworkInformation classes are build into
System.dll on all platforms. One way to solve this is to start splitting the different
platforms specific implementations into different source files so we could start to
include/exclude sources per platform and profile in a nicer way instead of just
ifdef:ing inside current source files. This strategy also matches how corefx have
structured their NetworkInformation sources making it easier in the future to bring
mono’s NetworkInformation implementation closer to corefx. This PR implements this strategy.
Due to the fact that we don’t have platform specific configs for all profiles
(like basic and build) we can’t exclude all platform specific sources from
common.sources in System and move them to platform specific profiles. Ones we
have that full capability we could drop the #if WIN_PLATFORM in all the Win32*
files and exclude them from common.sources and only include them in the corresponding
win32 specific profiles. The same strategy could then be applied for other platform
specific profiles as well.
For Windows specific profiles, like win32_net_4_x_System.dll and winaot_System.dll we
use the .exclude.sources to remove the unix/linux/macos NetworkInformation sources,
so with this commit we will get a System.dll that only includes the Win32 specific
NetworkInformation classes and none of the unix/linux/macos, this will make sure the
compile error during full AOT won’t happen since there is no classes left including
the icall not available on a Windows mono runtime.
Other platforms will have the same classes in System.dll as before for now
but the source code is now structured making it possible to include/exclude platform
specific source files for other platforms as well, when needed.
The previous system was a nice prototype, but it ran into the problem of
taking a global lock on every thread doing logging. A fully lockless
implementation of a data structure with so much state would have been
madness to debug, and I really didn't want to spend much time in the future
debugging this.
What I did is to make a thread that reads from a lockless queue and logs the
message from the queue.
Most of the rest of this code is to address the fact that hazard
pointers depend on state that is initialized after logging is expected
to come up.
[checked-build] don't collect state transition backtraces on abort_blocking
for the same reason as the other cases in this function - if we're in `RUNNING`
or `ASYNC_SUSPEND_REQUESTED` under hybrid suspend we're supposed to cooperatively
suspend. If we call `backtrace()`, we might block waiting for the low-level
dynamic linker mutex on Linux which may be held by a thread that was
preemptively-suspended already.
Returns a text description of the suspend policy currently in effect.
Also combine logic that probes for suspend policy defines and environment
variables into a single function that returns an enum value; use that to drive
the individual boolean predicate functions.
The policy is subject to configure flags from when mono was built, and the
assorted environment variables at runtime:
MONO_ENABLE_COOPERATIVE_SUSPEND
MONO_ENABLE_COOP
MONO_ENABLE_HYBRID_SUSPEND
(the second one is a backward-compatible alias for the first)
The logic is:
If coop xor hybrid is enabled by configure flags, always return that policy.
Otherwise if coop and hybrid env vars are set simultaneously, it's an error.
Otherwise if MONO_ENABLE_COOP or MONO_ENABLE_COOPERATIVE_SUSPEND is set use full coop.
Otherwise if MONO_ENABLE_HYBRID_SUSPEND is set use hybrid.
Otherwise use full preemptive suspend.
[mini] respect additional flags when caching runtime invoke wrappers
depending on `virtual_` and `need_direct_wrapper` we generate slightly
different IL. The interpreter always set `need_direct_wrapper`, but the
JIT doesn't, so this gets problemantic with mixed mode. We need to be
careful when we cache those results.
This bug has been lurking for four years, being introduced in commit
5b2bb8c901. BYTE_ORDER != G_BYTE_ORDER.
Not throughly tested, but System.Decimal from csharp seems to return
sane results again. (related: is z or AIX CI available for PR checks?
if not, what test suite is System.Decimal under?)
Also remove my shoddy workaround from a few months ago, it got the
BCL building, but was incorrect.
* [sdb] Add a AssemblyMirror.GetMetadata () method to read the metadata from the debuggee, make AssemblyMirror.Metadata return it, or null if its not set/read yet.
Fixes a regression introduced by b26a41cc3e. Parts of Mono.Debugger.Soft would check
AssemblyMirror.Metadata against null, and that would throw an exception when the debuggee was using an older protocol version.
* Bump API snapshot submodule
This PR prepares the upcoming removal of the Legacy TLS Provider.
- The internal (and soon-to-be-removed) class `MD5SHA1` has been moved and changed namespace.
- `Novell.Directory.Ldap.Connection` now uses `SslStream` instead of Legacy TLS, this ports the Novell Ldap library to use TLS 1.2, see #9363.
- Removed obsolete Ssl/Spnego authentication from `System.ServiceModel`.
- Removed duplicate copy of the Legacy TLS Provider from `System.ServiceModel`.
- Ported `System.Web.Mail.SmtpClient` to use `SslStream`.
- Removed the `Mono.Security.Protocol.Tls` documentation.
* Functions at start of lines for grep ^foo.
* [Coop] Convert System.Security.Cryptography.RNGCryptoServiceProvider.
* Remove 'count' in more places in favor of inc/dec buffer/size.
Guard all loops with while (size > 0).
Don't pretend that sizeof int32/16/8 is other than 4/2/1.
assert instead of loop forever of degenerate systems with small RAND_MAX and
without better random.
* [Coop] Some conversion of custom-attrs.c. (#9309)
* Add comment explaining mono_array_addr_with_size_fast vs. mono_array_addr_with_size.
* Have mono_array_addr_with_size reuse mono_array_addr_with_size_fast.
* split create_custom_attr_data into self and create_custom_attr_data_into_array, to avoid handle creation in loop (like alloca in loop)
Note there is a subtle semantic change here, in that previously
when invoke failed, we'd still store into the array.
The caller checks the error and throws out the data so it should be ok,
the same in the end.
* Combine mono_cominterop_get_com_interface and ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal which are nearly identical.
* Fix disabled COM.
* Replace unformative and possibly dangerous g_assert_not_reached with safer more informative g_assertf.
Fix many warnings like: icall.c:666:2: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
Most uses of mono_error_set_argument do not take a format string.
So rename mono_error_set_argument to mono_error_set_argument_format
and provide mono_error_set_argument that just takes one string, not to be formated.
Visit every call to mono_error_set_argument and change just a few to be mono_error_set_argument_format.
While there, notice that method_encode_code forms up extra data and does not use it.
* [debug] mono_pmip shouldn't assume it's called from an attached thread
`mono_pmip` calls `get_method_from_ip` which needs to make a string with the
name of a method. It used to call `mono_method_full_name` which is a `MONO_API`
function and so tries to switch to GC Unsafe mode (which requires the thread to
be attached).
However `mono_pmip` is often used from GDB/LLDB and it might be invoked by the
developer from a stopped thread that isn't currently attached which would assert.
Instead call `mono_method_get_name_full` in `get_method_from_ip` which doesn't
switch the thread state.
* [coop] mono_coop_cond_signal and mono_coop_cond_broadcast should switch to GC Safe
Under Linux/glibc `pthread_cond_signal` and `pthread_cond_broadcast` can block
on a futex in `__cond_quiesce_and_switch_g1`, so switch the thread to GC Safe
mode around the blocking operation.
* [coop] ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal shouldn't swith to GC Safe
On Win32, still do the thread state change here; on other platforms
its handled in the implementation of mono_w32handle_signal_and_wait
Add support for platform customization of native crash info output.
Add support to replace implementation of a post native crash handler behavior
if needed (used on none desktop Windows platforms).
NOTE, currently alternative implementations are in separate source file only
for Windows (since there was a need to implement in sources keept in external
closed repository). All other platforms (none Windows) still uses the exact same
logic still located in the same source file as before.
[interp] fix scope issue regarding `klass` var
`klass` exists in the main loop, but we defined `klass` again inside the
block, so the outer `klass` never had the right value.
Fixes https://github.com/mono/mono/issues/9023
* Update genproj makefile to include gensources
Update genproj argument parser to be more generous about displaying help
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Fix rebase issue
* Checkpoint
* Checkpoint
* Fix built sources only being added to one profile
* Fix typo
* Checkpoint
* Fix indentation
* Use csc instead of mcs
* Checkpoint
* Fix BUILT_SOURCES only being handled for the first profile processed
* Checkpoint
* Checkpoint
* Strip double slashes from paths to fix spurious csproj change
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint: Fix genproj compilation
* Checkpoint
* Checkpoint
* Checkpoint
* Fix crash when no targets were loaded (due to an error)
* Checkpoint
* Checkpoint
* Checkpoint
* Fix TryParseTargetInto bug
* Checkpoint
* Shuffle exclude logic around so that it works correctly during genproj diffing
* Remove gensources tracing
* Checkpoint
* Fix handling of oddball sources paths from executable.make
* Fix jay not being set to build
* Fix wrong slashes being used for embedded resource paths
* [csproj] Update project files
We had a problem with order of operations before. Makefile.am.in is
interpolated twice in the standard build. The first time happens when
autoconf runs. The second time happens when we enter the mono/mini directory
and execute our build. In the refresh, we lose our AM_CONDITIONAL conditionals
defined that aren't also AC_DEFINE variables on linux.
That's what it's vital to define all variables in all namespaces to have maintainable
automake code.
Furthermore, some of the CFLAGS logic we defined is designed for older LLVM copies, as
it includes some flags like O3 and Wall that we don't want.
In order to not get hacky with this, I moved the logic for using llvm-config into
a bash file in /llvm that creates a makefile fragment. The logic says that this fragment
should be null on calling autoconf, and then will be instantiated after we build llvm.
This fixes the build on Linux. We can expect bash behavior to be more consistent between
OSX and Linux than we can with automake too. I think this is a reorg with good long-time
maintainability.
* Use System.Security.Cryptography.Oid* from CoreFX.
* [csproj] Update project files
* Add CoreFX unit tests.
* Add obsolete S/MIME OID to make the Oid CoreFX tests pass on non-Mac systems.
* Enable Windows specific implementation of OidLookup.
* [sdks] Only rebuild MXE when it doesn't exist, not when we just cloned the sources
* [sdks] Default to ~/android-toolchain and ~/android-archives to better share with XA
Current DYNCALL on AMD64 didn’t handle scenario when spilling parameters from
registers to stack and that parameter was of type float/double. It then incorrectly
updated the floating-point register slot, but should have written it into the general
stack slot, making sure it will be correctly placed on callers stack in correct slot.
Current DYNCALL implementation didn’t handle the Windows x64 ABI when hitting a scenario
when spilling a valuetype into stack, it currently only supported the regular ArgOnStack
storage type, but Windows x64 will use ArgValuetypeAddrOnStack storage type.
There was also an additional issue with the number of stack slots allocated since it used
the stack argument offset instead of number of slots represented by the offset
(as used in later calculations). This caused to much stack space to be allocated and copied
(but things still worked as expected).
Commit also include a number of new test in aot-tests.exe mini regression test hitting above
issues.
* Modernize Windows random number generation.
- Less code.
- Less chance for failure.
- Not seedable.
- Requires Windows 7 or newer -- er, require Vista or newer until/unless Unity drops it, under ifdef.
This might get much further pruned with CoreFX import, which is on hold here, and doesn't really change much, except to indeed drop Vista support. (https://github.com/mono/mono/pull/9249)
After fixes issues in DYNCALL Windows x64 ABI all aot-tests.exe previously
excluded using !FULLAOT-AMD64 can now be reenabled since outstanding issues
have been fixed. There is one new test still failing on Windows x64,
test_42_arm64_dyncall_vtypebyval, that is now excluded until investigated
and fixed.
Correctly handle use cases when parameter storage is ArgValuetypeAddInIReg
or ArgValuetypeAddrOnStack. This is used for value types not fitting into
registers on Windows x64.
The Winx64 calling convention handles parameters in a way that was not
correctly implemented in some DYNCALL use cases. When using a method signature
like this (double, int, double), the Winx64 ABI dictates that the first parameter
goes into first floating point parameter register (XMM0), second parameter goes into
second general register (RDX) and third floating point goes into third floating point
parameter register (XMM2). So above call should use registers XMM0, RDX and XMM2,
but current DYNCALL implementation will just use next floating-point register,
like XMM0, RDX and XMM1 and this will load wrong parameter registers as expected by callee.
For an example https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx#Anchor_2
Fix makes sure mono_arch_start_dyn_call uses the already evaluated registry information
for floating point parameters. Currently it assumes floating point registers are assigned
in a linear fashion and that works for System V ABI, but not for Winx64’s ABI.
Commit also adds a couple of tests into ao-test.cs that works with mixed signatures
together with DYNCALL.
* [wasm] Add helper target to update the runtimes.
* [wasm] Reenable tests that previously crashed due to JS engine issues.
* [wasm] Update jsvu 1.3.1 so we get jsc on linux. Fix uname magic on OSX.
Omitting positional parameters works for gdb linked to python 2.7 / 3.1+. On older systems (e.g. redhat 6, centos 6) gdb might be linked to python 2.4-2.6 or 3.0, adding parameter ordinals enables proper backtraces on those systems.
Fixes#9292.
* [System]: `HttpWebRequest` now throws `WebExceptionStatus.RequestCanceled` on abort. #9031.
Cleanup the internal `HttpWebRequest.RunWithTimeout()` function and use
`GetWebException()` everywhere to throw `WebException` with
`WebExceptionStatus.RequestCanceled` on abort.
New tests for this will be added to the web-tests by extending the existing
`Xamarin.WebTests.HttpInstrumentationTests.AbortDuringHandshake` to check the
synchronous and begin/end async APIs as well, using both `GET` and `POST`.
See https://github.com/xamarin/web-tests/blob/master/Xamarin.WebTests.Tests/Xamarin.WebTests.HttpInstrumentationTests/AbortDuringHandshake.cs.
Fixes#9031.
* Fix exception checks, setting `TransferEncoding` without `SendChunked` is supposed to throw `InvalidOperationException`.
* [System]: Renegotiation in AppleTls requires OS X 10.12+.
* Make renegotiation version check conditional to `!MONOTOUCH`.
The rest of the renegotiation code is currently conditional to `!MONOTOUCH`
as well, we might want to eventually revisit this at some point.
Fixes#9234
Had additional restructure not been ok, at least typedefing the function pointer
would have helped.
Add const for efficiency -- make the copy-on-write faults count for more and
not take extra readonly data with them.
Remove unused and actually confusing parameter -- it is just zeroed memory
and almost cannot be used for anything (granted, could hash it).
* [sgen] Use longs with nursery array fill
Objects are 8 byte aligned. This enables us to support nurseries of up to 32GB.
* [sgen] Add explicit limit to nursery size
* g_string_insert does not update string->len, and copies the wrong number of characters around,
and does not allow for overlapping parameters,
and is not used -- remove it.
g_string_erase does not always update string->len,
and is not used -- remove it.
g_string_prepend does not update string->len.
Switch the only use to append in the reverse order, and fix a leak.
[runtime] Fix debugger dumping when unused
Somewhere in the daily rebasing to edit the PR, I lost the correct version of the early-exit. This fixes our native crash when we did not use the debugger. It's important to merge, or we'll crash before MERP/gdb dumping happens.
Using dynamic symbol resolve (LoadLibrary/GetProcAddress) for all unwind info related registration functions enables
building the same code on all Windows platforms where JIT is build and included.
There are Windows platforms (like UWP) that doesn't support getenv. The implementation
of g_getenv makes it possible to replace the implementation at build time on
none desktop platforms.
The throwing of the pending exception after the finally blocks are executed was in unreachable code.
Refactor the code a bit and exit the abort protected block directly in endfinally. We throw the abort after all guarding finally blocks were invoked, to avoid throwing from inside a finally block. Guard also fault handler, which are called from EH.
* [runtime] Implement tombstone scrubbing for our concurrent hashtables.
Tombstones must be scrubbed as they can end up taking up all space of a hashtable and make lookup fail.
* [runtime] Added regression stress test for #9176
This test triggers insertion and removal from runtime_invoke_hash to the point
that if there's no scrubbing it will cause a deadlock.
* [runtime] Disable new test under full-aot as it uses SRE.
The callback consists in `mono_thread_info_abort_socket_syscall_for_close` which itself calls `mono_threads_suspend_abort_syscall`. The problem with the previously existing interrupt callback is that, even if `mono_threads_suspend_abort_syscall` is called by the thread suspend mechanism, it would still call `mono_thread_info_abort_socket_syscall_for_close` which would duplicate the call to `mono_threads_suspend_abort_syscall`
* Helper scripts running mini regression tests in JIT/Full AOT on Windows.
A set of helper scripts running all mini regression tests, supporting both
JIT and full AOT (including building full AOT assemblies) using local build
Visual Studio mono runtime (can be switched in setp.env.bat). Includes logic
to pick correct Visual Studio toolchain and support to setup command prompt
targeting x64 full AOT build and running tests. NOTE, the scripts are not limited
to the mini regression tests, only includes a set of predefined assemblies making
it easier to execute regression tests.
Full AOT scripts includes capabilities to build dynamic library, static linked objects
or assembler output, it also supports switches to use LLVM when building full AOT
assemblies if supported by local build mono runtime.
By default, scripts follow default build configurations used by mono BCL builds and
Visual Studio x64 Release build mono runtime.
Examples to run all JIT regression tests:
run-jit-regression.bat all
To run individual programs using JIT (doesn’t need to be a regression test):
run-jit.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
run-jit.bat basic.exe
Examples to build all regression tests using full AOT:
build-full-aot-regression-tests.bat all
Builds all regression tests in full AOT including all needed support and
BCL assemblies. All build assemblies will end up in msvc\build\fullaot\winaot
folder by default. It is possible to build individual assemblies as well using:
build-full-aot-regression-tests.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
build-full-aot-regression-tests.bat basic.exe
Examples to run all regression tests using full AOT:
run-full-aot-regression-tests.bat all
Runs all regression tests in full AOT. It is possible to run individual assemblies
as well using:
run-full-aot-regression-tests.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
run-full-aot-regression-tests.bat basic.exe
There are some more features included in the scripts as well, but above shows
basic usage. It could also be possible to reuse the scripts in Visual Studio
build targets going forward to at least run the JIT regression tests
as part of Visual Studio build.
* Fixed some review feedback.
* Switching to 1 instead of -1 in case of errors.
* Used case insensetiv compare for some if's.
* Dropped use of ECHO OFF/ON in nested scripts.
* Removed clear of PATH (was not intended).
* [mini] Implement delegate tramp info using gsharing context.
* [mini] Remove duplicate patch type.
* expand a FIXME to include what needs fixing.
* [mini] Copy MonoDelegate::method from the delegate tramp info instead of emiting a rgctx fetch. This is 6% faster on a delegate microbenchmark.
* Fix Process.ProcessName on AIX
AIX has a procfs with raw structures congruent with Solaris. For i,
which lacks procfs, fall back to a libc call.
This doesn't solve the Process weirdness that bungs up the test
suite, but I hope it's a start.
* Bye bye, annoying AIX setschedparam warning
AIX (but weirdly, not i) complains every time you do this. Squelch
the warning on AIX and avoid line noise.
* Remove more assumptions of /proc on AIX
* should probably always use getprocs64 for w32process,
but looks like we could just use proclib on the fallback?
* there's some more cases relating to resource usage stat,
will have to investigate those cases further
* Basic process modules support on AIX (but not i)
Not aware of a PASE compatible API, but this will work on AIX. Not
sure about .ModuleName versus .FileName, but it seems to fill it in...
The gensources.cs currently checked in to master doesn't fail on missing files by default because it didn't work at the time. This turns that behavior on. It is currently only in my other in-progress branch so I'm moving it here.
Fixes#9232
* Enable failing on missing files in gensources
* Copy over the missing file checks from genproj2
* Trim whitespace off file names from sources files
* Strip double slashes from paths to fix spurious csproj change
Previously we called it only if gdb was enabled, and we called it after
we invoked handlers asynchronously, in ways that could eat our session
state. By moving it higher up, we can increase the numbder environments in which
debugger crashes are logged, and log them even in the case when
telemetry dumping kills the runtime quickly.
* [runtime] MONO_API mono_assembly_get_object needs GC Unsafe
* [runtime] MONO_API mono_array_length needs GC Unsafe
* [runtime] Make MONO_API mono_reflection_load_from_full external only
Also mono_reflection_load_from ()
Also make them both transition to GC Unsafe
* [runtime] Make MONO_API mono_assembly_load_full external only
And make it transition to GC Unsafe
* [runtime] Make MONO_API mono_assembly_loaded external only
Runtime should use mono_assembly_loaded_full.
Make mono_assembly_load transition to GC Unsafe
* [runtime] MONO_API mono_assembly_open needs GC Unsafe
Also mono_assembly_open_full
* [runtime] MONO_API mono_check_corlib_version needs GC Unsafe
* [runtime] MONO_API mono_class_enum_basetype needs GC Unsafe
* [runtime] MONO_API mono_value_box needs GC Unsafe
* [runtime] Make mono_type_get_object external only
Runtime should use mono_type_get_object_checked or mono_type_get_object_handle
* [runtime] MONO_API mono_string_to_utf8 needs GC Unsafe
* [runtime] MONO_API mono_raise_exception needs GC Unsafe
* [runtime] Make mono_reflection_type_get_type external only
Also make it use GC Unsafe.
Runtime should use mono_reflection_type_get_handle
* [runtime] MONO_API mono_object_new needs GC Unsafe
* [runtime] MONO_API mono_domain_assembly_open needs GC Unsafe
* [runtime] MONO_API mono_method_get_object needs GC Unsafe
* [runtime] MONO_API mono_method_full_name needs GC Unsafe
* [runtime] MONO_API mono_method_signature needs GC Unsafe
* [runtime] MONO_API mono_thread_create needs GC Unsafe
* [runtime] MONO_API mono_field_get_type needs GC Unsafe
* [runtime] MONO_API mono_field_get_value needs GC Unsafe
* [runtime] MONO_API mono_field_set_value needs GC Unsafe
* [runtime] Mark mono_image_open_from_data_with_name external only
Runtime should use mono_image_open_from_data_internal
* [runtime] MONO_API mono_image_open_from_data_with_name needs GC Unsafe
* [runtime] MONO_API mono_field_static_set_value needs GC Unsafe
* [runtime] MONO_API mono_property_set_value needs GC Unsafe
* [runtime] Make MONO_API mono_assembly_load_with_partial_name external only
Runtime should use mono_assembly_load_with_partial_name_internal.
Make mono_assembly_load_with_partial_name transition to GC Unsafe
* [profiler] Log whenever the profiler library fails to load
* [test] Fixup return type of mono_gc_toggleref_add
* [sgen] Don't pin obj in test_toggleref_callback under coop
Don't call mono_field_get_value which under coop will perform a thread state transition to GC Unsafe and that may include copying the stack data which will pin the toggle object and subsequently make the toggleref test fail. Call mono_field_get_value_internal which assumes we're already in GC Unsafe mode.
Uses mono LLVM master branch, build using cmake and VisualStudio 2015/2017.
Commit adds support for AOT/Full AOT LLVM codegen for Windows x64 Visual Studio
build mono runtime. Normal configure/make using cygwin won’t support LLVM and will
trigger an error if configured.
In order to build using LLVM first mono LLVM master branch must be build using
static linked LLVM configuration (dynamic loading can be added later),
NOTE mono LLVM build needs to include the following commit,
https://github.com/mono/llvm/commit/9b92b4b87607e137266f84dc307181b8842fe54a
in order to successfully build on Windows x64.
Build mono LLVM branch using the following cmake configuration:
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ZLIB=OFF
-DLLVM_TARGETS_TO_BUILD="X86"
-DCMAKE_CROSSCOMPILING=False
-DCMAKE_SYSTEM_NAME=Windows
Use cmake with -G "Visual Studio 14 2015 Win64" to generate VS 2015 x64
targets. NOTE, if mono runtime is build using VS 2017, then LLVM should
be build using the same VS version using -G "Visual Studio 15 2017 Win64"
To enable LLVM build in mono.sln, set MONO_ENABLE_LLVM to “true” and make
sure MONO_LLVM_INSTALL_DIR_PREFIX points to the install directory used in
LLVM build above, default msvc/dist/llvm. Above LLVM properties can also
be set if build using msbuild.
A sample LLVM configure script has been included in msvc/llvm-cmake-config.bat.
* [typesafe coop] Go through generated token-pasted helpers
instead of casting function pointers. This should be safer and
not trigger quashed gcc warning and I had hoped it would
work with WebAssembly, but seemingly not.
Add MONO_TYPEOF_CAST to avoid repitition.
Here we have a structured log and a richer "model" of states.
This serves to be a 10-foot view of the debugger. The debugger
has a lot of layers of abstractions, and lots of intermingled
bookkeeping.
This debugger log serves to be a summary of the state of the debugger
as a whole, and our ringbuffer of recent events helps put the debugger
state into context.
It also allows us to easily identify, for instance when we resume
a new thread versus a suspended thread. We can see single-stepping
through the breakpoints added, removed, and hit. Lastly, we have a view
of how commands and events are totally ordered over the TCP socket,
helping the server to understand what the client has seen and in which
order.
Previously one had to include the proper types for this header in
the file including this header, before this header is included. Rather
than put irrelevant includes in other files, I'm adding includes here so
this file brings in its own dependencies.
* Make coop handles typesafe.
Type-safe handles are a struct with a pointer to pointer.
The only operations allowed on them are the functions/macros in handle.h, and assignment
from same handle type to same handle type (which cannot be prohibited in C, but is ok here anyway.)
Type-unsafe handles are a pointer to a struct with a pointer.
This is a leakier abstraction and besides the type-safe operations, also allows:
1. compared to NULL, instead of only MONO_HANDLE_IS_NULL
2. assigned from NULL, instead of only a handle
3. MONO_HANDLE_NEW (T) from anything, instead of only a T*
4. MONO_HANDLE_CAST from anything, instead of only another handle type
5. assigned from any void*, at least in C
6. Cast from any handle type to any handle type, without using MONO_HANDLE_CAST.
7. Cast from any handle type to any pointer type and vice versa, such as incorrect unboxing.
8. mono_object_class (handle), instead of mono_handle_class.
None of those operations were likely intended and some are crashing sort of bugs, esp.
the last two. See https://github.com/mono/mono/pull/9188 for the last two. The rest all occur also but are not necessarily harmful. Raw(NULL_HANDLE) and IsNull(NULL_HANDLE) were both access violations, so NULL just as well. MONO_HANDLE_CAST is still pretty liberal in what it allows.
NULL_HANDLE has been brought into question and this will allow grepping for it instead of the plainer NULL (i.e. returning them as handles).
The interaction of these handles with JITed code depends on the ABI to pass/return a struct
with a pointer the same as a pointer. Marshalling assumes this.
There might be some OS/CPU ABIs that do not support this.
CI suggests it is broadly but not 100% viable (disabled for non-Mac non-Windows x86, but enabled for arm, arm64, amd64, Mac/x86, Windows/x86).
* Typesafe handles enforcement brings with it a little more pointer enforcement, mostly around const and volatile. Repair a bit, and disable temporary for Windows.
* Fix MONO_HANDLE_IS_NULL (NULL_HANDLE) to not null dereference.
* Fix MONO_HANDLE_RAW(NULL_HANDLE) to not null dereference.
This depends on a gcc/clang extension, and a Visual C++ (C) quirk.
Otherwise we have to chose double evaluation, or C++, or assignment or cast from void* to temporary (possibly passing more types to more macros).
Another choice is a runtime assert, and double evaluation or not.
Asserts seen can be covered up by first checking MONO_HANDLE_IS_NULL, which will not null dereference nor assert.
Prior to making RAW(NULL) not null derefence, fixing code of the form:
```gboolean is_null_handle = handle && MONO_HANDLE_IS_NULL(handle)```
to be
```gboolean is_null_handle = MONO_HANDLE_IS_NULL(handle)```
while working on this change led to failures.
* Add gcc -Werror=incompatible-pointer-types to catch some handle type mismatches.
This has slight collateral damage on other code, mostly around const and volatile, mostly in Android-specific code. Disabled for Windows/gcc at first.
* Change mono_icall_handle_new_interior to return gpointer instead of MonoObjectHandle. It isn't returning a handle and making the non-handle typesafe is unnecessary/incorrect.
Likewise change mono_handle_new_interior to return gpointer instead of MonoRawHandle (same thing).
gpointer* is more correct, gpointer is more opaque; unclear which is preferred here.
gpointer makes this a smaller semantic change, as MonoRawHandle was already equivalent, just a rename.
* Move NULL_HANDLE, NULL_HANDLE_STRING, NULL_HANDLE_ARRAY so they are near the comment that refers to all of them.
* Remove mono_handle_new_full prototype, the function does not exist.
* Remove unnecessary casts.
* Remove unused MONO_HANDLE_INIT.
* Add an assert to handle_assign.
* A refinement of this change should enable WebAssembly and skirt underlying safety less. WebAssembly does not allow the function pointer casts used here.
Try to catch situations leading to a segv in mono_domain_assembly_search by
checking that we never put NULL into domain_assemblies and that callers of
mono_assembly_names_equal_flags never pass NULL args to it.
* [coop] Use coop mutex
ldstr_section can be taken during jit compilation.
* [runtime] Switch to non recursive mutex
ldstr_section only guards hashtable accesses.
* Import System.Security.Cryptography.Pkcs from CoreFX.
* Change 'as' operator to a cast.
* Add missing EnvelopedCms overloads.
* Include CMS signing classes in all builds.
* [csproj] Update project files
* Add missing DSACertificateExtensions class.
* Update references.
* Rename EnvelopedCms.Overloads.cs to EnvelopedCms.cs.
* Enable some of the System.Security.Cryptography.Pkcs xunit tests.
* Update references.
* Bump API snapshot submodule
* Disable xunit tests that may depend on Windows PAL.
Contributes to https://github.com/mono/mono/issues/7589
One unit test is removed as part of the commit because it is not consistent with documentation and CoreFX behaviour on non-Windows platforms (https://github.com/dotnet/corefx/issues/30416).
The main goal of this patch is to actually get meaningful error messages when constructing X509Certificate2 from a byte array. Previously PKCS#12/PFX certificate import could fail due to unimplemented features (such as ECDsa support) or bugs. The certificate import would then be retried as PKCS#7 and the original error message was lost.
* Fix some handle type violations.
* MONO_HANDLE_CAST (MonoArray, NULL_HANDLE)
is fragile and deprecated except in optimized hot paths,
prefer NEW instead. NULL_HANDLE is const and cannot be assigned to,
NEW is not const and can be assigned to. It takes extra validation
to insure NULL_HANDLE is correct, and it is usually not worthwhile.
Brings in https://github.com/mono/bockbuild/pull/67.
This fixes the msbuild build problem where it'd crash with `error MSB4242: The SDK resolver "NuGetSdkResolver" failed to run. Unexpected failure reading NuGet.Config. Path: '@/external/bockbuild/builds/msbuild-15/artifacts/toolset/restore.proj/$HOME/.config/NuGet/NuGet.Config'.`.
The reason is that bockbuild exported the `XDG_CONFIG_HOME` environment variable with the value `$HOME/.config`. The problem is that the `$HOME` in there is never expanded so it just stays as the literal value.
`XDG_CONFIG_HOME` is later used by e.g. `Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)` which is what nuget uses to construct the path to NuGet.config - hence why we end up with the weird path.
We now just expand the variables in bockbuild before we pass them on.
Fixes https://github.com/mono/mono/issues/9179
(cherry-picked from cb54c26f6c)
Threads which do things with signals and locks may end up unresponsive
to our signals. I cannot get threads that crash in a lock to respond to
SIGTERM on Darwin even if I explicitly unmask SIGTERM on those threads.
In order to defensively program against platform bugs around signals and
stubborn threads, we need to be able to abandon these threads and
continue, dumping other threads.
[tests] reduce IO load in process-stress-3
The spawned process by the test iterates through the whole mono repo,
including submodules. On a loaded machine with a already slow I/O
device, 10 seconds could be a tight time budget. Instead of increasing
the timeout, let's try to reduce the generated output.
Fixes https://github.com/mono/mono/issues/6947 hopefully.
Ubuntu Linux (possibly others too, but only Ubuntu is tested thus the
limitation) don't need to build or use `mxe`, they instead use mingw packaged
for the distribution, thus making the build faster.
This commit detects the Linux flavor in use and, if it's Ubuntu, configures the
build so that system mingw is used instead of mxe.
Followup for 9ad5255338
Note that on win32 we already did the right thing because of nested
conditionals in mono_image_open_a_lot, but on non-win32 we need the extra
check.
[mono/mini/helpers.c:195]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[mono/mini/helpers.c:197]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
* [mcs] Rename darwin paltform to macos
Darwin is common to both macOS and iOS/tvOS/watchOS, while we use the darwin platform only for macOS.
* [mcs] Add Unix platform for other Unixes than Linux
* [mcs] Remove PLATFORMS from xammac_net_4_5 since it only make sense on macos
* [bcl] Bump corlib version
* [csproj] Update project files
Android NDK supports cmake in addition to the older make-based ndk-build as the
build system and Xamarin.Android is in the process of switching the build of its
native bits to cmake. The reason for this switch is that certain parts of
Xamarin.Android (libmonodroid) are built for both the host system and
the Android target. The host system build currently uses hand-crafted code
directly in .csproj to build the native bits while the Android build uses
ndk-build. This results in duplication of code, compiler parameters are
specified in two locations - it is easy to introduce incompatibilities, bug
fixes may be applied only in one scenario etc.
Using cmake allows us to use a single build "script" for all the targets, thus
making the build more reliable. Android SDK has a cmake package which contains
full support for NDK builds and allows us to easily use cmake across all the
supported platforms without having to install cmake on the host system.
This commit adds the cmake package to the Android SDK provisiong process and,
alas, at the same time adds a workaround to properly unpack the package. Unlike
other Android SDK packages, cmake doesn't unpack to a single subdirectory of the
zip root, instead all its files and directories are placed directly in the zip
root. This requires yet another workaround to install the package properly.
[segfault] hard crash if it is not a NRE
that is, if a `ji` is available, but the offset is too large to be a
plausible implicit null pointer.
The "upper bound" must be higher, but I don't know a good value. Any good suggestions other than "increase the value until all tests are passing"?
* [mini] Change region formation pivot from BB to EH clause.
The original BB region computation would loop all BBs and search which EH clause each of them.
EH search is implemented as a linear search, meaning performance was count(BB) * count(clauses).
Since each clause generates at least one BB, it's quadratic on the number of clauses.
Degenerate methods, with tens of thousands of EH clauses, would lead to minutes of JIT time.
New code loops over the clauses and mark all BBs covered by each of them. Given EH ranges are a much
smaller subset of all BBs, this performs significantly better. It remains possible to construct methods
that leads to degenerate compilation times, but it's less likely now.
* [mini] Bound the size of a linked list during liveness.
The `visited` linked list can grown to tens of thousands of entries with some degenerate methods.
This change uses a stack allocated array and switches to a hashtable on overflow.
* [mini] Change printf to g_print
* [mini][amd64] Limit more precise branch target optimization based on number of basic blocks.
On amd64 we update branch target data before each BB is emitted. This has quadratic behavior on number of basic blocks
and can lead to excessive compilation times in degenerate cases.
Limit the increased precision to methods with less than 800 basic blocks.
Reduces compilation time of #7809 by 88% (from 44s to 5s).
When creating dynamic methods, we put those in a queue so they can be collected later via `mono_jit_free_method ()`. the interpreter part was assuming, as soon as we allocate a dynamic method, it will be executed eventually and therefore an InterpMethod must exist in `info.interp_code_hash`, but this isn't necessarily the case.
Fixes https://github.com/mono/mono/issues/9109
We can't raise event before that as the profiler depends on too much runtime
infrastructure at this point for it to reliably work.
For example, we need the threading infrastructure to be init'd so we can access the
thread-local profiler state to store events there.
issue detected by cppcheck
[mono/metadata/threads.c:3993] -> [mono/metadata/threads.c:3991]:
(warning) Either the condition 'if(location&&location->source_file)'
is redundant or there is possible null pointer dereference: location.
condition is redundant indeed, it is nested in "if (location) {"
* [jit] Add some rules to the local propagation pass to transform iconst+sext+mul into mul_imm.
* [jit] Make OP_LDLEN more general by storing the offset of the array length field in it.
* [jit] Add span intrinsics.
* [jit] Avoid converting Span.get_Length () to OP_LDLEN, it doesn't help abcrem. Avoid asserts when running on portable spans.
* [jit] Convert Span.get_Length () to OP_LDLEN, only mark the loading of array lengths invariant.
* [uwp] UWP supports: ReplaceFile CopyFile LockFile UnlockFile GetDriveType GetComputerNameW
Some of these were already supported and identical code copied.
* Remove pre-Windows 2000 support -- use GetFileSizeEx instead of GetFileSize.
UWP does not support GetFileSize.
* Introduce fine-grained ifdefs.
This should make maintenance of Win32 subsets easier (see w32subset.h).
* Generally the code should be/stay in "classic.c" and the "uwp.c" files can/should go away. The uwp.c files were a medium-sized granularlity of reuse/replace, but the fine-grained ifdefs are better/smaller -- more code reuse.
Which involves:
`serialize_object`
`deserialize_object`
`mono_object_xdomain_representation`
and then the other users of `mono_object_xdomain_representation`:
`create_unhandled_exception_eventargs`
`call_unhandled_exception_delegate`
* [runtime] Add an 'interp_method' field to MonoDelegate.
* [runtime] Add a MONO_LD_DELEGATE_PTR jit opcode which is used to load the method ptr from a delegate, so the JIT and interpreter could have a different implementation.
* [runtime] Store the interpreter method invoked by the delegate in MonoDelegate.interp_method, make MonoDelegate.method_ptr always point to a JIT callable entry point.
* [interp] Avoid sharing pinvoke and non-pinvoke signatures in mini_get_interp_in_wrapper ().
* [interp] Fix interp_get_remoting_invoke (), it receives a interp entry trampoline as well.
* [interp] Store remoting invokes into interp_method in delegates.
* [interp] Handle compilation failures in do_jit_icall (). Handle calls to delegates created in JITted code.
* [jit] Add a 'aot-skip=' MONO_DEBUG option to skip loading the Nth aot loadable method, useful for forcing mixed mode transitions during testing.
* [jit] Add tests for fullaot+interp mode
The tests work by injecting interp-jit transitions in varying locations controlled by the MONO_DEBUG=aot-skip= option.
* [interp] Avoid races when caching method pointers. Fix wasm support.
* Revert "[interp] Avoid races when caching method pointers. Fix wasm support."
This reverts commit 0f78c230b5102d625c300a4e1c6eaf97ad055dd5.
* [interp] stub native-to-managed on platforms where it is not working
* [ci] add fullaotmixed-regression step
Currently if we change for example `corlib.dll.sources` and then execute `make` - the `make` won't rebuild the lib, because it depends only on `net_4_x_corlib.dll.sources` and doesn't depend on all `#include` inside it.
As a temporarily solution we can depend on all *.sources files in the directory so a change in any of them will trigger rebuild. Unfortunately changes in un-related profiles will also trigger the rebuild but it's better than nothing for now I guess. For better experience we should fetch all #includes recursively for the current profile
The only reason for the restriction was that handle_alloc previously would not handle generic instances.
This speeded up the following microbenchmark by 19x (3.38s x 0.17s):
```
class Driver {
static T Identity<T> (T t) {
return t;
}
[MethodImpl(MethodImplOptions.NoInlining)]
static Func<T,T> MakeDelegate<T> () {
return new Func<T, T> (Identity);
}
static void Main () {
object o = new object ();
for (int i = 0; i < 400 * 1000; ++i) {
MakeDelegate<object>()(o);
}
}
}
```
* [Coop] Cleanup ahead of converting ves_icall_System_Threading_Thread_GetAbortExceptionState.
- serialize_object and deserialize_object are almost identical and
can be implemented on top of the same function.
- Error propagation was a little wierd and had FIXME comments.
It involved MonoError, MonoException, and gboolean *failed, and
some conversions. Converge on mostly MonoError, with fewer conversions,
albeit still sometimes holding a MonoException.
* Move error parameter to last.
Move static locals to global -- more easily seen in debugger.
Remove errant exclamation point.
* [jit] Make the interp_in wrappers work better with byref arguments.
* [runtime] Move some EH tests to exceptions.cs.
* [interp] Fix some problems in the interp entry/exit code in mixed mode.
* [jit] Avoid code patching from gshared code when the callee is an interp entry trampoline.
* [aot] Map byref return values to int&.
* [interp] Handle r4 return values in do_jit_call ().
This lets the linker catch any missing symbols, and fixes a problem
I had building AIX with CoreFX PAL. Fixes#8979, though there may
be more cases like this.
dotnet/corefx#30012 is blocking on this.
Since GitHub pages rolled out HTTPS support, links to `www.mono-project.com` can now be `https://` :) This also removes a `www.` 301 users currently hits.
In the case of the FSEvent FileSystemWatcher, the CFRunLoop event loop thread has already an interrupt handler installed in the icall, and mono_monitor_try_enter may try to install one as well which is not supported. So we create separate event tasks before we use the Operation() method.
We'd get the following warning during the build:
```
'/Users/alexander/dev/mono/mcs/class/System.Data.Services.Client/ONO_PATH' in MONO_PATH doesn't exist or has wrong permissions.
```
The reason is that we didn't escape the $ symbol in the resgen template
so the embedded $$MONO_PATH in the RESGEN variable ended up being mangled.
I'm kinda surprised this worked at all for so many years ¯\_(ツ)_/¯
* [loader] Make mono_assembly_names_equal_flags visible
Previously was static assembly_names_equal_flags in assembly.c
Add "mono" prefix to all the names
* [loader] Ignore version if assembly name isn't a strong name
When checking if a loaded assembly satisfies a request for a given assembly
name, don't compare versions if requested name doesn't include a public key
token.
Fixes https://github.com/mono/mono/issues/8820
* [loader] Add MONO_ANAME_EQ_IGNORE_CASE flag
In some circumstances we may need to compare one MonoAssemblyName to another
ignore case differences in simple names (ie "Asm1" vs "asm1" should be
considered equal)
* [tests] Regression test for simple name assembly preloading
Regression test for https://github.com/mono/mono/issues/8820
If one assembly references another that has a simple name (no public key), then
the requested version and the actual version don't need to match.
Also - the simple names are compared case-insensitively.
* [loader] When looking for already loaded assemblies, ignore case differences
When we're looking for a loaded assembly by simple name, ignore case differences.
* [debugger tests] use runtime flags for debugee
* [debugger] handle managed-to-native frames
fixes DebuggerTests.InspectThreadSuspenedOnWaitOne on the interpreter
* [interp] set SP in monoctx that is passed to exception handling
fixes DebuggerTests.ExceptionFilter on the interpreter
* [debugger] fix debugger_invoke frame in interp case
fixes DebuggerTests.BreakpointDuringInvoke on the interpreter
Currently the list elements are allocated in the root domain, while the data can be allocated in other domains. We need to clear the reference when removing the list element so we are not left with hidden cross domain refs.
Ideally we should have per domain lists, so we also would just let the list and elements die, without having to iterate through them at domain unload time.
* [mono-threads] Introduce mono_thread_info_get/set_tools_data so they can store data sanely.
The tools_data is a helper to bind tls data lifecycle to MonoThreadInfo.
This is needed to make it sane to deal with posix TLS destructors.
* [profiler] Switch tls storage to use mono_thread_info_get/set_tools_data. Fixes#7683
External threads are detached using TLS destructors and this leads to non-determinism around to cleanup ordering of keys.
This causes the profiler to see the profiler tls key null'd even though it was not detached yet.
* [profiler] Since we depend on thread_info to be attached before tls works, do so for the helper threads.
We can't just move the mono_thread_attach call earlier as it leads to all sorts of weird crashes (as it generates events and we won't be attached).
This is the second and final part to bring Client Certificate support.
It needs to be landed on top of #8753 and #8756.
* `Mono.Security.Interface.IMonoSslStream`: Add `CanRenegotiate` and `RenegotiateAsync()`.
* `Mono.Security.Interface.MonoTlsSettings`: Add `DisallowUnauthenticatedCertificateRequest`.
* `AppleTlsContext`: fully support renegotiation.
- we may now receive `SslStatus.PeerAuthCompleted` and `SslStatus.PeerClientCertRequested`
during `Read()`. It should in theory not happen during `Write()`, but I added it there
as well just to be on the safe side.
- `SetSessionOption()` may only be called before the initial handshake.
* `MobileAuthenticatedStream`: this is the major part of the work and the most complex one.
- added a new `Operation` enum to keep track of what is going on and detect invalid state.
- a renegotion may only be triggered while we're idle - that is no handshake, read or write
operation is currently active.
- `InternalWrite()` may now be called from `SSLRead()`, the new `Operation` tells us what
is currently happening.
- `ProcessHandshake()` now takes a `bool renegotiate` argument.
- added sanity checks to `ProcessRead()` and `ProcessWrite()`.
* `MobileTlsContext.SelectClientCertificate()`: check for
`MonoTlsSettings.DisallowUnauthenticatedCertificateRequest`
* `MonoTlsProviderFactory.InternalVersion`: bump the internal version number.
Tests have already been added to `web-tests/master`, they will auto-enable themselves when
using a Mono runtime that contains this code.
* Remove two methods with incorrect arguments
These two methods on `IPersonalizable` don't match the .NET 4.7.1 API.
In both cases the methods should take one `PersonalizableDictionary`
argument, but _that_ type does not exist.
Since nothing in the current class library code is using these methods,
just remove them.
* Bump API snapshot submodule
This is the first of two Pull Requests to implement Client Certificates :-)
Part One binds the new native APIs that will be used internally, finishes
the certificate selection callbacks, but without the more riskly changes
to the underlying handshake and I/O layer.
Part Two will bring support for TLS Renegotiation - and due to the required
changes in the underlying handshake, it is the more risky one.
* `Mono.Security.Interface.MonoTlsSettings`: Add `ClientCertificateIssuers`.
* `MobileTlsContext`:
- fully implement `SelectClientCertificate()`; the `acceptableIssuers` parameter
is now actually set and we also have a reasonable default selection.
- add `CanRenegotiate` and `RenegotiateAsync()` - these are not hooked up yet.
* `AppleTlsContext`:
- we will only ever call `RequirePeerTrust()` once per session, so we can
also remove it alltogether and just use `EvaluatePeerTrust()` instead.
- use proper exceptions for `SslStatus.PeerNoRenegotiation` and `PeerUnexpectedMsg`.
- don't call `SetClientSideAuthenticate()` on the client side.
- bind and hook up `SSLAddDistinguishedName()` and `SSLCopyDistinguishedNames()`.
- bind `SSLReHandshake()`.
* `MobileAuthenticatedStream`: minor cleanups; there will be more uses of the new
`GetInvalidNestedCallException()` helper class once Part Two lands.
* Enable some more constants in `SecureTransport.cs`.
* Add new `MonoBtlsError.GetErrorReason()` and `mono_btls_error_get_reason()`
implementation, only supporting `SSL_R_NO_RENEGOTIATION` at the moment.
* Add new native `mono_btls_ssl_ctx_set_client_ca_list()` function and managed
`MonoBtlsSslCtx.SetClientCertificateIssuers()`; hooked up via
`MonoTlsSettings.ClientCertificateIssuers`.
* According to a comment in the header file, `SSL_get_client_CA_list()` may only
be called during the selection callback or while the handshake is paused.
To respect this restriction, we now call it during the client certificate
selection callback and pass the list from native to managed.
- changed signature of `MonoBtlsSelectFunc` from
`int (* MonoBtlsSelectFunc) (void *instance)` to
`int (* MonoBtlsSelectFunc) (void *instance, int countIssuers, const int *sizes, void **issuerData)`.
- the managed counter-part is in `MonoBtlsSslCtx.NativeSelectFunc` / `NativeSelectCallback`.
* MonoBtlsContext:
- use the new `MonoBtlsError.GetErrorReason()` to throw a `TlsException` with
`AlertDescription.NoRenegotiation` that can be checked for by user code.
- `SelectCallback()` now has a `string[] acceptableIssuers` argument; pass it
to `SelectClientCertificate()`.
- the native backend does not support TLS Renegotiation, so `CanRenegotiate`
always returns false.
Implements #7075
Rather than reaching into the library internals and potentially
violating its invariants, assemble a cipher string and call the
supported public API. (There's no need to touch the version-specific
cipher lists because mono/btls never configures them.) The existing code
also had a bug; it incorrectly assumed OPENSSL_malloc returned a
zero-initialized buffer for in_group_flags. (Though Mono doesn't set
SSL_OP_CIPHER_SERVER_PREFERENCE, so I suspect this was a no-op.)
Additionally, this should hopefully ease updating to a less outdated
version of BoringSSL in the future.
Note I've changed the return value of this function from returning the
number of ciphers to merely returning 0/1 for whether the operation
succeeded. The only caller of this function, MonoBtlsSslCtx.SetCiphers,
only cares about success vs. failure.
* [jit] Move the handling of special methods like pinvoke etc. into mini-runtime.c, since they are not handled by the JIT.
* [jit] Add a --full-aot-interp command line argument which is the same as --full-aot with a fallback to the interpreter.
* [jit] Implement fallback to the interpreter in full-aot+interp mode.
* [jit] Add a 'methods using the interpreter' stat.
The old thunk machinery was sort of working on 64bit (before
f4bd084438 ), but it relies on having on
the memory layout of allocated chunks for code. Either the property got
lost due to some refactoring, or it was never true on ppc64. Anyway,
this patch switches the implementation to something we do on arm32 too:
If we potentially need some thunks for the emitted code, we reserve some
space for it at the end of the code buffer. That wastes a bit more
memory, because we often don't need it, but at least it works reliable.
Untested on 32bit systems.
The "problematic images" are Windows-specific assemblies that are often
included with applications that do not work on Mono, but for which Mono has its
own implementation.
Previously (9ec8ec5389) we changed mono to deny
loading problematic images using Assembly.Load or when one assembly references
another and we find a problematic image using the usual assembly search.
For Assembly.LoadFrom, we used to emit a warning and then load the assembly anyway.
In this commit, we change the behavior: If Assembly.LoadFrom tries to open a
problematic image, we will instead probe for an assembly of that name in the
default context. That should eventually end up opening Mono's version of that
assembly.
Example:
Suppose a problematic System.Runtime.InteropServices.RuntimeInformation.dll
is in the application bin path: /home/user/myapp/bin
1. User code does (for whatever reason)
Assembly.LoadFrom ("/home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll")
2. We find the image and try to open it; add it to the images absfpath to
image hash; note that there are no binding redirects; but that it is a
problematic image. We extract the assembly
name ("System.Runtime.InteropServices.RuntimeInformation", version x.y.z.w
and public key token 123456789a) from the problematic image.
3. We probe for "System.Runtime.InteropServices.RuntimeInformation version
x.y.z.w public key token 123456789a" in the default context.
4. We find
/home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll in
the application bin path; we try to open it, we see it's already in the
images hash, but it's a problematic image, and we're not in a loadfrom
context (we re-probed with default!) so we keep probing
5. We find
<prefix>/lib/mono/4.5/Facaded/System.Runtime.InteropServices.RuntimeInformation.dll,
it's not a problematic image, so we open that and return it to (3)
6. We return to (2) and close the problematic image and return the good one
instead.
7. Assembly.LoadFrom returns with the good image.
Fixes https://github.com/mono/mono/issues/8726
When we switched to the new version of Monitor.Enter, we didn't expand the try block to include the call. This led to unreleased locks when we acquired the lock but were aborted shortly afterwards.
This brings the internal `MailAddressParser` class and switches `MailAddress` and `MailAddressCollection` to the CoreFX version.
The tests have been updated to reflect the CoreFX behavior, which is more strict about rejecting invalid addresses.
When PropertyGrid contains more than one propertyTab it crashes whith NullReferenceException. And when clicking on propertyTab toolstripbutton it didn't switch to this tab.
* [jit] Unify the way the results of inlined calls are pushed on the stack.
* [jit] Allow class inits during inlining if the class has no cctor.
* [bcl] Mark EqualityComparer<T>.get_Default () with MethodImplOptions.AggressiveInlining, its used in inner loops in the corefx code.
* [jit] Implement devirtualization of some EqualityComparer<T>.Equals calls, the corefx code assumes this.
* [jit] Rename has_array_access to needs_decompose to better reflect its meaning.
To make sure that System.Reflection.Emit types in the class libraries
are properly removed by the linker, mark them with the "sre" feature in
the embedded linker descriptor file for mscorlib.
It contains this fragment:
```
<TargetFrameworkFallbackSearchPaths Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworkFallbackSearchPaths);/Library/Frameworks/Mono.framework/External/xbuild-frameworks</TargetFrameworkFallbackSearchPaths>
```
This PR introduces a new tool, gensources.cs, which replaces gensources.sh. It is able to parse the whole set of .sources files for a library in one go so that genproj can use that information to encode all our platform and profile specific files into one csproj file.
For now this PR just introduces it and switches libraries to using it instead of gensources.sh.
* Fix assert to print the error, and not sometimes itself crash. It was evaluating varargs twice.
* Fix all the warnings in the eglib tests. Leave them not building for now.
* [jit] Decompose some CEE_BOX opcodes later to allow more optimizations.
Optimize a code sequence emitted for Enum.HasFlag () by newer csc versions.
Also mark the temporary bblocks used by decompose_vtypes () as out-of-line if
the bblock under processing is out-of-line. Mark the domainvar as volatile to avoid
optimizing it away since references to it can now be generated later from the
decomposition of OP_BOX.
* [jit] Check that the enum types are the same.
* [jit] Fix support for generic enums.
* [jit] Disable the optimization with 64 bit enums on 32 bit platforms.
* Use size_t for gsize if it matches, else C99 uintptr_t.
Using size_t provides for an exact match with functions like malloc and pthread_attr_getstack, no warnings.
* GINT_TO_POINTER and co. need no autoconf, beyond chosing gsize, gssize.
* Use autoconf to find size_t among unsigned int, long, long long, __int64 for printf purposes.
Avoid 18+ year old C99 print("zu") dependency but still less likely to warn than the previous approach which only looked for matching size, not matching type.
* mini-ppc-os.h doesn't exist. If the OS lacks a define,
give an error instead of a broken include.
* Remove redundant Mac OS case.
* Move AIX define for sigaction above cross-compile case,
so it won't get lost in the noise there.
* [aot] Fix encoding/decoding of types with custom modifiers.
Fixes https://github.com/mono/mono/issues/8701.
* [aot] Add a test, disabling for now because it depends on c# 7.2.
* [aot] Bump AOT file format version.
* [aot] Only disable the test with mcs.
* [aot] Fix compilation of test.
* [sre] ParameterBuilder.SetConstant should work with Nullable<T>
Rewrite ParameterBuilder.SetConstant like CoreCLR
Same logic as TypeBuidler.SetConstantValue from coreclr at
src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
The details are different because we don't have CorElementType in corlib (so
use TypeCode), and we want to write to a var instead of directly invoking an icall.
Among other things, this enables ParameterBuilder to work with Nullable<T>.
If a parameter is of type Nullable<T> then pb.SetConstant (null) should work.
Also pb.SetConstant (value) should work when T is one of the supported
types (primitives, enum, datetime, etc).
Fixes https://github.com/mono/mono/issues/8597 and fixes https://github.com/mono/mono/issues/8504
* [test] ParameterBuilder.SetConstant with a nullable type
mkbundle works by generating a small C source file which, in addition to
embedded assemblies/configs/etc, contains a certain amount of code to initialize
the bundle, uncompress the assemblies and set runtime options (e.g. AOT mode).
This source code is generated based on a number of templates shipped as
resources inside `mkbundle.exe` and is not part of any public, maintained API.
The generated code contains calls to Mono runtime which work just fine when
mkbundle is used to generate a desktop application bundle with the default
template code. However, it breaks when a third party (like Xamarin.Android)
embeds Mono runtime and loads it dynamically **after** the application is
initialized. Such third parties must ensure that the bundle's startup code is
able to access the Mono runtime functions it needs by providing pointers to
them, loaded using e.g. the `dlsym` function.
However, as the Mono calls are hard-coded into the generated source code, the
third party needs to resort to search-and-replace methods (e.g. Xamarin.Android
https://github.com/xamarin/xamarin-android/blob/62e7792ca52949f2fa213330d292865ad78d2bfa/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs#L159-L166)
which are very fragile and prone to undetected breakage.
One example of such breakage which slipped under the radar is
https://github.com/xamarin/xamarin-android/issues/1651 which was caused by
addition of the `mono_jit_set_aot_mode` call to the generated code. The change
slipped under the radar and was discovered only after release.
This commit attempts to make the situation better by establishing a sort of a
code contract between "upstream" mkbundle and the third party. Since the
template code is not "public" (nor should it be), the third party cannot simply
include a header file with the API definitions. Instead, the idea here is to
ensure that all and any Mono runtime calls needed by the template code are
placed in a dispatch structure as pointers to functions and that the structure
needs to be initialized by the embedding party before calling the
`mono_mkbundle_init()` function. The third party is responsible for maintenance
of its own version of the dispatch structure as well as for its initialization
via the `initialize_mono_api` function in the template code. The generated code
must include the third party's version of the structure, in place of the default
one as shipped with `mkbundle`, and to make it possible this commit adds the
`--mono-api-struct-path` mkbundle parameter which points to a file that's
injected into the generated code, replacing the default structure definition.
Following that, the `mono_mkbundle_init()` code calls the `validate_api_struct`
function which checks each and every pointer in the structure for `null`,
exiting the application with error if any `null` pointer is encountered.
This (along with the `initialize_mono_api` function in the template) has the
additional effect that if the third party's structure is incompatible with the
default one a build error will happen, thus allowing early detection of obvious
incompatibilities/omissions.
As long as all the new Mono runtime calls are added to the structure, the above
should make it possible for issues like the one linked to above to not happen in
the future.
* `SslStream`: Reject attempts of setting conflicting callbacks using both the
Mono-specific `MonoTlsSettings` and the new `SslClientAuthenticationOptions` /
`SslServerAuthenticationOptions`.
This makes it consistent with CoreFx behavior where those callbacks may only be
specified in one of the possible places.
* `ChainValidationHelper` - this internal class has received a major overhaul and
lots of old and unused code removed.
All callbacks are not invoked with the correct `sender` parameter to make it
match the .NET / CoreFx behavior.
* `Mono.Security.Interface.CertificateValidationHelper`: remove unused internal code.
* Volatile static field accesses lack barriers.
This is a contributing factor to https://github.com/mono/mono/issues/8321.
finally_block_ending_in_dead_bb.exe does not poll the volatile field.
This is not the entire problem.
* [llvm] Notice the MONO_INST_VOLATILE flag on load/store, not just MONO_INST_FAULT.
This is related to https://github.com/mono/mono/issues/8321 finally_block_ending_in_dead_bb.exe
however emitting a barrier suffices to get LLVM to do the read.
* method_to_ir: Factor out operand decoding, including of constants.
* Cleanup unused file.
* Use MonoOpcodeEnum_Invalid instead of (MonoOpcodeEnum)-1.
* Move CHECK_STACK and CHECK_STACK_OVF mostly to central place, except variable
ones like call/ret/newobj.
* No _Static_assert on msvc.
* Remove some FIXMEs.
* Remove an inline.
* Less use of `tailcall_calli`, more use of `tailcall`, by assigning first to second.
And then eliminate `tailcall_testvalue`, as it just becomes `tailcall`.
* Merge the end, almost just the end, of CALLI with CALL/CALLVIRT.
Also merge the start, and with JMP, i.e. initializing shared variables.
This eliminates a bunch of shared code, without being too complicated (subjective)
and gives CALLI its missing sequence point.
goto here is disliked, maybe later a function.
* Change virtual_ from int to gboolean, assign it TRUE and FALSE instead of 0 and 1.
* Change guint32 call_opcode to MonoOpcodeEnum il_op.
* Replace *ip with il_op.
il_op is chosen over op, to disambiguate IL from IR.
And this is why C++ enums are not just ints:
enum Animal {dog, cat};
enum Color {red, blue};
Color color = dog; // valid C, invalid C++ (sometimes a warning in C)
Animal animal;
if (color == animal) ... // valid C, invalid C++ (sometimes a warning in C)
* add a FIXME
* Bring `SslClientAuthenticationOptions`, `SslServerAuthenticationOptions`
and `SslApplicationProtocol` from CoreFX.
* SslStream: Added new public overloads from CoreFX:
- All authentication methods have a new overload without the `SslProtocols` argument.
- New `AuthenticateAsClientAsync(SslClientAuthenticationOptions,CancellationToken)`.
- New `AuthenticateAsServerAsync(SslServerAuthenticationOptions,CancellationToken)`.
- We now use `SecurityProtocol.SystemDefaultSecurityProtocols` (which is zero) as
default value everywhere.
Everything below is internal:
* `Mono.Security.Interface`: Add internal `MonoServerCertificateSelectionCallback`,
`IMonoAuthenticationOptions`, `IMonoSslClientAuthenticationOptions` and
`IMonoSslServerAuthenticationOptions`.
* `Mono.Security.Interface.IMonoSslStream`: Add new overloads without the
`SslProtocols` argument.
* `Mono.Security.Interface.IMonoSslStream2`: New internal interface, extending
`IMonoSslStream` with the new internal APIs.
* `Mono.Net.Security`: New internal `MonoSslAuthenticationOptions`,
`MonoSslClientAuthenticationOptions` and `MonoSslServerAuthenticationOptions`
classes; these are just proxies for `SslClientAuthenticationOptions` and
`SslServerAuthenticationOptions` (which unfortunately don't share a common
base class).
* `Mono.Net.Security.MobileAuthenticatedStream`:
- Implement `IMonoSslStream2`.
- `ProcessAuthentication()` now takes `MonoSslAuthenticationOptions` instead
of the old argument list, added `CancellationToken`.
- All `IMonoSslStream` facing APIs now construct `MonoSslAuthenticationOptions`
to pass it to `ProcessAuthentication()`.
* `Mono.Net.Security`: `MobileTlsContext` and `MobileTlsStream` now use
`MonoSslAuthenticationOptions` to store all options.
Tests for the new APIs are in https://github.com/xamarin/web-tests/commit/fe347589326206f36d3cd42b59d305ff3c291857.
* Use MonoOpcodeEnum instead of int. Provide MonoOpcodeEnum_Invalid = -1.
* Fix and cleanup bounds checks.
Some were off by one, some could be clearer.
This pattern will go away anyway and is partly gone below.
* Prepare to fix incorrect read behind.
* Add test to hit assert in incorrect readbehind in ldvirtftn.
* Confuse the JIT (or runtime) into crashing.
* Fix parens.
* Move some macros from verify.c to verify-internals.h.
* Attempt to make IL readahead easier to understand, by having
less spread out instruction sizing and decoding.
This converts several readaheads but not all.
It is possible we should just convert to a large array of pointers,
and then do these optimizations.
This also fixes the incorrect readbehind.
* Disable new test. Fixing the readbehind fixes the assertion failure but still sigsegvs later in trampoline.
* More use of common code. More to do here.
Old gcc does not allow pragma diagnostic within function.
Fixes#8572
#if is a deliberate shorter form than #ifdef
- shorter
- allows for #define foo 0
- standardly undefined silently evaluates to 0
- potential for if instead of #if, though that does require #define foo 0, no
silent undefined => 0
* [jit] Fix a warning about disabling an unknown warning: trace.c:147:32: warning: unknown warning group '-Wframe-address', ignored [-Wunknown-warning-option]
* [jit] Fix a warning.
* [jit] Fix a warning.
Fix OSX x86 warnings.
In particular:
1) Be sure to pass a function all of its parameters, no more, no less.
You can't have a stack imbalance because parameters usually fit in registers,
and because calling conventions except for __stdcall are explicitly designed
to accomodate common programming mistakes, e.g. printf ("%d") and printf ("%d", 1, 2),
are well defined on all modern ABIs to never crash (except for the extreme
case of printf ("%d") where stack is near the top and it accesses invalid next page,
most unlikely).
2) size_t and gsize are not always the same type.
For example, one can be unsigned int and the other unsigned long (32bit).
Or unsigned long and unsigned long long (64bit).
3) gsize is not necessarily unsigned long, nor even the same size as it.
It could be any of:
unsigned int -- viable on all 32bit (Win32 and Unix32)
unsigned long -- viable on Win32 and all Unix (Unix32 and Unix64)
unsigned long long -- viable on Win64 and Unix64
unsigned __int64 -- viable on Win64, possibly same as unsigned long long
To printf a gsize in the "u" style (not the "x" nor "d" styled), G_GSIZE_FORMAT is provided.
(Fix for Win32 and Win64 forthcoming.)
We should strongly consider typedef size_t gsize but this a larger change.
4) Pop without push.
```
mono-publib.c:27:30: warning: incompatible function pointer types initializing 'gpointer (*)(gsize)' (aka 'void *(*)(unsigned int)') with an expression of type
'void *(*)(size_t)' (aka 'void *(*)(unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~
mono-publib.c:27:46: warning: incompatible function pointer types initializing 'gpointer (*)(gpointer, gsize)' (aka 'void *(*)(void *, unsigned int)') with an
expression of type 'void *(*)(void *, size_t)' (aka 'void *(*)(void *, unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~~
mono-publib.c:27:77: warning: incompsatible function pointer types initializing 'gpointer (*)(gsize, gsize)' (aka 'void *(*)(unsigned int, unsigned int)') with an
expression of type 'void *(*)(size_t, size_t)' (aka 'void *(*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~
mono-time.c:204:1: warning: unused label 'exit' [-Wunused-label]
exit:
^~~~~
mono-threads-posix.c:92:43: warning: incompatible pointer types passing 'gsize *const' (aka 'unsigned int *const') to parameter of type 'size_t *'
(aka 'unsigned long *') [-Wincompatible-pointer-types]
res = pthread_attr_getstacksize (&attr, stack_size);
^~~~~~~~~~
/usr/include/pthread.h:250:85: note: passing argument to parameter here
int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict);
^
profiler.c:1062:57: warning: incompatible pointer types passing 'void (MonoProfiler *, MonoProfilerGCEvent, uint32_t)' (aka 'void (struct _MonoProfiler *,
MonoProfilerGCEvent, unsigned int)') to parameter of type 'MonoProfilerGCEvent2Callback' (aka 'void (*)(struct _MonoProfiler *, MonoProfilerGCEvent,
unsigned int, int)') [-Wincompatible-pointer-types]
mono_profiler_set_gc_event_callback (current->handle, gc_event_cb);
^~~~~~~~~~~
../../mono/metadata/profiler-events.h:85:1: note: passing argument to parameter 'cb' here
MONO_PROFILER_EVENT_3(gc_event, GCEvent2, MonoProfilerGCEvent, event, uint32_t, generation, mono_bool, is_serial)
^
profiler.c:908:2: note: expanded from macro 'MONO_PROFILER_EVENT_3'
_MONO_PROFILER_EVENT(name, type)
^
profiler.c:897:103: note: expanded from macro '_MONO_PROFILER_EVENT'
mono_profiler_set_ ## name ## _callback (MonoProfilerHandle handle, MonoProfiler ## type ## Callback cb) \
^
marshal.c:4770:72: warning: format specifies type 'unsigned long' but the argument has type 'gsize' (aka 'unsigned int') [-Wformat]
mono_error_set_out_of_memory (error, "Could not allocate %lu bytes", size);
~~~ ^~~~
%u
trace.c:146:32: warning: unknown warning group '-Wframe-address', ignored [-Wunknown-warning-option]
^
trace.c:148:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
^
```
* Cleanup IL operation size checks -- data driven.
* Removed duplicate declaration.
* Prepare to cleanup IL IP advancement. Do a self-checking run first, which found incorrect sizing of switch, dyncall, icall.
* Cleanup -- looks like macro debris.
* Cleanup IL IP advancement -- mostly data driven.
Occasionally due to https://github.com/Microsoft/visualfsharp/issues/4637
Mono will assert if it tries to load a PPDB file that has an incorrect number
of MethodDebugInformation rows:
* Assertion at metadata.c:1117, condition `idx < t->rows' not met
Instead of asserting, check that the method index is in bounds, and print a more informative error.
* Fix mono_icall and mono_dyn_call operands in opcode.def.
This might require cpan install XML::Parser, or disable
the generation of opcode.def in Makefile.am.
* Fix sizing of switch instructions: 5 + 4 * n, not 4 + 4 * n.
* Hi Mono Team,
This commit fixes an interesting bug that relates to the System.Net.Http nuget packages.
So the short story is that System.Net.Http can view the internals of this assembly because of InternalsVisibleTo and the HttpClient references System.Net.Logging's "On" _property_. The problem is that mono has implemented "On" as a _field_ . When the latest version of System.Net.Http.HttpClient tries to invoke a SyncAsync using Mono, you get a MissingMethodException because:
bool System.Net.Logging.get_On()
does not exist.
This commit is simple and only changes the signature of On to match that of the reference source (property instead of field). This will cause the Missing Method Exception not to be thrown.
* Fix indentation
* [System]: The big WebConnectionStream cleanup.
`WebResponseStream` has been broken down into smaller pieces and now
fully supports GZip / Deflate decompression.
The entire `contentLength`, `readBuffer` and `totalRead` logic has been
replaced by a nested layer of `WebReadStream` classes.
* `WebReadStream` is a new abstract base class.
* `BufferedReadStream` handles the situation where we have some buffered
data and an (optional) inner stream to read from.
* `ContentDecodeStream` takes care of GZip / Deflate decompression.
* `FixedSizeReadStream` handles the `contentLength` logic - ie. making sure
we are only reading up to `contentLength` bytes from the stream.
* The old `MonoChunkStream` has been renamed into `MonoChunkParser` (as it was
really just a parser and not a stream) and a new `MonoChunkStream` has been
added that's based on `WebReadStream`.
* Remove HttpWebRequestTest.TestLargeDataReading().
This test was using Reflection to poke around implementation internals.
* [csproj] Update project files
* Cosmetic cleanups.
* [btls] Do not give gcc flags to msvc.
* [btls] #include "btls-foo.h" instead of #include <btls-foo.h> to work
with existing build system, on Windows, with out-of-tree build.
Not sure which factor does not like <> but "" should be ok.
* [blts] MONO_API is not used consistently and therefore errors on Windows.
1. Make it be nothing.
1b. Use a .def file if there are actual exports.
Really, .def files are a good idea.
or
2. Use it consistently.
This does #1.
* Fix, classify, enable some CoreCLR tests.
* [Tailcall] Add partial calli support, so a test passes.
* Disable r4/r8 mismatch for all architectures, and one due to interface on ARM.
* [runtime] Transition to GC Unsafe in MONO_API functions
The idea is that on any external->runtime transition we want to ensure that we
switch to GC Unsafe mode (and back on return). This allows Mono embedders to
be oblivous about hybrid suspend - the runtime will run native embedder code in
GC Safe mode (and use preemptive suspend when necessary) and when they switch
back to the runtime we will switch to GC Unsafe mode (and use cooperative suspend).
Since this needs to be backported, we're going to make this osx-specific
for now, and then I'll backport this. This is fully working on linux,
including the android SDK at the time of this commit
The debug log fnptr is used with MonoStringHandle arguments since
cc7406b226
The corresponding functions and prototypes in mini/ have already been updated.
The renderer would stop at the first XML comment `-->` which means
the diff was cut off.
We can fix this by switching from storing the diff in an HTML div to
a script tag instead.
Fixes https://github.com/mono/mono/issues/8469
* [Tailcall] Implement x86 OP_TAILCALL_REG (https://github.com/mono/mono/issues/8582)
This should enable calli, which isn't just for cee_calli but also internal purposes.
* [Tailcall] Split x86_align_for_patch out of emit_call.
* [Tailcall] Align x86 tailcall patches, using x86_align_for_patch.
* [Tailcall] Allow x86 tailcall to be AOTed.
* [Tailcall] Make all the 'missed tailcall' cases more similar looking.
* [Tailcall] Fill in a little more tailcall support.
* [arm] emit_big_add: Handle degenerate imm == 0 and dreg == sreg.
* [arm] Split emit_call_reg into emit_call_reg and emit_jmp_reg (for reuse by tailcall).
* [arm] handle hardfloat in tailcall
* [arm] Fill in TAILCALL_MEMBASE and TAILCALL_REG (reuse emit_jmp_reg)
virtual calls should work now (but not interface)
* [Tailcall] Comment about tail.calli -- no this-type in signature, to check for byref valuetype.
(data is available on compile-time staci, and a proposal to check for ldloca/ldarg pending)
* Add some asserts.
* More detangling of vtable_arg/imt_arg (extra_arg) from tailcall_supported -- they must be set, or nullness predicted, earlier.
* [Tailcall] Capture inputs to is_supported_tailcall and assert they don't change.
* [Tailcall] ARM32 tailcall not supported if mono_class_is_interface (cmethod->klass).
* [System]: Free ServicePoints when they're no longer used.
* Cleanup.
* Don't crash when ServicePoint.CloseConnectionGroup() is called after the ServicePoint has been freed.
* Remove the CloseConnectionGroupConcurrency() test.
This test was for a regression in a piece of code that no longer exist
and the test is poorly designed as it depends on precise timings.
It also attempts to make a web request to a non-exisiting server and
just ignores the error - it is unclear whether that is intentional or not.
In CoreFX, `ServicePointManager.SecurityProtocol` defaults to
`SecurityProtocolType.SystemDefault` (which is zero).
We now allow this value to mean "whatever the system default is"
in both AppleTls and BTLS.
The default value of `ServicePointManager.SecurityProtocol` has also
been changed to be consistent with CoreFX.
* [jit x86] Move microoptimization down a level: x86_mov_reg_reg do nothing
if source == desta and size == 4 (size is always 4, except in amd64 reuse,
which was only used once, unnecessarily, remove it).
[jit x86] x86_mov_reg_reg size is always 4,
split into unused. x86_mov_reg_reg_size and specialized x86_mov_reg_reg
* Remove last parameter from x86_mov_reg_reg that is always 4.
It is not guaranteed to work if the valuetype was allocated in the same stackframe.
This was initially leading to crashes because when storing in **this**, we were storing as a valuetype instead of the pointer (**this** valuetype is passed as pointer). Even if we fixed this issue, the other problem still exists.
* [interp] Fix stobj
When writing to a stackval, we write at least 4 bytes. Because we were wrongly casting destination to stackval*, we could be clearing other fields for 1/2 byte stores.
* [interp] Use memmove also with stackval_to_data
As we do with stackval_from_data to prevent unaligned faults.
* [sdks] Use cmake to build llvm.
* [sdks] Build all targets for llvm32 as well, since android might not build llvm64.
* [sdks] Build the llvm windows builds using cmake as well.
* Address review comments.
* Switch to the release60 branch of LLVM as an experiment.
* [sdks] Bump LLVM.
* Bump LLVM.
* [sdks] Fix the build.
* [llvm] Emit default debugging info for all llvm builders otherwise methods without debug info like iterators will fail to compile.
* Fix a crash if ctx->minfo is not set.
* [sdks] Add an LLVM_BRANCH variable.
* [llvm] Emit default debugging info for all llvm builders otherwise methods without debug info like iterators will fail to compile.
* Fix a crash if ctx->minfo is not set.
* [Tailcall] Add tailcall-return-valuetype.il test.
This can be fixed easily -- when F1 calls F2 tailcalls F3.
F2 can pass F3 the temporary it got from F1 instead of having another temporary.
* [Tailcall] Add a test for passing large valuetypes by value.
This has problems on some ABIs but not others -- arm64 and Windows/amd64 fail.
Presumably the temporary is either within the paramete area
or is a local. The first works, the second does not.
* [Tailcall ppc/s390x] Update ppc/s390x to be more like x86/amd64/arm/arm64
i.e. matching return storage, and s390x matching struct-ness/size.
* [Tailcall] Let valuetypes be returned through tailcalls.
Specifically there was already this handling them:
mono_emit_call_args:
{
if (tailcall) {
if (mini_type_is_vtype (sig_ret)) {
call->vret_var = cfg->vret_addr;
//g_assert_not_reached ();
}
so when F1 calls F2 and F2 tailcalls F3, F3 will return the value
where F1 was expecting it. There is no extra code needed after F3
returns to copy it from F2's temporary.
* CallInst.tailcall field is read before written in amd64, and is also wrong for llvmonly.
Replace CallInst.tailcall with MONO_IS_TAILCALL_OPCODE when accuracy is desirable and works.
Add FIXME when inaccurate CallInst.tailcall is presently required.
Tailcall field should probably be replaced by FALSE, except CEE_JMP needs attention first.
(see https://github.com/mono/mono/pull/8571)
* [Tailcall arm64 amd64 s390x] Do not allow tailcall when passing large valuetypes.
For s390x this is being conservative and might not be needed.
For ppc it is already done. Needed?
arm32/x86 seem to pass struct inline so it works, nice.
Small structs are sometimes passed in registers as well.
* Disable tailcall/coreclr/JIT/opt/ETW/TailCallCases.exe.
It passes a struct by value and fails.
Typo: is_adressable_valuetype_load => is_addressable_valuetype_load
Don't mark large multi-called function inline.
Remove lines that are all whitespace (leave whitespace at ends of lines, there is a lot).
One case of spaces to tabs.
* [System] When doing process redirect, use Console.OutputEncoding instead of Console.Out.Encoding. Fixes#8417.
This change makes mono behave in the same way as dotnet, which uses Console.OutputEncoding instead of whatever Console.Out is.
* [System] Add regression test for #8417.
https://jenkins.mono-project.com/job/test-mono-pull-request-coop/3429/testReport/junit/(root)/BuildSubmissionTest/EndBuildWaitsForSubmissionCompletion/
```
BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion
Failing for the past 1 build (Since Unstable#3429 )
Took 36 sec.
add description
Stacktrace
MESSAGE:
#5
Expected: less than or equal to 00:00:02.5000000
But was: 00:00:09.1408213
+++++++++++++++++++
STACK TRACE:
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in /mnt/jenkins/workspace/test-mono-pull-request-coop/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
```
* [x86] Add support for tracing native-to-managed thiscall wrappers.
* [x86] Add support for native-to-managed thiscall wrappers.
* Add test for managed thiscall methods.
interp: If one of the operands is NaN, we have a default result: It is false (0)
when doing a compare (`ceq_r8`), but must be true (1) on `cne_r8`.
JIT: match behaviour what C# compiler would generate for float/double.
If you load Foo.dll and it happens to be version 2.0.0.0 and an app.config says
to redirect all versions of Foo.dll to version 2.0.0.0, we're there already -
don't close the image and probe again, that's silly.
When running with cookieless sessions, the file_path does not necessarily contain a leading '/' character which can lead to a Uri being constructed from something that looks like, "http://hostmyPage.aspx" which immediately fails and throw an exception stating that the hostname could not be parsed.
This is not trivial to fix -- either a range check
in the backend as to if the parameter is in the frame, or
value tracking in the frontend to see if it came from the frame.
mcs/tools/xbuild/data/deniedAssembliesList.txt:
- sorted by name and assembly version
- This file had one duplicate line
System.Text.Encoding.CodePages.dll,FD178CD4-EF4F-44D5-9C3F-812B1E25126B,4,0,2,0
mono/metadata/image.c:
- sorted by hashcode
- This had one duplicate line
IGNORED_ASSEMBLY (0xFA686A38, SYS_TEXT_ENC_CODEPAGES, "FD178CD4-EF4F-44D5-9C3F-812B1E25126B", "4.3.0 net46"),
commit 0b3cb8ac12cd839f8110775d4085e822e8af4d7b (HEAD -> master, origin/master, origin/HEAD)
Author: Zoltan Varga <[email protected]>
Date: Tue May 1 14:52:22 2018 -0400
Emit an LSDA for methods without landing pads too since we need the information about the 'this' register.
to fix generic-stack-traces2.2 -- so it gets a generic type definition
instead of a generid type instance, consistent with other execution modes.
See https://github.com/mono/mono/issues/8356
Backtrace can deadlock with threads that have been suspended while holding a
dynamic linker lock on Linux.
In checked build mode we collect backtraces on state machine transitions.
When we transition from BLOCKING->RUNNING under hybrid suspend the thread must
not block without polling. So we must not collect a backtrace on this
transition.
* Make autogen.sh output accurate -- print actual commands run.
* Have automake copy instead of symlink.
- This sounds analogous to libtool --copy that we do.
- It enables sharing a source tree more broadly.
For real example, Cygwin symlinks are not portable to Windows Subsystem For Linux, and probably vice versa.
For real example, Homebrew symlinks are not portable to Linux in Docker.
Downside I notice is that ls -l is less informative as to what is from git vs. a symlink to outside.
git clean -xxddff works just as well either way.
Hypothetical downside is that updating automake/autoconf doesn't upgrade the copies.
This has never mattered to me, but it might matter. It might be viewed as an advantage.
* [interp] Don't throw exceptions if we are in the middle of EH
Fixes delegate2.exe failures
* [interp] Don't set parent for invoke frame
This leads to unwinding same frame twice (once when going through the parent frame and, after we have no more parent frames, again through the pushed LMF). We should unwind past invoke only through LMF structures.
Fixes https://github.com/mono/mono/issues/8372
* [Coop] Introduce mono_gchandle_new_weakref_from_handle.
* Convert some old code to `mono_gchandle_new_weakref_from_handle`.
* [Coop] Convert ves_icall_Mono_Interop_ComInteropProxy_AddProxy to coop.
* [Coop] Convert ves_icall_Mono_Interop_ComInteropProxy_FindProxy to coop.
* Remove whitespace from whitespace-only line.
* [Coop] Remove 140+ uncooperative pointers due to calls to mono_set_pending_exception ().
Instead typically use:
ERROR_DECL (error); // sometimes already present
mono_error_set_xxx (error, ...);
mono_error_set_exception_pending ();
* Improve error in not supported.
* Allow null in set_error_messagev.
* () and (void) are not the same in C, use (void)
When/if these functions are revisited for further coop conversion, the first and last line might be deleted but the second is likely to survive asis.
Context: https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
When making the bumps to use the `mono-sdks` upstream in Xamarin.Android,
we were getting build errors such as:
usage: mktemp [-d] [-q] [-t prefix] [-u] template ... (TaskId:404)
The build bot is running Mavericks (10.9), so it must be an issue with older
versions of macOS.
When reading the Unix StackExchange post, it appears that the `-t` option
without a template should work more reliably on older macOS versions.
Then I tested it locally via `make -C sdks/builds provision-android`.
The command:
mktemp -d unzip_android_archive_XXXXXXXX
Resulted in paths such as:
creating: unzip_android_archive_Nt1XzgS5/android-P/
And sure enough, looking into `sdks/builds` it had created a directory in
the working directory, so it isn't using a path inside of `$TMPDIR`.
Changing the command to:
mktemp -d -t unzip_android_archive_XXXXXXXX
Resulted in paths such as:
creating: /var/folders/nx/rzr6lcqj6j3_vp7vtp28v2cw0000gn/T/unzip_android_archive_W247QkyW/android-P/
The StackExchange post mentions `-t` is a "prefix" that gets expanded to
`$TMPDIR/{prefix}.XXXXXXXX`, so I think it is better to use this option as
long as it works on all platforms.
[Coop] Convert Microsoft.Win32.NativeMethod to coop.
These are all pretty trivial. There are no pointers or handles.
The only small wrinkle is internal calls -- split the function into w/ and w/o MonoError*.
CEE_LDFLD replaces at the top of the stack the object/valuetype one of its fields. MINT_LDFLD_VT loads a valuetype field from the object/valuetype at the top of the stack. When loading a field from a valuetype, at the end we also did a MINT_VTRESULT to pop the vtspace. If previously we were loading also a valuetype, then, when popping the original valuetype, we discard memory from the loaded field. With this change, we use 2 MINT_VTRESULT, one to pop the loaded field and second to copy it in place of the original valuetype.
* [threads] (windows,mach) If a thread self-suspended, initiator shouldn't wait
Under hybrid suspend if the suspend initiator raced with
done_blocking/abort_blocking, then the thread self-suspended and is already
waiting for the resume semaphor - there's nothing else for the suspend initiator
to do, so don't add victim to the pending operation set.
* [profiler] Do GC state transitions in profiler helper threads
After the calls to `profiler_thread_check_detach`, the GC doesn't skip
the profiler helper threads anymore (because of the call to
`mono_thread_info_set_flags (MONO_THREAD_INFO_FLAGS_NONE)`.
Under hybrid or full cooperative GC, the helper threads in GC Unsafe
mode should not block without periodically polling. Otherwise we get
into a deadlock on shutdown when finalizing the root domain: The profiler
threads have been told to detach and we run a GC in preparation for
running the finalizers. The GC STW ends up waiting for the dumper and
writer threads which never self-suspend.
* style - (void) vs. (), favor (void) in C; function names at start of line for grep ^foo
* [Coop] Convert ves_icall_System_Threading_Thread_Resume to coop.
Cleanup three instances of "Thread has not been started, or is dead.".
Move raising exception (on current thread) outside of locking of resuming thread.
Keep lock hold times shorter.
* [Coop] Convert ves_icall_System_Threading_Thread_Interrupt_internal.
Cleanup uses of ThreadStateException.
I added an option to allow storing a "thread dump" of the running program into a file in the specified directory. It is useful when you need to understand what is going on in your application and you cannot capture stdout or attach a debugger.
Replace bounds check assertions of mono_assembly_get_assemblyref (and
everything that it calls) by Bad Image MonoErrors.
Call from System.Reflection.Assembly.InternalGetReferencedAssemblies to cope
with malformed images
* [runtime] If a MonoError was set, display its message.
* [verifier] Cleanup the metadata verifier interface to use MonoError instead of the old GSList hack.
Runs of bumping `code` should be followed by calling set_code_cursor, every so often, or least when done.
Checks for enough room and realloc should be instead realloc_code.
Reads and esp. write of code_len, code_size, native_code should be relatively rare.
* [mini] Don't verify types if you store to a pointer byref. Workarounds #8403.
* [mini] Add regression test for punting a type system check.
* Fix variable names in test to match comments
The only place where the handler thread should block is in the
kqueue_notimeout() call; interrupting the thread should cause
that call to exit with EINTR, and allow the thread to exit.
* [Tailcall] Fix the patching of GOT sites under FullAOT.
This fixes bug https://github.com/mono/mono/issues/8273 where FullAOT generic-shared (valuetype?) runs hundreds of times slower than regular AOT due to hitting the trampoline for every call.
[Coop] Fork test 8273.il from 3.il and increase iteration count
so it takes a long time previously.
Also possibly fix a JIT path where gshared but not gsharedvt handled.
Tailcall:
Remove arm32 limit of 64 bytes of stack usage. Limit it to 4K instead (12bit immediate displacement).
Remove arm64 limit of 0 bytes of stack usage. Limit it to 1G instead (32bit limit).
i.e. copy arm64 stacked parameters
Limit x86 and amd64 stack usage to 1G (32bit limit).
Even as small as 100 is reasonable.
Add OP_TAILCALL_PARAMETER for more accurate earlier tailcall sizing,
including of unbounded parameter lists.
i.e. a certain number of bytes per parameter (including enregistered,
which makes it an overestimate)
Allow arm64 to return r4 -- caller and callee must agree, which means
caller's caller gets what it expects.
Add test coverage for large parameter list (256+).
Cleanup:
Introduce ins_get_size in place of ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
Use it in a few places. Replace PowerPC's ins_native_length with it.
Cleanup usage of EXTRA_CODE_SPACE vs. 16 -- EXTRA_CODE_SPACE everywhere.
This will get further cleaned up shortly.
Replace if (need to realloc code) with while (need to realloc code.
It is almost the same, but protects against degenerate very small code
where doubling is not enough (except for zero).
Use fsig we already have instead of another call to sig = mono_method_signature.
(for OP_TAILCALL and nearby existing code)
There are 4 different ways that an assembly can be loaded in .NET:
1. default context - `Assembly.Load(string)` does this.
2. reflection only context - `Assembly.ReflectionOnlyLoad` and `Assembly.ReflectionOnlyLoadFrom` do this.
2. load from context - `Assembly.LoadFrom(string)` does this. The interesting bit is that the assembly at the specified path is probed for its assembly name, and then binding redirects are applied to figure out if we need to load a different version of the assembly (from elsewhere in the search path, presumably).
3. "no context" (.NET Core's [AssemblyLoadContext](https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/assemblyloadcontext.md) design doc calls it "custom context", and internally they implement it as `IndividualAssemblyLoadContext`) - in Mono I'm going to call it the "individual context". This is what `Assembly.LoadFile(string)` and `Assembly.Load(byte[])` do: you get exactly the thing you asked for even if something with the same assembly name is already loaded and you get to have problems with type resolution.
So this PR adds:
1. `MonoAssemblyLoadContextKind` enum - default, refonly, loadfrom and individual.
2. Store the `MonoAssemblyLoadContext` in every `MonoAssembly` instead of a boolean `refonly` flag.
3. When loading references from assemblies, consider the load context of the requesting assembly.
4. Do the wacky `LoadFrom` probe and rebind dance.
5. Don't check for duplicated for the individual assembly context.
Not in this PR:
The managed assembly load context stuff in .NET Core. If we eventually want to add it, it will likely build on this work, but it's not here now.
Details:
* [loader] Replace 'refonly' by an assembly load context (NFC)
Replace MonoAssembly:ref_only field by a new context field of type MonoAssemblyContext (which right now just contains a single 'ref_only' boolean).
The .NET Framework documentation describes for contexts for assembly loading:
1. default context - Load(string) and referened assembly loading use this context.
2. LoadFrom context - LoadFrom(string) and references from LoadFrom assemblies.
3. reflection only context - ReflectionOnlyLoad and ReflectionOnlyLoadFrom use this.
4. individual assembly context[footnote:1] - Used by Load(byte[]) and LoadFile(string)
This commit only implements default context and reflection only context. As such, there should be no functional change.
[footnote:1]: Individual assembly context is called "no context" in the .NET
Framework docs, but "individual" is what the .NET Core assembly load context
implementation calls it.
https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/assemblyloadcontext.md
* [loader] propagate MonoAssemblyContextKind instead of refonly, loader_from_context flags
Instead of passing a pair of booleans around, pass a MonoAssemblyContextKind value.
In System.Reflection.Assembly.LoadFrom, pass MONO_ASMCTX_LOADFROM, instead of default.
In System.Reflection.Assembly.Load(byte[]), pass MONO_ASMCTX_INDIVIDUAL instead of default.
In SRE, create new assemblies with MONO_ASMCTX_INDIVIDUAL or refonly
Finally in mono_assembly_load_reference:
For a LOADFROM context always include the requesting assembly's basedir when probing for references.
For INDIVIDUAL context, don't probe for their references - they must be already loaded or else resolved by an AssemblyResolve event.
In a REFONLY context, only look at loaded assemblies or fire the
ReferenceOnlyAssemblyResolve event.
In a DEFAULT context, follow Mono's existing strategy: first probe without
including the basedir (and let the managed AssemblyResolve event fire), then
probe again with the basedir set (potentially firing the event again).
* [reflection] Implement System.Reflection.Assembly.LoadFile as a separate icall
The difference between LoadFrom and LoadFile is that LoadFile should not look in the loaded assembly's basedir when resolving references. (It is also not be subject to remapping).
Also, for LoadFile never return a previously loaded assembly even if one with the same name is already cached by a domain.
Fixes https://github.com/mono/mono/issues/8149
The changes to mono_assembly_load_from_predicate (in conjunction with using MONO_ASMCTX_INDIVIDUAL) for the LoadAssemblyRaw icall also fix https://bugzilla.xamarin.com/show_bug.cgi?id=11199 and https://bugzilla.xamarin.com/show_bug.cgi?id=33728
* [loader] Apply binding redirects to LoadFrom assemblies
Fixes https://github.com/mono/mono/issues/8152
* [loader] Include class failure cause in find_method_in_class TypeLoadException
* [loader] apply binding redirects to LoadFile() and Load(byte[])
Same as LoadFrom: If the identity of the assembly matches a binding redirection, drop the currently opened image and go probing by name instead.
* [loader] Print assembly load context in debug traces
* [loader] Split up mono_assembly_load_full_nosearch
There are two phases: first try the preload hook, second look in the gac, the given base directory, and in the default_path.
Split out the second phase into its own function.
* [loader] Apply remapping and binding when looking for INDIVIDUAL asmctx references
* [loader] Probe the GAC and assemblies path for INDIVIDUAL asmctx
Checked on .NET Framework 4.7.1
Despite the documentation insisting that `LoadFile` does not do any probing for referenced assemblies, it seems that actually, assemblies from the GAC (or at least the framework Facade assemblies such as `System.Runtime`) are nonetheless loaded if no context assembly depends on it.
This commit does the same thing for Mono (except we will additionally look in MONO_PATH).
This makes the xunit console runner work:
At startup they call LoadFile() on all the assemblies in the main executable's dir without doing anything to resolve the references. Those LoadFile assemblies then have broken references to things like System.Runtime that should be in the GAC but that haven't been loaded yet.
* [tests] Add tests for Assembly.Load(byte[]), LoadFile and LoadFrom
Test that loading two assemblies from two different paths (or byte arrays) with the same AssemblyName will produce different results if using Load(byte[]) or LoadFile() but will reuse the first assembly if using LoadFrom().
Regression tests for:
- https://bugzilla.xamarin.com/show_bug.cgi?id=11199
- https://bugzilla.xamarin.com/show_bug.cgi?id=33728
- https://github.com/mono/mono/issues/8149
* [tests] Check that binding redirects work for Assembly.Load(byte[]), LoadFile and LoadFrom
In old version of .NET it was only supposed to work for LoadFrom, but now it should work for all three.
Regression test for https://github.com/mono/mono/issues/8152
* [tests] Don't run Assembly.Load(byte[]) tests with AOT
* [aot] Make load_image return the aot module assembly for LoadFile
LoadFile allows loading more than one assembly with the same name. That means that just calling mono_assembly_load is unlikely to find the correct assembly (it'll just return the first one loaded). But we shouldn't hardcode the full assembly filepath into the AOT image, so it's not obvious that we can call mono_assembly_open_predicate.
Fortunately, an assembly opened with LoadFile is supposed to only refer to already-loaded assemblies (or to GAC & MONO_PATH) assemblies - so nothing new should be loading. And for the LoadFile'd assembly itself, we can check if the name and guid of the current AOT module matches the wanted name and guid and just return the AOT module's assembly.
* [mini] Fixup one MonoClass member access to use getter
* If check_call_signature fails and we break on it, run it again, i.e. so you can
step in a debugger.
* Change check_call_signature to returning a boolean, albeit in the same perhaps backwards way.
* [arm] Create trampoline for passing fixed arguments
It is the same as static rgctx trampoline, but it clobbers ARMREG_IP
* [arm] Create trampoline for native to interp transition
* [arm] Add interp entry from trampoline
Tweak CallContext methods to work in opposite direction
* [interp] Create wrapper that saves lmf for m2i transitions
If we want to unwind from interpreter directly into managed code we need to have a wrapper whose purpose is to save the lmf, so we can start unwinding frame by frame.
* [arm] Add unwind info for interp entry trampoline
We need to unwind through this trampoline since it sits between jitted code and the interp lmf wrapper.
* [interp] Let the unwinder unwind through trampolines
These frames are still ignored (by EH and stack walking), they are only used for unwiding further to the caller.
[Coop] Abort_internal and ResetAbortNative to coop/handle.
* [Coop] Add some comments.
* [Coop] Convert thread abort and interruption to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_ResetAbort to coop/handle.
* Make mono_set_pending_exception_handle static.
* [Coop] mono_join_uninterrupted: Avoid creating handles in loops.
If we have
`catch (Exception e) when (SomeMethod (e))`
.. then the exception object received in `SomeMethod` has an empty
trace. This is because in `handle_exception_first_pass` we populate the
trace in `MonoException` object only at the "end":
- filter returns TRUE
- exception caught
- unhandled exception
But if we have a filter then the trace at that point needs to be
accessible. And if the filter fails then as we unwind more frames, the
earlier frames (`trace_ips`) need to be retained to get the correct full
trace.
`dynamic_methods` needs to be handled similarly and in
`setup_stack_trace` we need to add to the existing `dynamic_methods` in
the MonoException object.
Fixes https://github.com/mono/mono/issues/7649 .
* [Tailcall] Print more. Clarify printing. Dial back a fix by one line
until a test demonstrates it is required.
Move debug_tail up for easier editing.
* [Tailcall arm64] Add tailcall_reg support.
* Fix new warning about maybe-used-uninitialized -- moving variables down is incompatible slightly with goto around them.
* [runtime] Handle failed classes in mono_type_get_checked (). Fixes https://github.com/mono/mono/issues/8311.
* [runtime] Use m_class_has_failure ().
* [runtime] Set the error if the class has a failure.
* [runtime] Add a signal handler for sigterm
* [runtime] Register sigtramp when merp handler enabled
* [runtime] Limit sigterm handler symbol definition to OSX
* [Tailcall] Use tailcall_reg to tailcall internal `calli` to improve F# FullAOT tests.
Rework printing a bit and add more.
Split mini_emit_calli into mini_emit_calli and mini_emit_calli_full.
mini_emit_calli_full takes an extra tailcall parameter.
This enables fixing some F# tests.
`check_sp` inhibits tailcall -- share logic and assert -- in order
to only call `is_supported_tailcall` once.
mono_emit_call_args is big and probably shouldn't be inlined; let compiler decide
anyway, which it always does.
Significant reworking of is_supported_tailcall.
Have it compute "regular" and "calli".
Replace is_interface with imt_arg which should be a more accurate
representation of the important part.
Capture complex conditionals `virtual_generic` and `virtual_generic_imt`
into local variables, so they can be evaluated a second time,
so that `is_supported_tailcall()` can be called just once with its
final inputs.
Move `tailcall` and `tailcall_calli` `tailcall` down
to initialization and make them const (with a temporary/internal non-const).
Note that tailcall still gets changed/reevaluated in multiple places,
and the new value is not returned. One such duplication is the form
of shared logic and an assert (check_sp), the other (calli + llvmonly) is not.
The correct value is needed, sometimes, for e.g. remove_ret.
There also remains a path that appears to change it to false but true in `ins`.
* [interp] fix warning
```
interp/interp.c: In function ‘ves_real_abort’:
interp/interp.c:251:17: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
printf ("\t[%ld] 0x%08x %0.5f\n", sp-stack, sp[-1].data.i, sp[-1].data.f);
~~^ ~~~~~~~~
%d
```
* [mini] ignore GCC warning in trace.c
```
trace.c: In function ‘mono_trace_enter_method’:
trace.c:145:3: warning: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Wframe-address]
printf (") ip: %p\n", MONO_RETURN_ADDRESS_N (1));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
* [tramp-x86] remove unused function
```
tramp-x86.c:171:1: warning: ‘get_vcall_slot_addr’ defined but not used [-Wunused-function]
get_vcall_slot_addr (guint8* code, mgreg_t *regs)
^~~~~~~~~~~~~~~~~~~
```
* [mini-x86] remove unused function
```
mini-x86.c:6327:1: warning: ‘emit_load_aotconst’ defined but not used [-Wunused-function]
emit_load_aotconst (guint8 *start, guint8 *code, MonoCompile *cfg, MonoJumpInfo **ji, int dreg, int tramp_type, gconstpointer target)
^~~~~~~~~~~~~~~~~~
```
* [tramp-x86] remove unused function
```
tramp-x86.c:146:1: warning: ‘get_vcall_slot’ defined but not used [-Wunused-function]
get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
^~~~~~~~~~~~~~
```
* [mini-x86] change previous_lmf to pointer type (same as amd64)
```
mini-runtime.c: In function ‘mono_push_lmf’:
mini-runtime.c:806:24: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ext->lmf.previous_lmf = *lmf_addr;
^
mini-runtime.c:808:24: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ext->lmf.previous_lmf = (gpointer)(((gssize)ext->lmf.previous_lmf) | 2);
^
mini-exceptions.c: In function ‘arch_unwind_frame’:
mini-exceptions.c:420:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
*lmf = (MonoLMF *)(((guint64)(*lmf)->previous_lmf) & ~3);
^
mini-exceptions.c: In function ‘unwinder_unwind_frame’:
mini-exceptions.c:715:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
*lmf = (MonoLMF *)(((guint64)(*lmf)->previous_lmf) & ~7);
^
```
* [monolmf/x86] make int cast dependend one machine word size
```
In file included from debugger-agent.c:36:0:
debugger-agent.c: In function ‘get_top_method_ji’:
debugger-agent.c:2501:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
g_assert (((guint64)lmf->previous_lmf) & 2);
^
../../mono/eglib/glib.h:710:46: note: in definition of macro ‘G_UNLIKELY’
#define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
^~~~
debugger-agent.c:2501:3: note: in expansion of macro ‘g_assert’
g_assert (((guint64)lmf->previous_lmf) & 2);
^~~~~~~~
```
* [interp] remove unnecessary code
* [mini] fix ptr with int cmp
this was wrongly changed.
```
mini-exceptions.c: In function ‘unwinder_unwind_frame’:
mini-exceptions.c:702:33: warning: comparison between pointer and integer
if (unwinder->last_frame_addr > (gsize)(*lmf)) {
^
```
This include breaks compiling the interpreter on platforms which don't have a
signal.h. The code in interp.c doesn't seem to need it to be included anyway.
* [wasm] Fix CI target.
* [wasm] Switch to do a local install of npm packages.
* [wasm] Switch to fine-grained execution steps to avoid VM bugs.
* [wasm] Disable System.Core under Chakra as the JS engine crashes.
* [Tailcall] Remove OP_JMP support. Require OP_TAILCALL.
This only hurts mips and sparc -- it breaks them.
Remove front end support for OP_JMP and conditionalality of OP_TAILCALL.
* And remove MONO_ARCH_HAVE_OP_TAILCALL and require mono_arch_tailcall_supported.
* And tailcall_remove_ret becomes temporarily irrelevant.
* [Tailcall] Keep mips and sparc working, albeit never tailcalling.
* Remove jmp opcode too.
for F# FullAOT.
Add some FIXMEs about alignbment and possible
improvements (fixed size rep mov to move tailcall parameters).
Grow static unknown sizes to 255.
* [sdks] Wrap configure to provide better output.
Wrap configure in a script that:
* Captures stdout/stderr and only shows it in case of errors.
* If configure fails, and a cache file was used, deletes the cache file and
tries again.
* If configure really fails, then print config.log in addition to
stdout/stderr, since a lot of valuable diagnostic output is in that file
(and it's annoying to track down configure failures on bots when the file
with the important output has already been deleted).
* Only show config.log when running on bots.
* [System.ServiceMode] Create unit test for #46917
* [System.ServiceModel.Discovery] Fix messages validation
The current validations are not correct and throws an exception calling
GetVideoSources API in an ONVIF media client. This API
is a combination of a first message with an input parameter and
a second message with the reply that is not void.
Removing this checks makes the client work correctly.
Fixes#46917
* [threads] Check that thread is in a valid suspend state before notifying the initiator.
* [threads] Suspend running threads cooperatively in coop or hybrid suspend
Reverts an inadvertant change from 282ee4bfd7
* [checked-build] Add a mutex in collect_backtrace
GNU libc backtrace() calls _Unwind_Backtrace in libgcc which internally may
take a lock.
That allows for a deadlock situation where two threads try to call collect_backtrace and
one of them takes the lock and is async suspended with the lock held, while the
other is supposed to cooperatively suspend but it is blocked waiting for the
backtrace mutex.
The suspend initiator ends up waiting indefinitely for the threads to suspend,
and the runtime hangs.
As a workaround we add a mutex around the call to backtrace() and only collect
a backtrace if we can immediately grab the lock without contention.
* [threads] Drop DoneBlockingNotifyAndWait & AbortBlockingNotifyAndWait
These two actions were causing a race in hybrid suspend.
Suppose thread T is in blocking and thread S (suspend initiator) wants it to
suspend:
S sets T to BLOCKING_SUSPEND_REQUESTED and sends a suspend signal and waits for
pending operations.
T continues running and comes to exit the GC Safe region.
T executes done_blocking and transitions to BLOCKING_SELF_SUSPENDED and returns
DoneBlockingNotifyAndWait.
T notifies S; T waits for a resume.
S wakes up, does whatever it needs to do and resumes T - T goes from
BLOCKING_SELF_SUSPENDED to RUNNING.
T wakes up and finishes the done blocking transition.
Suspend signal finally arrives in T. T attempts finish_async_transition from
RUNNING. Assertion. Crash.
What we do in this commit is change done blocking not to notify the initiator.
Instead done blocking immediately waits for a resume.
In that case T is waiting for a resume in BLOCKING_SELF_SUSPENDED, and S is
waiting for pending operations. So when T's suspend signal handler runs, it
will return FALSE (raced with self suspend), send a notification to the
suspend initator, and then immediately return. T then will continue waiting for
the resume. S will wake up, do what it needs to do and switch T to RUNNING and
post the resume to wake it.
class-inlines.h:13:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
mono_get_void_type ()
In C: () means accept any parameters -- K&R unprototyped
(void) is new-standardized-in-1989 form meaning accept no parameters
In C++ this is fixed and they mean the same thing -- accept no parameters.
To accept any parameters in C++, use (...), which is not valid in C, C requires
at least one fixed-type parameter when you use "...".
() is very rarely what you want in C, or in C++ headers consumable from C.
If you do need () for highly unusual code, for a function that accepts anything,
and has no fixed parameters, then use ifdef __cplusplus and ... for C++.
printf for example does not fit in this bucket because it always has the const char *format.
In fact, it is so rare because a variable-argument ("varargs") function would need *some* way to decide what is in "...".
* Teach sn.exe about PE32+, and while there ROM images and MS-DOS-less.
See https://github.com/mono/mono/issues/8218.
* Make Error static.
* Remove .Close () redundant with using.
* Use helper function ReadMore and System.Array.Resize.
* Fix typos in comment.
* Move hash.Hash to fix 'Hash must be finalized before the hash value is retrieved.'.
* Cleanup.
* Fix Automatic Proxy Configuration protocol for OSX 10.13
Reference comparison of kCFProxyTypeAutoConfigurationURL doesn't work in 10.13. Added fallback to do value/string comparison to get proxy type
* Change string comparison from C# string to CFString for possible memory safety and efficiency
* Code style changes
The previous code would produce
```diff
-public const string Version = "11.11.0";
+public const string Version = "11.9.1";
```
instead of
```diff
-public const string Version = "11.9.1";
+public const string Version = "11.11.0";
```
when diff are inlined. The addition and removal sections are fine.
* [wasm] Fix build scripts to work on linux.
* [wasm] Force emscripten version to 1.37.36 to fix OSX breakage.
* [wasm] Fix failure in new FloatF test.
* [wasm] Fix detection of test failure.
commit message said
> [w32file-unix] convert nano seconds to microseconds properly, by using
> TICKS_PER_MILLISECOND (which has L suffix in its definition)
first it talks about microseconds, but then uses constant for _milli_
seconds
* [runtime] Add public API to set the pending exception.
Xamarin.iOS and Xamarin.Mac need a public API to set the pending exception
when converting Objective-C exceptions to managed exceptions.
This adds a public API to support this scenario.
Partially fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60065.
* [runtime] Document that pending exceptions should not be overwritten when the runtime is handling a thread abort request.
* [threads] Have Hybrid Suspend not depend on Coop Suspend
* [threads] Enable CI
* [hybrid suspend] Wait for pending operations when suspending a blocking thread
In hybrid suspend we should wait for the pending suspend to finish when we're
suspending a blocking thread.
In full cooperative suspend, we treat blocking threads as already suspended, so
in that case there is nothing to wait for.
* [checked-build] don't use malloc for thread state history
Use a ring buffer, so we're signal safe.
* [checked-build] checked_build_thread_transition - async signal safe variant
Can't call backtrace on Linux from a signal handler.
Change mono_threads_transition_finish_async_suspend not to collect a
backtrace.
* [class] Rename MonoClass byval_arg field to _byval_arg
Update all use sites to use the getter method m_class_get_byval_arg instead
when possible.
* [runtime] add mono_get_*_type accessors for common MonoTypes
Just do void, object, int32 and int (aka IntPtr) for now
Refactor g_print on top of new g_printv. g_log / g_logv provided precedent.
The intent is like:
void foo_print (const char *format, ...)
{
if (debug_foo || MONO_IS_TRACED (foo, log)) {
va_list args;
va_args (format, args);
g_printv (format args)
}
}
so I can either set the environment variable, or edit the global,
besides removing the two parameters from every mono_trace call.
* [jit] Enable float32 by default.
* [arm64] Fix some 32 bit float compares so they handle unordered operands correctly.
* [runtime] Disable a coreclr test which fails with float32.
* [FileTest] regression for https://github.com/xamarin/xamarin-macios/issues/3929
* [w32file-unix] fix File.Copy timestamps
4a8d840d6f introduced that the destination
file of a copy operation has the same modification and access timestamps
as the source file.
With e0e185d70a this behaviour regresses,
since getting timestamps provides more precise information. Fixing this
by being more accurate when applying timestamps to destination file.
* [w32file-unix] convert nano seconds to microseconds properly, by using TICKS_PER_MILLISECOND (which has L suffix in its definition)
* [w32file-unix] introduce constant for ns->qs conversion with proper suffix
fixes problem on 32bit.
* [jit] Add a r8->r4 conversion in stind.r4 when the item on the stack is a r8 because of stack merging.
* [jit] Disable a SIMD test which can fail with -O=float32 due to precision problems.
* [jit] Use m_class_get_byval_arg ().
* [jit] Fix OP_RCONV_TO_I on amd64.
* [jit] Revert '[jit] Use r8 for r4 stack vars to avoid problems with stack merges when one side is an r4 and the other an r8. Add conversions for compares. (#8196)'. It causes r4-r4 merges to produce an r8 stack value, leading to invalid il errors.
* [Mono.Options] Allow CommandSet nesting, spaces in command names.
`git` (largely) only provides a single level of sub-commands, and
this is the use case that `Mono.Options.CommandSet` originally
supported.
However, this isn't the case for all command-line applications.
Take for example the Azure [`azure`][azure] command, which allows near
arbitrary command name depths:
[azure]: https://docs.microsoft.com/en-us/azure/virtual-machines/azure-cli-arm-commands
$ azure config mode arm
$ azure vm create
$ azure vm list
$ azure vm disk attach
Try to integrate "arbitrary" command nesting through two new
mechanisms:
1. `Command` names may now contain spaces, and
2. `CommandSet`s may be nested within `CommandSet`s.
`Command` names containing spaces allows for the same *style* of
"nested" sub-commands, but means that C# nesting isn't as deep:
var azure = new CommandSet ("azure") {
new Command ("config mode") {...},
new Command ("vm create") {...},
new Command ("vm list") {...},
new Command ("vm disk attach") {...},
};
When `CommandSet.Run()` is invoked, separate string indexes will be
"merged" while attempting to find a matching command-name, allowing
the "natural" command-line invocation to be used:
mono example.exe vm disk attach
# Invokes `vm disk attach` command
Alternatively, a `CommandSet` may be added to a `CommandSet`:
// C#
var azure = new CommandSet ("azure") {
new CommandSet ("vm") {
new Command ("create") {...},
new Command ("list") {...},
},
};
When this is done, `CommandSet.Suite` is required on the command-line:
mono example.exe vm list
If a "`Command` with spaces" has the same command-name as a nested
`CommandSet`, the `Command` "wins" and is invoked.
* [Mono.Options] Fix unsupported MCS compiler feature
* Bump API snapshot submodule
This brings the patch: https://github.com/dotnet/coreclr/pull/6898
Fail faster for `Wait(0)` when no counts available.
Don't allocate in the `Wait(0)` and `WaitAsync(0)` fail paths.
1M iters Server GC
method | pre (ms) | post (ms) | improvement
-------- |------- |------- |------ |
Wait(0) | 33,788.25 | 12.28 | x 2751.5
WaitAsync(0) | 360.79 | 24.38 | x 14.8
Memory allocations, saves 360MB over the 1M ops
* [jit] Use r8 for r4 stack vars to avoid problems with stack merges when one side is an r4 and the other an r8. Add conversions for compares.
* [jit] Use m_class_get_byval_arg in one place.
* Add a FIXME.
* [runtime] Get rid of the GLIB_LIBS autoconf define, it prevents automake from detecting the dependency on libeglib.la. Fixes#8175.
* [runtime] Link eglib against -lm to avoid duplication.
* [runtime] Remove a few extra -lm options.
* [runtime] More GLIB_LIBS fixes.
In interp we implement the leave statement by enqueuing finally ips (and the destination ip that we are leaving to) that we call as we exit finally blocks. When throwing an exception from a finally block we need to flush these ips, so we don't jump back into clauses that were already skipped by EH.
* [runtime] Make GetFrames consider nested exceptions
Fixes#7260
* [runtime] Add test from repro for #7260
* [runtime] FIx test using absolute line numbers
* [ci] Add {,hybrid,full}aot_llvm presets to make sure we compile with LLVM
* [configure] Rename runtime_preset to runtime-preset
* [bcl] Make sure we build the testing_aot_{hybrid,full} profiles when building all profiles
* [test-runner] Factor test-runner parameters for picking up and passing arguments to the runtime
* [hybridaot] Fix testing_aot_hybrid build
* [mini-llvm-aot] Fix common race condition in parallel builds due to common defaults.
When a connection fails, the socket error was being incorrectly reported
as an address family not supported error, instead of connection refused.
Why did this happen? The order of addresses returned from
`Dns.GetHostAddresses` changed. The newer code returns the IPv6 address
first, and the IPv4 address second. While `GetCheckedIPs` mentioned in a
comment that it skips addresses that don't match the address family, it
did not. The code using the addresses returned by `GetCheckedIPs` will
use the first address in the array. If this address happens to match the
address family of the socket, things will work "properly" (the correct
socket error will occur).
If, however the first entry has the wrong address family, then the
socket error will be an address family not supported error, since the
socket was created with different address family.
This change modifies `GetCheckedIPs` to filter the addresses, removing
those which do not match the address family.
[coop] Hybrid suspend
## Summary
This is a new suspend mode where threads that are running managed or native runtime code (what we call "GC Unsafe") are suspended cooperatively using safepoints, but threads running either embedder code or P/Invoke code or blocking syscalls (what we call "GC Safe") are suspended preemptively using signals.
The motivation is to make an embedder-friendly coop suspend mechanism where the runtime will do GC Safe -> GC Unsafe transitions on calls to `MONO_API` functions, but the embedders themselves don't have to have any special knowledge of coop safepoints or state transitions.
To try this out, set **both** `MONO_ENABLE_COOP` and `MONO_ENABLE_HYBRID_COOP` environment variables.
## Implementation
Here's a picture of the new state machine. There's two new states `Blocking_Suspend_Requested` and `Blocking_Async_Suspended` and one updated transition `req_s` (request suspension).

### State machine states and transitions
The hybrid cooperative suspend mechanism works like this:
- when a thread is executing in GC Unsafe mode, we use cooperative suspend and expect
the thread to periodically checkpoint its execution (as in the ordinary full
coop mode).
- when a thread is executing in GC Safe mode, we use a preemptive signal-based
suspend. This is new - previously in full coop we would allow `BLOCKING`
threads to continue executing and only suspend them when they wanted to go
from GC Safe to GC Unsafe (via the `BLOCKING_SELF_SUSPENDED` state).
There are two new states and one updated transition - the transition will
service both running and blocking threads: The idea is that suspend mechanism
is determined by the suspend initiator, and is not embodied in the the state
machine. The state machine just has to return distinctive enough values from
the transitions for the initiator to select a policy.
Resume mechanism is determined by the state that a thread finds itself in when
it is resumed, and the original suspend policy.
The primary differences between suspend mechanisms are: the preemptive
suspend is two phase - the `finish_async_suspension` does not
apply for cooperative suspend; the cooperative policy uses the `poll` transition when the thread is running.
We renamed `mono_threads_transition_request_async_suspension` to `mono_threads_transition_request_suspension`.
- It must be called by a suspend initiator on a victim thread that is not
itself.
- There can only be one suspend initiator for a victim at a time - if the
suspend initiator initiates a suspension it must follow through with the
whole protocol.
- If a victim is `RUNNING` we transition it to `ASYNC_SUSPEND_REQUSTED` and return
`ReqSuspendInitSuspendRunning` which signals that the caller must initiate
suspension for a running thread. (Same as the old `AsyncSuspendInitSuspend`).
- If a victim is `BLOCKING` we transition it to `BLOCKING_SUSPEND_REQUESTED`.
Note that this is different from the old `request_async_suspension` which just
incremented the suspend count and returned `AsyncSuspendBlocking`. Now we
return `ReqSuspendInitSuspendBlocking`. The return of
`ReqSuspendInitSuspendBlocking` means the initiator may signal the victim and
must wait to be notified of the suspension (in preemptive suspend it will be
notified by the signal handler, in cooperative when the blocking thread
attempts to exit from blocking mode).
- In `BLOCKING_SUSPEND_REQUESTED` we
may increment the suspend count. This is slightly too lax if we're going to
be using preemptive suspend on blocking threads: in that case we're in the
middle of a two-phase suspend and since there is only one suspend initiator,
we wouldn't expect another suspend to be initiated until we have a chance to
finish suspending. We leave it to the suspend initiator to rule out by returning
`ReqSuspendAlreadySuspendedBlocking` from this state.
- In all the not executing states (`SELF_SUSPENDED`, `ASYNC_SUSPENDED`,
`BLOCKING_SELF_SUSPENDED`, `BLOCKING_ASYNC_SUSPENDED`) we just
increment the suspend count.
- All other transitions are illegal.
- Note that `BLOCKING` must always have a suspend count of 0 and
`BLOCKING_SUSPEND_REQUESTED` must have suspend_count > 0.
We add two new states:
- `STATE_BLOCKING_SUSPEND_REQUESTED` - this is a new state that indicates that a
suspend initiator wants to suspend this victim thread.
- The thread is still executing in this state.
- We only transition into this state with
`mono_threads_transition_request_suspension`.
- The only legal transitions out from this state are:
- `resume` - decrements the `suspend_count`. If the `suspend_count` becomes 0 we
go back to `BLOCKING`, otherwise we stay in `BLOCKING_SUSPEND_REQUESTED`.
- `finish_async_suspension` (executed by the suspend signal handler to
finish the two phase preemptive suspend request and notify the suspend initiator),
- `done_blocking` and `abort_blocking`. It means that the a
suspend initiator requested a suspend but we got to done (or abort)
blocking before the signal was delivered. We return `NotifyAndWait` and the
caller is supposed to send a notification to the suspend initiator and
wait for a resume(with suspend count == 0) which will return to
`RUNNING` (the victim thread goes to `STATE_BLOCKING_SELF_SUSPENDED`).
- `STATE_BLOCKING_ASYNC_SUSPENDED`
- The thread is not executing in this state (it is waiting for a `resume`).
- a thread transitions into this state from `STATE_BLOCKING_SUSPEND_REQUESTED`
on a `finish_async_suspension` transition (see above).
- on a `resume` transition we decrement the suspend count. if it's still
positive we stay in this state. if it's 0 the thread transitions out of
this state. Unlike other resume transitions, in this case the thread goes
back to `BLOCKING` and resumes executing in GC Safe mode. The resume caller
must notify the resume initiator (ie this is a `ResumeInitAsyncResume`).
- on a `request_suspension` we stay in this state and just increment the
suspend count.
- all other transitions from this state are illegal.
We add two new return values for `abort_blocking` and `done_blocking`:
- `DoneBlockingNotifyAndWait` and `AbortBlockingNotifyAndWait`. Similar to
`SelfSuspendNotifyAndWait` - there was a race between the second phase of a
preemptive suspend and another operation (in that case a poll, in this case a
done or abort blocking) and the other operation won, so its caller should
notify the suspend initiator. Since the thread is now suspended, the caller
should wait for the resume signal.
We add new results for `request_initiate_suspension` `MonoRequestSuspendResult`
(formerly `MonoRequestAsyncSuspendResult`):
- `ReqSuspendAlreadySuspended` means the thread is not executing and we just
incremented its suspend count and there's nothing else for the suspend
initiator to do. (The old `AsyncSuspendAlreadySuspended`)
- `ReqSuspendAlreadySuspendedBlocking` means the thread is in
`BLOCKING_SUSPEND_REQUESTED` and we initiated another suspend request. This
should only happen with full cooperative suspend - with hybrid suspend we
will use a two phase preemptive suspend on a blocking thread and since only
a single suspend initiator is active, this state should not be visible to
another suspend initiator.
- `ReqSuspendInitSuspendRunning` - Thread is executing in GC Unsafe mode and the
caller should suspend it. This is the old `AsyncSuspendInitSuspend`. In
full preemptive suspend this is the only suspend initiation action and the caller
should begin the preemptive suspend procedure. In full coop we expect the
victim thread to reach a safepoint and poll to finish suspending.
- `ReqSuspendInitSuspendBlocking` - Thread is executing in GC Safe mode and
the caller should initiate a suspend. In full coop the caller has nothing
to do - a thread executing in blocking mode is assumed to be suspended. In
hybrid suspend, the caller has to initiate a preemptive suspend.
### Suspend initiator, signal handler, self suspender
Basically we call `mono_threads_transition_request_suspension` instead of `mono_threads_transition_request_async_suspension`.
Then if it says to suspend a running thread we call `begin_suspend_for_running_thread`, if it says initiate a suspension of a blocking thread, we call `begin_suspend_for_blocking_thread`, and if it says do nothing we do nothing.
**Questions**
1. We have an assumption in `safe_interrupt_thread` that we can return from a self interrupt if we're using coop suspend. I'm not sure if that makes sense for hybrid suspend, and not clear what to do about it.
2. In `mono_thread_info_safe_suspend_and_run` we expect that the callback won't return `KeepSuspended` if coop is enabled. I'm not sure what this means for hybrid.
3. A bunch of tests like `monitor-abort` and `appdomain-threadpool-unload` are failing if I enable hybrid suspend. Don't know why yet.
* fix ThreadPool.SetMinThreads fails if ThreadPool.GetMaxThreads was not called before #7988
* check mono_lazy_initialize in ves_icall_System_Threading_ThreadPool_SetMaxThreadsNative first
[console-unix] retry `tcsetattr` if it was interrupted by signal
if configuring the terminal failed, we still try to continue (see
a3ce2f008b ) and therefore succedings
`read`s can fail.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=26983
Change begin_cooperative_suspend and begin_preemptive_suspend to return one of
three results: suspend fail, suspend succeeded using cooperative suspend,
suspend succeeded using preemptive suspend.
This is used by check_async_suspend to decide whether to check the
MonoThreadInfo for the result of a suspend. (If a thread is suspended
cooperatively, it doesn't make sense to check).
Fixes sporadic failures in mono/tests/monitor-abort.exe
When the environment variable is set, Mono will use cooperative safepoint
suspend for threads running in GC Unsafe mode (running managed code or native
runtime code), and preemptive suspend for threads running in GC Safe
mode (running native embedder or P/Invoke code, or blocking system calls)
The environment variable is visible through
mono_threads_is_hybrid_suspension_enabled ().
This commit just adds the env var, it doesn't turn on hybrid coop suspend.
The hybrid cooperative suspend mechanism works like this:
- when a thread is executing in GC Unsafe mode, we use cooperative suspend and expect
the thread to periodically checkpoint its execution (as in the ordinary full
coop mode).
- when a thread is executing in GC Safe mode, we use a preemptive signal-based
suspend. This is new - previously in full coop we would allow BLOCKING
threads to continue executing and only suspend them when they wanted to go
from GC Safe to GC Unsafe (via the BLOCKING_SELF_SUSPENDED state).
There are two new states and one updated transition - the transition will
service both running and blocking threads: The idea is that suspend mechanism
is determined by the suspend initiator, and is not embodied in the the state
machine. The state machine just has to return distinctive enough values from
the transitions for the initiator to select a policy.
Resume mechanism is determined by the state that a thread finds itself in when
it is resumed, and the original suspend policy.
The primary differences between suspend mechanisms are: the preemptive
suspend is two phase - the finish_async_suspension transition only does not
apply for cooperative suspend; the cooperative policy uses the poll transition
when the thread is running.
We renamed mono_threads_transition_request_async_suspension to mono_threads_transition_request_suspension.
- It must be called by a suspend initiator on a victim thread that is not
itself.
- There can only be one suspend initiator for a victim at a time - if the
suspend initiator initiates a suspension it must follow through with the
whole protocol.
- If a victim is RUNNING we transition it to ASYNC_SUSPEND_REQUSTED and return
ReqSuspendInitSuspendRunning which signals that the caller must initiate
suspension for a running thread. (Same as the old AsyncSuspendInitSuspend).
- If a victim is BLOCKING we transition it to BLOCKING_SUSPEND_REQUESTED.
Note that this is different from the old request_async_suspension which just
incremented the suspend count and returned AsyncSuspendBlocking. Now we
return ReqSuspendInitSuspendBlocking. The return of
ReqSuspendInitSuspendBlocking means the initiator may signal the victim and
must wait to be notified of the suspension (in preemptive suspend it will be
notified by the signal handler, in cooperative when the blocking thread
attempts to exit from blocking mode).
- In BLOCKING_SUSPEND_REQUESTED we may increment the suspend count. This is
slightly too lax if we're going to be using preemptive suspend on blocking
threads: in that case we're in the middle of a two-phase suspend and since
there is only one suspend initiator, we wouldn't expect another suspend to
be initiated until we have a chance to finish suspending. We leave it to
the suspend initiator to rule out by returning
ReqSuspendAlreadySuspendedBlocking from this state.
- In all the not executing states (SELF_SUSPENDED, ASYNC_SUSPENDED,
BLOCKING_SELF_SUSPENDED, BLOCKING_ASYNC_SUSPENDED) we just increment the
suspend count.
- All other transitions are illegal.
- Note that BLOCKING must always have a suspend count of 0 and
BLOCKING_SUSPEND_REQUESTED must have suspend_count > 0.
We add two new states:
- STATE_BLOCKING_SUSPEND_REQUESTED - this is a new state that indicates that a
suspend initiator wants to suspend this victim thread.
- The thread is still executing in this state.
- We only transition into this state with
mono_threads_transition_request_suspension.
- The only legal transitions out from this state are:
- resume - decrements the suspend_count. If the suspend_count becomes 0 we
go back to BLOCKING, otherwise we stay in BLOCKING_SUSPEND_REQUESTED.
- finish_async_suspension (executed by the suspend signal handler to
finish the two phase preemptive suspend request and notify the suspend initiator),
- done_blocking and abort_blocking. It means that the a
suspend initiator requested a suspend but we got to done (or abort)
blocking before the signal was delivered. We return NotifyAndWait and the
caller is supposed to send a notification to the suspend initiator and
wait for a resume(with suspend count == 0) which will return to
RUNNING (the victim thread goes to STATE_BLOCKING_SELF_SUSPENDED).
- STATE_BLOCKING_ASYNC_SUSPENDED
- The thread is not executing in this state (it is waiting for a resume).
- a thread transitions into this state from STATE_BLOCKING_SUSPEND_REQUESTED
on a finish_async_suspension transition (see above).
- on a resume transition we decrement the suspend count. if it's still
positive we stay in this state. if it's 0 the thread transitions out of
this state. Unlike other resume transitions, in this case the thread goes
back to BLOCKING and resumes executing in GC Safe mode. The resume caller
must notify the resume initiator (ie this is a ResumeInitAsyncResume).
- on a request_suspension we stay in this state and just increment the
suspend count.
- all other transitions from this state are illegal.
We add two new return values for abort_blocking and done_blocking:
- DoneBlockingNotifyAndWait and AbortBlockingNotifyAndWait. Similar to
SelfSuspendNotifyAndWait - there was a race between the second phase of a
preemptive suspend and another operation (in that case a poll, in this case a
done or abort blocking) and the other operation won, so its caller should
notify the suspend initiator. Since the thread is now suspended, the caller
should wait for the resume signal.
We add new results for request_suspension MonoRequestSuspendResult
(formerly MonoRequestAsyncSuspendResult):
- ReqSuspendAlreadySuspended means the thread is not executing and we just
incremented its suspend count and there's nothing else for the suspend
initiator to do. (The old AsyncSuspendAlreadySuspended)
- ReqSuspendAlreadySuspendedBlocking means the thread is in
BLOCKING_SUSPEND_REQUESTED and we initiated another suspend request. This
should only happen with full cooperative suspend - with hybrid suspend we
will use a two phase preemptive suspend on a blocking thread and since only
a single suspend initiator is active, this state should not be visible to
another suspend initiator.
- ReqSuspendInitSuspendRunning - Thread is executing in GC Unsafe mode and the
caller should suspend it. This is the old AsyncSuspendInitSuspend. In
full preemptive suspend this is the only suspend initiation action and the caller
should begin the preemptive suspend procedure. In full coop we expect the
victim thread to reach a safepoint and poll to finish suspending.
- ReqSuspendInitSuspendBlocking - Thread is executing in GC Safe mode and
the caller should initiate a suspend. In full coop the caller has nothing
to do - a thread executing in blocking mode is assumed to be suspended. In
hybrid suspend, the caller has to initiate a preemptive suspend.
* [sdks] New SDK target: soft debugger + non-nunit exe
This adds support for building an arbitrary .exe (dtest-app is hardcoded
now, but changing that and setting the arguments is another line or two,
to bu customized to the app being bound)
When an environment variable is set, the runtime will wait for the
managed debugger. This enables the desktop to debug the deployed .exe.
This will be used for the Mono.Debugger.Soft tests, but is useful for
isolated reproductions with android bugs.
An unmanaged debugger versions of the managed debugger is coming in
another PR.
* [runtime] Provide argument to dtest-app when running remotely
* [runtime] Fix case of VMDisconnectionException when getting Process of remote host that has disconnected
* [runtime] Script monodroid desktop debugger agent
* [runtime] Use g_warning in debugger agent
* [sdks] Ship PDBs on android
* [sdks] Add Android target to run debugger tests
* [sdks] Add desktop profile target for debugger tests
* [sdks] Disable debugger tests on mobile that use unsupported apis
* [sdks] Add monodroid test profile to android sdks
* [runtime] Allow dtest-app to be built on non-debugger-client profiles
* [runtime] Allow dtest-app building on mobile profiles
* [bcl] Mark some some code with DISABLE_COM which depends on icalls which are disabled in the runtime when --enable-minimal=com is used.
* [bcl] Fix compilation of System.Runtime.InteropServices.WindowsRuntime.dll.
* .
When we tried switching mono-project.com to enforce HTTPS these tests
started failing on systems without working SSL configuration.
Use a different domain which is guaranteed to be available over HTTP instead.
Note that eventually, the length will depend on stack_usage
difference between caller and callee, though for arm64 it does not currently.
This should fix https://github.com/mono/mono/issues/8112.
* [jit] Add a MONO_ARCH_FLOAT32_SUPPORTED arch-specific define, use it to disable float32 on platforms which don't support it.
* [amd64] Fix r4fp support for the ATOMIC_LOAD/STORE_R4 opcodes.
* [jit] Disable a unused test method with invalid IL.
* [jit] Handle r4->u conversion correctly in float32 mode.
* [amd64] Fix some OP_R<cmp> opcodes.
If the runtime is configured using --enable-minimal=soft_debug, the debugger code will be compiled into a separate
libmono-dbg.a library which needs to be linked into the app. The debugger needs to be registered with the runtime by
calling mono_debugger_agent_init () before runtime initialization.
* [llvm] Add intrinsics support for some of the new MathF icalls when using llvm+float32.
* [jit] Use m_class_get_name ().
* [llvm] Fix the signature of the llvm instrinsic used by OP_ABSF.
* [llvm] Use llvm.fabs only on amd64, it doesn't seem to be supported on some platforms.
* [ci] Update csproj files during PRs
Similar to how API diff is done.
Replace EXTERNAL_DRAWING_FACADE in csproj in genproj
It'd embed the absolute path in the csproj, but we want the variable instead.
* [csproj] Update project files
Custom modifiers are an odd feature of .net which allow types to
be tagged. These tags are semantically relevant. A method with a
modifier should not override a method without a modifier, for
instance (github bug #6936).
We don't put enough information into the modifier to uniquely find the
Image associated with the token we have in the type. Modifiers from
different referring assemblies will have different tokens to refer to
the same modifier class, making it important to resolve the tokens to
MonoClass pointers at runtime. Pointer equality of these classes is the
way to determine two custom modifiers the same, or unique.
We cannot resolve the image just from the MonoType because it is
possible to put modifiers on primitive, builtin types. These builtin
types lack any filled-out pointers in the data block, meaning we have
zero metadata associated with our floating token.
Other places in the codebase fixed this by passing around MonoImages,
but adding a MonoImage argument to our type comparison function for
this single bug would be a very poor decision with much code churn all
throughout the runtime.
The bug above resolves to two I4 types, one of which has a modifier, one
of which does not.
In order to pass this MonoImage around, we need to put a reference to it
into something reachable from the MonoType. We can't put it in the
custom module type because that is exported. It is part of the public
API.
MonoTypes do not adhere to pointer equality, and custom modules are structs
baked directly into the MonoType. We need therefore to make MonoType
point to a MonoCustomModInternal, a new type. This type embeds the
public type as a struct and carries around the image as another element
in the struct.
All public interfaces still see the same metadata endpoints for parsing the
modules, including the icalls. It is only our type comparison code that
accesses our new field.
This fixes https://github.com/mono/mono/issues/8074.
I see this 100%. Why others do not? I usually skip aot so usually I don't see it. Linux Ubuntu 1604 and
1710 tested. mono-devel package is installed, which is probably not relevant.
git clean -xddf (or new git clone)
./configure --with-runtime_preset=fullaot likely also with others (hybridaot)
make
Many errors like:
MONO_PATH="./../../class/lib/build:$MONO_PATH" /s/mono/runtime/mono-wrapper ./../../class/lib/build/sn.exe
-q -R ../../class/lib/testing_aot_full/mscorlib.dll ./../../class/mono.snk Couldn't sign the assembly
../../class/lib/testing_aot_full/mscorlib.dll with this key pair. Public key of assembly did not match
signing public key. ../../build/library.make:342: recipe for target
'../../class/lib/testing_aot_full/mscorlib.dll' failed
If you run make V=1 you see the sn command.
You can see the installed sn works ok. Remove the -Q for quiet and you see a warning about missing
machine.config. Run with ptrace and you see it looking for 4.5/machine.config. Look in the tree and you
see 1.1 and 2.0. Copy the 2.0 to 4.5 and problem goes away. And can be edited down a bunch. Actual fix is
to move symlink of the file to outside a conditional.
Maybe people aren't using fullaot or git clean? Repro is 100% for me.
I was going to bisect, but it was occuring as far back as September 2017 so I did not.
.
* [sdks] Add support for building llvm unless the USE_PREBUILT_LLVM Make.config var is set.
* [sdks] Use prebuilt llvm binaries on ios CI.
* [sdks] Use the IGNORE_PACKAGE_LLVM variable to enable the building of llvm.
* [runtime] Handle interpreter-related frames in async stack walks.
* [profiler] Fix exception clause reporting.
This fixes three separate issues:
* Finally clauses in the non-exceptional case were not reported because we
implement these by simply calling them from managed code, as opposed to the
exceptional case where we call them from runtime C code.
* The catch portion of a try-filter-catch clause was being incorrectly reported
as a filter.
* Actual exception filters were not being reported at all.
Because we have to instrument JIT'd code to report non-exceptional finally
clauses, a new mono_profiler_enable_clauses () function has been introduced
which profiler API users must call in order to get exception clause events, in
a similar fashion to mono_profiler_enable_allocations (). Since this is a
breaking change, the profiler API version has been bumped.
Fixes#7525.
* [profiler] Remove the iomap_report event and associated code.
The IOMap profiler no longer exists, so we no longer need to expose this
somewhat hacky event.
* [profiler] Replace the old gc_event with gc_event2.
* [coop] Squash the thread state machine state numbering
In
https://github.com/mono/mono/commit/9767b8a55ec8be3fc46055d7a1e21b6894fd0fc5
we removed STATE_SELF_SUSPEND_REQUESTED
but left a hole in the state numbering, as a result, `state_name()` was off by
one (and falling off the end of the array).
* [coop] Renamed STATE_BLOCKING_AND_SUSPENDED -> STATE_BLOCKING_SELF_SUSPENDED
Noticed this while looking at Jenkins logs today:
```
15:00:56 /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/lib/net_4_x/mscorlib.dll
15:00:56 cant resolve internal call to "System.MathF::ModF(single,single*)" (tested without signature also)
```
We need to use `single` in the icall def instead of `float`.
It was introduced by https://github.com/mono/mono/pull/7941
Using `Task.Delay (timeout)` has the potential of possibly allocating and holding large
chunks of memory throughout the timeout period. While this is not strictly speaking a
memory leak because those objects will eventually be disposed and garbage collected, it
can cause memory usage of apps to grow quite significantly in the short run.
The default timeout values are as follows:
* `HttpWebRequest.ReadWriteTimeout`: 5 minutes.
* `HttpWebRequest.Timeout`: 100 seconds.
* `ServicePointManager.MaxServicePointIdleTime`: 100 seconds.
And these values can be increased by the user. This means that we're potentially holding
hundreds, maybe even thousands of timeout objects in memory for 5+ minutes.
This has now been fixed by using the `Task.Delay(int,CancellationToken)` constructor.
Note that disposing a `CancellationTokenSource` will not cancel it, so the following code
will still leak:
using (var cts = new CancellationTokenSource ()) {
Task.Delay (TimeSpan.FromDays (3), cts.Token);
// Work
}
To actually make the `Task.Delay` instance go away when we're done with it, we need to
use this pattern:
var cts = new CancellationTokenSource ();
try {
Task.Delay (TimeSpan.FromDays (3), cts.Token);
// Work
} finally {
cts.Cancel ();
cts.Dispose ();
}
We also cannot use `CancellationToken.CancelAfter()` for timeouts because unfortunately
some of the underlying framework code that we're using does not honor cancellation
requests - like for instance `NetworkStream`.
This is a partial fix for #7356. While this commit significantly improves the problem,
there may be other unrelated issues left that needs to be investigated.
Output formatting is now delegate to a `Formatter` subclass. The default
one remains HTML with `HtmlFormatter` so any script should not see any
difference.
The output file is largely identical, except a few whitespace changes
that could not easily be avoided and how modified base types were
reported, since that was different from the rest.
The big change is the `--md` option which can output markdown, which
is the format to use from docs.microsoft.com. There are less options
available, e.g. colors, so additions are rendered using the `csharp`
blocks, while modification are rendered as a `diff` block.
Each assembly output is made to be easy to re-assemble into a single
document if needed, e.g. https://github.com/xamarin/xamarin-macios/pull/3814
* [coop] Include function names in coop state change assertions
i.e. better reporting here:
https://jenkins.mono-project.com/job/test-mono-pull-request-coop/2298/parsed_console/log.html
***** MonoTests.System.Runtime.Remoting.RemotingServicesTest
***** MonoTests.System.Runtime.Remoting.RemotingServicesTest.Bug46473
Assertion failure in thread 0x7f21a504b740 due to: Cannot transition thread 0x7f21a504b740 from STATE_BLOCKING with DO_BLOCKING
Last 3 state transitions: (most recent first)
[DO_BLOCKING] RUNNING -> STATE_BLOCKING (0) 0 at:
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ef31a) [0x560336a6f31a]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2eb477) [0x560336a6b477]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ec7a2) [0x560336a6c7a2]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ec7e6) [0x560336a6c7e6]
This will provide one function instead of 0 or n, and could be expanded to include more.
This bloats shipping binary some (under condfigure only) which can be addressed with
an #if that conditionally turns the strings to null or empty. And slight code bloat.
Note that JIT and products and test use all this stuff and are left compatible and unchanged.
Previously:
foo(gpointer *stackdata)
{ ...
}
stackdata pointing to uninitialized, and not even size-specified
is now:
foo_internal(MonoStackData *stackdata)
{
...
}
foo(gpointer* stackpointer)
{
MonoStackData stackData = { &stackdata, __func__ }; // define MONO_STACKDATA
stackdata.stackpointer = stackpointer; // replacing &stackdata
foo_internal(&stackdata);
}
with __func__ being a known-inaccurate standin for the caller.
If products/JIT/test evolve, flags to indicate which fields are present are likely in order.
Currently only the top function is printed, but we can likely store them longer.
As well running the debugger will help.
backtrace library could also be expanded. Currently it finds symbols on Mac but not Linux.
* [Tailcall] Disable tailcall-virt.exe tailcall/fsharp.exe per-arch instead of !AMD64
so we can whittle away at it.
* [Tailcall, arm64, jit] Make mono_arm_emit_destroy_frame flexible
as to if ip0 or ip1 (or both) is temporary. This isn't strictly necessary as caller
can carefully chose the correct one, i.e. ip0.
* [Tailcall jit arm64] Add virtual tailcall support to ARM64 (OP_TAILCALL_MEMBASE).
It could be either "interleaved" with regular tailcall support as done here,
or split up into a separate case. The level of code sharing with interleaving
is not huge.
* [Tailcall] Spell out 'membase' as 'tailcall_membase' for clarity.
Remove extra "shadowed local" MonoCallInst *call and use
the other one. It achieves the same thing in this case
and helps debugging experience. Alternative would be
to rename the second one to "tailcall".
* [Tailcall] x86 tailcall_membase support (i.e. for virtual now, interface later)
* [Tailcall] Be sure not to tailcall interface calls on ARM.
* [Tailcall] More debugprinting.
* [Tailcall] arm64: allow floating point through (but only full registers)
arm, x86, amd64: require caller and callee return storage to match (arm64 already did)
Cleanup and debugprint.
* [Tailcall test] Always get hugeint (recursion depth) via function call,
so we can edit it one place.)
* [Tailcall] Add a FIXME for returning structs that can be made to work.
* [Tailcall test] Turn the F# test into three variations:
deeptail same as original -- failure mode is stack overflow
shallowtail which tailcalls but not to great depth -- it won't stack overflow
and so it should have no other failure, but make sure -- for example
this might still struggle on arm and we might split it up further
shallownotail which is really should be nothing special
In this commit, all three are the same -- copy w/o edit.
* [Tailcall test] Make shallow in two tests and remove tail in one.
* [Tailcall test] Disable deeptail TailCallLoopGenericClass<DateTime> for all architectures.
It fails on x86 and arm64. It passes on amd64. arm tbd.
* [Tailcall test] Enable F# tests for x86 and arm64 (three internally are disabled for all architectures, one of which passes for amd64).
* [Tailcall test] Every configuration should be able to run the shallow/notail F#/tailcall tests.
They don't depend on tailcall, but either correctness w/ or w/o tailcall,
and if they do fail, it is not due to stack overflow.
* [Tailcall test] Fix .assembly directive to make some tailcall tests AOT compatible.
* [Tailcall] Dial back debugprint bloat after merge.
it won't be scanned by the GC, defer string allocation to execution-time instead.
this fixes a GC crash when running mini regression suite on iOS/arm64.
OS: Ubuntu 18.03
CMake: 3.10
For some reason cmake fails to detect any make program (be it ninja or make)
when cross-compiling for Android in XA. It happens despite the programs being in
$PATH and working correctly. The effect is that CMAKE_MAKE_PROGRAM is set to
"not found" in CMakeCache.txt and configuration fails as follows:
Call Stack (most recent call first):
external/mono/external/boringssl/util/android-cmake/android.toolchain.cmake:1140 (CMAKE_FORCE_CXX_COMPILER)
external/mono/sdks/builds/android-armeabi-v7a-debug/mono/btls/build-shared/CMakeFiles/3.10.2/CMakeSystem.cmake:6 (include)
CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
This commit does not fix the issue, per se, but it works around it by finding
the first ninja/make (as configured) executable in $PATH and setting the
CMAKE_MAKE_PROGRAM to full path of the executable. I haven't spent too much time
investigating *why* cmake fails to find the executable (I merely ran it with
--trace-expand --debug-output which revealed nothing of consequence) but this
workaround should be safe for any version of CMake and any OS we use makefiles
on.
* [gc] Silently ignore mono_gchandle_free(0) so callers do not have to check.
* [threads] Take advantage of mono_gchandle_free(0) being nop (a few extra instructions
in dynamic path for when it is 0, same path length if it is not 0).
* [threads] Restore one if, it isn't clearly correct otherwise.
This pull request brings support to Mono's class libraries for the new `System.MathF` type which includes operations for single-floating point.
This is needed to run some new applications like:
https://github.com/aras-p/ToyPathTracer
With this change, it is possible to run this unmodified. With this support, and the `-O=float32` option, it is possible to improve the performance from 6.3Mrays/sec to 7.8Mrays/sec on a Mac.
Oddly, this seems to be faster than .NET Core 2.1.4, which is at 4.2Mrays/sec.
* Bump API snapshot submodule
* [wasm][corlib] Disable some tests that don't work with WASM.
* [wasm][corlib] Disable IO test that requires threading.
* [wasm] Disable parallelism when building the wasm runtimes. Fixes CI build.
* [wasm] The incremental test runner can now skip tests in bulk.
* [wasm] Address reviewer feedback.
Current build uses `tar` to extract ZIP archives. This works with BSD
tar but not with GNU tar, alas. Tar was used in order to strip the root
directory of Android archive while moving files into place. This commit
replaces `tar` with a call to a shell script (because doing what it does
using Make defines is an exercise in pain) which works both on macOS/BSD
and on Linux.
* [Tailcall] Dial back single -v output, and enable under MONO_DEBUG=tailcall, and -v -v.
* [Tailcall] MONO_LOG_LEVEL=debug MONO_LOG_MASK=tailcall and mono_trace instead of mono -v -v and g_print
This fixes `test_0_simple_double_casts` on iOS/arm64.
According to the C standard (section [conv.fpint]), the behaviour of
such a cast is undefined if the truncated value doesn't fit into the
destination type.
```c
unsigned char __attribute__ ((noinline)) convr8u1 (double i)
{
return (unsigned char) i;
}
```
for arm64, `clang -O0` produces:
```
_convr8u1:
100006848: ff 43 00 d1 sub sp, sp, #16
10000684c: e0 07 00 fd str d0, [sp, #8]
100006850: e0 07 40 fd ldr d0, [sp, #8]
100006854: 08 00 78 1e fcvtzs w8, d0
100006858: 00 1d 00 53 uxtb w0, w8
10000685c: ff 43 00 91 add sp, sp, #16
100006860: c0 03 5f d6 ret
```
while `clang -O2` produces:
```
_convr8u1:
100006ae8: 00 00 78 1e fcvtzs w0, d0
100006aec: c0 03 5f d6 ret
```
which is fine according the standard: Any value < 256 gets casted just
fine, but for example `convr8u1 ((double) 0xffff)` would end up with
`0xffff` in `w0`.
We workaround this behaviour by casting to a 32bit int first, the
resulting code looks like this then:
```
_convr8u1:
100006ae4: 08 00 78 1e fcvtzs w8, d0
100006ae8: 00 1d 00 12 and w0, w8, #0xff
100006aec: c0 03 5f d6 ret
```
* [Tailcall] Require an exact match on return type. Sometimes this makes sense (float<=>double), sometimes
it is a little overly restrictive (integer truncation, I <=> I[48])
* [Tailcall] Disable CoreCLR tests that have mismatched return types.
[mini] Introduce MonoEEFeatures with a single feature use_aot_trampolines.
MonoEEFeatures is meant to replace the mode flag soup with have.
Each feature is supposed to be checked alone and descriptive enough of the underlying behavior.
use_aot_trampolines is a good example because the inter_aot_llvmonly mode could set it to false and
skip all the trampoline engine nonsense as trampolines are C functions.
Contributes to #7885
* [wasm] Switch wasm interp to not set use_aot_trampolines.
This allows the regular "JIT" tramp path be used instead of hacking our way around the AOT runtime.
* [mini] Introduce MonoEEMode to let us enumerate non-aot execution modes.
This lets us have all code setting up mono_ee_features in a single place.
* [Coop] Opportunistically remove some raw pointers.
Replace some uses of mono_thread_interruption_checkpoint with
mono_thread_interruption_checkpoint_void or mono_thread_interruption_checkpoint_bool.
* [Coop] Remove some more raw pointers opportunistically -- mono_thread_execute_interruption to mono_thread_execute_interruption_void.
* Fix warnings from old bad merge.
* Add another static.
* [coop] Remove more raw pointers.
* [sdks] Add provisioning for Android SDK and NDK
This will also be used by XA
* Add missing backslash to mxe.mk
* Only grab bin/autopoint
* [sdks] Use provisioning for MXE
We want to treat MXE the same way we do Android SDK and NDK because it only rarely changes, and it's very long to build it.
* WCF: ChannelDispatcher/ListenerLoopManager.Setup validate InstanceProvider, not InstanceContextProvider
- the creation of endpoints requires an instance provider or a default constructor
- InstanceProvider vs InstanceContextProvider was obviously a typo
* include InstanceContextProvider for validation as before
- two unittests failed due InstanceProvider is null and ed.DispatchRuntime has not type set
- comment for the validation is not useful anyway (It is tested at Open(), but strangely it is not instantiated at this point.)
* [Facades] Add System.Memory facade to mobile profiles
Contains only the types we have right now.
Fixes https://github.com/mono/mono/issues/7610
* Bump API snapshot submodule
In 38a348c991 we got rid of
mono_threads_transition_reqest_self_suspension. So there is now no way to
enter into STATE_SELF_SUSPEND_REQUESTED, so we no longer need to have cases for
transitioning out of it.
It's done by ifdef'ing WASM because I don't see a way to change Environment.Platform / Environment.OSVersion without touching the public API.
Right now OSDescription is being used to return the execution environment. Once we properly support node and other non-web embeddings, it will be adjusted to do so.
* [runtime] Fix class visibility check for protected nested classes. Fixes#7657.
A nested class that has protected access must be checked using the same inheritance based rules as members.
The existing code ignores that and does a plain visibility check that is only amendable for public/internal nested types.
* [runtime] Add regression test for nested famility visibility.
* [runtime] Add a --disable-btl-lib configure option to disable the building of the btls lib, but compile the managed code with btls support.
* Disable building btls/ and support/ on the bcl build, they are not needed.
* [Tailcall] Copy some tests from CoreCLR.
* [Tailcall] Copy and build some tests from CoreCLR.
* [Tailcall] Add mono --test-tailcall-require switch
that asserts that every tail. is honored.
Add some tailcall output under -v.
* [Tailcall] Switch tests/coreclr/tailcall to tests/tailcall/coreclr
on the theory that this is where additioanl tailcall tests will go,
not that is the coreclr test area.
Also remove leading "./" which did afford easier search/replace
but will likely be seen as noise, and might break out of tree builds.
* [Tailcall] update readme
* [Tailcall] Tweak logging and first working Makefile, w/o disabled tests.
Next step is try to restore parallelism.
* [Tailcall] Add indent and fix check-tailcall to be parallel and incremental.
* [Tailcall] Out of tree builds just need mkdir.
* [Tailcall] Remove accidental content.
* [Tailcall] Undo fix for out of tree builds.
* [Tailcall] Use environment variable MONO_DEBUG in place of command line parameter despite
environment variables having problems and being banned in other contexts.
Accept and ignore empty MONO_DEBUG option so that ",foo" can be appended without
first checking for empty -- without having to learn how in another language.
Use g_print instead of printf in new code, i.e. for Android debugger.
Remove newlines to restore unreadability/unmergability.
Make running tailcall tests not incremental by default but leave I= to make it incremental.
Add comments indicating "tailcalllog" is a public interface, not to be changed
without changing its users.
* [Tailcall] Resolve a recent "FIXME".
* [Tailcall] Compile but do not run the C# tests.
* [Tailcall] Split disabled compile from disabled run, and compile the last of the tests.
Disable compile remains, because one of the tests contains 3 files, and putting
the three sources in the sources variable (for distribution) implies building them each separately.
Disable compile is used to remove two of them from compiling independently
and then another dependency rule makes them compile together.
* [Tailcall] Follow convention without incrementality and less verification.
* [Tailcall] Disable new failing tests on x86/arm/arm64 and Linux/amd64.
* [Tailcall] Disable more tests for x86 and sort the lists.
* [Tailcall] Move from .NET Standard to mscorlib see if that works better.
* [Tailcall] Add missing build dependency.
* [Tailcall] Do not compile tailcall/coreclr/JIT/opt/Tailcall/TailcallVerifyWithPrefix.exe for
FullAOT. Compiling it fails an assert where it is supposed to raise an exception. Fix later.
* [Tailcall] For now, do not run any CoreCLR tailcall tests with FullAOT.
--compile-all fails an assert there. Instead we have to find what can run, and don't use --compile-all.
* [Tailcall] Disable all CoreCLR tests under FullAOT. Some fail to tailcall.
Many work, w/o assertion failure and printing success, but none exit with 0 exit code.
* [Tailcall] Add clarifying comment.
* [Tailcall] Add two opportunistic tail. prefixes.
add some OpenBSD patches
Hi,
A few trivial additions of OpenBSD to ifdefs, plus the change of the abort signal to SIGUSR1 which fixes the SIGABRT problem (other compilation problems remain). SIGTTIN is broadcast to the process group which leads to the SIGABRT (at least on OpenBSD).
The original design review is here: dotnet/corefx#22866 . To summarize, this adds a new flag to `BindingFlags` called `DoNotWrapExceptions`. When this flag is used to invoke a method using reflection, any exceptions thrown are not wrapped with a `TargetInvocationException`.
It has already been implemented in some other version of .NET:
- dotnet/corert#4437
- dotnet/coreclr#13767
I would be delighted if this handy feature was also available in Mono.
I have in part based my changes on the CoreCLR implementation. There all already tests for this feature in corefx, so I have added those to the corlib_xtest.dll.sources file.
I have a couple of concerns about my implementation:
- I notice that `DynamicMethod.Invoke` was ignoring the BindingFlags and other arguments. I changed this method to pass along all the arguments. For what it's worth, it appears that [CoreCLR respects](https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs#L488) these arguments.
* [sdks] Pass LLVM_SRC from XA to use `xamarin-android/external/llvm`
We do not clone to `$(LLVM_SRC)` because this is up to XA.
* [sdks] Pass IGNORE_PACKAGE_MXE from XA
This is to avoid rebuilding MXE while XA already took care of it.
* [sdks] Only checkout specific MXE and LLVM commit when cloning
It is enough to check for iconv
dependencies once in the eglib/configure
- just use the generated libtool
library file to automatically
add additional dependencies (if any).
While here, make sue libeglib.a
has libraries returned by LTLIBTOOL
as a libtool dependency.
* [genproj] Move obj to common folder and remove unnecessary properties
We now default to mcs/class/obj instead of writing to the assembly folder.
* [genproj] Fix jay path on Unix
* [genproj] Fix IntermediateOutputPath for Facades
* Add some PerformanceCounter test code from reference source and MSDN,
combined and lightly edited per local conventions.
* Restructure PerformanceCounter code for type safety and fix incorrect typing.
* [monograph] Don't link duplicate copies of metadata and utils
Monograph builds against mono/mini/($LIBMONO_LA) (aka libmonosgen-2.0.la), so
the only pieces it would pick up from staticlly linking the extra libs are
non-API functions (such as the MonoClass getters), but at the cost of linking
errors due to duplicate symbols.
Also replace calls to MonoClass getters by mono API functions.
* [ilgen] Fixup MonoClass getter usage
Followup for e610e443cd
* [boehm] Fix a few direct MonoClass accesses
* [monograph] Statically link against the mono runtime
Dynamically linking but using some symbols (such as mono_read32) on some
platforms that are hidden in the library means that we had to statically link
against the runtime anyway, which then caused build issues.
* [monograph] Fix runtime crash on startup
```
mono_os_mutex_lock: pthread_mutex_lock failed with "Invalid argument" (22)
```
* [msvc] Fix monograph build
* [runtime] Rework how the native-to-managed eh callback is called.
Instead of catching all exceptions in the native-to-managed wrapper and calling the callback from the catch clause, call it directly from the EH code. The
previous approach caught all exceptions, which messed up debugging, since the debugger wouldn't break on uncaught exceptions raised from native-to-managed
callbacks.
* [coop] Enable tests bug-58782-plain-throw and bug-58782-capture-and-throw for PRs
* [mini] Installed native-to-managed exception handling callback from second pass.
The constraints are:
1. We must allow managed exceptions to be caught and finally blocks must run
2. We must not call the unmanaged exception handler if the first unwinding pass
detects that there is a native-to-managed wrapper and a callback is
installed that will handle managed exceptions (by unwinding the native code
and either re-raising the managed exception or otherwise dealing with it).
So we change the return value of handle_exception_first_pass to be:
- MONO_FIRST_PASS_HANDLED - caught by a managed frame (with a matching filter if one was present).
- MONO_FIRST_PASS_CALLBACK_TO_NATIVE - there's a native-to-managed wrapper and a ftnptr_eh_callback is installed.
- MONO_FIRST_PASS_UNHANDLED - first pass unwound all the way and there was no wrapper or there was no callback installed.
In mono_handle_exception_internal, we treat MONO_FIRST_PASS_CALLBACK_TO_NATIVE
as handled and unwind the managed stack, invoking finally clauses as we go,
until we reach the managed-to-native frame, at which point we invoke the callback.
* [test] Test for mono_install_ftnptr_eh_callback
* [test] AOT-friendly test for mono_install_ftnptr_eh_callback
* [sre-save] Remove type_token assignment in mono_image_fill_export_table
In 9725d50c87 we added the `g_error`, that should
fire if the MonoClass:type_token and the TypeBuilder token ever disagree. As a
result, this assignment is strictly redundant.
* [pedump] Use MonoClass getters
* [monograph] Use MonoClass getters
* [mini] Use MonoClass getters in a few more places
Catch up with recent commits.
In 9725d50c87 we added the `g_error`, that should
fire if the MonoClass:type_token and the TypeBuilder token ever disagree. As a
result, this assignment is strictly redundant.
Adopts a linked list of MonoW32HandleSlot (based on feedback from Rolf Kvinge). This allows for an unlimited amount of handles to be allocated, as well as for a lower cost to allocate only 1 handle across the process.
Fixes https://github.com/mono/mono/issues/7460
This implements a simple deduplication of source files in the .csproj's.
A postprocessing step opens the files and grabs all ItemGroups with sources
and then does an intersection. It then moves files that are common
across all platforms into a separate ItemGroup.
* Fix warning: Add static.
* Fix warning: Remove unused function from a recent incorrect merge/rebase.
* Fix warning(s): Cast away const.
* Add static to avoid global link-namespace pollution.
* Add const on input strings.
* (void) and () are not the same in C, overwhelmingly you want (void)
{0} does not portably zero unions, so favor memset
braces at start of function go on their own line
space before parens on function calls
spaces around binary operators
favor memset (x, 0, sizeof(x)) instead of memset (x, 0, sizeof(type))
favor TRUE/FALSE over true/false unless/until we switch to C++
This batch of commits makes further updates to our support for building the BCL using msbuild (Visual Studio, to be specific).
* Generates a single sln and set of csproj files with support for all of our build profiles (orbis, monodroid, net_4_x, etc)
* Project configuration selector (in VS or as parameter to msbuild) can be used to select which profile to build
* Includes partial dependency information so that culevel and jay are compiled before the rest of the sln (this keeps pre/post events from from failing on first build)
As of this rev things are working pretty good, but a lot of the measures I took here are temporary so I'd appreciate thoughts on how to go about them. The hard-coded System.Web -> Culevel dependency feels gross, for example - I kind of want to go through and build an automatic solution for it but I'm not sure it's necessary.
Implements #6858
---
* Checkpoint: Generate single .csproj file with conditional item/property groups
* Checkpoint: Updates to csproj and sln generation to support building specific profiles
* Move targets file in csproj template so that it isn't evaluated before all properties are set
* Checkpoint profile fallback (use net_4_x if project does not have appropriate profile)
* Use in-process cache for project guids to fix bug where many guids were being generated. Fix profile fallback.
* Clean up unnecessary debug writelines
* genproj error fixes
* Remove duplicate gacutil entry from makefile to fix order.xml corruption. Cleaner project names in msbuild sln. Compile genproj before generating inputs.
* Delete genproj.exe at beginning of update-solution-files because otherwise syntax errors will cause an old version to be used silently
Cleaner messages from genproj
* Hard-code the guid for culevel and add it as a dependency for system.web
* Bug fixes
* sln files are sensitive to whitespace format
* Don't generate pointless solution configurations if we have no information for them
* Updates based on PR feedback
Contributes to #7682
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=12850
FtpWebRequest used to work incorrectly with sub directories.
Let's say we have a following FTP structure
```
myserver
├── file1
└── subdir
└── file2
└── file3
```
Old behavior:
### 1) For `ftp://myserver/subdir/` printed:
```
file2
file3
```
Expected:
```
file2
file3
```
### 2) For `ftp://myserver/subdir` printed:
```
file1
subdir
```
Expected:
```
subdir/file2
subdir/file3
```
### 3) For `ftp://myserver/subdir/file2` printed:
```
file2
file3
```
Expected:
```
file2
```
With the fix in this PR it works as expected (matches netfx and netcore behaviors).
* [mini] Don't wait for other threads to finish JITing if the current thread is running a cctor.
This eliminates a possible source of deadlocks found during AOT runs of Roslyn.
* [mini] Introduce a 1s timeout to JIT job control to ensure we don't simply deadlock in case of execution dependency bugs.
* [mini] fix spelling5DD
* [metadata] Use getters in a few ilgen files
* [mini] Use MonoClass getters in several files
* [mini] Use MonoClass getters in mini-generic-sharing.c
* [debugger-agent] Use MonoClass getters
* [monodis] Use MonoClass getters in get.c
* [Tailcall] Add but do not use the F# tailcall test suite.
* [Tailcall] Compute inst_tailcall much earlier, it is cheap, and it will be used more and earlier.
* [Tailcall] Compute supported_tail_call and tail_call earlier.
* [Tailcall] Fix virtual generic methods that F# test TailCallLoopGenericClassAndMethodAbstractClass<byte>.Method3<byte> uses.
There is a general problem of customized code paths missing pieces.
This fixes just part of it.
* [Tailcall] Use common code for removing ret after tailcall, and not handling return value.
* [Tailcall] Cleanup.
* [Tailcall] Short circuit looking at parameters for has_vtargs.
* [Tailcall] Tailcalls presumably do not need sequence points, or anything, after them.
* [Tailcall] Fewer labels, more booleans, move existing label up, with additional booleans
controlling its behavior -- intent is to tease one altered behavior (tailcall of
virtual generic) and one existing and one new sharing of common code (remove_ret).
Longer term might have more tailcall handling.
* [Tailcall] F# tests closer to original.
* [Tailcall] Add the F# tests in blob form.
comment out the two failing tests
fsharpc --standalone --optimize- fsharp.fs
monolinker fsharp.exe to trim a little
change resource-using code to use constant strings
* [Tailcall] CI fails roughly where local passes.
* [Tailcall] Merge fsharp.fs into fshar.il as a comment.
* [Tailcall] Cleanup, remove unused labels, etc.
* [Tailcall] Cleanup test code some.
* [Tailcall] Cleanup.
* [Tailcall] Try harder to disable fsharp for AOT due to CI failures.
The only user was Xamarin.iOS in a weird way: The define is only set for
device builds where the icall table is excluded anyway. For the cross
compiler however, the define isn't set, and therefore those icalls can
be resolved by the AOT compiler.
With the interpreter now, this define actually had an effect: The
guarded icalls weren't inclueded in `libmono-icall-table.a`.
* [mkbundle] Automatically bundle config files and machine.config files for the simple/cross compiler scenario, fixes one of the missing issues for #6230
* Remove debug writeline
* Remove outdated information
* Bump API snapshot submodule
* [interp] Handle mono_handle_exception () returning a ctx which refers to JITted code by restoring the context.
* [aot] Clear the pinvoke flag from the interp_in wrapper signatures, so they get an lmf in mini_get_interp_in_wrapper (), this is needed for mixed-mode exception handling.
* [aot] Change the semantics of the 'interp' option, use it only to emit additional interp wrappers etc. instead of disabling code generation as well.
* [aot] Emit more interp-in/interp-out wrappers when using --aot=full,interp.
* Add a --interp=interp-only= command line option, used for testing.
In full-aot+interp mode, prefer full-aot code instead of interp code, except for methods in the classes listed
in the interp-only option.
Use normal runtime invokes in full-aot+interp mode.
* [interp] Prefer AOTed code when making calls out of interpreted code in full-aot mode.
* [aot] When running with --aot=interp, preserve the previous behavior of only emitting interp wrappers and trampolines.
* Revert "[Tailcall] Quick fix for building F#. Do not tailcall any method with a vtable_arg. (#7609)"
This reverts commit 8ceead93e3.
* [Tailcall] Correct fix for regression from change b4ee86154f.
Regression test not yet available.
* extra brace
* [Tailcall] Add FIXME for tail. not followed by ret. Correct behavior is to raise an exception, not fail an assert.
* [Tailcall] Add disabled debug code to break when compile a tailcall and/or execute a tailcall.
* [Tailcall] Add disabled debug code to try to tailcall any call followed by a ret.
This might be reasonable in the future, as well as a little data flow
analysis skipping nops and branches, as csc w/o -optimize outputs.
* [Tailcall] Add more tailcall tests, i.e. that would
have caught recent regression.
* [Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,
tailcall_all. Consider MONO_TAILCALL_DEBUG instead.
* Revert "[Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,"
This reverts commit 796d9490f672625189dfac47ff24b05f3fb65cbe.
* [Tailcall] Replace #if 0 with ifdefs:
define DEBUG_TAILCALL_BREAK_COMPILE breakpoint in method-to-ir
define DEBUG_TAILCALL_BREAK_RUN 1 codegen outputs breakpoint
define DEBUG_TAILCALL_TRY_ALL 1 consider any call followed by ret, can expand later
define DEBUG_TAILCALL 1 low volume logging under -v instead of -v -v
* [Tailcall] Dial back tailcalls on ARM32, where there is no
volatile non-parameter register in the ABI, in which to pass
an extra parameter. (Why not just pass as a regular first/last parameter?)
* [Tailcall] Dial back untested architectures MIPS S390x PowerPC SPARC.
* [Tailcall] Copy tailcall-generic-cast-il.il to tailcall-generic-cast-nocrash-il.il and tailcall-generic-cast-conservestack-il.il
All platforms should be able to run it without crash,
but only some can run it and conserve stack.
* [Tailcall] Finish splitting tailcall-generic-cast into nocrash and conservestack variations.
All platforms can run nocrash, only some conservestack.
* [Tailcall] Nested if and ifdef in certain order do not render well in some editors, so just use if.
* [Tailcall] Fix typo.
* [Tailcall] Disable tailcall-mrgctx.exe and tailcall-rgctxa.exe on ARM32 MIPS PowerPC due to MONO_ARCH_HAVE_VOLATILE_NON_PARAM_REGISTER=0 SPARC has no disabling.
ARM32 is very difficult to fix, maybe not possible.
The other architectures are not tested, so the progress is not enabled.
process_breakpoint() will process breakpoint, stepping, and method
exit/entry events all at the same time when checking a sequence point.
So, if there is is a breakpoint and a stepping event at the same time,
the debugger agent will suspend the current thread twice, which means
you have to click the step button in the debugger client twice on that
line. Considering only one of these events at a time seems to fix
the issue without breaking any current unit tests or showing any other
noticeable issues in testing.
* Fix bug #60843 and add test:
If an enum was nested inside a generic class, using it as an argument to a custom attribute would cause a runtime error in the custom attribute decoder. Update the decoder to forward this special case through the normal primitive loading path.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60843
* Update based on PR feedback
* Don't use caller info attributes since FullAOT does not have them
* Revert "Don't use caller info attributes since FullAOT does not have them"
This reverts commit 316afb686363ef0e46c15d5858bbc1b85ffd5264.
* Fix embarassing bug in test case
* Update outdated test category name
* Disable bug 60843 test in interpreter
In commit 8ba48b5a41
mono_string_new was adjusted to only assert for
out of memory rather than all errors to preserve
previous behavior for invalid strings. This
change preserves behavior for mono_string_new_wrapper.
This commit allows customization of WCF service creation via the Factory attribute in an .svc file:
`<%@ ServiceHost Language="C#" Service="CustomService" Factory="CustomServiceHostFactory" %>`
All the patch does is uncomment a few lines that were already there and fix a small error. I am not sure why these lines were commented. Possibly the code is not sufficiently robust or it was just never given another look. But this works for me and it seems better than no support at all. For example, a custom ServiceHostFactory appears to be the only way to create a WCF service in a managed host which customizes EndpointDispatcher.AddressFilter and EndpointDispatcher.ContractFilter. This in turn is useful for proxied WCF services.
See also http://mono.1490590.n4.nabble.com/Mono-WCF-ServiceHost-Factory-option-td4251992.html (from 2012; never posted on the mailing list for some reason).
The previous code was handling only objects residing in 2 32bit card protected address spaces. This means card table scanning for objects larger than 4GB was potentially broken, while card scanning of objects larger than 8GB was completely broken.
Fixes https://github.com/mono/mono/issues/7537
[threads] Delay abort via handler block guard when in abort protected block.
`mono_install_handler_block_guard` is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
Fixes#7588
The latest `WebCompletionSource<T>` changes (PR #7358) exposed and
intensified the side-effects of a race condition between `WebOperation`
and `ServicePointScheduler`.
* WebCompletionSource<T> now contains new `CurrentResult` and `CurrentStatus`
properties, which allow completion status to be checked in a non-blocking way.
* WebOperation.CompleteResponseRead() has been renamed into Finish() and
contains the continuation that was previouly known as FinishReading().
Calling this new Finish() method will now complete the `finishedTask`
completion, which has a new accessor called `Finished`.
* The ServicePointScheduler's main-loop is still woken up by completion of
`WebOperation.Finished.Task`, but we use the new `CurrentResult` property
to check state in a non-blocking way. This ensures the the clean-up and
bookkeeping work that's necessary after `WebCompletion.Finish()` always
happens prior to starting new connections.
* [w32file] remove unused mono_w32file_get_times ()
* [w32file-unix] replace SECMULT with TICKS_PER_SECOND
* [w32file-unix] use CONVERT_BASE in more places
* [w32file-unix] factor setfiletime
* [w32file-unix] use utimes if available in order to set subsecond information on access and write time
* [FileTest] add regression test for github issue 7646
* [w32file-unix] reduce compiler warnings
* [w32file-unix] 1000ns = 1us and 1us = 10ticks
* [w32file-unix] add LL suffix to constant in order to prevent overflowing on 32bit systems
* [loader] Don't load framework Facade assemblies that are older than expected.
If there is an older framework Facade assembly in the search order before the
one that we want, don't load it.
"older" here means just compare the major components of the version.
Fixes https://github.com/mono/mono/issues/7624
Even though it's found during configure when targetting 10.7, it's not "really" available before versions 10.12 and it would crash with "lazy symbol binding failed".
When mono is used as a submodule then .git will be a file instead of a
directory. Adjusted the version.h generation code to support that.
Also newer git version started to use `(HEAD detached at <git sha>)`
in `git branch` output instead of `(detached from <git sha>)`,
fixed the regex to support that pattern too.
* [Tailcall] Cleanup is_supported_tail_call to only check virtual_, not opcode == CALLVIRT.
* [Tailcall] Generate tailcall address earlier to honor NT ABI.
Let R11 through tailcall.
Assert alignment when patching.
* [Tailcall] Factor out two copies of SysV varargs handling to a helper function and remove for NT.
Tailcall needs a third instance, and it likely gets in the way of NT tailcall, where it is not needed.
* [Tailcall] Teach amd64_patch how to patch jmp rip+32 and jmp [rip + 32]
very similar to call rip+32 and call [rip + 32]. This might be useful.
* [Tailcall] Fix varargs handling of tailcalls.
* Remove new asserts and just leave comments.
* [Tailcall] No need to free RAX on non-reg calls.
send an internal VM_DISPOSE command to shut down the debugger thread
properly. This prevents runtime hangs that occur during profile
events after the debugger shuts down.
* Fix bounds manipulation in Control.DrawToBitmap and dispose objects properly.
* Add test for DrawToBitmap and fix one more bug in the implementation.
Fixes#7620
On macOS the stopwatch's elapsed time was regularly getting skewed by 200-800ms. On average, yielding decreases the number of GCs by only 25%, while the elapsed time error is always less than 15ms.
Fixes#6999
When a thread has a handler block guard installed (a `finally` block
that checks the exvar to see if it should issue abort the thread because
another thread called Abort on it), ves_icall_thread_finish_async_abort
is called. It must clear the handler block guard for the current thread
in case the abort landed while we're in an abort protected block (a
cctor, most commonly). In that case we must resume the interruption
when we leave all the abort protected blocks, not just at the end of an
intermitent catch clause.
mono_install_handler_block_guard is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
* Revert "[Tailcall] Quick fix for building F#. Do not tailcall any method with a vtable_arg. (#7609)"
This reverts commit 8ceead93e3.
* [Tailcall] Correct fix for regression from change b4ee86154f.
Regression test not yet available.
* extra brace
* [jit] Incorrect code under mono --trace.
* [Tailcall] call_opcode == CEE_CALLVIRT does not matter for tailcall_membase, only virtual_ does.
* [Tailcall] Add FIXME for tail. not followed by ret. Correct behavior is to raise an exception, not fail an assert.
* [Tailcall] Add disabled debug code to break when compile a tailcall and/or execute a tailcall.
* [Tailcall] Add disabled debug code to try to tailcall any call followed by a ret.
This might be reasonable in the future, as well as a little data flow
analysis skipping nops and branches, as csc w/o -optimize outputs.
* [Tailcall] Add more tailcall tests, i.e. that would
have caught recent regression.
* [Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,
tailcall_all. Consider MONO_TAILCALL_DEBUG instead.
* Revert "[Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,"
This reverts commit 796d9490f672625189dfac47ff24b05f3fb65cbe.
* [Tailcall] Replace #if 0 with ifdefs:
define DEBUG_TAILCALL_BREAK_COMPILE breakpoint in method-to-ir
define DEBUG_TAILCALL_BREAK_RUN 1 codegen outputs breakpoint
define DEBUG_TAILCALL_TRY_ALL 1 consider any call followed by ret, can expand later
define DEBUG_TAILCALL 1 low volume logging under -v instead of -v -v
* [Tailcall] Dial back tailcalls on ARM32, where there is no
volatile non-parameter register in the ABI, in which to pass
an extra parameter. (Why not just pass as a regular first/last parameter?)
* [Tailcall] Dial back untested architectures MIPS S390x PowerPC SPARC.
* [Tailcall] Copy tailcall-generic-cast-il.il to tailcall-generic-cast-nocrash-il.il and tailcall-generic-cast-conservestack-il.il
All platforms should be able to run it without crash,
but only some can run it and conserve stack.
* [Tailcall] Finish splitting tailcall-generic-cast into nocrash and conservestack variations.
All platforms can run nocrash, only some conservestack.
* Change the logic for closing ToolStrip drop-downs to work for more complex nesting.
* Implement SetOwner/GetParent(with_owner=true) behavior for X11 and Carbon backends.
Fixes the logic for closing ToolStripDropDowns for the following cases:
* ComboBox embedded in ToolStripDropDown as seen in KeePass when the window is resized to be small enough for the toolbar to overflow.
* ToolStripDropDown containing controls that open other ToolStripDropDowns and the user clicks on the top-level ToolStripDropDown. The child ToolStripDropDown, and only that child, should be closed in that case.
* Update AnchorLayoutEvents to match Windows behavior, make Bug82762 test platform independent.
* Cache affected layout control and property across SuspendLayout/ResumeLayout.
* Extend AnchorLayoutEvents test.
* Update for little nuances in the layout code.
* Unify flow layout for ToolStrips and FlowLayoutPanel by using the IArrangedContainer and IArrangedElement abstractions.
* Implement basic table layout support for ToolStrips.
* Clean up handling of FlowLayoutSettings.
* Fixes for default values of LayoutSettings in tool strips.
* Remove more of the duct tape holding the ToolStrip layouts together and replace it with calls into the LayoutEngine. Fix other small bugs that prevented ToolStrip overflows from being displayed correctly. Tested with KeePass.
* Fix indentation.
* Address code style issues.
* Remove unnecessary override.
* Fix indentation.
* Bump API snapshot submodule
* Fix error in vcxproj filter causing load error in Visual Studio.
* Fixes issue #7596 on Windows x64.
Passing value types in Windows x64 not fitting into register will be passed
by reference (ArgValuetypeAddrInIReg or ArgValuetypeAddrOnStack )
using a local variable allocated in caller’s frame.
Current implementation sized and marshaled the native struct correctly when
using pinvoke, but it sized the final local passed as reference to the native method
using the managed stack size instead of the native. This caused the final copy
into the local to overwrite other locals on stack if managed and native struct stack
sizes differed.
The fix is to flag the local variable used as stack parameter with its pinvoke state.
This makes sure the stack allocation size will be correct when using value types
passed on the stacks in pinvokes.
When running other unit tests with sequence points I hit a similar issue with
empty structs as return parameters (using [StructLayout (LayoutKind.Sequential, Size = 0)].
This commit includes a fix to ignore the return value if it’s an empty struct on Windows x64.
* [sgen] Use current nursery size when computing allowance
The allowance is the minimum heap growth that we allow between two majors (which is 4 * nursery_size). We need to use the current nursery size instead of the 4MB default, in order to facilitate low memory uses.
* [sgen] Account for soft heap limit in allowance calculation
This is relevant in cases where the nursery size and soft heap limit are comparable in size.
* [profiler] Fix wrong docs for mono_profiler_set_call_instrumentation_filter_callback ().
* [mini] Don't inline methods if they're going to be instrumented for coverage.
This handles coverage instrumentation in a similar fashion to call
instrumentation.
Fixes#6186.
* [mini] Add MonoError to mini_get_shared_method_full and replace bucket of booleans with a flags enum.
* [mini] Eliminate mini_get_shared_method in favor of the variant that takes a MonoError.
* [mini] Rename GetSharedMethodFlags members to follow our coding conventions.
* [mini] Remove reduntant arguments in get_shared_inst.
* [mini] Inline partial in mini_get_shared_method_full.
* [mini] In mini_get_shared_method_full, rename gsharedvt to use_gsharedvt_inst and move it's value to depend on all_vt.
* [mini] Eliminate SHARE_MODE_ALL_VALUETYPES as its semantically equivalent to SHARE_MODE_GSHAREDVT.
* Fix platform-specific build issues
These changes allow some of the Mono code used by the debugger to build
on a few additional platforms. Specifically, this includes platforms:
* That don't have access to the full Win32 API
* That don't have access to the full Posix API
* That don't support IPv6
* Wrap `access` and `_access` in `g_access`
* Convert indentation to tabs
* Wrap `mktemp` and `_mktemp` in `g_mktemp`
* Wrap `open` and `_open` in `g_open`
* Wrap `write` and `_write` in `g_write`
* Fix indentation
* Use proper asserts
* Add a configure check for `access`
* Remove the use of HAVE_XBOXONE_WINAPI_SUPPORT
* Replace the previous definition of `g_open`
I missed that it was here in my earlier commit, and ended up redefining
it.
* Use `g_error` instead of `g_assert(0)`
* [Tailcall] Quick fix for building F#.
Do not tailcall any thing with a vtable_arg.
This does often work, but not in F#, along with unbox in the call target.
The problem is being further reduced and debugged, but this will serve for now.
Regression is from change b4ee86154f.
* [Tailcall] Temporarily disable tests that depend on tailcall.
* [Coop] ves_icall_System_Threading_Thread_GetDomainID convert to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_ConstructInternalThread to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Thread_internal to coop/handle.
* [Coop] Convert mono_threads_get_max_stack_size ves_icall_System_Threading_Thread_SystemMaxStackSize/typo SystemMaxStackStize to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Suspend to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_SpinWait_nop to coop/handle.
* [Coop] Convert threadpool.c to handles -- no pointers, just MonoError.
* [Coop] Convert ves_icall_System_Threading_InternalThread_Thread_free_internal to coop/handle.
* [Coop] Convert mmap to coop/handle -- where there aren't pointers, just unused errors.
* [Coop] Rename some error to ioerror or win32error.
* [Coop] Convert ves_icall_System_Threading_Thread_current_lcid to coop/handle -- no pointers.
* [Coop] Convert mono_mmap_open_file, mono_mmap_open_handle to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Yield to coop/handle (no pointers).
* [Coop] Layer ves_icall_System_Threading_Thread_ConstructInternalThread over new mono_thread_construct_internal.
* Ignore out of memory.
* Favor mono_error_set_generic_error over small factories (loss of breakpoint?).
* Restore accidentally lost barrier.
* [Coop] Mostly undo commit d7bdbcc9a2e76913861b69ff106f0bf9573e7ea6
Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
for now.
It duplicates mono_thread_execute_interruption to mono_thread_execute_interruption_handle
which we want to ensure does not last long.
This should be achieved better by pull
https://github.com/mono/mono/pull/6639
which removes all but one pointer user and leaves
that pointer user layered over handle instead of duplicating.
* [Coop] Fix Windows build.
* [Tailcall][Windows] Add missing error parameter.
* [Tailcall] Cleanup is_supported_tail_call to use language-base short circuit.
* [Tailcall] Move more of the logic into is_supported_tail_call.
* [Tailcall] Be sure not to use TAILCALL_MEM_BASE if not supported.
i.e. not if virtual_, besides CALLVIRT -- they are not quite the same.
* [Facades] Make System.Net.Http.Rtc.dll a net_4_x only facade
It doesn't make sense on mobile (see https://github.com/mono/mono/pull/7541#issuecomment-372434424) but we'd like to keep it in net_4_x to match Desktop .NET
* Bump API snapshot submodule
We implemented them in the facades until now but in .NET 4.7.1
they were promoted into the regular class libraries.
Use PLATFORM_DEBUG_FLAGS for IL-less assemblies
Also replace some files with corefx that were identical.
* Fix the test for OnCreateControl.
* Do not create child controls until the parent is created.
* Fix showing menus after CreateControl behavior change.
* Make all top-level controls call SetTopLevel.
* Fix TopLevelControl property to actually return top-level controls, not just Forms.
* [threads] Fix race between abort socket syscall and thread shutdown
The race happens when we call mono_thread_info_abort_socket_sycall_for_close on
a thread that's about to shut down.
We lookup the MonoThreadInfo for that thread outside the
mono_thread_info_suspend_lock, and then use it to send the signal once we've
taken the lock.
In between those two actions, the other thread already finished
unregister_thread and pthreads may already have destroyed its TLS keys and
otherwise started to dismantle the thread.
The fix is to do a second mono_thread_info_lookup once we have the lock and
only signal the other thread if it still around.
Fixes https://github.com/mono/mono/issues/6998
* [threads] Simplify mono_thread_info_abort_socket_syscall_for_close
Call mono_thread_info_lookup while holding the thread info suspend lock.
We no longer need to check for STATE_DETACHED because removing MonoThreadInfo on
detach is done while holding the suspend lock.
* [metadata] split IL generation code into seperate compilation units.
* [metadata] move ENABLE_ILGEN definition to configure
* [metadata] split IL generation code into seperate compilation units.
By adding callbacks for IL generating runtime code, we can link in code
later into the runtime that does such for configurations which do not
need IL generation initially. This is the case if you configure the
runtime with `--enable-minimal=jit,interpreter`.
In such configuration, the build will produce an additional library,
called `libmono-ilgen`.
An embedded can choose to link this library to the final binary and
initialize IL generation with the following three, newly added, API
calls:
* `void mono_marshal_ilgen_init (void)`
* `void mono_method_builder_ilgen_init (void)`
* `void mono_sgen_mono_ilgen_init (void)`
This change is mostly moving code around, but there are minor changes
like introducing the enum `MarshalTypeCheckPositions`, so we avoid
copy/paste constants accross compilation units.
* [windows] add IL gen files to windows build and set ENABLE_ILGEN
* [fixup!] fix windows build
* [fixup!] resolve merge conflicts with class getter commits
* marshal.c: b8da973620
* sgen-mono.c: 8ba4947f7a
at some point I gave up to resolve merge conflicts and worked through
errors/warnings by compiling with
> `CFLAGS=-DENABLE_CHECKED_BUILD_PRIVATE_TYPES=1`
so the result is likely a bit different
* redo lost changes from 57f3f34e60
* redo lost changes from 52514effbf
* [fixup!] fix array marshal
* [method-builder] use eglib types
review comment by Ludovic,
https://github.com/mono/mono/pull/7375#discussion_r171876337
* [marshal] remove stelem strings from header
review comment by Rodrigo,
https://github.com/mono/mono/pull/7375#discussion_r171921029
* gboolean g_is_usermode_native_debugger_present (void).
i.e. Win32 IsDebuggerPresent which is just call mov mov ret.
Other slower methods on other systems if possible and unintrusive (OSX).
This is very useful as in:
if (g_is_usermode_native_debugger_present ()) G_BREAKPOINT
"native" meaning "not managed"
"usermode" meaning "not kernel"
Both other kinds exist and are detected differently.
* Move new debugging utility from glib to mono/utils.
* Redo it with CoreCLR as basis. https://github.com/dotnet/coreclr/blob/master/src/pal/src/init/pal.cpp
* Link to a specific stable revision, not master.
https://raw.githubusercontent.com/dotnet/coreclr/f1c9dac3e2db2397e01cd2da3e8aaa4f81a80013/src/pal/src/init/pal.cpp
* Use a clearer form of boolean normalization.
* Update Visual Studio project files.
* Fix include path, remove unnecessary boolean canonicalization, spell out words, swap int/boolean.
* Header got missed in the move from glib.
It'd fail with the following errors since e6de24c2d1:
```
MCS [net_4_x-darwin] net_4_x_System.Data.OracleClient_test.dll
Test/System.Data.OracleClient.jvm/MonoTests.System.Data.Utils/ADONetTesterClass.cs(337,71): error CS0012: The type `System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] net_4_x_System.Json.Microsoft_test.dll
Test/System.Json/JsonValueTest.cs(23,12): error CS0012: The type `System.Dynamic.IDynamicMetaObjectProvider' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] DummyAssembly.dll
error CS0518: The predefined type `System.Object' is not defined or imported
error CS0518: The predefined type `System.ValueType' is not defined or imported
```
* [ci] Add compiling class lib tests to mcs job
* Avoid recalculating Document on TextBox controls without handles. Properly dispose graphic contexts.
* Make sure all CreateGraphics calls are wrapped in using block.
* Avoid a couple more no-op calls in RichTextBox.
* Fix default values and the StartPage property in PrintPreviewControl.
* Do not cache resized bitmaps in PrintPreviewControl if the source data are scalable metafiles.
* [interp] Use jit's dead basic block detection
Using generating_code doesn't cover all cases since it doesn't do basic block liveness calculation.
* [interp] Throw instructions clear the stack
* [interp] Add stack check at return
There would be a compilation error in the XA build as follow:
```
obj/Release/bundles/armeabi-v7a/temp.c: In function 'install_aot_modules':
obj/Release/bundles/armeabi-v7a/temp.c:49:25: error: 'MONO_AOT_MODE_NORMAL' undeclared (first use in this function)
mono_jit_set_aot_mode (MONO_AOT_MODE_NORMAL);
^
obj/Release/bundles/armeabi-v7a/temp.c:49:25: note: each undeclared identifier is reported only once for each function it appears in
```
* [Tailcall] Fix the F# code; let rec functiona ()= printfn "%d" 1; functionb ()
and functionb ()= functiona ()
let ()= functiona ()
The test case and the fix are from https://bugzilla.xamarin.com/show_bug.cgi?id=25224.
Just bringing in change ca0dd5c0bb:
commit ca0dd5c0bb
Author: Zoltan Varga <[email protected]>
Date: Thu Dec 11 15:37:29 2014 -0500
[jit] Enable tail calls from gshared code. Fixes#25224.
Previously it was reverted due to performance regression, which has been fixed.
The problem was that use vs. patch of jmps was using inflated vs. non-inflated code.
Fixed here: https://github.com/mono/mono/commit/fe95e4b34b00caa8073dfa3b4473a43182abcbbb
The IL is:
.method public static !!a functiona<a>() cil managed
{
.
.
.
IL_001d: tail.
IL_001f: call !!0 '1'::functionb<!!0>()
IL_0024: ret
}
.method public static !!a functionb<a>() cil managed
{
IL_0000: tail.
IL_0002: call !!0 '1'::functiona<!!0>()
IL_0007: ret
}
* [Tailcall] Add tail.callvirt support to AMD64 JIT. Not yet
any other architecture (arm, x86, etc.) or scenario (AOT, LLVM,
interpreter, etc.)
This is based on F# that stack overflows to report failure:
type A() =
member this.f2 (a) = if a > 0 then this.f1(a - 1)
else 1
member this.f1 (a) = if a > 0 then this.f2(a - 1)
else 2
let a = A()
printfn "%d" (a.f1(1000 * 1000 * 10))
and in turn C#, self checking instead of stack overflowing:
using System;
using System.Runtime.CompilerServices;
using static System.Runtime.CompilerServices.MethodImplOptions;
unsafe class A
{
static int check (long stack1, long stack2)
{
return (stack1 == stack2) ? 0 : 1;
}
[MethodImpl (NoInlining)]
public virtual int f1 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f2 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public virtual int f2 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f1 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public static void Main ()
{
int stack;
Environment.Exit (new A().f1 (100, (long)&stack, 0));
}
}
And then IL, inserting tail prefixes and cleaning up a little:
.assembly extern mscorlib { }
.assembly b { }
.class A
{
.method static int32 check(int64 stack1, int64 stack2)
{
ldarg.0
ldarg.1
beq.s IL_0006
ldc.i4.1
ret
IL_0006:
ldc.i4.0
ret
}
.method newslot virtual instance int32 f1 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f2 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method newslot virtual instance int32 f2 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method static int32 Main () noinlining
{
.entrypoint
.locals init (int32 V_0)
newobj instance void A::.ctor()
ldc.i4 0x100
ldloca.s V_0
conv.u
conv.u8
ldc.i4.0
conv.i8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
}
.method instance void .ctor ()
{
ldarg.0
tail. call instance void [mscorlib]System.Object::.ctor ()
ret
}
}
* Allow comments anywhere in .md line, not just the start.
* [Tailcall] Avoid changing ins->sreg1 in OP_TAILCALL_MEMBASE.
This was likely based on OP_CALL_REG which has more reason to do
it but still not a good example.
* [Tailcall] Rollback x86/arm/ppc/llvm until changes are actually
complete/working.
* [Tailcall] Fix code formating: default at end, open brace at right on
previous line.
* [Tailcall] Consolidate comments out of tailcall-virt.cs and tailcall-virt.fs and into tailcall-virt.il.
Make IL less unreadable with whitespace.
Disable instead of enable tailcall-virt test.
* [Tailcall] Combine assert and default that it made unreachable and make assert more informative.
* [Tailcall] Remove a newline.
* [Tailcall] Add additional verbose output.
Add 3 tests that would seem focused on this change and would
seem to be fixed -- all three pass on desktop, all three fail
on previous mono, two are fixed now -- one needs more debugging --
generic value types.
Problem is probably:
is_supported_tail_call:
if (fsig->hasthis && cmethod->klass->valuetype)
/* this might point to the current method's stack */
supported_tail_call = FALSE;
* [Tailcall] Allow tail.callvirt on AMD64 AOT now, having tested it.
* [Tailcall] LLVM support for tail.callvirt/OP_TAILCALL_MEMBASE, now having tested it.
* [Tailcall] Disable new tests for interpreter as I had intended.
* [Tailcall] Consolide interpreter disabling of tailcall tests.
Address https://github.com/mono/mono/issues/7093 in kind of an adhoc way.
The correct fix is to make
```
((IEnumerable<U>) (new T[] {...})).GetEnumerator()
```
return an `IEnumerator<U>` (like .NET does) instead of `IEnumerator<T>`
and to stop marking IEnumerator as an array special interface.
fetching Microsoft.NET.Build.Extensions nuget from `cli-deps` to
`dotnet-core`. Both of these should have the same nugets but sometimes
seem to be off by one.
To pick up:
commit 345755cb49ee1979df280399f03178aae0b4029a
Author: Alex Rønne Petersen <[email protected]>
Date: Tue Mar 6 13:40:16 2018 +0100
Add build support for RISC-V. (#6)
Use `MonoClass` getters in the rest of the code in `mono/metadata/`
1. Add `mono_class_contextbound_bit_offset()` which returns the bit offset of `MonoClass:contextbound` which is needed by `remoting.c`
2. Add `mono_class_create_array_fill_type` which is used by sgen to write over unused nursery fragments.
3. Alllow `metadata-cross-helpers.c` to access `MonoClass` fields directly. Rationale: it needs to compute field offsets.
4. Everything else shouldn't have any functional changes.
https://github.com/mono/mono/issues/6925
---
* [metadata] Fix warnings in class-accessors.c
Fix warnings about missing prototypes for class-abi-details.h functions.
* [cominterop] Use MonoClass getters in cominterop.c
* [loader] Use MonoClass getters in loader.c
* [runtime] Use MonoClass getters in icall.c
* [metadata] Add mono_class_contextbound_bit_offset() accessor
Compute the bit offset of MonoClass:countextbound
* [remoting] Use MonoClass getters for remoting.c
* [boehm] Use MonoClass getters in boehm-gc.c
* [callspec] Use MonoClass getters in callspec.c
* [sre] Use MonoClass getters in dynamic-image.c
* [w32] Use MonoClass getters in w32process.c
* [debug] Use MonoClass getters in mono-debug.c
* [runtime] Use MonoClass getters in method-builder.c
* [runtime] Use MonoClass getters in security-manager.c
* [coop] Use MonoClass getters in handle.c
* [reflection] Use MonoClass getters in reflection.c
* [sgen] Add mono_class_create_array_fill_type
Used by sgen to fill nursery fragments before a collection
* [sgen] Use MonoClass getters in sgen-mono.c and the GC bridges
* [verify] Use MonoClass getters in the verifier
* [sre] Use MonoClass getters in SRE
* [custom_attr] Use MonoClass getters in custom-attrs.c
* [metadata] Use MonoClass getters in gc.c
* [security-core-clr] Use MonoClass getters in security-core-clr.c
* [metadata] Use MonoClass getters in metadata.c
* [metadata] Allow metadata-cross-helpers to access MonoClass fields
* [coop handle] Use MonoClass getter in mono_handle_unbox_unsafe
attribute(deprecated(message)) was introduced in gcc 4.5.
attribute(deprecated) was introduced in gcc 4.0?
pragma GCC diagnostic 4.2?
https://github.com/mono/mono/issues/7408
* Update many of the unit tests to pass on Windows.
* Update the TextBox default colors.
* Update ToolStripManager.RevertMerge error handling.
* Update menu item cloning to pass unit tests.
* Update PreviewKeyDownEventArgs.KeyValue behavior.
* Update return value of AccessibleObject.State.
* Update TextBoxBase.IsInputKey to treat backspace as input key.
* Update constructors of BindingCompleteEventArgs to properly set the Cancel property.
* Fix and cache ToolStrip[Item] default font.
* Run fixed layout unit tests.
* Silence the warnings and debug prints in unit tests.
* Update the default colors for ComboBox to match the TextBox.
* Remove superfluous debug prints that are already checked by Assert anyway.
* Make sure HandleCreated event is called for MDI children.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions and lot of noise in the unit test output.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions.
[System.Windows.Forms] Layout fixes
This is accumulation of layout related fixes from https://github.com/filipnavara/mac-playground. Some of the patches were rewritten, small bugs were fixed and it passes the unit tests now.
All the changes are listed in the commits, but the main ones are listed here:
- Rewritten TableLayout, which handles many quirks and unifies the code for GetPreferredSize and the actual layout.
- Fixed FlowLayoutPanel.GetPreferredSize to respect flow breaks.
- Many of the GetPreferredSize implementations fixed to return sensible values. For container controls with default layout the implementation is moved to DefaultLayout and shared.
- Implemented cache for GetPreferredSize that greatly improves the performance for complex layouts.
- Cleaned up implementations of SetBounds, SetBoundsCore and UpdateBounds that improve the performance by reducing the number of re-computations of the same values.
- Moved the calculation of dist_right and dist_bottom for anchor layouts to DefaultLayout.InitLayout.
The Linux build currently just displays "tarball" since we don't
have the .git directory when building the Linux packages.
This allows us to pass environment variables that contain the
branch+commit to the build for generating version.h so we can
show the more detailed info like on OSX.
Same as in https://github.com/mono/mono/pull/6033 to fix the following error on the FullAOT armel/armhf builds:
```
Ran out of trampolines of type 0 in '/home/builder/jenkins/workspace/test-mono-mainline-fullaot/label/debian-9-armhf/mcs/class/lib/testing_aot_full/mscorlib.dll' (limit 9000)
```
Now explicit bounds are only updated in SetBoundsCore, no more all the updating and restoring with UpdateBounds calls.
Rely on the WM_WINDOWSPOSCHANGED message to be sent from XplatUI.SetWindowPos to call UpdateBounds. This avoids an explicit call to XplatUI.GetWindowPos and UpdateBounds in SetBoundsCore.
Fix events triggered in incorrect order when Control.Controls.Remove is called.
Update Dispose behavior with events and exceptions to match the reference implementation more closely.
Rework the layout engines to use AutoSizeInternal property since TextBoxBase has its own AutoSize that should not be respected by layout engines.
Rework automatic sizing behavior of TextBoxBase to return correct values.
Rework TableLayout completely to use same code for layout and calculation of preferred size.
Co-authored-by: Jiri Volejnik <[email protected]>
The Label control has special sizing behaviour that predates the introduction of layout engines in .NET Framework 2.0. In earlier versions of the framework it used to auto-size itself. Now it does it only if it's contained in the default layout engine, otherwise it lets the layout engine do its magic.
* [mcs tests] fix runtime arguments passing to test harness
This fixes a regression introduced by
https://github.com/mono/mono/pull/5484/files#diff-d4a99dd2b7df29f027dae0b3eec6c8e6R193
The change it subtle: Variables are moved into another one, but one
variable got changed from `TEST_RUNTIME_FLAGS` to `RUNTIME_FLAGS`, which
causes the harness not picking up `--interpreter` if set.
* [interp] disable System.Threading.ThreadTest.Test_Interrupt
* [sre-save] Emit a warning if overwriting a MonoClass token with unequal value
It's not clear to me how we could ever have a class without a type_token set
even with a TypeBuilder.
* [sre-save] Use MonoClass getters in sre-save.c
* [sre-save] Change g_warning to g_error in mono_image_fill_export_table
We think this case should not happen.
* [sdks] Move common targets
* [sdks] Have RELEASE be empty when CONFIGURATION != 'release'
* [sdks] Create common runtime compilation template
* [sdks] Use runtime template for Android
* [sdks] Use runtime template for iOS
* Use VSCMD_ARG_TGT_ARCH env in mkbundle on Windows when trying to autodetect target architecture.
Using mkbundle on Windows with VS toolchain, mkbundle will detect target
architecture (x86/x64) by looking at the architecture of executing .NET runtime.
This could lead to some surprises when run from a VS development command propmt setup
to target x86 or x64 but running a mono binary using opposite architecture.
To mitigate this issue mkbundle will look now at the VSCMD_ARG_TGT_ARCH
set in VS development command prompts and use target architecture based
on this env variable. If not defined, current behavior will be used, picking the target
architecture based on executed .NET runtime architecture.
* Updated mkbundle documentation.
* [corlib] Remove IVT for S.R.I.RuntimeInformation facade
The types live in corlib now so we don't need the IVT anymore.
Also removed leftover SR.cs file.
* Bump API snapshot submodule
The original version of this code overwrote the same string over and over
again. Because of the order of operations, when looking for siblings of
Test.dll, we would probe for Test.dll.mdb, then Test.pdb, then Test.pdb.config
(note the last one - should be Test.dll.config).
New version of the code uses fresh strings for each sibling.
Fixes https://github.com/mono/mono/issues/7262
* [sdks] Add armv7s device build.
* [sdks] Disable dtrace on the cross compiler builds.
* [sdks] Avoid building mono-dtrace.h for the cross compilers, its not needed anymore.
* [sdks] Add a configure-mono target.
* [sdks] Put back the call to CheckXcodeDir.
* [sdks] Enable ccache if possible.
* [sdks] Generalize iosDeviceTemplate so it can build the tvos runtime as well. Add tvos device build.
- This is independent of optimization, which is seemingly what we want.
- This does not have bug under optimization that `error` has, that
currently breaks FullAOT builds.
This is an alternative to https://github.com/mono/mono/pull/7353.
Use ifdef GNUC || clang to indicate we know clang is compatible,
and not just depend on clang defining GNUC and being very compatible.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628.
* [runtime] Export mono_runtime_get_aotid () for use in the profiler.
* [profiler] Add nanoseconds startup time to file header.
Fixes#6178.
* [profiler] Add a TYPE_AOT_ID event containing the current runtime's AOT ID, if available.
Fixes#6181.
* [profiler] Add Mvid to image load events.
Fixes#6180.
* [profiler] Add generation field to heap object events.
Fixes#6174.
* [profiler] Remove TYPE_SAMPLE_UBIN and some more dead ELF code.
We had a few stubs that threw not implemented exceptions in Dispose()
which causes the finalizer thread to abort.
Since those classes throw in the constructor already there's no way
to create a valid object and we can remove the throw in Dispose().
Fixes https://github.com/mono/mono/issues/7338
This new helper class uses `TaskCompletionSource<>` internally, but instead
of using TrySetException(), it sets a result containing an `ExceptionDispatchInfo`.
The problem with using TrySetException() is that it wraps the exception
object in an `AggregateException`, that would be unobserved if the caller
throws the original exception.
* [System]: Enable some System.Net.Requests tests from CoreFX.
* tests.make: add `$(XTEST_HARNESS_PATH)` to `TEST_MONO_PATH`,
so we can find xunit.assert.
* corefx/SR.cs: add `System.Net.Requests` resources from corefx.
* HttpWebRequest: See below for detailed summary.
* Match parameter names of overridden base class members.
* Fixed order of some argument / state checks to match the
tested behavior.
* Most async methods now throw exceptions instead of returning
faulted tasks when called with incorrect arguments.
* HttpWebResponse.ContentType: use `string.empty` as default.
* WebConnectionStream.FlushAsync: override to return a finished task.
* HttpWebRequestTest.AllowReadStreamBuffering: removed this test.
* test-helpers/RemoteExecutorConsoleApp: silently ignore compiler-
generated helper methods.
Enabled tests from CoreFX:
--------------------------
Added the following tests from external/corefx/src/System.Net.Requests/tests:
* AuthorizationTest, FileWebRequestTest, GlobalProxySelectionTest,
HttpRequestCachePolicyTest, HttpWebRequestTest, HttpWebResponseHeaderTest,
HttpWebResponseTest, LoggingTest, RequestStreamTest, WebRequestTest
Not working yet:
* AuthenticationManagerTest, FtpWebRequestTest
We are currently using
../../../external/corefx/src/System.Net.Requests/tests/*.cs:AuthenticationManagerTest.cs,FtpWebRequestTest.cs
Summary of HttpWebRequest changes:
----------------------------------
* Host - we are now using the implementation from corefx.
* DefaultMaxResponseHeadersLength (unused) - fix default value.
* AllowReadStreamBuffering (unused) - allow this property to
be read/written.
* ContinueTimeout - likewise.
* DefaultCachePolicy (unused) - allow this property to be
read/written and set default value.
* DefaultMaximumErrorResponseLength (unused) - likewise.
* Connection - use implementation from corefx.
* Method - use implementation from corefx, which has additional
error checks.
* MaximumResponseHeadersLength - use implementation from corefx,
adding error checks.
* ReadWriteTimeout - likewise.
* ProtocolVersion - include parameter name in ArgumentException.
* TransferEncoding - use implementation from corefx.
* BeginGetRequestStream / GetRequestStreamAsync / GetRequestStream:
throw exceptions when called with incorrect arguments rather than
returning faulted tasks.
* Disable the corefx tests for the moment.
* Bump API snapshot submodule
* Update tests.make
* [acceptance-tests] Revert part of 1216780e83.
This didn't work as well as I'd hoped.
* [libgc] Export GC_start_blocking () and GC_end_blocking ().
* [libgc] Allow GC_start_blocking ()/GC_end_blocking () to be called unbalanced.
This makes things a bit easier in Mono.
* [libgc] Implement GC_start_blocking ()/GC_end_blocking () for Windows.
* [utils/event] Export the MonoOSEvent APIs for use in the profiler.
* [runtime] Implement thread info flags and get rid of tools threads.
The concept of a tools thread was originally a good solution to the problem of
some internal threads needing to be exempt from stop-the-world. Since they were
introduced, however, we've added more code in the profiler's internal threads
which require certain properties that don't hold true for tools threads. In
particular, we call into some APIs in the metadata layer that, while not
needing the managed heap, do need a domain to be set under certain conditions
(see #6188).
To avoid further complicating the semantics of tools thread by trying to set a
domain for them in a way that doesn't break things horribly, we'll instead do
away with the concept entirely. We already had mono_gc_set_skip_thread () to
flag a thread as being exempt from stop-the-world, which we used in thread pool
threads. This means we already have the infrastructure that is necessary for a
thread to be fully attached to the runtime as a managed thread while still
being exempt from stop-the-world.
So, we do the following:
1. Introduce a set of flags that can be set on a MonoThreadInfo at arbitrary
points (although not in async context). These can indicate that the thread
doesn't want to participate in stop-the-world, doesn't want to receive
sampling signals, etc.
2. Change the thread iteration macros to allow skipping threads with specific
flags set and use this where appropriate (e.g. SGen stop-the-world code).
3. Get rid of mono_gc_set_skip_thread () and make runtime code use the new
mono_thread_info_set_flags () instead.
4. Switch all internal profiler threads to using mono_thread_attach () and
mono_thread_detach (). Use mono_thread_info_set_flags () to disable
stop-the-world and sampling signals for these threads immediately after they
start.
With these changes, internal profiler threads are now fully attached threads
and can call any APIs in the runtime as long as they don't touch the managed
heap.
* [libgc] Add a note about how GC_start_blocking ()/GC_end_blocking () differ from upstream.
* [runtime] Use getters in IS_MONOTYPE()
* [metadata] Add m_class_offsetof_fieldName accessors
These look like:
```c
intptr_t
m_class_offsetof_someField (void) {
return MONO_STRUCT_OFFSET (MonoClass, someField);
}
```
When Mono is compiled with the definition of MonoClass
hidden (--enable-checked-build=private_types),
only the function prototypes are available via
mono/metadata/class-abi-details.h
When Mono is compiled without the checked build flag,
the functions are inlined into that header.
* [metadata] Add accessor function mono_class_set_nonblittable
This is needed by mono_marshal_load_type_info ()
* [marshal] Use m_class_get_ getters to access MonoClass fields
* OpenBSD hasn't have /dev/srandom anymore. See:
https://mastodon.social/@_xhr_/99389358375291806
* Crichton hasn't touched Mono since 2004, per logs. I
doubt they're who to consult about this issue anymore, if
someone somehow does.
* Always enable explicit null checks for AIX
AIX has a "null page" that allows reads (but not W|X) to occur on
*0; allegedly legacy crap for old stupid C programs that poorly
managed string handling. Because of this, we can't catch SIGSEGVs
to give out NREs with - we have to do null checks ourselves. As
such, turn this debug option on all the time; it's seemingly what
other managed runtimes have done, at least according to with what
one contact says.
* Make explicit null checking definable by architecture headers
Turns out other OSes do this too; so best to keep it generic.
To the poor souls on HP-UX and IRIX, good luck!
* Make arch-specific explicit null checks a backend option instead
Don't put ifdefs into JIT code except in that init_backend func;
also make ifdef name consistent with the debug flag name
* Rework the Win32 drag and drop bridge not to depend on Hwnd object.
* Avoid using Hwnd.GetBorderWidth directly.
* Unify GetParent calls to make same sense out of them. They should either consider form owners or not, which wasn't consistent across the XplatUI backends and uses.
Reimplement Control.FromChildHandle using XplatUI instead of relying on Hwnd class.
* Update GetParent parameters.
* Remove direct accesses to Hwnd objects from Control.
* Don't create the Hwnd object in the XplatUIWin32 backend.
* Split handling of Hwnd.GetNextStackedFormLocation for MDI windows into MdiClient to remove dependency on Hwnd objects.
We were previously passing to EH the address to the context that is being set up by the suspend mechanism. This context could get modified while we unwind, confusing EH (could raise `cfa_reg != -1` assertion)
This commit significantly reduces the race window and should mostly avoid crashes (if we get the wrong context we should just fail to invoke clauses from managed)
Don't assert when comparing if an "array special interface" is assignable from
an array.
The code assumed that the special interface is some sort of generic instance
like ``IList`1<string>``, but it could be a generic type definition
``IList`1``.
There is a case where we would be obligated to return TRUE:
If someone used reflection to get the generic param of ``IList`1`` and then made an
array:
```
var i = typeof (IList<>);
var iparam = i.GetTypeInfo().GenericTypeParameters [0]; // returns gparam T
var a = iparam.MakeArrayType (); // T[]
Console.WriteLine (i.IsAssignableFrom (a));
```
But that case is handled by the `MONO_CLASS_IMPLEMENTED_INTERFACE` check,
earlier in mono_class_is_assignable_from.
So we can return FALSE here.
Fixes https://github.com/mono/mono/issues/7095
* [metadata] Fix m_classdef_get_next_class_cache getter to be byref
Apparently the way this field is used is to internally chain cached classes, so
we need its address.
* [metadata] Use MonoClass getters in image.c
* [metadata] Allow debug-helpers to access MonoClass fields directly.
* [metadata] Use MonoClass getters in mono-error.c
* [sgen] Use MonoClass getters in sgen-debug.c
* [sgen] Use MonoClass getters in sgen-client-mono.h
* [metadta] Use MonoClass getters in appdomain.c
* [metadata] Use MonoClass getters in exceptions.c
The mkbundle VS toolchain build has never supported zlib and the -z argument.
Commit adds zlib.lib or zlibstaticlib (depending on use of --static) to the
linker command line when using -z argument.
NOTE, user still needs to make sure zlib.h, zconf.h, zlib.lib or zlibstatic.lib
is visible to cl.exe and link.exe when running mkbundle using VS toolchain.
* [metadata] Create transient ginst during parsing.
Allocate the instantiation types transiently so that they can be freed if
we're going to ultimately discard this MonoGenericInst candidate.
* [metadata] Store GenericParamInfo for anonymous generic params in a cache in MonoImage
The issue is that mono_metadata_parse_generic_param can be called from
mono_metadata_parse_method_signature_full without a MonoGenericContainer which
means we will image_alloc0 temporary MonoGenericParamInfo every time.
This happens, for example in method_from_methodspec in loader.c when we
parse a generic instantiation without having a generic container on hand.
* [metadata] Use MonoGenericParamFull for all generic params
We used to allocate a smaller MonoGenericParam for anonymous generic
parameters. Instead always allocate a MonoGenericParamFull now (which has the
extra MonoGenericParamInfo fields).
As a result, update call sites that checked whether mono_generic_param_info
returned non-NULL to check gparam->owner->is_anonymous instead.
As a fesult of that, update mono_metadata_load_generic_params to create
non-anonymous parameters right away if we know the class or method that will
eventually own them.
* [metadata] Remove anon gparam MonoClass caches from MonoImage
Now that all generic parameters are MonoGenericParamFull and have a pklass
field, cache the class corresponding to a generic param in the struct itself
instead of an external cache.
* [metadata] Remove gshared constraint gparam caches from MonoImage
Now that every gparam is a MonoGenericParamFull, we can always cache the
MonoClass for a gparam in MonoGenericParamFull:pklass.
* [wasm] Enable LTO in release builds. Change packaging to include both debug and release builds.
* [wasm/sgen] Make it possible to disable debug helpers and do so under wasm. Saves 2% on a release build.
* [Tailcall] Add 11 tests. They all run w/o exception or stack overflow, on all platforms.
They are self-checking and report if they were tail called.
All 11 pass on Windows .NET.
2 pass with Mono on Windows or Mac.
CoreCLR not tested as it is a difficult/unknown command line environment.
Mono has problems with at least:
virtual
non-managed pointers
generics
calli
managed references even if not to current frame
Tests originally written in C# and then run through ildasm and perl.
See https://github.com/jaykrell/mono/commits/tailcalltest2.gen.
* [Tailcall] Interpreter fails all tailcall tests.
SvcHttpHandler is supposed to be thread-safe so it shouldn't use plain
Dictionary without additional locking.
The problem is apparent when running test app from issue #7134 with
hyperfastcgi as the following exception sometimes surfaces:
```
[System.NullReferenceException]: Object reference not set to an instance of an object
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00111] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:441
at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (TKey key, TValue value) [0x00000] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:223
at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00048] in .../mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:82
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x008fd] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:1338
at System.Web.HttpApplication.Tick () [0x00000] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:927
```
* Add test for bug 18941
* Expand and update bug 18941 test because there are more problems with our handling of empty structs
* Remove array offset calculation from test because it uses unmanaged sizes. Fix calculation of struct sizes used in marshal struct layout (fixes SizeOf(TestOffsets))
* Correct Marshal.SizeOf implementation to use mono_marshal_type_size instead of returning native sizes
* Remove commented out code
* [sre] Remove S.R.E.FieldBuilder:table_idx field
The field was used in two ways:
1. as the temporary token returned by MemberInfo.MetadataToken
property
2. as a way for sre-save to record the field index in the dynamic assembly.
For (1) we now use the value returned by
ModuleBuilder.GetToken(MemberInfo) (ie a pseudotoken).
For (2) we lookup the field index in the dynamic assembly hash that maps
MonoClassField pointers to indices.
* [sre] Assign consecutive tokens to all fields in a class.
Ensure that a token and a Module are enough to uniquely identify every
MonoClassField.
Because of how metadata is represented in Mono, the fields defined in a
class must have consecutive tokens (because the MonoClass:field.first
and and MonoClass:field.count are used to index into the
MonoClass:fields array).
When the class is created we bump the "next available field token" value
in the ModuleBuilder. Any FieldBuilder objects that are still alive
after the type is created will use RuntimeResolve() to map from their
pseudotoken to the real token.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [sre] Change S.R.E.ModuleBuilder.get_next_table_index to take a count
Allow us to reserve more than one consecutive token.
(For now all the callers just have count == 1)
* [sre] Access S.R.E.ModuleBuilder:table_indexes from typebuilder_setup_fields
Use the ModuleBuidler:table_indexes array for assigning tokens to fields
when a TypeBuilder is constructing a type. Also register those tokens
with the runtime so that ResolveMember calls work.
* [test] System.Reflection.Emit.ModuleBuilder field tokens in a module should be distinct
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [runtime] Relax assertions in mono_class_{get,set}_first_field_idx
Removed the !klass->image->dynamic check. Classes created by SRE are
of kind MONO_CLASS_DEF and have a first field index.
* Fix issues due to API changes.
* Bump mscorlib version
https://github.com/mono/mono/issues/7200
Three styles:
1. LIBS="$LIBS -lfoo" -- common and probably works
2. LIBS+="-lfoo" -- was here and does not work
3. LIBS+=" -lfoo" -- should work
%p-formatted numbers already include '0x'
Fixes this output when dumping threads:
"Threadpool worker" tid=0x0x7000105cc000 this=0x0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
to become:
"Threadpool worker" tid=0x7000105cc000 this=0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
* [configure] Remove sgen_copying. It's dead.
* [configure] Add sgen_gc_bridge and sgen_split_nursery to the configure flags.
* [configure] Remove more dead configure flags.
* [configure] Par is now just a feature of conc, remove that too
* [sgen] Fix enable minimal for concurrent configuration.
* [sgen] Fix enable minimal for the split nursery.
* [sgen] Use the new enable minimal to compile the bridge code out.
* [wasm] Switch to the new enable minimal flagd and add mono-opt.js build. The new flags save 300k out of 2.8m.
* Fix *setup_async_callback and add *resume_sighandler_ctx on PPC
mono_arch_setup_async_callback didn't work on systems that use
function pointers. For consistency with other backends with
exception support, also add mono_arch_setup_resume_sighandler_ctx,
which we can use to support mono_arch_setup_async_callback, like
those other backends.
Also enable async callbacks on AIX, then enable
*resume_sighandler_ctx on PPC Linux (untested) and AIX. With this,
I can now ^C in the REPL with AIX and have it work; whereas before
it bombed out, with or without async callbacks enabled or disabled.
* Don't configure func descriptors twice, set args reg with user data
* No sense configuring configuring function descriptors if
the restore sigcontext call already set them up. (If Mac
OS supports is verified and added to the ifdef maze, it'd
be safe to remove this whole ifdef, and let the call in
`exceptions-ppc` handle it all, as all supported OSes
would have that call...)
* Set user_data in an arguments register, like what amd64
and z do.
These don't seem to cause any regressions, like the first patch.
* Remove unnecessary case for PPC
* mono_ppc_set_func_into_sigctx is unused now, remove it
* Everyone has MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX on PPC now
* Everyone has MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX on PPC too
mono_threads_is_safepoints_enabled is used to check if cooperative suspend safepoints are enabled, while mono_threads_is_blocking_transition_enabled is used to check if GC safe/unsafe transition are enabled.
* [mini] Change mono_arch_is_inst_imm () to receive the non-imm and imm opcode.
* [mini] Provide a stub for mono_arch_exceptions_init ().
* [mini] No need to define MONO_ARCH_FPSTACK_SIZE on platforms that don't use it.
* [mini] Remove some dead defines from backend headers.
* [mini] Remove the unused dummy_store opcode.
* [mini] Handle dummy init instructions in all backends.
* [mini] Implement live range instructions in all backends.
* [mini] Allocate trampolines from the domain code manager where appropriate.
* [wasm] Add server.py for those that want to experiment with streaming compilation.
* [wasm] Implement System.Threading.Timer.
Timer implementation is done in a somewhat convoluted way.
First, we change Timer to not depend on a scheduler thread.
What we do is call for the runtime to schedule a timed callback to be executed.
Next step, the runtime. We add enough plumbing to get this call to JS.
Finally, in JS we either call setTimeout or schedule it to be run on the next tick.
Oh, wait, timeouts are ignored on non-web environments? Yes, right now its only use case
is offline testing, so ain't no time to wait for all this timeouting.
* [aot] Add hybrid aot tests.
* [jit] Disable partial sharing during JITting, its only been tested in full aot mode, and doesn't seem to work with JITted methods. Fixes https://github.com/mono/mono/issues/7085.
Context: https://github.com/xamarin/xamarin-android/pull/1078
xamarin-android uses `mono-api-html` and `mono-api-info` in order to
perform API comparisons; see e.g. 4e459045.
A recent problem has arisen regarding "inter-API-level diffs": there
are many API changes which we consider to be acceptable, and thus
would like to ignore. Unfortunately, `mono-api-html` doesn't support
ignoring many of these constructs, e.g. base class changes:
<h3>Type Changed: Android.Preferences.CheckBoxPreference</h3>
Modified base type: <span class='removed removed-inline removed-breaking-inline'>Android.Preferences.Preference</span> <span class='added '>Android.Preferences.TwoStatePreference</span>
and property type changes:
<h3>Type Changed: Android.Views.InputEvent</h3>
<p>Modified properties:</p>
<pre>
<div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> int DeviceId { get; }
</div><div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> InputSourceType Source { get; }
Overhaul the `mono-api-html` "ignore" infrastructure:
* Introduce ignore "scoping". Previously, the ignore options would
only match the *member* text against any provided regular
expression. Thus, `mono-api-html -r ToString` would ignore *all*
members containing `ToString`. Furthermore, there was no way to
restrict the ignore to a particular type. Expand the regex
semantics so that the declaring type is used as a "prefix" for the
to-be-matched text. For example, if a class `Example` is removed,
`mono-api-html` will now match the following value against any
`-r` regular expressions:
Example: Removed type
* Add a `mono-api-html -v` option, to control output verbosity.
When specified, `mono-api-html` will print out available `-r`/etc.
option values:
$ mono-api-html expected.xml new.xml -v
Possible -a value: Android.Resource: Added fields: public static const int AccessibilityEventTypes;
Possible -r value: Android.Preferences.CheckBoxPreference: Modified base type: 'Android.Preferences.Preference' to 'Android.Preferences.TwoStatePreference'
Possible -r value: Android.Views.InputEvent: Modified properties: public int DeviceId { get; }
Possible -n value: Android.Views.UnavailableException: Added type
...
Additionally, allow `mono-api-html` to take a
`Mono.Options.ResponseFileSource`, which allows `@response-files` to
be used as command-line options.
Althought it was previously defined in a public API header, the macro was not
usable for the last several years since it was implemented in terms of
the MonoClass definition which was not visible in the public API.
There is a subtle semantic change here: mono_type_is_generic_parameter will
return FALSE if it's given a byref type parameter, the previous definition of
the macro would return TRUE. (E.g. if you had "class F<T>" then
IS_INTERFACE("T&") used to return TRUE but will now return FALSE. )
Also
- Move mono_class_set_failure definition to class-accessors.c
- Move a few functions that set up specific MonoClass fields to class-init.c:
- mono_class_setup_has_finalizer
- mono_class_setup_nested_types
- mono_class_setup_supertypes
Some terminals like vt220 don't have a format string for setting foreground
or background colors. In that case, the set*color members of the
TermInfoDriver are set to null and trying to set the background color throws.
Signed-off-by: Kai Ruhnau <[email protected]>
* [profiler] Document addition of MONO_ROOT_SOURCE_EPHEMERON.
* [profiler] Remove dead ELF traversal code.
This was buggy and hasn't been enabled for a long time.
The code uses reflection to access all the fields in the RuntimeFeatures
class. When running the linker we strip out these fields since
they're `const` and the test fails because it can't find the expected values.
Since the linker always removes all constant fields we can't simply
"use" the field in the test and instead we just bail out when encountering this case.
Also used Dictionary instead of tuples for the test since it renders
better in the nunit output.
Fixes https://github.com/mono/mono/issues/7145
* Assorted fixes for AIX and i
* Fix a bug I introduced when changing the MonoArray vector
type; array lengths wouldn't match up to what they
actually were on AIX/i.
* Use a custom mkdtemp implementation on Unices without
mkdtemp - and ones that do but don't necessarily have it,
like i 7.1, which lacks mkdtemp in its libc. We can't
determine this at runtime, so AIX will have to suffer
with i.
* Enhance PowerPC hwcap on AIX to detect features like
Linux does.
* Don't use clock_getres on AIX, because i 7.1 doesn't have
that syscall - it's in libc, but it'll bomb out with a
SIGILL; the way unimplemented opcodes are handled on i.
* Don't use PROT_NONE for hazard pointer alloc when on AIX
AIX and i 7.2 are OK with doing this, but i 7.1 is not and will
SIGSEGV because we violate access privleges; not even mprotect will
change this. As such, change to r/w protection for AIX/i.
* Fix Environment.OSVersion on AIX/i
Before, it would report "Unix 1.0.0.0" due to the fact AIX only
puts the minor version number where other Unices would put the
whole version in uname. Set up an ifdef for AIX and deal with this
semantic difference with a sprintf.
* Disable mffgpr on AIX
Reports of it not working on i 7.1 on POWER7; tester reports
disabling this in hwcap makes it run. This requires further
investigation.
* Fix threadpool errno delivering bogus values with _THREAD_SAFE
We didn't set this, and we need it so that errno is thread-local on
AIX/i. Oops!
* Make suggested changed to AIX branch
* use sizeof (utsname) for sanity's sake
* use a variable for hazard table protection
* match defines for CPPFLAGS -> libmono_cflags
In certain cases of having concurrent WCF requests
HttpReplyChannel.TryReceiveRequest can return true with the context
being null ("at closing phase").
This patch prevents crashing the whole application with a
NullReferenceException as reported in issue #7134.
Whether this is just covering the issue over or a real fix is yet to be
determined.
Fixes https://github.com/mono/mono/issues/7134
Assume a class implementing multiple generic I`1 interfaces. If a virtual call invocation is trying to resolve the correct interface using object O implementing I`1 also , the interface is resolved using a set of rules (not fully implemented in Mono), but a requirement is that the chosen interface is "variant-compatible" with object O, that is its generic parameters are set to the same types.
This last requirement is relaxed as an implementation-specific detail when I`1 is IEnumerator`1, in which case e.g. a virtual call on a class implementing IEnumerator<byte> can happen with an object of type IEnumerator<sbyte> by way of sharing IEnumerator`1 as a generic interface they define. Here, clearly the interfaces are not "variant-compatible", and this is allowed.
Resolution of classes implementing IEnumerator should still attempt to select a compatible interface using the standard rules before attempting to apply this special rule.
This is unnecessary and doesn't really make sense semantically in general as
some targets might define a different arch_target depending on bitness, while
still using the same arch/ subdir.
* Change first parameter of mono_nullable_box from guint8* to gpointer to avoid casts.
* [Coop] Provide object creation functions that return handles
and related. Existing functions are left unchanged
instead of layering over new to allay performance concerns.
Note that there are several variations new_object:
alloc vs. non-alloc
fast vs. regular -- fast does not handle finalization or weak fields and is external only
specific vs. non-specific -- specific is "vtable" and "non-specific" is "class"
"_handle" implies "_checked" if we can get away with it, as conversion continues
mono_gc_alloc_handle_array
mono_gc_alloc_handle_mature
mono_gc_alloc_handle_obj
mono_gc_alloc_handle_pinned_obj
mono_gc_alloc_handle_string
mono_gc_alloc_handle_vector
mono_gc_register_object_with_weak_fields(MonoObjectHandle) (raw "obj" vs. handle "object")
mono_gc_wbarrier_object_copy_handle
mono_nullable_box_handle
mono_object_clone_handle
mono_object_new_by_vtable "_by_vtable" instead of "_specific", and implies handle
mono_object_new_handle "_by_class" implied
mono_object_new_handle_mature "_by_class" implied
mono_object_new_pinned_handle "_by_class" implied
mono_object_register_finalizer_handle
mono_value_box_handle
* Combine mono_object_new_fast and mono_object_new_fast_checked.
Suppose we wanted to use coop handles to implement the following icall:
[MethodImpl (InternalCall)]
extern void GetGenericValueImpl<T> (int idx, T out value);
The question is: how should we pass the argument "value" to the C code?
If it was a reference type like "string" , we would use a coop handle:
void ves_icall_GetGenericValueImpl_string (gint32 idx, MonoStringHandleOut value, MonoError *error);
But if it was a valuetype, we would instead pin the memory with an interior
handle and pass the raw address:
void ves_icall_GetGenericValueImpl_int32 (gint32 idx, gint32 *value, MonoError *error);
But we don't have two different implementation on the C side - there's just one
icall - we have to choose a single mechanism.
So the mechanism we choose is to treat all the args like valuetypes - pin the
memory in the wrapper and pass a raw pointer to the C side.
The other troubling possibility is if someone writes:
[MethodImpl (InternalCall)]
extern void BadInternalCall<T> (Something s, T bad);
Now we really don't have any options. So we just assert that noone ever writes
such a call.
On interp we can't async abort since we cannot unwind from an ip in the interp, so the interpreter does explicit checks as part of branch instructions.
Note this can lead to increased stack usage when compiling with -O0.
* [offsets-tool] Add an '--output' argument to specify the output file directly instead of generating it from the target triple.
* [sdks] Add targets for the watch cross compiler.
* [mkbundle] Automatically bundle config files and machine.config files for the simple/cross compiler scenario, fixes one of the missing issues for #6230
When using the interp_wrapper to enter interp from native we don't need to save the lmf since it doesn't make sense to unwind to native. Also make sure we have the interp context set up if we weren't attached at interp transition time.
While Mono does copy the values of arrays back when they are marshaled
to unmanaged code, .NET does not seem to be doing this, and manifests
as the Syscall.poll invocation in Mono.Posix with .NET Core does not update
the values in the provided array.
The following example should print "Got 1 and 1" with the following command:
```
echo foo | dotnet run
```
But instead prints 0 and 1 on .NET Core, but the correct result with Mono.
This patch is going here for the sake of the Mono.Posix.NetCore package that
we publish.
Sample:
```
using System;
using System.Runtime.InteropServices;
class X {
private struct _pollfd {
public int fd;
public short events;
public short revents;
}
[DllImport("libc")]
static extern int poll ([In,Out]_pollfd[] ufds, uint nfds, int timeout);
static void Main ()
{
var p2 = new _pollfd [1] { new _pollfd () { fd = 0, events = 1 } };
var m = poll (p2, 1, -1);
Console.WriteLine ("Got: {0} and {1}", n, pollmap [0].revents);
Console.ReadLine ();
}
}
```
* [runtime] Unboxing of nullable enums should throw for boxed ints. Fixes gh #6666.
For some reason, one can't unbox the underlying type of an enum into a nullable.
This is counter intuitive to the unboxing rules of enums, but it's what dotnet does.
* [interp] Unboxing of nullable enmus should throw for boxed ints
fixes https://github.com/mono/mono/issues/6666 for the interpreter
Ensure that the callback to mono_domain_foreach_safe can actually do stuff with the domain argument like running code.
This new function make it possible to do so safely, unlikely the previous one.
This ensures that the process exit callback has a shot of correctly executing on domains racily being unloaded.
The ProcessExit event is fired before the threadpool is shutdown, so we can leverage that to run them
with a timeout.
The timeout is 3 seconds per appdomain. It could be improved by making that global to all domains if that
ever becomes an issue.
MonoError is simplified for MME by having the error message eagerly created, which simplifies things A LOT.
Managed Exception creation is simplified by only setting Message, as it's done by other runtimes.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* [utils] Fix swapped member and signature fields in error message.
* [runtime] Simplify MME by only setting the message field since ClassName/MemberName don't need to be set.
* [runtime] Add mono_error_set_method_missing to exceptions.c and collapse setting MME to a single function.
This implements the cleanup discussed in the PR.
* [runtime] Cleanup MonoError for BadImageFormatException.
Move mono_error_set_bad_image & mono_error_set_bad_image_name to exception.c.
Rename mono_error_set_bad_image_name to mono_error_set_bad_image_by_name.
Introduce mono_corlib_exception_new_with_args to be used when creating exception objects.
It's easier to consume than mono_exception_from_name_two_strings_checked as it takes string arguments as char*.
Fix usage of mono_error_set_bad_image_by_name to never dup the supplied image name as the callee does it.
Fix some empty error messages.
Finally, reduce the cruft in mono_error_prepare_exception by using the new exception creation function from above.
* [runtime] Cleanup MonoError of FileNotFoundException.
Move it to use the generic first_argument and make it a simple error - IE, get_message doesn't format anything.
* [runtime] Rework MonoError for MissingFieldException.
* Fix build issues
* [runtime] Ensure memory is freed using new MonoError set functions.
When unboxing nullable we call Nullable.Unbox which returns the valuetype, but CEE_UNBOX needs to return an address to it. Therefore we store the result in a local in the frame so we can get its address.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* Fix gshared support for default interface methods by always passing an mrgctx to them.
This is needed because these methods can be part of more than one inheritance hierarchy or
be present more than once in the same inheritance hierarchy so its not possible to
assign rgxtx slots to their gshared entries that would work in all cases.
* [jit] Add a mini_method_is_default_method () helper function.
Fix a regression introduced in the new web stack - when connecting
to a DNS host name that resolves to multiple IP addresses, we need
to probe them all.
On iOS, "localhost" will resolve to both "::1" and "127.0.0.1".
* [runtime] Make icall tables loadable.
Move the icall table code into a separate icall-table.c file, which is either linked into libmono or compiled into a
separate libmono-icall-table.a archive which can be linked into an app, and installed by calling mono_icall_table_init ().
* Change ClCompile to ClInclude for new .h file.
We must not push one vararg at a time since the alignment of the argument is not the same as the alignment of a value type in interp (which is always 8)
Detect conflicts caused by diamond inheritance during vtable construction, and throw an exception when a conflicting
methods is called.
Disable generic sharing for default interface methods, it doesn't work yet, probably
because these methods are called on classes, but the gshared information is associated with the interface.
Enable dim-diamondshape.exe test.
Setting ReadTimeout in WebResponseStream.ctor throws System.Net.Sockets.SocketException : Invalid arguments on iOS.
Set it in WebConnection.InitConnection() immediately after establishing a connection, before we read/write anything.
* [jit] Simplify some gshared code by calling mini_method_get_rgctx () in more places, make mono_method_lookup_rgctx () static. NFC.
* [jit] Get rid of the 'method' argument to emit_get_rgctx (), it should always be equal to cfg->method. NFC.
.. process. Version from:
https://github.com/dotnet/cli/blob/501e11d928c21608999c934f0a7078570b688c6c/build/DependencyVersions.props
```
<MicrosoftNETSdkPackageVersion>2.1.0-preview1-62414-02</MicrosoftNETSdkPackageVersion>
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
```
Also, update the list in the runtime and deniedAssembliesList.txt
installed for use by msbuild.
.. assemblies.
This is specifically required for handling .net assemblies in
`Microsoft.NET.Build.Extensions` nuget which don't work on mono. These
assemblies are bundled with msbuild and we want to be able to deny these
at runtime.
* [configure.ac] Add --enable-checked-build=private_types option
The idea is that when private_types is turned on, we will hide the definitions
of various structs in Mono and only allow access via getter/setter
methods.
If private_types is off, those same getters would be static inline functions
and also the struct definition would be visible (to allow for incremental
conversion of existing code).
* [metadata] Move _MonoClass definition to class-private-definition.h
* [metadata] Define a getter for every MonoClass field
in a checked build, the getters are just declared in class-internals.h and
defined in class-accessors.h
in a non-checked build, the getters are static inline functions in class-internals.h
For a field foo of type FooType define
FooType m_class_get_foo (MonoClass *klass) { return klass->foo; }
The exceptions are fields that are embedded structs, e.g. MonoType byval_arg,
for those we return a pointer to the field instead of a copy:
MonoType * m_class_get_byval_arg (MonoClass *klass) { return &klass->byval_arg; }
* [metadata] Rename MonoClass boolean getters to use is/has names
instead of the string m_class_get_fieldname pattern
- m_class_is_inited
- m_class_is_size_inited
- m_class_is_valuetype
- m_class_is_enumtype
- m_class_is_blittable
- m_class_is_unicode
- m_class_was_typebuilder
- m_class_is_ghcimpl
- m_class_has_finalize
- m_class_is_delegate
- m_class_is_gc_descr_inited
- m_class_has_cctor
- m_class_has_references
- m_class_has_static_refs
- m_class_has_no_special_static_fields
- m_class_is_com_object
- m_class_is_interfaces_inited
- m_class_is_simd_type
- m_class_is_has_finalize_inited
- m_class_is_fields_inited
- m_class_has_failure
* [metadata] (class-internals.h) Use m_class_get_ getters
* [metadata] (class-inlines.h) Use m_class_get_ getters
* [metadata] (class-accessors.c) Use m_class_get_ getters; setters not done
The setters are not converted.
Ultimately, I think that will sort itself out - a few of them are only used
from SRE and from MonoClass construction - we will eventually provide setters
for just two places and hide them elsewhere.
When doing a vararg call we push on the vtstack the current call signature followed by the params. The child_frame will have a pointer to this memory on the parents vt_stack from where it can linearly access the varargs using the same ArgIterator logic.
Use `git blame -C10 mono/metadata/class-init.c` to see attribution for most of the old code.
This PR comprises:
* [metadata] Move (some) MonoClass construction to class-init.c
So far moved MonoClassDef, MonoClassGtd and MonoClassGenericInst construction
functions.
The idea is to eventually isolate functions that needs write/setter access to
MonoClass fields in a separate translation unit and make MonoClass opaque and
only accessible via getters everywhere else.
* [metadata] Move pointer MonoClass creation to class-init.c
* Mark mono_ptr_class_get as external only, runtime should use
mono_class_create_ptr.
* [msvc] Add mono/metadata/class-init.c (and .h) to the .targets file
* [metadata] Rename mono_generic_class_get_class
to mono_class_create_generic_inst
* [metadata] Move array class creation to class-init.c
* Mark mono_array_class_get external only, runtime should use
mono_class_create_array
* Mark mono_bounded_array_class_get external only, runtime should use
mono_class_create_bounded_array
* [metadata] Move generic param creation to class-init.c
* Also move mono_class_setup_vtable_general, mono_class_init_sizes, mono_class_setup_methods
* [metadata] Move mono_class_setup_basic_field_info to class-init.c
* [metadata] Move mono_class_setup_fields to class-init.c
* [metadata] Rename mono_class_from_generic_parameter_internal
to mono_class_create_generic_parameter
* [metadata] Move mono_class_layout_fields to class-init.c
* [metadata] Move mono_class_setup_{properties,events} to class-init.h
* [metadata] Move mono_class_setup_interfaces to class-init.c
* Also move mono_class_setup_mono_type
* [metadata] Move mono_class_setup_parent to class-init.c
* [metadata] remove some extern statistics
* [runtime] Add a 'frame_addr' field to MonoStackFrameInfo, which is equal to either interp_frame or ctx->sp.
Use this field to compare frames with each other or with stack addresses instead of setting ctx->sp to
the interp frame address, which breaks mixed mode, since mixed mode assumes ctx->sp is the real
sp of the last native interpreter frame.
* [ci] Reenable mixed mode tests.
* [System]: WebResponseStream now correctly reads the chunk trailer when using gzip/deflate.
This should actually fix bug #59779.
* Add missing ConfigureAwait(false)
SUBDIRS= po $(libgc_dir) mono $(ikvm_native_dir)$(support_dir) data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests llvm
ifENABLE_NETCORE
update_submodules=
else
update_submodules= update_submodules
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 po $(libgc_dir) mono ikvm-native $(support_dir) data runtime scripts man samples tools msvc docs acceptance-tests llvm
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 netcore
all:update_submodules
all:$(update_submodules)
SUBMODULE_ERROR='Could not recursively update all git submodules. You may experience compilation problems if some submodules are out of date'
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<!--
This MSBuild file is intended to be used as the body of the default
publishing release pipeline. The release pipeline will use this file
to invoke the PushToStaticFeed task that will read the build asset
manifest and publish the assets described in the manifest to
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<!--
This MSBuild file is intended to be used as the body of the default
publishing release pipeline. The release pipeline will use this file
to invoke the PublishSymbols tasks to publish symbols to MSDL and SymWeb.
Parameters:
- PDBArtifactsDirectory : Full path to directory containing PDB files to be published.
- BlobBasePath : Full path containing *.symbols.nupkg packages to be published.
- DotNetSymbolServerTokenMsdl : PAT to access MSDL.
- DotNetSymbolServerTokenSymWeb : PAT to access SymWeb.
- DotNetSymbolExpirationInDays : Expiration days for published packages. Default is 3650.
!!! Changes made in this directory are subject to being overwritten by automation !!!
The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first.
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project Sdk="Microsoft.NET.Sdk">
<!--
This MSBuild file is intended to be used as the body of the default
publishing release pipeline. The release pipeline will use this file
to invoke the the SignCheck tool to validate that packages about to
be published are correctly signed.
Parameters:
- PackageBasePath : Directory containing all files that need to be validated.
- SignCheckVersion : Version of SignCheck package to be used.
- SignValidationExclusionList : ItemGroup containing exclusion list to be forwarded to SignCheck.
- EnableJarSigningCheck : Whether .jar files should be validated.
- EnableStrongNameCheck : Whether strong name check should be performed.
-->
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<!--
From 'Signing.props' we import $(SignValidationExclusionList)
echo"Creates a toolchain and sysroot used for cross-compiling for Android."
echo.
echo"Usage: $0 [BuildArch] [ApiLevel]"
echo.
echo"BuildArch is the target architecture of Android. Currently only arm64 is supported."
echo"ApiLevel is the target Android API level. API levels usually match to Android releases. See https://source.android.com/source/build-numbers.html"
echo.
echo"By default, the toolchain and sysroot will be generated in cross/android-rootfs/toolchain/[BuildArch]. You can change this behavior"
echo"by setting the TOOLCHAIN_DIR environment variable"
echo.
echo"By default, the NDK will be downloaded into the cross/android-rootfs/android-ndk-$__NDK_Version directory. If you already have an NDK installation,"
echo"you can set the NDK_DIR environment variable to have this script use that installation of the NDK."
echo"By default, this script will generate a file, android_platform, in the root of the ROOTFS_DIR directory that contains the RID for the supported and tested Android build: android.21-arm64. This file is to replace '/etc/os-release', which is not available for Android."
exit1
}
__ApiLevel=21# The minimum platform for arm64 is API level 21
echo"BuildArch can be: arm(default), armel, arm64, x86"
echo"LinuxCodeName - optional, Code name for Linux, can be: trusty, xenial(default), zesty, bionic, alpine. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
echo"lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine"
echo"--skipunmount - optional, will skip the unmount of rootfs folder."
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
Loaded 100 of 8031 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.