* [runtime] Treat calling a non-virtual method through an open delegate the same as the normal case instead of the OPEN_VIRTUAL case.
* [amd64] Fix the return value mapping in gsharedvt calls, the return address might be in different registers in the caller and callee.
* [runtime] Always initialize del->method_ptr even if interp_method is set, JITted code makes calls through it in mixed mode.
* Add a test for open delegates and gsharedvt.
* Increase nrgctx trampoline count, its needed by dynamic-method-churn.exe in full-aot-interp mode.
* Initial commit to migrate libgc to bdwgc.
* Fix submodule url
* Don't force Boehm as runtime wrapper. Was just for testing locally.
* Build bdwgc as single object file. Helps with performance.
* Bump bdwgc submodule.
* Attempt to fix windows MSVC based build.
* Remove any references to GC_INSIDE_DLL as we manually managed threads on Windows.
* Allow building boehm on Windows amd64.
* Allow building boehm with msvc.
* Bump bdwgc to fix line endings
* Use LF for sh, am, m4, and ac files in bdwgc
* Bump bdwgc & libatomic_ops with fix for cygwin
* Bump bdwgc to fix mono-boehm being generated as libtool wrapper script.
* Link the static boehm library.
* Revert "Link the static boehm library."
This reverts commit 1f90d81d08308a61c890743cd79d8f6bb791bc99.
* Use --export-all-symbols on cygwin/mingw to fix issues with boehm causing mono symbols not to be exported.
* Fix
* [wasm] Compile corelib as 32 bit.
* [wasm] Add a netcore cross compiler.
* [wasm] Add netcore+aot support.
* [aot] Load the dedup module lazily instead of at startup.
The previous version didn't work on netcore because it couldn't resolve references to corlib etc.
since they were not yet registered in the root domain at the time of loading.
* Add more icall trampoline signatures.
* Add more netcore pinvokes.
* Fix the build.
* Add more icall trampoline signatures.
* Add an --embed-file option to the packager.
* Add more netcore pinvokes.
* [interp] Return FALSE for IsDynamicCodeCompiled.
* Add a netcore project and targets for running BenchmarkDotNet.
* Fix pinvoke tables.
* Add missing files.
* Fix make clean.
* Add a comment.
* Revert "Fix pinvoke tables."
This reverts commit 998065e77614b7e621d2873510aabc3930669ca9.
* Make xunit-runner into a dotnet project. Add a netcore version.
[interp] fix array_element_size intrinsic
`mono_class_array_element_size` gives us the size of the provided MonoClass if it would be an array element. But here we want the element size of a given array's MonoClass. That's what `mono_array_element_size` is returning.
This leads to all kind of weird crashes otherwise, specifically here:
https://github.com/mono/mono/blob/2c20649539ac16e069a65f2a750c793eb341e50f/netcore/System.Private.CoreLib/src/System/Array.Mono.cs#L64
Which is then used later to compute the size to memset in order to clear the content of an array. If it's larger than it should be, then this will cause memory corruption. For example this would crash eventually:
```csharp
using System;
using System.Collections.Generic;
namespace HelloWorld {
class Program {
static void Main(string[] args) {
for (int j = 0; j < 0x1000; j++) {
var d = new Dictionary<string, string> ();
for (int i = 0; i < 197; i++)
d.Add (i + "", i + "foo");
d.Clear ();
}
}
}
}
```
Thanks to @EgorBo for reporting.
`remove_gc_finalizing` wasn't initialized so its value is undefined.
The `count_thread_check_gc_finalizer()` function only sets it in some cases so we could end up with the variable having an undefined (and probably not 0) value.
This resulted in the returned thread count from the debuggee being wrong because we'd decrement `count` even though we shouldn't.
Regression from https://github.com/mono/mono/pull/15618
It looks like the mirror didn't fully quiesce prior to snapping coreclr/corefx for the runtime consolidation. As a result the libraries build is breaking.
Signed-off-by: dotnet-bot <[email protected]>
* Forced filesystem creation
* [Wasm] Added new hello-io sample
- Goal is testing file preloading through System.IO
- Filesystem is now always forced to support later file preloading
- build-io-sample target showcases such
* Added --enable-fs flag to packager.exe
* Update packager.md
Fix NetStandard issue in System.IO.FileSystem.AccessControl
We built the fix incorrectly so that it would only apply for netcoreapp3.0 but customer needs it on netstandard2.0 (desktop + core). Customer impact is that they’ll see a PlatformNotSupported exception rather than the new API.
Signed-off-by: dotnet-bot <[email protected]>
* Updating Vector128.AsVector3 to have a functioning implementation
* Adding test template metadata covering the new methods for converting between S.Numerics and S.R.Intrinsics
* Regenerating the existing tests
* Generating the new Vector conversion tests
Signed-off-by: dotnet-bot <[email protected]>
* Add span-based CopyTo and CopyToAsync methods
* Update according to feedback
* Add span-based CopyTo overrides for MemoryStream
* Improve span-based CopyTo arguments validation
To avoid code duplication
* Update according to second review
Stream API is changed
* Resolve InternalReadSpan/Memory inlining
* Refactor ValidateCopyToArgs
* Update according to third review
* Update after fourth review
* Override span CopyTo for UnmanagedMemoryStream
* Apply suggestions from code review
Co-Authored-By: Stephen Toub <[email protected]>
* Update after fifth review
* Add cross sync/async support for span-based CopyTo
* Call sync action directly in async context
* Rework cross sync/async support for span-based CopyTo
Co-Authored-By: Stephen Toub <[email protected]>
Signed-off-by: dotnet-bot <[email protected]>
* Method Add(ref BigInteger lhs, uint value, ref BigInteger result) would store most of the result blocks into lhs instead of result.
* Method ShiftLeft(ulong input, uint shift, ref BigInteger output) with a shift argument exceeding 32 would generally compute the higher blocks incorrectly.
* Multiply(ref BigInteger lhs, uint value, ref BigInteger result) would not set result._length in some cases.
* IsZero() would incorrectly return false for non-canonical zeros with _length > 0.
Fix:
* Inline Add(ref BigInteger, uint, ref BigInteger) into Add(uint).
* Inline ShiftLeft(ulong, uint, ref BigInteger) into Pow2.
* Inline ExtendBlock and ExtendBlocks into Pow2.
* Properly handle 0 in SetUInt32 and SetUInt64.
Signed-off-by: dotnet-bot <[email protected]>
FileStream has two modes, decided upon at construction time. When it's created in non-async mode, the Read/WriteAsync methods end up queueing work items to invoke the synchronous Read/Write methods. To do this, the base methods on Stream delegate to Begin/EndRead/Write (since they were around first) and then the resulting IAsyncResult is wrapped. However, Stream has an optimization that checks to see whether the derived stream actually overrides Begin/EndXx, and if it doesn't, then it skips using those and goes straight to queueing a work item to Read/Write. However, FileStream does override those, but when it delegates to the base implementation because it's in non-async mode (rather than because it's a type derived from FileStream), going through Begin/EndXx is just unnecessary overhead. So, in the right circumstances, we can call to Stream's special helper instead.
Signed-off-by: dotnet-bot <[email protected]>
* When we try to call a method to get the async_id to do an async debug and we are trying to do this in a generic method like this:
async Task<T> ExecuteAsync_Broken<T>()
{
await Task.Delay(2);
return default;
}
We need to inflate the generic type before call the method or we will get the error: Could not execute the method because the containing type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[T_REF]’, is not fully instantiated.
Fixes#17549Fixes#17569
* [llvm] Use explicit null checks with LLVM.
When the LLVM backend is used for a method, explicit null checks will
unconditionally be used at the mini IR level. We had previously used
implicit null checks at the mini IR level combined with llvm-volatile
loads and stores to avoid mis-optimization of the generated code.
During AOT compilation, LLVM's `ImplicitNullChecks` pass is enabled.
This conservatively elides these explicit null checks. This pass only
modifies branches tagged with `make.implicit` metadata.
Null check branches are now tagged with `make.implicit` metadata, with
three exceptions:
1. For platforms with backends that do not support zero page fault
handling, null check branches are not tagged with `make.implicit`.
2. This commit also adds a `MONO_DEBUG` option:
`llvm-disable-implicit-null-checks`. When it is enabled, null check
branches are not tagged with `make.implicit`.
3. This commit alters the behavior of the `explicit-null-checks`
`MONO_DEBUG` option. Enabling `explicit-null-checks` also implies
`llvm-disable-implicit-null-checks`, because this option is documented
(e.g. in https://www.mono-project.com/docs/debug+profile/debug/) to
completely disable signal/seh-based null checks.
* Add llvm-disable-implicit-null-checks to the MONO_DEBUG help string.
* Add llvm-disable-implicit-null-checks to mono.1.
* Don't tag null checks in EH regions with `make.implicit`.
This relocates the logic formerly used to guard individual LLVM-level
loads and stores with explicit null checks inside EH regions.
* Use atomic/volatile loads and stores for the terimation flag in thread-suspend-suspended.
LLVM was hoisting the load of and branch against `finished` out of
thread t1's loop, resulting in an infinite spin.
* Use ImplicitNullChecks with LLVM JIT.
* Suppress emission of the .llvm_faultmaps section.
Bump external/llvm to release_60
(7a8dc89adbe7e123220e070a527e096ee91e66d5).
* [ci] use LLVM built from repository
* [wasm] Change netcore support to use a prebuilt corefx runtime.
* [wasm] Build and test netcore support on CI.
* [wasm] Disable netcore tests on CI for now.
* [wasm] Add an error check.
* [wasm] Add a linker exclusion.
* [wasm] Add netcore runtimes to the nupkg.
* Rewrite the rest of the array non-generic fast paths in C# (#27703)
* Rewrite the rest of the array non-generic fast paths in C#
* Add missing resource string
* Use CorElementType and handle native ints to match the unmanaged implementation
* Avoid try pattern for Sort and Reverse
* Match the native implementation more closely
Signed-off-by: dotnet-bot <[email protected]>
* Rewrite Enum.CompareTo in C# (dotnet/coreclr#27792)
* Rewrite Enum.CompareTo in C#
* Handle floating point too for match the existing native implementation
Signed-off-by: dotnet-bot <[email protected]>
* Remove unused argument from GetRegionDisplayName (dotnet/coreclr#27806)
* Remove unused argument from GetRegionDisplayName
* Address race conditions in CultureData
While most of the race conditions in this file are benign, in these cases, a thread could end up returning an intermediate value due to multiple potential writes to the same field.
Signed-off-by: dotnet-bot <[email protected]>
* Fix StyleCop rule SA1129 ("Do not use default value type constructor") (#27716)
Will enable the rule in corefx once these changes have propagated.
Signed-off-by: dotnet-bot <[email protected]>
* Remove non-shared Enum.CompareTo/InternalCompareTo implementation, add new Array icalls used by shared code
This has the following benefits:
* Clearer structure for mirroring
* Slight build time improvement on bundled zlib use (as it only builds once)
* Removes pages of subdir-objects spew from autogen
[WinForms] Fix#10559 In MaskedTextBox wrong Lines value when Mask se…
<!--
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
-->
* [WinForms] Fix#12249 scroll orientation was not defined in ScrollEventArgs of ScrollBar.cs
* [WinForms] Fix 12249 scroll orientation was not defined in ScrollEventArgs of DataGridView.cs
It tried to use dynamic codegen which is not available in FullAOT.
We can use the `RuntimeFeature.IsDynamicCodeSupported` to check for this, added a JIT intrinsic which returns false in FullAOT.
Used a linker friendly way to check for TypeBuilder by adding an `internal virtual IsTypeBuilder` method in the `Type` class which returns false, and overwrote it in `TypeBuilder`.
* [wasm] Bump emscipten to 1.39.2.
* Disable some code in libtest.c which causes emscripten to fail.
* [wasm] Source emscripten env before make install as well.
* Add EventWaitHandle creation extension method that takes an ACL (#42213)
* Add EventWaitHandle creation extension method that takes an ACL
* Call OpenExisting, add basic unit tests, move MAX_PATH in csproj for all Windows platforms, ensure same exceptions are thrown in both netcore and netfx.
* Address suggestions: using for the created handle, simplify try finally, merge methods, remove an unnecessary Debug.Assert
* simplify using, reorganize PInvokes a bit, let VS format resx as it expects it, remove BOM from csproj
* Add more unit tests
* Save basic access rights in a constant, generate name randomly
* Use FullControl (EVENT_ALL_ACCESS); update unit tests to use EventWaitHandleRights
* Apply suggestion of creating an EWH, then replacing its SWH.
* Remove using causing chaos, add more unit tests, remove null string unit test.
* spacing
* Address comments
* Remove unnecessary checks/exceptions, update unit tests
* Fix netfx x86 ut failure - different exception for mode validation.
* Small documentation fix
* Remove documentation for exception thrown with null security
* more documentation fixes
* New file for unit tests
* Dispose and remove windows only attributes in tests
* suggestion to not use var
* Remove duplicate resx after merge
* Readd cs files lost during merge
* Remove resx modification since it was untouched for this PR
* Address test comments
Signed-off-by: dotnet-bot <[email protected]>
* Move NativeLibrary.Free null check to managed (dotnet/coreclr#27744)
Signed-off-by: dotnet-bot <[email protected]>
* Arm64: Add S.P.CoreLib instrinsics UnzipEven and UnzipOdd (#27731)
Signed-off-by: dotnet-bot <[email protected]>
Approved API Proposal: #41662
Description
We don't currently have a way to create a Semaphore with a given ACL in .NET Core. We can modify the ACL, but it would be more secure to have the proper ACL on the object from the start.
Customer impact
Before this change, customers had to create a Semaphore, then set its ACLs. This presents a few problems:
- Potential security hole as semaphores can be accessed between creation and modification.
- Porting difficulties as there isn't a 1-1 API replacement
This change addresses those problems by adding a new extension method that allows creating a Semaphore and ensuring the provided ACLs are set during creation.
Signed-off-by: dotnet-bot <[email protected]>
* [reflection] Pass assembly load context through mono_reflection_get_type_with_rootimage
The entry points are mono_reflection_type_from_name_checked and
mono_reflection_get_type_checked which for now pass in an ambient ALC, but
should be updated to take an ALC argument.
Internally mono_reflection_get_type_with_rootimage is recursive through a half
dozen helper functions which all get an ALC argument too.
The principle place where the ALC is used is in
_mono_reflection_get_type_from_info which passes it to
mono_assembly_loaded_internal and to replace the call to mono_assembly_load by
a direct call to mono_assembly_request_byname with an explicit ALC set in the
request.
* Mark mono_assembly_load as external only
* Pass an alc through non-static reflection functions
* Fix usage in wasm debugger
* Relax assertions due to wasm
- Allows the on-device runner to work with the xunit framework in preparation for netcore.
- Added a simple UI to show the test run progress
- Report the test result XML back to the host so we can process it on Jenkins/AzDO
* [profiler] Add test case for pinvokes and reverse pinvokes
* [profiler] Fix crash in native to managed wrappers
When we call back to managed from a pinvoke, we're in GC Safe mode and the
profiler instrumentation is inserted in the wrapper before it does the
transition to GC Unsafe. So we need an extra transition before the profiler
calls its locking functions
Fixes https://github.com/mono/mono/issues/17687
* [coop] Mark internal GC Unsafe functions with MONO_PROFILER_API
Allow the profiler to transition to GC Unsafe mode
* [profiler] ptestrunner.pl fix profiler modules directory
we used to specify mono/mini/.libs but that's not where the profiler plugins live, they're in mono/profiler/.libs. We probably picked up the profiler plugins from the system Mono install.
Approved API Proposal: #41662
Description
We don't currently have a way to create a Mutex with a given ACL in .NET Core. We can modify the ACL, but it would be more secure to have the proper ACL on the object from the start.
Customer impact
Before this change, customers had to create a Mutex, then set its ACLs. This presents a few problems:
Potential security hole as mutexes can be accessed between creation and modification.
Porting difficulties as there isn't a 1-1 API replacement
This change addresses those problems by adding a new extension method that allows creating a Mutex and ensuring the provided ACLs are set during creation.
Signed-off-by: dotnet-bot <[email protected]>
Running Start-Process, Wait-Process on msbuild.exe have showed a couple
of hangs in the build script. This is most likely due to msbuild.exe
spawned child processes (like compile servers) running longer than
spawned msbuild.exe process. Since there is no specific requirements
when spawning the process from build.ps1, switch to regular process
exec and LastExitCode.
* Add Span<T>.Sort
Shares existing Array-based implementation by changing that implementation to be span based.
* Additional work to enable span-based sorts
- Cleans up changes from the previous commit, e.g. corrects nullable annotations, removes TODOs, using GetRawSzArrayData instead of GetRawArrayData, etc.
- Passes spans around rather than spans+lo+hi.
- Deletes the native TrySZSort, preferring to use the managed implementation in all cases.
Signed-off-by: dotnet-bot <[email protected]>
* Prevent DivideByZeroException in EventCounter.ToString()
Maybe it should print something other than 0. Maybe "Mean" should be excluded. But at least with this it doesn't divide by zero. Ternary operator in interpolated string is not super readable; didn't know if making the code more descriptive would have performance implications.
* Update src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs
Co-Authored-By: Stephen Toub <[email protected]>
Signed-off-by: dotnet-bot <[email protected]>
* [mini] Fix Coverity CID 1455161 & 1455162
> Null-checking "ji" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
* do not rely on assert to guard ji-nullness. refactor a bit
* Fix correct accumulated time for parallelized jobs in SGEN.
Current implementation incorrectly accumulate time for scan jobs for
the follow metrics when running parallel minor GC:
time_minor_scan_major_blocks,
time_minor_scan_los,
time_major_scan_mod_union_blocks,
time_major_scan_mod_union_los
Commit fix so updates are atomic making sure values are correct in cases
where parallel minor GC is used.
* Implement 64-bit atommic add fallback in SGEN.
We didn't do this because it had some issues when GetType was invoked through reflection. This issue would also be present with jit but, because jit doesn't use direct wrappers, the GetType call can't be intrinsified in that scenario. See https://github.com/mono/mono/pull/5350 for the context of the issue.
Discovered by Coverity:
```
>>> CID 1455205: (CONSTANT_EXPRESSION_RESULT)
>>> The expression "flag && 2" is suspicious because it performs a
Boolean operation on a constant other than 0 or 1.
```
Support for Windows Mono NetCore build/test wihtout any need for
cygwin/wsl/automake just MSBuild and MSVC. Windows build support mirror
technologies used by coreclr/aracade builds msbuild + powershell.
Windows only Mono NetCore build, makes a port of existing build.sh and
Makefile, implementing a build.ps1 and build.targets. So far full build
support + execution of corefx test suite is implemented. Other make file
rules can be added when needed.
MSVC build runtime seems to hits a couple of additional test failures
in corefx test suite that needs to be investigated further.
Building NetCore Mono on Windows can now be done without cygwin or wsl.
Build depends on regular VS install (or build tools), if xunit summary
is requested, python needs to be installed.
Move MonoError from managed wrappers to native wrappers.
Move MonoError from managed wrappers (ilgen) to native wrappers (C preprocessor).
Alternative to https://github.com/mono/mono/pull/15869.
Which says: Previously, we would emit a call to memset
since the struct is large (> 100 bytes). Only the error code
field needs to be initialized.
Which that PR and this PR both fix, in different ways.
In the past:
- This did not work due to a possible dependency on precise GC,
interacting with what gets zeroed or not here.
That is why I put it on the managed side.
We'll see if that reproduces.
(https://github.com/mono/mono/pull/11294/files#diff-efe0070415f3f0c0f24ed0221aa1962aR339
external/coreclr/tests/src/CoreMangLib/cti/system/weakreference/weakreferenceisaliveb.exe.)
- Some indication that embedding API should expose MonoError
and not set_pending_exception. This does not seem relevant
presently, and the code seems better structured and
more efficient this way. It can revisited if/when new public API
is the dominant concern, or do it this way for these functions,
and another way for actual public functions.
(https://github.com/mono/mono/pull/11294#issuecomment-432443485)
* [netcore] Remove the type_info field from RuntimeType, extend the TypeCache structure instead.
* [netcore] Remove some linker exclusions which are not needed.
Doing this we avoid using slow ldrmfld in the common case of loading fields from instance methods, when we execute on the real object. We could do this also for strmfld but we need to track on the stack if the instance object is this, which is not worth the trouble.
* [interp] Optimize void calls
By avoiding setting of retval
* [interp] Avoid computing param count for every call
* [interp] Remove wrong profiler check
From the times when interp had its own EH mechanism. We raise this event from mono_handle_exception_internal for interp.
* [interp] Remove profiling check code from method exit
We emit MINT_PROF_EXIT opcode when under profiler. Unify profiling enter/exit with tracing enter/exit since they are very similar.
* Modify run-jenkins.sh to adapt wasm build for the OSX CI lane
* Round 2... Go
* Make ENABLE_WASM_DYNAMIC_RUNTIME conditional on non-OSX
* Add runtime-threads target
* Ignore 'multiple rules generate' on osx
* Fix typo
* Remove blank line
* Exclude CoreXml.Test.XLinq.FunctionalTests.EventsTests.EventsReplaceNodes.XElementReplaceNodes
* Revert "Ignore 'multiple rules generate' on osx"
This reverts commit 5010721bd710d6955aaee47aa7f49ad7845763fc.
* Check if OSX lane can follow general build flow
On top of https://github.com/mono/corefx/pull/369 this improves the execution time of `System.Core-xunit` on Linux/ARM64 by 2x, so from:
```console
$ make -C mcs/class/System.Core run-xunit-test
[...]
=== TEST EXECUTION SUMMARY ===
net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 131.143s
```
to
```console
$ make -C mcs/class/System.Core run-xunit-test
[...]
=== TEST EXECUTION SUMMARY ===
net_4_x_System.Core_xunit-test Total: 48774, Errors: 0, Failed: 0, Skipped: 6, Time: 74.636s
```
This is only relevant for non-netcore. The CoreCLR folks just recently fixed something similar (thanks to Marek sharing this link): https://github.com/dotnet/coreclr/pull/27543
* [wasm] Error out on duplicate assemblies in the packager.
* [wasm] Switch search path order to avoid duplicate references to assemblies.
* Copy all xunit binaries to test_lib_dir.
* Revert "Copy all xunit binaries to test_lib_dir."
This reverts commit b15b03c16b508c04dc6121196fddca0e6d949e2f.
* [interp] Don't print NOPs during cprop
They can become numerous and distracting.
* [interp] Fix mono_interp_print_code
Regressed after code_size was changed to byte count instead of short count.
The default behavior on .NET Framework is _HotkeyPrefix.None_ when creating a _TabControl_ element (ampersands not escaped).
If an user wants to override this behavior, he has to declare a _DrawItemEventHandler_ (with _DrawMode = OwnerDrawFixed_).
Fixes#16206
- Use string.IndexOf rather than an open-coded, unsafe loop.
- Avoid an unnecessary SequenceEquals at the end: we're only at this point if a `%` was found highlighting that something escaped was found.
- Use stack memory for smaller inputs if possible, to avoid unnecessary ArrayPool interaction
- Remove an unnecessary argument to a helper function.
- Fix ValueStringBuilder.Grow to only copy the contained data.
Signed-off-by: dotnet-bot <[email protected]>
* [netcore] Move corlib around to match CoreCLR directory layout better
This is a prerequisite to making a sane migration of this whole
directory from mono.git to coreclr.git
* Revert removal of SuppressGCTransition from SystemNative_GetTimestamp() (#27473)
* Revert removal of SuppressGCTransition from SystemNative_GetTimestamp()
* Insert GC_POLL before statement with unmanaged call.
* JIT test for insertion of GCPoll
Signed-off-by: dotnet-bot <[email protected]>
* Add file creation method that takes an ACL (dotnet/corefx#42099)
Approved API Proposal: #41614
Related change for directory creation method that takes an ACL: #41834 -merged and ported to 3.1 Prev2
Description
We have extension methods in System.IO.FileSystem.AclExtensions that let the user get and set ACLs for existing files, but we do not have methods that create files with predefined ACLs.
.NET ACL (Access Control List) support is Windows specific. This change will reside inside the System.IO.FileSystem.AccessControl assembly.
Customer impact
Before this change, customers had to create a file or filestream, then set its ACLs. This presents a few problems:
Potential security hole as files can be accessed between creation and modification.
Porting difficulties as there isn't a 1-1 API replacement
Stability issues with background processes (file filters) can prevent modifying ACLs right after creation (typically surfaces as a security exception).
This change addresses those problems by adding a new extension method that allows creating a file and ensuring the provided ACLs are set during creation.
This change is expected to be backported to 3.1.
Signed-off-by: dotnet-bot <[email protected]>
* [runtime] Add a stub for MacOsIPInterfaceProperties::ParseRouteInfo icall on non-osx platforms to fix the wasm aot build.
* [wasm] Avoid generating invalid ninja build files if an assembly is specified on the command line and its also an implicit reference.
* Put back and ifdef.
* Fix the windows build.
1. Fix NullReferenceException. When the filter args exceeded the
hard-coded size limit GetDataFromController would return data = null.
The code previously asserted that data was not null and triggered NRE
when it was. The fix correctly null checks the value instead of
asserting and uses an empty args dictionary in this case, the same as if
filter args had been empty to begin with.
2. ETW has always limited filter args to 1024 bytes but EventPipe has no
such restriction. When using DiagnosticSourceEventSource it can be
useful to specify a larger filter arg blob. I can't do anything about
ETW's restriction but there is no need for the runtime to force
EventPipe to be equally limited. The larger size also reduces the chance
that we need to hit the fallback path above causing filter args to be
ignored.
Signed-off-by: dotnet-bot <[email protected]>
ReadAsyncInternal is correctly passing its token into the two call sites where it delegates directly to the underlying stream, but in one place it calls through ReadBufferAsync, which is currently not defined to take a token. Fix that, and pass the token through.
Signed-off-by: dotnet-bot <[email protected]>
The stubbed out SecurityElement implementation does not support extensibility that ISecurityElementFactory was designed for.
Signed-off-by: dotnet-bot <[email protected]>
[mini] Initial tiered compilation work
Enable it with `./autogen.sh --enable-experiment=tiered`.
Let's consider `Simple.cs`:
```csharp
using System.Runtime.CompilerServices;
using System;
public class Simple {
public static void Main (string []args) {
HotMethod ();
Console.WriteLine ("cnt: " + cnt);
HotMethod ();
Console.WriteLine ("cnt: " + cnt);
}
static int cnt = 0;
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void HotMethod () {
for (int i = 0; i <= 1000; i++)
cnt += i;
}
}
```
```console
$ csc Simple.cs
$ MONO_LOG_LEVEL=debug MONO_LOG_MASK=tiered ./mono/mini/mono-sgen --trace=M:Simple:HotMethod --interp=-all Simple.exe
[0x10ec275c0: 0.00000 0] ENTER:i Simple:HotMethod ()()
Mono: tiered: queued Simple:HotMethod ()
[0x10ec275c0: 0.00010 0] LEAVE:i Simple:HotMethod ()(
Mono: tiered: patching 0x7fe855803224 with patch_kind=INTERP @ tier_level=0
Mono: -> caller= Simple:Main (string[]) [{0x7fe85420df88} + 0x34 interp] (0x7fe8558031f0 0x7fe855803258) [0x7fe85420c880 - Simple.exe]
Mono: -> callee=Simple:HotMethod ()
Mono: tiered: patching 0x7fe8558031f2 with patch_kind=INTERP @ tier_level=0
Mono: -> caller= Simple:Main (string[]) [{0x7fe85420df88} + 0x2 interp] (0x7fe8558031f0 0x7fe855803258) [0x7fe85420c880 - Simple.exe]
Mono: -> callee=Simple:HotMethod ()
cnt: 500500
[0x10ec275c0: 0.04093 0] ENTER:c Simple:HotMethod ()()
[0x10ec275c0: 0.04095 0] LEAVE:c Simple:HotMethod ()(
cnt: 1001000
```
Note the suffix after `ENTER:`
* `i` indicates it's executed by the interpreter
* `c` indicates it's a compiled method (JIT)
Another example:
```console
$ make -C mono/mini gshared.exe
$ ./mono/mini/mono-sgen --interp=-all --stats ./mono/mini/gshared.exe
Regression tests: 84 ran, 0 failed in Tests
[...]
Tiered statistics
Methods promoted : 68
```
It's a basic proof-of-concept for now. An incomplete list of future work items:
* Right now it only works for direct calls, need to expand it to virtual/interface calls.
* Calls of the JIT leading into the interpreter again can't be patched yet.
* Kind of related, no concept of versioning compiled methods does exist yet. The interpreter maintains its own table of "transformed" methods, however, when doing the transition from JIT->interpreter, the wrapper+interpmethod will end up in the JIT table. We need a way to have multiple JIT compilation results for the same MonoMethod exist.
* Investigate actual performance. We might have to optimize the interp<>JIT transition.
* Patching is racy. Need to make that atomic.
* All the FIXMEs in this PR
<!--
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 newLine parameter to StringCoda methods
* Update Options.cs to handle both kinds of newlines
* Add test to OptionSetTest
* Directly handle \r\n instead of using the TextWriter.NewLine
* Additional and adjusted logging for parallel minor GC.
When running parallel minor GC we currently get incorrect timing
on several loggings and counters due to work being put on thread pool
and accumulated. This commit fix so that the logging is accurate
when running with and without parallelization. In parallel mode a new
logging is also added to show the accumulated split between major and los
remset scan jobs.
The counters time_minor_scan_remsets and time_minor_scan_roots are only
updated when not running parallel GC since they are not correct when
running parallel GC.
* Fix WASM build error.
The offsets-tool.py uses some magic to map `typename` to `<underscore>typename` for looking up runtime types.
This caused issues on netcore because we aliased it to a different name.
To fix this let's keep the `_MonoInternalThread` name instead and just fix the one location where `_MonoThread` is used.
* dump_native_stacktrace should always register the sigterm handler.
Cherry picked from the https://github.com/mono/mono/pull/17310
* [merp] Introduce a new 'dump mode' that allows different signal behavior when dumping
The primary reason for this is gaining the ability to interpret SIGTERM properly as a crashing signal when outside of 'dump mode', and as a utility signal during the 'thread summarizer' dumping process.
When embedders call mono_runtime_quit or mono_jit_cleanup, we need to do unbalanced transitions to GC Unsafe, because after mini_cleanup runs we don't have GC thread states anymore and MONO_EXIT_GC_UNSAFE will assert.
* [runtime] Do an unbalanced GC Unsafe transition in mono_jit_cleanup
After mini_cleanup, we don't have GC thread states anymore because all that
stuff was cleaned up, so MONO_EXIT_GC_UNSAFE would assert
* [runtime] Mark mono_runtime_quit external only.
Runtime should use mono_runtime_quit_internal.
After we call the quit_function (aka mini_cleanup) we don't have any GC thread
states anymore because all that stuff got cleaned up. So MONO_EXIT_GC_UNSAFE
can't work.
- The code passed to `CompileFunction` is not a function definition. Instead it must create and return a function instance.
- Solves the problem of accessing `Node.js` functionality as defining a JavaScript function executes in the global space and does not get `Node.js` access.
- Returning a function instance allows the function to initialize and maintain encapsulated state.
* [interp] Optimize stelem instructions
* [intepr] Optimize stelem_ref and slowpath casts
mono_object_isinst_checked uses coop handles and is very slow. Attempt to use the straightforward mono_class_is_assignable_from_checked.
Makes stelem_ref 5x faster.
* always use -place-safepoints pass in JIT mode
* ignore loaded llvm
* remove gc.safepoint_poll after optimizations
* fix typo
* cleanup
* cleanup
* cleanup
* cleanup
* Do not emit safepoints on entry thus simple functions (without calls and loops) won't have them at all
* Undo -spp-no-entry=true
* fix failing tests
* do not emit sp in Allocators
* Fix `System.Diagnostics.Trace.TraceError` crash.
- WASM does not have access to the command line arguments through the browser so the length is 0 causing index out of range error.
- The zero index of the command line arguments is what decides the `AppName` so under WASM the AppName will be blanks.
* Address review comments
* Remove #ifdef for WASM only.
- Addresses review note.
- As per channel discussion some embedding scenarios might be the same.
Some of the includes already were unconditional, including both on Win32 and Unix.
It is part of ANSI C 89, albeit in a reduced form compared to typical Unix (no sigaction).
Remove configuration of MSG_NOSIGNAL which has no other uses.
Preserve configuration of signal.h temporarily due to other uses of ifdef HAVE_SIGNAL_H.
i.e. LLVM?
* [cxx][x86] Another int/ptr cast.
* More casts. Notice these are under
`#if defined (MONO_ARCH_USE_SIGACTION) && !defined (MONO_CROSS_COMPILE)`
which would explain them not showing up.
* use GC.AllocateUninitializedArray for allocating internal char buffers
* force inlining of AllocateUninitializedArray to have no perf hit on the small buffers hot path
* insrease the threshold from 256 to 2048 bytes
* use Unsafe.As instead of a cast
* remove the size precondition from AllocateNewArray method, the called AllocateSzArray is responsible for handling negative size
Signed-off-by: dotnet-bot <[email protected]>
* Updating S.P.Corelib to start building Vector2/3/4 and supporting types
* Removing HAS_INTRINSICS usages from Matrix4x4
Signed-off-by: dotnet-bot <[email protected]>
### Overview
After the removal of the Legacy TLS Provider, we can make some cleanups and improvements to the `SslStream` class. Since both the remaining providers use the internal `MobileAuthenticatedStream` and support Task-async code, we can get rid of some of the Begin/End async logic and the the underlying
`Stream` class handle it instead.
This also fixes a nasty issue with some of those task objects leaking unobserved exceptions. The problem was that `SslStream.Dispose()` needs to clear out all resources, but in doing so also nulls out the `Impl` handle to the `MobileAuthenticatedStream` - so a subsequent `End*()` call will not reach it's corresponding `TaskToApm.End()` method.
There are also some cleanups in the internal APIs that were only ever used internally and not intended for public consumption.
### Mono.Security.dll
* `Mono.Security.Interface`: removed internal `ICertificateValidator2` interface.
* `Mono.Security.Interface.IMonoSslStream`: this internal interface is only used by the web-tests, which only use it as a way to get the `SslStream` instance, so all those `Begin/End` async methods are now gone.
* `Mono.Security.Interface.IMonoSslStream2`: removed another internal interface.
* `Mono.Security.Interface.MonoTlsProvider`: removed some `internal abstract` methods; these have been moved into a new `Mono.Net.Security.MobileTlsProvider` inside `System.dll`.
### System.dll
* `Mono.Net.Security.MobileTlsProvider`:
New abstract internal base class, which received the aforementioned abstract internal methods. The naming is such to make it consistent with the already existing `MobileTlsContext` and `MobileAuthenticatedStream`.
Since both `AppleTlsProvider` and `BtlsProvider` now have an abstract internal base class inside `System.dll`, they can use the `ChainValidationHelper` class directly and we can also avoid some `Mono.Security` dances like for instance that `MonoSslPolicyErrors` enum.
This will also help make the code easier to read and maintainer.
* `Mono.AppleTls.AppleTlsProvider` and `Mono.Btls.MonoBtlsProvider`: change base class into `MobileTlsProvider` and reflect above mentioned overload changes.
* `Mono.AppleTls.AppleCertificateHelper`: use `ChainValidationHelper` as well.
* `Mono.Net.Security.ChainValidationHelper`: only implement `ICertificateValidator`.
The `ICertificateValidator` interface is still required because it is in use by the web-tests, but the previous `ICertificateValidator2` was an internal dance.
* `Mono.Net.Security.MobileAuthenticatedStream`: largely cleaned up this class.
- we now implement the current slimmer version of `IMonoSslStream`.
- moved all those overloads into `SslStream` that only fill in default values for some of their arguments and then call another overloaded version of their own.
- removed lots of `Begin/End` methods that are not used anymore.
* `Mono.Net.Security.MonoTlsProviderFactory`: use `MobileTlsStream` everywhere.
* `Mono.Net.Security.MonoTlsStream`: cleanup `SslStream` creation logic; instead of going throw `provider.CreateSslStream()`, we can now use an internal constructor directly, thus avoiding the `IMonoSslStream` interface while also making the code a lot easier to read and understand.
* `System.Net.Mail.SmtpClient`: same here.
* `System.Net.HttpWebRequest`: use `MobileTlsProvider`.
* `System.Net.Security.SslStream`: largely cleaned up this class.
- we now use `MobileAuthenticatedStream` directly instead of the `IMonoSslStream` interface and therefore could also get rid of `IMonoSslStream2`.
- cleanup constructor logic to allow the internal constructor being used with a `MobileTlsProvider` instead of going through `provider.CreateSslStream()`.
- all those overloads that are only filling in default values for some of their arguments before calling another overloaded version of their own now live here instead of in the `MobileAuthenticatedStream` class. The reason is to simply that `MobileAuthenticatedStream` is already quite a complex and difficult class, and removing some of that complexity out of it will make it easier to understand.
- handle the `TaskToApm.Begin()` / `TaskToApm.End()` here to ensure that we are not leaking any task objects with unobserved exceptions.
- removed `BeginRead()` and `BeginWrite()` overloads to let the underlying `Stream` class handle these.
* Bump API snapshot submodule
* [csproj] Update project files
* fix eglib on AIX/PASE
* Work around access(2) syscall bug on PASE
On PASE, X_OK will always returns true. This is contrary to
how AIX behaves (though corresponds to documentation!). This
is probably because it's an upcall to the ILE version of
access, and that seemingly always returns true.
* Always export the dummy function in the test suite
The AIX linker didn't export this properly, without using the
giant sledgehammer of -bexpall. Write an export file and use
it. This required some build system changes to expose an
AIX-only automake conditional.
* Use a file that exists on PASE for tests
PASE doesn't use Unix-style DNS resolution, so /etc/hosts is
missing. Use /etc/magic, since that seems to be present.
* Don't use /bin on AIX/PASE for tests
This is a symlink to /usr/bin, and it seems chdir/getcwd
follows links. Use /usr instead, that is unlikely to be a
symlink.
* Make a note what directory we're in if we fail test_cwd
* Change manual executable access check change per Jay
* Change test on POSIXy platforms to always use root directory
* [interp] Add also floating versions for stloc.np
* [interp] Add super instructions for stfld
When storing into a field of a local or an argument (ldloc/ldarg -> random instructions that end up pushing one value -> stfld). We add this instruction to the cprop pass because the instructions that are optimized together are not consecutive and we need the stack information to be able to access the instruction that loaded the argument / local and to make sure that the local wasn't dirtied. Alternatively we could make the super instruction pass stack aware, which we should probably do if more super instruction candidates turn out to require stack state information.
* [interp] Enable cprop for methods without locals
We do some optimizations here that don't apply to locals.
* [interp] Fix result stack type of CEE_CONV_OVF_I_UN
With this change we will get the following logging on level 1:
2019-10-22 15:46:59 Start nursery collection 38898 00000205A0000000-00000205A1000000, size: 16777216
2019-10-22 15:46:59 restarted (pause time: 2728 usec, max: 689233 usec)
showing the pause time and when runtime was restared, before this fix
we will only see the start log message on level 1.
* Wire up the managed side of the portable thread pool
* Remove old native thread pool code
* Fix non-netcore build
* Fix Thread.IsThreadPoolThread
* Fix MSVC builds
* Code style fix
* Make the locking primitives uninterruptible
* Revert icall changes for non-netcore
* Implement Thread.ResetThreadPoolThread
* Compile out more thread pool code for netcore
* Remove ThreadPoolBoundHandle, it is shared now
* Address PR feedback on code style
Today `async ValueTask/ValueTask<T>` methods use builders that special-case the synchronously completing case (to just return a `default(ValueTask)` or `new ValueTask<T>(result))` but defer to the equivalent of `async Task/Task<T>` for when the operation completes asynchronously. This, however, doesn't take advantage of the fact that value tasks can wrap arbitrary `IValueTaskSource/IValueTaskSource<T>` implementations.
This commit gives `AsyncValueTaskMethodBuilder` and `AsyncValueTaskMethodBuilder<T>` the ability to use pooled `IValueTaskSource/IValueTaskSource<T>` instances, such that calls to an `async ValueTask/ValueTask<T>` method incur 0 allocations (ammortized) as long as there's a cached object available.
Currently the pooling is behind a feature flag, requiring opt-in via the DOTNET_SYSTEM_THREADING_POOLASYNCVALUETASKS environment variable (setting it to "true" or "1"). This is done for a few reasons:
- There's a breaking change here, in that while we say/document that `ValueTask/ValueTask<T>`s are more limited in what they can be used for, nothing in the implementation actually stops a `ValueTask` that was wrapping a `Task` from being used as permissively as `Task`, e.g. if you were to `await` such a `ValueTask` multiple times, it would happen to work, even though we say "never do that". This change means that anyone who was relying on such undocumented behaviors will now be broken. I think this is a reasonable thing to do in a major release, but I also want feedback and a lot of runway on it.
- Policy around pooling. Pooling is always a difficult thing to tune. Right now I've chosen a policy that limits the number of pooled objects per state machine type to an arbitrary multiple of the processor count, and that tries to strike a balance between contention and garbage by using a spin lock and if there's any contention while trying to get or return a pooled object, the cache is ignored. We will need to think hard about what policy to use here. It's also possible it could be tuned per state machine, e.g. by having an attribute that's looked up via reflection when creating the cache for a state machine, but that'll add a lot of first-access overhead to any `async ValueTask/ValueTask<T>` method. For now, it's tunable via the `DOTNET_SYSTEM_THREADING_POOLASYNCVALUETASKSLIMIT` environment variable, which may be set to the maximum number of pooled objects desired per state machine.
- Performance validation. Preliminary numbers show that this accomplishes its goal, having on-par throughput with the current implementation but with significantly less allocation. That needs to be validated at scale and across a variety of workloads.
- Diagnostics. There are several diagnostics-related abilities available for `async Task/Task<T>` methods that are not included here when using `async ValueTask/ValueTask<T>` when pooling. We need to evaluate these (e.g. tracing) and determine which pieces need to be enabled and which we're fine omitting.
Before shipping .NET 5, we could choose to flip the polarity of the switch (making it opt-out rather than opt-in), remove the fallback altogether and just have it be always on, or revert this change, all based on experimentation and data we receive between now and then.
Signed-off-by: dotnet-bot <[email protected]>
* Removing all fixes to fix#15203 and #17083, and trying a new approach to fix this #17084, together.
The thing is when we are executing on hybrid suspend the caller is executed inside try catch in the runtime_invoke_ method that is generated. And this try catch should be ignored for the debugger exception, otherwise it's the last try catch in main thread, but should always be considered to generate the stack trace.
Fixes#17084
* This test check the case that we were missing. On preemptive this test always runs perfectly, on Hybrid, never run well until this PR.
* Changing how call unit test.
Changing variable name.
Scanning LOS list as part of minor GC didn't parallelize well since
all scan jobs needed to walk the complete LOS list. This led to touching
a lot of memory walking the list, increasing minor GC pause times
when the number of items in the LOS list increased. As an example,
stressing LOS data structure using ~600 MB's of random sized byte arrays
caused minor GC pause times between ~20ms without parallelization and ~19ms
with parallelization. NOTE, the more work each job gets (more memory to scan)
we will get a better parallelization, but still a lot of room for improvement.
Changing from a normal linked list to a SgenArrayList makes it more effective
to parallelize the scan jobs and since the list is using sequential
memory, this will also reduce cache misses for each thread iterating LOS
objects. Tagging objects in SgenArrayList with reference information reduce
cache misses dramatically in cases where objects not including references
exists on the list, since scanning jobs can skip these items without any
need to touch object memory causing cache misses.
Same scenario running with fix gives us minor GC pause times, without
parallelization in ~7ms (down from 20~ms) and with parallelization,
< 5ms (down from 19ms). NOTE, the more work each job gets (more memory to scan)
we will get a better result using parallelization, so the delta will increase
between using and not using parallelization, this scenario primarily stress
the extreme case where most LOS objects doesn't have references.
In total, this optimization reduce minor GC pause time 4x, from ~19ms when
using parallelization down to < 5ms.
[wasm] Avoid adding an extra arg to native-to-managed wrappers.
Fixes https://github.com/mono/mono/issues/17389.
<!--
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
-->
* Adding SkipInit to Internal.Runtime.CompilerServices.Unsafe
* Updating the runtime to handle Unsafe.SkipInit
* Updating Decimal.DecCalc to use Unsafe.SkipInit
* Removing 'workaround for CS0165' comments
Signed-off-by: dotnet-bot <[email protected]>
Together with a few very simple super instructions. We replace common instruction patterns to avoid indirection via interp stack, instruction dispatch overhead and to allow the compiler to generate better code for the instruction.
When replacing a stloc with a pop, we should retry the pass, since it is very likely that we will be able to kill the instruction that pushed that value on the stack.
* [test] GetCustomAttributes on generic type definition
* [reflection] mono_method_get_base_method on a GTD should use canonical ginst
The issue is in how we pass along the generic instantiation. So there are two
parts here: we start with a method on a GTD which has to decompose into the GTD
and it's instantiation with its own generic parameters, and then we go up to
its parent and grandparent inflating and decomposing the resulting
instantiation. The instantiations keep passing the last parameter as the number
of parameters shrinks so that the gparam index from the original type is now
out of bounds for the parent and grandparent. If we mess up, we'll get a
BadImageFormatException from the runtime
Fixes https://github.com/mono/mono/issues/17278
* [checked] Mask the thread state in GC thread state assertions
Because we have extra bits (like suspend count and the no_checkpoints bit) on
the thread state, we have to mask it to get the actual thread state enum value
* [coop] Use bitfields to represent coop thread state
Instead of using a 32-bit int, use bitfields and type-punning through a union
type. We need to type pun because we need to access the entire state as a 32-bit int so that we can do atomic CAS.
* use atomic load of thread state in unwrap_thread_state.
Saw one stack trace on CI on the full coop lane where check_thread_state saw STATE_RUNNING
but with a positive suspend count. Another thread was starting a GC a
the time. Seems like we saw the state as runnning, but the suspend
count as if we were already in async_suspend_requested.
Thread 22 (Thread 0x7f43c03ff700 (LWP 39860)):
- Merge RuntimeImports that has just a few FCalls into Buffer.
- Delete assembly implementation of memcpy for ARM. The implementation was outdated and it was used only on Windows ARM and only for fraction of memcpy callsites.
- Delete unnecessary PInvoke into SysStringLen. We have a managed equivalent on System.Runtime.InteropServices.Marshal.
- Delete large amount of redundant code between SecureString.Windows.cs and SecureString.Unix.cs, and switch SecureString to use Spans
- Fold null check into IsWin32Atom
Signed-off-by: dotnet-bot <[email protected]>
* Rewrite Buffer.BlockCopy in C#
Fixes#27106
* Workaround to enable type check optimizations for BlockCopy only
Signed-off-by: dotnet-bot <[email protected]>
* Updating double.IsNaN and float.IsNaN to just `return x != x`
* Updating x86 codegen to optimize `x != x` for floating-point
* Changing the isnan optimization to only check the operand assigned registers
Signed-off-by: dotnet-bot <[email protected]>
* Wrap MoveNext Action for TPL event tracing
Wraps the MoveNext action of the AsyncStateMachineBox in a
continuation wrapper when async causality tracing is on so that the
TPL event source can find the task that is associated with a
continuation. Does not wrap otherwise.
* Clarifying comment
* removing trailing whitespace
* code review feedback.
Makes AsyncMethodBuilderCore.TryFindContinuationTask check to
whether the target of a continuation is itself a task, as a fall-back
to checking to see if the continuation is a ContinuationWrapper
* Got rid of unnecessary null checks
Signed-off-by: dotnet-bot <[email protected]>
* Provide mechanism to remove the GC transition from a P/Invoke.
New Attribute: 'System.Runtime.InteropServices.SuppressGCTransitionAttribute'
Signed-off-by: dotnet-bot <[email protected]>
* [jit] Avoid running mono_handle_native_crash () on the altstack, it can't produce a backtrace. AMD64 only for now.
* Fix checks so stack overflows work again.
In file included from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android/mono/metadata/icall.c:42:
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android/mono/metadata/icall-internals.h:89:10: fatal error: 'type_traits' file not found
- The checking for the existence of the object is incorrect: Missing parens around undefined.
- Modify error description returned back to managed code.
- Fix capitalization in global object check error.
* `MonoTlsProviderFactory` now treats "legacy" as an alias for "default".
* `Mono.Net.Security/LegacySslStream`: Removed. This class also wasn't using the `MobileAuthenticatedStream` base class, thus preventing cleanups simplifications in that area.
* `Mono.Net.Security/LegacyTlsProvider`: Removed.
* `Mono.Security/Mono.Security.Protocol.Tls*`: Removed all the old legacy code.
* `Mono.Security.Interface.MonoTlsProviderFactory`: Bump internal version to 4.
If we have coverage profiling enabled for a method (mono_profiler_coverage_instrumentation_enabled, with coverage_filter callback), then we should be able to allocate a coverage info structure (mono_profiler_coverage_alloc). After https://github.com/mono/mono/commit/52429673dc617fd437518757c04c7448211075e9, coverage_filter was reporting wrapper methods as ok to profile, while mono_profiler_coverage_alloc was refusing to allocate the necessary structure, leading to crashes.
* [corlib] Mark YieldAwaitable struct readonly
Make it consistent with .NET Standard/Core which makes future API Compat runs report one less difference.
* Bump API snapshot submodule
* [interp] Move instructions together
For easy check if an instruction is unary or binary operation. We consider conversion instructions to be unary operators and compare instructions to be binary operators.
* [interp] Add stloc.np also for longs
* [interp] Add stats for total number of emitted instructions
Also make the killed_instructions counter actually track the total amount of killed instructions. It was not previously tracking instructions killed as part of addition of stloc.np / movloc.
* [interp] Improve logging during cprop
Make dumping instruction support also InterpInst's not just compacted instructions.
* [interp] Constant folding of common unary operators
* [interp] Constant fold binary operations
* [interp] Remove MINT_CONV_U8_I4 opcode
It is equivalent with MINT_CONV_I8_U4.
This commit avoid unnecessary memory barriers on x86 and amd64.
Volatile writes have release semantics, volatile reads have acquire semantics. Organize the code a little bit to indicate this. On x86 and amd64 we don't require barrier for acquire and release semantics since they are provided by the arch, so we can skip them. Ideally we should have 3 memory barrier interp instructions for each type, but, currently, they would all seem to call mono_memory_barrier so it is useless at this point.
Changes will default Windows SDK version as well as Platform Toolset to
the default versions used in the targeted VS version. If the projects are
opened up in VS2015, it should default to Windows SDK 8.1 and v140, but if
the same projects are opened in VS2019, it will default to latest Windows SDK 10
and v142. This way the project files should adapt to used VS version, meaning
that we could still build them using VS2015 (what's currently used on CI) but also
using VS2017 and VS2019. There should not be a need to install any previous versions
of build tools, unless an older version is targeted. It is also possible to set
PlatformToolset when calling msbuild and that should adapt to corresponding default
Windows SDK version for targeted toolset version.
Commit makes many changes and adjustments, aligning all vcxproj files but changes
should not affect build output.
In https://github.com/mono/mono/pull/17341 we change the caller of
CompareExchange_T<T>(ref T, ...) to call CompareExchange (ref object, ...), but
didn't delete the declaration.
It's already deleted in unmanaged and in the netcore version of this file.
* Update dependencies from https://github.com/dotnet/core-setup build 20191015.17
- Microsoft.NETCore.App - 5.0.0-alpha1.19515.17
* Update dependencies from https://github.com/dotnet/corefx build 20191015.14
- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha1.19515.14
* Reenable a test that was fixed
* [bcl][jit] implement Interlocked.Exchange<T> in terms of object
Exchange<T> is supposed to be picked up as an intrinsic. But if it isn't,
since T has a class constraint, call the `Exchange (ref object, ref object, ref
object)` overload instead.
This works around a limitation in the JIT:
https://github.com/mono/mono/blob/82a07273c22b996b08fa88ee2e6632d782ac2242/mono/mini/mini-trampolines.c#L704-L713
if we're in the common call trampoline, and the caller is generic method and
the callee is a generic method, if we're using generic sharing for the caller,
but there's no generic jit info for the callee, we will not patch the call
site.
In this case we had Exchange<T> calling Exchange_T<T>
where the callee is an icall (and evidently didn't have generic jit info).
So every time we called Exchange<T>, we would go through the trampoline when
trying to call Exchange_T<T> without patching the call site.
Addresses part of https://github.com/mono/mono/issues/17334
* Bump Mono
* Also drop CompareExchange_T<T>
* Sprinkle some Unsafe magic.
Mark the non-icall methods that we expect the JIT to treet as intrinsics with [Intrinsic]
* aot-runtime doesn't need Volatile.Read<T>/Write<T> code
Both of those methods are implemented as calls to the object overload of Volatile.Read/Write
Follow-up to https://github.com/mono/mono/pull/17331.
We were running nuget pack and tests explicitly in the Azure Pipelines
config so we weren't capturing failure telemetry.
Replace mono_assembly_name_free use with mono_assembly_name_free_internal.
Maybe just remove the GC mode change and remove the internal form.
We don't really equate malloc/free with GC/locks/hangs, though arguably we should. Arguably this change is right.
* [interp] Make StackValue more intuitive
Replace the opcode field with an enum which will represent what type of value is contained (STACK_VALUE_LOCAL, STACK_VALUE_I4 etc)
* [interp] Add the mint type to the local data
Makes the emitting code easier and we no longer compute the mint type for each local access, which is fairly expensive.
* [interp] Handle indirect locals saner during cprop
Instead of checking for the indirect flag when loading from a local, simply never store a StackValue into such a local since we can't use it. We use the same logic when not pushing on the stack values for such locals.
* [interp] Add constant folding for integers
We decode the values from LDC_I4 and LDC_I8 opcodes and track/propagate the values on the stack and in the locals using the existing infrastructure. When loading a local, we try to load using the known constant value instead, so we might get to kill that local.
* [interp] Similar to stloc.np we can optimize pop/push pairs
If the pushing instruction pushes the same value that was popped by the previous instruction, we can kill them both
* [tests] Remove issue that seems to have been fixed for a while
* Fix SafeHandle marshalling in ref/in/out parameters
* Reorder code to make it exception safe, update comments
* Revert the code reordering because it breaks the invariant that new handle returned from native code should always create new SafeHandle on the managed side
* Fix test_0_safehandle_ref test. The test was expecting incorrect behavior, verified on .NET Core 3 and .NET Framework 4.8.
* Address PR feedback
* Fix cut & paste error
* Fix build
* Really fix the test_0_safehandle_ref tests
* Add more tests for SafeHandle marshalling
* Add exclusion for broken CoreFX test
* Add support for tests via safari browser
* Run safari browser tests on CI for Mac lanes
* Update to fix syntax error using UNAME to `if [[ ${CI_TAGS} == *'osx-amd64'* ]];`
* Fix syntax error with `if`
In https://github.com/mono/mono/commit/fd424c5dd07b2dbbd4aafbf9165a42166d789438 we switched over to the `TextWriter.cs`/`StreamWriter.cs` implementation of corefx. One subtle difference is that an override for `WriteLine(string)` in `StreamWriter` was introduced:
https://github.com/mono/corefx/blob/8e3b279377d1f01d2d089f24548e33855bf6502e/src/Common/src/CoreLib/System/IO/StreamWriter.cs#L526-L531
Previously the definition in `TextWriter` was used, which would call the base case `Write(char[],int,int)`. The new override however won't call the base implementation at all, but directly uses the `Span`-variant.
This is a problem for our `CStreamWriter` implementation, since `WriteLine(string)` won't end up in the special handling for `Write(char[],int,int)`, which accounts for terminal cursor changes.
This is the real fix for https://github.com/mono/mono/issues/16701
This also reverts commit 68f5613422. ("[TermInfoDriver] update top/left value on Console.{CursorTop,CursorLeft} access (#16745)")
While it kind of masked the issue, it also posed a performance issue on some terminals (e.g. GNOME Terminal).
* Load VSTS telemetry helpers into build.sh script
* First cut adding some basic VSTS-compatible telemetry on failures
* Don't make `ci=true` the default, make it a build.sh flag
Otherwise the script will not replace the variable and we get confusing error messages like this:
```
[command]/bin/bash --noprofile --norc /home/builder/azdo/_work/_temp/ba0890e7-8c80-4245-b9dc-14253b0d399f.sh
/home/builder/azdo/_work/_temp/ba0890e7-8c80-4245-b9dc-14253b0d399f.sh: line 2: llvm: command not found
/home/builder/azdo/_work/_temp/ba0890e7-8c80-4245-b9dc-14253b0d399f.sh: line 2: [: =: unary operator expected
```
* This adds the ability to continue loading the application even though the .pdb files are not found.
When uploading an app built with mono-wasm the `.pdb` may not get committed so they will not exist when trying to load them.
- Add new boolean variable to MONO library support to control skipping these files on errors.
- `mono_wasm_ignore_pdb_load_errors` default is true
- Modify the assembly file fetching routine `mono_load_runtime_and_bcl` within our MONO module.
- Allows skipping the .pdb files if the `mono_wasm_ignore_pdb_load_errors` flag is true.
* [System.Net.Http] Clean up HttpMessageHandler setup
to avoid reflection and not to be recursive
Superseded #15051 and #15922
* [csproj] Update project files
* Remove unused mono_class_get_field_from_name_cached.
* Replace gcc-specific:
mono_array_class_get_cached
mono_array_new_cached
mono_array_new_cached_handle
with portable forms that are easy enough to use and general enough.
Before was "easier" because cache provided for you -- possibly multiple.
Before was more general because rank was a parameter -- and had to be a constant.
It was always 1.
* [sdks] properly shutdown runtime for Mono.Debugger.Soft test app
mini_jit_cleanup will cause mono_runtime_try_shutdown to be called before
mono_runtime_quit which will set the shutting down flags in the runtime.
* [test] Re-enable disabled tests
* Update parameters in MERP WerReportMetadata xml
To enable backend analysis, we need to update our parameters to match our back end event type, which is MonoAppCrash.
It doesn't make sense to me that the previous implementation constructed the XML here in Mono, but depended on the user (VSMac in this case) to add the "correct" event type. The parameters in the XML, must match exactly what is expected for the given EventType, and so we should ensure they are always in-sync by defining them here. Thus, I removed the usage of `eventType` in `mono_merp_enable` and hard coded the expected eventType.
* [merp] Don't pass eventType from managed
The eventType must me MONO_MERP_EVENT_TYPE_STR ("MonoAppCrash") - the backend
determines the format of the other fields based on the event type, so it
doesn't make sense to pass other values from managed since the runtime controls
the other fields.
For compatability Mono.Runtime.EnableMicrosoftTelemetry will still take a
string parameter (now called "unused" instead of "eventType_str") but it will
not pass it down to the internal call.
* Bump corlib version
* [merp] Revert paramerters in WerReportMetadata.xml
Still need event type to be `MonoAppCrash` but the parameters will be the same as before.
* Rewriting the ARM64 HWIntrinsic JIT infrastructure to share with and mirror the x86 infrastructure where possible.
* Lowercasing the hwintrinsicarm64 and hwintrinsiclistarm64 files.
* Applying formatting patch.
* Fixing up some names in the PAL and VM that were missed.
* Adding support for AdvSimd.Add
* Ensure impSpecialIntrinsic returns nullptr for unsupported base types.
* Rewording various method headers and simplifying some code.
* Fixing getEmitter to GetEmitter
* Adding support for the ld1 instruction
* Applying formatting patch
* Clarifying a todo comment and removing a stray newline
* Fixing the Arm64 impSpecialIntrinsic to not assert for helper intrinsics
* Fixing some intrinsic signatures that were incorrect
* Adding the initial template files for generating Arm HWIntrinsic tests
* Generating the initial batch of Arm HWIntrinsic tests
* Replace gtRegNum with GetRegNum()
* Fixing the test template alignment checks for Arm
* Regenerating the Arm HWIntrinsic tests
* Fixing the namespace checked for Arm intrinsics
* Changing Base to ArmBase and fixing some Arm hwintrinsic metadata
* Fixing the arm emitter and lowering to not assert for hwintrinsics
* Fixing the arm intrinsics to not set the number of vector elements for SIMDScalar intrinsics
* Updating the AdvSimd.Abs tests to use negative input values
* Regenerating the arm hwintrinsic tests
* Fixing the arm hwintrinsic codegen to use the element size for simd scalar operations.
* Fixing the arm scalar intrinsic tests to check for 0 on upper bits
* Regenerating the ARM intrinsic tests
* Fixing AdvSimd.AbsScalar and AdvSimd.AddScalar to be recursive
* Marking AdvSimd.Arm64 and ArmBase.Arm64 as implemented
* Ensure that AdvSimd.Arm64.Abs is marked as variable size
Signed-off-by: dotnet-bot <[email protected]>
* [interp] Replace STLOC to dead local with MINT_POP
* [interp] Optimize MINT_POP
It was only used for 0 and 1 values. The implementation for values larger than 1 was broken anyway.
* [interp] Remove unnecessary usage of MINT_POP1
When storing a static field from a CEE_STFLD instruction.
* [interp] Prevent optimizing away the stack, after a branch
We know the contents of the stack following a branch, so we could have optimized away some instructions preceding the branch. We shouldn't do this because the code we are branching to expects a certain stack size.
* [interp] Clear instructions which push unused values on stack
* [interp] Properly initialize stack when pushing local
* Incorrect constrained virtual call in method using gsharedvt for reference type.
For generic constrained virtual calls using reference type's, the
virtual call will be dispatched using instance vtable. When the same
virtual call is taking place in a gsharedvt method, mono_gsharedvt_constrained_call
gets called that will assist making the call, the problem is that it will
use the constrained class for reference types meaning that it will not call
the most derived implementation of the method. This difference in the behavior
compared to none gsharedvt versions of methods, gives inconsistent results.
One way this will reproduce is by using Dictionary<Type, EmptyStruct>. For
methods that will take both Type (reference type) and EmptyStruct (value type)
like Add, calling that through IDictionary (hiding details from compiler) will
use the gsharedvt version of the method. Internally that method will call
Type.GetHashCode (), and since Type really is a RuntimeType it overrides
GetHashCode. But since mono_gsharedvt_constrained_call will use the constrained
class instead of the instance class, the called method will be
Object.GetHashCode, that gives a different result. When later ContainsKey
is called using the same Type, it only takes a reference value, so not
using a gsharedvt version of the method, then the most derived version of
GetHashCode will be called, given a different hash, not finding item
in dictionary.
Fix is to make sure behavior in mono_gsharedvt_constrained_call match
behavior for regular constrained virtual calls when having a reference type.
This makes sure we always call the most derived version of the method.
Commit also adds a test for this specific scenario using a dictionary.
* Updated to a more low-level test.
Running these tests makes the application crash, probably at shutdown. Even if the tests are reported as passing, check if disabling them fixes the suite timeout on android osx sdks.
Remove varargs from g_assert and g_assert_not_reachable (save 200+ bytes per frame in wasm interp).
g_assertf unchanged.
I have a strong suspicion, this will save approximately 432 - sizeof (InterpFrame) bytes of stack
per function call in the WebAssembly interpreter.
It will not significantly benefit or hurt any other system.
Systems with disabled asserts will receive a small size improvement.
WebAssembly has no provision for varargs.
Emscripten emulates it.
It appears the emulation allocates room in the frame per outgoing varargs call.
No stack packing.
So each g_assert takes space.
Alternative would be to discourage or disable or remove asserts.
* [Mono.Posix] Add support for memfd_create() and file sealing
Add the linux syscall memfd_create() and add support for file sealing with
fcntl().
* Bump API snapshot submodule
* Fix check for FastAllocateString that used old name
* Fix linker scripts
* Update the icall name for FastAllocateString to match managed name
* Update size check in managed allocator
* One more 64-bit target fix
When doing memory copy dest is the destination address and src is the source address. If we are copying a single reference, we need to emit a write barrier and pass to the write barrier the value, not the pointer where the value is stored.
Both just call into NDirect::LoadLibraryFromPath, and so this simplifies the code by removing a superfluous QCall
Signed-off-by: dotnet-bot <[email protected]>
* [intepr] Add define for constant
* [interp] Pass separately pop_vt_sp argument
Cleans up the code a bit. There is no need to do fancy bit operations for such a slow opcode.
The tests are kinda bogus since they create a SafeWaitHandle from `new IntPtr(1)` which causes a crash during finalization when releasing that handle.
See https://github.com/mono/mono/issues/17224
* [Mono.Posix] Move Mono_Posix_{From,To}MremapFlags() to support/sys-mman.c
Since b522eab5ff Mono_Posix_FromMremapFlags()
and Mono_Posix_ToMremapFlags() contain manual changes for NetBSD. Move the
functions from support/map.c to support/sys-mman.c so that they won't be
overwritten when create-native-map is rerun.
* [Mono.Posix] Fix prototypes in support/stdio.c
In ed892ccf27 wrapper functions for several
stdio functions were added, but the prototypes in map.h were manually
written, not using create-native-map. This commit changes the prototypes so
that they match the output of create-native-map.
* [Mono.Posix] Undefine HAVE_STRUCT_SOCKADDR_IN6 in support/map.c on MSVC
In 22b6b95814 a manual change to support/map.c
was added to prevent Mono_Posix_FromSockaddrIn6() and
Mono_Posix_ToSockaddrIn6() from being built for windows even if
HAVE_STRUCT_SOCKADDR_IN6 is defined. Instead undefine it in a header file
to avoid manual changes to map.c.
With this commit map.c, map.h and NativeConvert.generated.cs contain no
manual changes anymore.
If we eliminate these instructions, it means we removed instructions that use the top of stack. Without them we might be able to optimize away that stack slot usage. If we retraverse the instruction stream, then we must handle movloc and stloc.np separately.
* Introduce new dladdr wrapper in glib, AIX reimpl, and convert usage
Provides a wrapper around dladdr that should be platform-neutral.
Also provided is a reimplementation for AIX, which should enable
that platform to get some previously dladdr-specific functions like
the crash reporter. It is somewhat flawed in that it only gets info
for symbols in .text, returns non-constant allocated strings, and
allocates heap memory for buffers.
Then convert usages (except a macOS specific one) of dladdr to the
new eglib function. It has a different signature, which should
simplify intent and reduce structiness. Also free memory on AIX due
to limitations of its reimplmenetation.
* Enable (and fix build of) crash reporter on AIX
So far crashes don't seem any different, but the code for it is
built.
* typo fix (guess this isn't compiled on aix)
* attempt to fix macOS and win32 builds
* Implement more of g_module_address on Win32
Implements the filename stuff. Untested; don't have Windows.
* Look for backtrace_symbols in an IBM compat library for i
Enables i to natively dump a stack trace. (AIX "works" too if you
copy the compat lib's code and hack it in - it probably needs to be
in EGlib.) Unfortunately, it's not perfect. The backchain from the
signal handler is empty on i, and AIX sometimes mangles the stack
frame in a way that severely confuses the backtrace code, causing
it to dereference invalid memory by interpreting instructions as a
pointer. (I have seen somewhat similar for the sigaltstack case,
where the native memory dump attempts to read something it should
not.) Perhaps mincore could be used, but that feels like a sloppy
workaround, especially in the "AIX making an invalid stack frame"
case.
* If the file isn't an archive, don't format its name like one
* Fix up search for backtrace_symbols to look in libexecinfo
FreeBSD ships it in base and Haiku has a package; likely others too.
* Win32 suffers in g_module_address as well
* That should habe been guarded with AIX due to limitations
Otherwise seems to free things that shouldn't be freed
* Casting for win32
* Fix up Win32 impl of module address
* Free HMODULE to lower reference count after using it
* Change dladdr based impl to always dup for impl consistency
Means freeing afterwards shouldn't be ifdefable.
* probably shouldn't strdup NULL
Likely why macOS has failures.
* Don't dup/return const strs, but copy to caller-provided buffers
...which can be on the stack. This makes it far less risky to use
in a crash reporter scenario, because malloc can be hosed then.
Also fix profiler up better to work with this new reality.
* Bump version to 6.9
* Add missing new linker source file
* [csproj] Update project files
* No monolinker on MCS mode, new linker version needs Roslyn
There is a bug in mono-service.cs file.
`setup.ApplicationBase = Environment.CurrentDirectory;`;
General `Environment.CurrentDirectory` does returns `Directory.GetCurrentDirectory()`.
And retuened value 'current path' without last character `/` but `AppDomain.CurrentDomain.BaseDirectory`;
It have a problem in my service application.
In my service application code,
```cs
using System;
using System.IO;
namespace BaseDirTest
{
internal class Program
{
public static void Main(string[] args)
{
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine($"baseDir={baseDir}");
Console.WriteLine($"Path.GetDirectoryName(baseDir)={Path.GetDirectoryName(baseDir)}");
}
}
}
```
When I launch `mono app.exe`,
```bash
baseDir=/workspace/test/mono-owin-test/ConsoleApplication1/BaseDirTest/bin/Debug/
Path.GetDirectoryName(baseDir)=/workspace/test/mono-owin-test/ConsoleApplication1/BaseDirTest/bin/Debug
```
But when I launch `mono-service --no-daemon app.exe`,
```bash
eDir=/workspace/test/mono-owin-test/ConsoleApplication1/mono-service-umc/bin/Debug
Path.GetDirectoryName(baseDir)=/workspace/test/mono-owin-test/ConsoleApplication1/mono-service-umc/bin
```
Because my service application can not founds plugin directory and scans it.
* If there is a perform_wait_callback in the stack there will be another catch generated by the owner thread, so we don't need to throw, we can continue and find the next catch.
Fixes#17083
* Reverting unit test changed on commit 405d521.
* Fixing assert when calling mono_jit_info_get_method if it was a trampoline.
* [offfsets-tool] Embed a copy of the clang bindings, the version in PIP doesn't work with newer clang versions.
* [wasm] Bump emscripten version to 1.38.47.
* Optimize and extend System.Array intrinsic identification.
i.e. do the strcmp last.
Add GetRawArrayData.
* Use [Intrinsic] attribute instead of comment.
* [mixed] Add interp entry wrappers for devirtualized calls as well.
* [aot] Generate code for string:memcpy/memset/bzero even in profile mode, they are called by the generated code.
* [aot] Treat string:memcpy as always AOTed in mono_aot_can_enter_interp () as well.
* [aot] Always aot string ctors as well, the JIT doesn't generate interp entry code for them.
* [wasm] Update print-table.py.
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
* Fix stackalloc reuse bug in Environment.UserDomainName
According to the comment, this code is never expected to be used (so it should either be deleted or the comment fixed), but in the meantime, if it were to be executed, things could go badly due to potentially passing the same buffer into LookupAccountNameW for two different arguments.
* Fix existing ValueStringBuilder usage to dispose the builder
Signed-off-by: dotnet-bot <[email protected]>
* Make relevant types static (mostly Interop)
* Fix a few stray semicolons
* Remove unnecessary locals
Some can be removed entirely, some can be replaced by discards.
* Remove unnecessary usings
* Move Unix-specific helper method to TimeZoneInfo.Unix.cs
* Remove duplicated code
* Remove duplicative checks
* Remove [ThreadStatic] initialization
These are all the default values and wouldn't be necessary for any static, but inline initialization for [ThreadStatic]s is particularly unuseful (and in non-default cases problematic) because the fields are only set to these values on the initializing thread.
* Fix methods whose return value is never used
* Use string.IsNullOrEmpty
* Remove unnecessary field initialization
All ctors overwrite these values.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* [aprofutil] Add skip regexes to simplify expression of removal matching
* [aprofutil] arguments to skip and take by count for automatic profile testing
* [interp] Refactor tracking of stack/local values
Previously we had just an InterpInst* inside StackContentInfo, which was representing the instruction that pushed a certain local/value on the stack. This makes many things awkward, since an instruction is logically different from a value, that a local or a stack slot have. If we clear an instruction, it doesn't necessarily mean that the value that the instruction produced can't be stored on stack or in a local.
This commit creates a new structure StackValue, which holds the value.
* [interp] Generalize contents of StackValue
StackValue contains an opcode and some data to enable reconstruction of the value. For example instead of doing a LDLOC for a local, we can see if the local has a known value and use it instead (this could be a LDLOC from another local, whose value was propagated, or in the future a LDC). This will make more sense when we also start to track constant values.
Also decouple MOVLOC instructions from the cprop pass. They serve no purpose there. They are useful though when we do deadce, since we currently don't know how to kill instructions that change the stack.
* [interp] Handle dup opcode during copy propagation
* [interp] Avoid losing track of stack values for some opcodes
For some opcodes, that access stack values below the top of the stack, we were assuming they pop everything and then push the stack back, in order to prevent optimizing away instructions that pushed some of these values, since the original instruction expects those values to reside on the stack. We handle these instruction separately and keep track of the values of the stack, so we can further propagate the stack values, even though we currently can't optimize away those instructions.
* [interp] Propagate values for ctor arguments
* [interp] MINT_CASTCLASS no longer clobbers top of stack
* [mkbundle] Fix mono_aot_register_module declaration (#17139)
This change reflects the declaration introduced in jit.h in #15132.
* [mkbundle] Remove spurious function declaration (#17139)
The comment is clearly outdated after the introduction of #15132.
* [merp] Don't overrun buffer in copy_summary_string_safe
MonoFrameSummary:str_destr is an array of MONO_MAX_SUMMARY_NAME_LEN bytes, not
MONO_MAX_SUMMARY_NAME_LEN + 1 bytes.
Fixes Coverity CID 1454563
* [merp] Use g_strlcpy for copy_summary_string_safe
Fixes Coverity CID 1454563
We would sometimes write to MonoSummaryFrame:str_descr which is
MONO_MAX_SUMMARY_NAME_LEN bytes long at index MONO_MAX_SUMMARY_NAME_LEN which
is one past the end of the array.
* nit: rename confusing parameter names
old names were confusing - we were copying from 'out' to 'in'. Now we copy to
'dest' from 'src'
After https://github.com/mono/mono/commit/9ff3b0d65ee4, in an aot image we can emit addresses either as bl offset (which uses 4 bytes) or as ldr pc, =<label>; <addr> (which uses 8 bytes). Before this commit we were dereferencing an instruction pointer, in get_call_table_entry, assuming 8 bytes per entry. This could overflow and crash if we used in fact only 4 bytes per entry. Fix this by including the entry size in the aot image.
Fixes random crashes on arm CI on full-aotmixed suite.
* Build MSVC only runtime using make file system.
Add a new option to only build MSVC version of mono runtime and native
tools, --enable-msvc-only. In the past, --enable-msvc build both
mingw as well as MSVC runtime, this commit adds an option to only build
MSVC version of runtime and native tools using make file system.
Commit updates all native make file making sure mingw/gcc builds are
not done if --enable-msvc-only has been used. It also makes sure we
build and use MSVC based tools as part of build and tests.
Result will be a build without any mingw/gcc artifacts, but where all
existing make files still works with the MSVC build artifacts.
This commits is also preparing to switch the .NETCore build over to use
MSVC build runtime in order to get LLVM support, something that is
currently only supported on Windows MSVC build.
* Add link to mono-sgen.exe and clean windows binaries.
* Fix failures in mono/tests test-aot on Windows.
* Add fullaot-mixed tests on Windows x64.
* Run msbuild in parallel.
* Default to x64 mingw host on cygwin build.
```
configure.ac:6695: error: required file 'netcore/corerun/Makefile.in' not found
Makefile.am:24: error: required directory ./netcore/corerun does not exist
```
* [mini] Use clr memory model by default
Otherwise we can have potential crashes in the bcl on arm targets, since a lot of code that assumes this memory model is now shared with mono.
Keep the old clr-memory-model option alive for now, to avoid potential build problems, if building older mono with newer mono.
* [build] Remove clr-memory-model option
It is default now
* [man] Add entry for weak-memory-model
* [merp] Include any managed methods in the 'unmanaged_frames' portion of the output also
This can help correlate the two lists when we have mixed managed & unmanaged stacks in our crash output.
* Wehn symbol/function address is not found, still output the IaP
* Don't set native_offset to ip, that's not what it means
* [merp] Bump protocol version
* Minor formatting fix
* Remove paths from assembly image names
* Remove unused var
* Refactor filling in managed info for stack frame
* Revert "Remove paths from assembly image names"
This reverts commit defe86b471f37e12fa66a104747cac932943dca1.
* Use macOS version not Darwin version in MERP
Fixes#17004
* Update mono-merp.c
Ensure this is only for Mac
* Don't allocate in macos_version_string
Use a static buffer.
Also some formatting fixes.
`System/RemoteExecutorTests.cs` tests are excluded in the mobile test profiles. It makes sense to do the same for wasm.
Fixes https://github.com/mono/mono/issues/17038.
* allow ASCII equality ordinal fast path for en-* cultures
* dont use StartsWith in the initialization execution path
* Update src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs
Co-Authored-By: Jan Kotas <[email protected]>
Signed-off-by: dotnet-bot <[email protected]>
* Moving the Arm64 intrinsic files into the Arm folder.
* Refactoring the ARM Hardware Intrinsics based on the new design.
* Adding support for AdvSimd.Add
* Adding LoadVector64 and LoadVector128 APIs to Arm.AdvSimd
* Marking the LoadVector64 and LoadVector128 methods as unsafe
* Removing the ARM64 HWIntrinsic tests
* Renaming Arm.Base to Arm.ArmBase, as per the design
* Fixing Base.cs to ArmBase.cs in the shared projitems
* Fixing the doc comments for the AdvSimd.LoadVector methods
* Marking various IsSupported methods as new, now that they inherit from ArmBase
* Fixing a malformed doc comment that was missed
* Marking AdvSimd.Arm64 as [Intrinsic] and new
Signed-off-by: dotnet-bot <[email protected]>
A valid path might be something like \\\\.\\pipe\\pipename (i.e. \\\\.\\ is a valid root). If we blindly strip all instances of `.\\` then we end up confusing our path cleaning algorithm. So permit a directory component of `.` in UNC path roots.
Closes: https://github.com/mono/mono/issues/16460
* [mini] Add memory barriers to more stores inside objects
We should now have membars for all stores of an object ref inside another object (for the stores done by the jit). Used by clr-memory-model debug option.
* [mini] Add memory barrier for storing objref in static fields
For clr-memory-model debug option.
In 6d2c77fb33 we changed the representation of
the runtimes that we will probe from a NULL-terminated array to a linked list.
Unfortunately we made a typo, and in the case where the caller of
mono_init_internal provided a runtime_version, we still picked
DEFAULT_RUNTIME_VERSION instead of the given runtime_version.
This is an issue for embedders like XA that use the "mobile" runtime - all
their assemblies are compiled with the "mobile" version number (2.0.5.0) but
Mono running with the default runtime configuration will remap to 4.0.0.0. As
a result, when there are references to 2.0.5.0 assemblies, the load requests
will be remapped to 4.0.0.0 which will never see the already loaded 2.0.5.0
assemblies, and we will fall back on the embedder's preload hook or filesystem
probing every single time. This is a performance fail.
Reverts mono/mono#16882
This broke the Mono Android SDKs build in master though for some reason it doesn't show up in the PR build:
```
[2019-09-26T03:19:55.366Z] Undefined symbols for architecture x86_64:
[2019-09-26T03:19:55.366Z] "_mono_tls_key_jit_tls", referenced from:
[2019-09-26T03:19:55.366Z] _mono_tls_get_jit_tls in libmain_a-main-sgen.o
[2019-09-26T03:19:55.366Z] "_mono_tls_key_lmf_addr", referenced from:
[2019-09-26T03:19:55.366Z] _mono_tls_get_lmf_addr in libmain_a-main-sgen.o
[2019-09-26T03:19:55.366Z] ld: symbol(s) not found for architecture x86_64
[2019-09-26T03:19:55.366Z] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[2019-09-26T03:19:55.366Z] gmake[6]: *** [Makefile:1634: mono-sgen] Error 1
[2019-09-26T03:19:55.366Z] gmake[6]: Leaving directory '/Users/builder/jenkins/workspace/archive-mono/master/android/debug/sdks/builds/android-host-Darwin-debug/mono/mini'
```.
Add loading the default Mono configuration file.
Add loading the default Mono configuration file in the examples of Mono Embedded.
Also include header in existing usage of `mono_config_parse`.
This fixes problems under Raspbian, when extending the sample with your own code.
The `teste.c` is still not compiling, because the `mono_set_allocator_vtable` function is not up to date. But I was not able to find the documentation for this function.
* Revert "[Mono.Debugger.Soft] Properly close connections"
This reverts commit 2da7707373.
This was previously reverted because it was causing issues and it still does. It is a hack fix. We signal the connection for closing and next we send the dispose command over the network. This is obviously racy.
* [Mono.Debugger.Soft] Make sure receiving thread always closes
When we want to close the connection, setting the close flag is not enough, because a thread can be already stuck in a blocking receive, without getting to check the flag. We fix this by additionaly breaking the connection, by using socket.Shutdown.
Fixes https://github.com/mono/mono/issues/7377
* Bump API snapshot submodule
* BeginConnect complete to early when not using callback.
The following commit, https://github.com/mono/mono/commit/068e8fe0424806753d7ab72a7b9bf0e54b58408b#diff-33b28a9dc0b8032650ed77213481a99f
changed the way we do DNS resolve in BeginConnect using host name. Instead
of doing a blocking DNS resolve, it switched to an async DNS resolve, followed
by an async connect. The returned IAsyncResult was just representing the
completion of the DNS resolve task and not the underlying connect. It
also turns out that part of doing EndConnect, we did some validation
of the used IAsyncResult making sure it was an instance of SocketAsyncResult,
meaning that if EndConnect was called on the returned IAsyncResult from
BeginConnect, EndConnect would throw and exception.
NOTE, this only happens if you use pattern like this:
var result = sock.BeginConnect (hostName, port, null, null);
result.AsyncWaitHandle.WaitOne (2000);
sock.EndConnect (result);
It did not happened if you used callbacks, since then EndConnect would
be called as part of callback and that IAsyncResult was of correct type,
or if you did a BeginConnect with an EndPoint or IPAddress[] since that
won't trigger the DNS resolve.
Fix is to make sure we hand out the SocketAsyncResult instance that will
be used in our internal connect calls from BeginConnect. We also make
sure, we chain the DNS resolve task together with a task doing the async
connect (using the same SocketAsyncResult instance). This will make sure
the IAsyncResult returned from BeginConnect is the same one as used in
internal connect call, so it will only complete when the connect call
completes.
* Adding test for BeginConnect using host name.
* Bump API snapshot submodule
When we detach from the debugger, we reset the state by starting a new debugger thread (why don't we just use the existing thread?). As per commit https://github.com/mono/mono/commit/540ef385faa230bc226c7a83bfabd0730520911e we should shut down the debugger thread when the connection drops. However, since that commit was acting as a Dispose command was sent instead, it would end up relentlessly spawning and closing new debugger threads up until the runtime is shut down. This commit makes sure we don't respawn once the connection hangs.
* [threading] embedded mono hangs
When embedded mono is executing a C++ code, it didn't start to execute a C# code, we don't need to suspend the thread to run GC.
Fixes#16192Fixes#14725
* Changing what was discussed with Aleksey during our 1on1
* Changing what was suggested by Aleksey
* Separating mono_init_version that is being used on tests from the embedded ones
* Remove unnecessary asserts
* Make several classes static
* Use is instead of as+null check
* Use T? instead of Nullable<T>
* more static classes
* Mark locals as const
* Merge declaration and initialization of some variables
* Remove unnecessary casts
* Remove unnecessary "unsafe"s
* Simplify several lambda expressions
* Remove redundant parentheses
* Remove redundant '== true'
* Remove redundant empty lines
* Simplify boolean comparison with '== false'
* Replace if-statement with return statement
* Use while for infinite loop
* Add static to all partial static class declarations
* Use ++/-- operator instead of assignment
* Use string.IsNullOrEmpty
* Use coalesce expression
* Simplify lazy initialization
* Use coalese expression
* Join string expressions
* Use regular string literal instead of verbatim string literal
* Optimize StringBuilder.Append calls
* Remove redundant assignment
* Remove unnecessary unsafe context
* Merge processor directives
* Use String.Equals instead of String.Compare
* Use Debug.Fail instead of Debug.Assert(false
* Remove Attribute suffix
* Use predefined type
* Use compound assignment
* Use while statement to create an infinite loop
* Remove redundant base ctor call
* Avoid using catch (Exception)
* Remove empty regions
* Span comparison to null
* Avoid unnecessary boxing of value type
* Expression is always equal to 'true'
* Remove unused method
* update coalesce assignment
* fix unsafe
* fix redundant parens
* Fix whitespace errors introduced
Signed-off-by: dotnet-bot <[email protected]>
Currently netcore-build doesn't need submodules (except LLVM) so a task somewhere in arcade/microsoft.build.tasks.git always complain if those are not cloned.
Set EnableSourceControlManagerQueries=false to ignore the warnings.
* 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
* Remove old RenamedEvent* files
* Remove IsFastSort optimizations from String
- Fix bugs in the Span-based globalization fast paths. Note that some of these bug fixes are going to affect performance of the globalization fast paths.
- Use Span-based globalization fast paths for strings
- Avoid static array allocation for HighCharTable
Fixes#26758
Signed-off-by: dotnet-bot <[email protected]>
Addresses 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 added a set of tests for some time zones to verify jumping into DST in general.
Fixes https://github.com/mono/mono/issues/16395
* Creating a new version of MOD_KIND_EXCEPTION_ONLY to support VsWin features, discussed with Joaquin Jares.
Because we don't have this functionality of get every other exception that is not specified, VsWin was getting every exception and filtering later. But this causes a slowness during the debugger because we stop all thread on each exception that we get, even if they are caught and we don't want to stop.
* Fixing other unit test because now we have 2 nested classes.
Fixing indentation.
* Creating a flag in the MOD_KIND_EXCEPTION_ONLY protocol event and not creating a new protocol event.
* Changing what was suggested by Zoltan.
* Coding style
* Bump API snapshot submodule
The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.
config.log contained this:
```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
^
//
```
This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.
It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in https://github.com/mono/mono/commit/8f5cef936491e8b20888bbf18d426482c890637c.
Fixes https://github.com/mono/mono/issues/16974
Restores previous ExecutionContext Capture behavior where we were copying a new SynchronizationContext as opposed to a reference to the existing one.
The old behavior caused SynchronizationContextAwaitTaskContinuations to not post to a SynchronizationContext.
Fixes https://github.com/mono/mono/issues/16759
Reverts a fix for https://github.com/mono/mono/issues/12421
* Include Mono.WebBrowser.dll in mkbundle bundles (Closes: #7454)
Because System.Windows.Forms.dll includes an assemblyref on
Mono.WebBrowser.dll, bundles need to be able to include it
in order for WinForms to work (even if they don't actually
use a browser component)
Compare:
```
$ mkbundle hellowin.exe -o hellowin --cross mono-6.0.0-ubuntu-18.04-x64 --i18n all
From: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64
ERROR: Unable to load assembly `Mono.WebBrowser' referenced by `/home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Windows.Forms.dll'
```
to
```
$ mkbundle hellowin.exe -o hellowin --cross mono-6.0.0-ubuntu-18.04-x64 --i18n all
From: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64
Using runtime: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/bin/mono
Assembly: /tmp/hellowin.exe
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Windows.Forms.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/mscorlib.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/Mono.Security.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Configuration.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Xml.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Security.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Core.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Numerics.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Drawing.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Runtime.Serialization.Formatters.Soap.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/Accessibility.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/Mono.WebBrowser.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/Mono.Posix.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Data.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.Transactions.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/System.EnterpriseServices.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.CJK.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.MidEast.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.Other.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.Rare.dll
Assembly: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/lib/mono/4.5/I18N.West.dll
systemconfig: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/etc/mono/config
machineconfig: /home/directhex/.mono/targets/mono-6.0.0-ubuntu-18.04-x64/etc/mono/4.5/machine.config
Generated hellowin
```
For the test code:
```
using System;
using System.Drawing;
using System.Windows.Forms;
public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}
public HelloWorld ()
{
Button b = new Button ();
b.Text = "Click Me!";
b.Click += new EventHandler (Button_Click);
Controls.Add (b);
}
private void Button_Click (object sender, EventArgs e)
{
MessageBox.Show ("Button Clicked!");
}
}
```
* Also add Novell.Directory.Ldap (consumed by System.DirectoryServices)
* Doing the same fix from Android to IOS.
* On mini-exceptions.c check if there is no ji we can continue and generate the exception without checking wrapper_type.
Fixes#16824
The same functions are referenced by JIT and runtime.
The JIT uses cannot be inlined. The runtime can.
Since I could not get anything else to build and the change is simple and mechanical, now two sets of functions are provided, inline and extern. Extern just calls inline.
This PR appears to change all the uses, but it is only the JIT uses. The runtime ones just work and keep the old names.
We should also consider building desktop with LTO/LTCG, which would do all this automatically, smarter, more generally. A quick experiment shows it grows the runtime size, which is why I say desktop.
This includes resolving a somewhat deep problem involving
a void* that is usually to a int/float, but can be a MonoObject** or at least MonoString**.
An additional MonoStringHandleOut parameter is pass around to address this.
Perhaps it should be MonoObjectHandleOut for more generality.
[interp] avoid exception checkpoint when in thread is in GC Safe state
Usually the interpreter operates in GC Unsafe state. There is an exception however, and that is when it executes a `managed-to-native` wrapper in cooperative (or hybrid) suspend.
The wrapper does essentially:
1. enter GC Safe state via `mono_threads_enter_gc_safe_region_unbalanced`
2. call native function
3. exit GC state via `mono_threads_exit_gc_safe_region_unbalanced`
Usually upon return of a native function call, the interpreter would check for thread interruption and, if applicable, throw an exception. That, however, would mess with the GC state as the interpreter operates in GC Safe state at this moment.
Note that ignoring thread interruption at that point shouldn't be a problem, because after 3. the `managed-to-native` wrapper will check for thread interruption anyway.
Contributes to https://github.com/mono/mono/issues/16819
This is required by the newer arcade builds.
We can simplify our scripts since we no longer need the special publishwitharcade.proj.
Added copyright and license to the .nuspecs since the new arcade validation now
verifies this against a set of Microsoft policies.
We also need to make the .nupkg pre-release by appending the -preview suffix as stable versions are not permitted in non-stable feeds.
* [System] Make FileSystemWatcher backend non-static
The FileSystemWatcher `watcher` field is the backend IFileWatcher that's
supposed to be used for the actual operations.
Each backend has a `bool GetInstance (out watcher)` method that returns a
singleton object, so each new instance of FileSystemWatcher gets the same
IFileWatcher instance. (They will get different `watcher_handle` instances
which are used by some backends to uniquely identify this FileSystemWatcher).
However when the first FileSystemWatcher instance is `Dispose`d, it will set
`watcher = null` which will prevent the remaining instances from calling
watcher?.StopDispatching (watcher_handle);
watcher?.Dispose (watcher_handle);
which means that the backend won't properly cleanup resources for any other FSW
instances that have other `watcher_handle` values.
Addresses https://github.com/mono/mono/issues/16709
* [Coop] InterlockedExchange (object and T), InterlockedCompareExchange (object and T).
- Usually intrinsified.
- Always?
- Avoid coop handles by manually always using ref to object.
- For efficiency on input, and efficiency wrt MonoError.
- For correctness on output (due to aliasing in the wrappers).
- To probably avoid assertion failure in runtime around icall marshaling of generics.
- Unclear on location.
* Balance parens in prints, so they are balanced in the code.
* Reduce local arrays from 16 to auto-sized 1.
* Update and reformat System.Threading.Interlocked signature recognition.
* Rename the generic again to "_T" (or "Generic"?) on the theory
that the aot-runtime.c signature check is too strict/incorrect,
but that if we loosen it, it is not clearly specific to the generic.
* Revise corlib version again.
* Bump API snapshot submodule
ApplicationTrustEnumerator used to call itself. The following snippet crashed with SO:
using System.Security.Policy;
public class Program {
public static void Main (string[] args)
{
ApplicationTrustCollection col = ApplicationSecurityManager.UserApplicationTrusts;
col.GetEnumerator ();
}
}
hybrid suspend won't get disabled when using --enable-cooperative-suspend
triggering configure error:
Hybrid suspend and Cooperative suspend cannot be both enabled.
Fix explicit set hybrid suspend default behavior to no if cooperative
suspend has been configured.
- Use __builtin_bswapxx for s390x rather than inline assembler
- s390x ABI specifies that %f8-%f15 are protected between calls so avoid using or save/restore as required
- Save the "protected" FP registers in the context structure
[mini] Add missing membars when initializing rgctx entries
Whenever we are publishing changes to the rgctx arrays, we are racing with rgctx_lazy_fetch_trampoline, so we need to make sure any pointers we set there must have their contents initialized.
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`.
This started as an effort to reduce the size of System.Net.NameResolution.dll when publishing a trimmed app. It's not that big to begin with, but it's carrying around a copy of all of the IAsyncResult helper types, because the Get*Async methods are currently wrappers for the Begin/End* methods.
This PR inverts that, wrapping the Begin/End* methods instead around the Get*Async methods, using the same TaskToApm helper we use in other places in corefx for the same purpose. This makes the Get*Async methods faster and lighterweight, but it does increase the number/amount of allocation in the Begin/End* APIs. Since these are considered legacy, I normally would consider that a good trade, however we still use these Begin/End methods in a few places in System.Net.Sockets, and I didn't want to regress those use cases.
So, this also then trims some additional fat, which helps the Get*Async cases even further, and gets the Begin/End* to be even better than before the change. This includes not allocating an IPHostEntry when we're just going to unwrap it and return its addresses, computing the exact IPAddress[] size we need rather than using a List<> to grow it and ToArray to create the actual array, avoiding creating the HostName if we don't need it, and avoiding an unnecessary SafeHandle allocation.
As part of this, I also noticed that we had some bugs in how some of our interop structures on Windows were defined. In particular, fields that in the native types were size_t were defined as int rather than IntPtr in the managed code. It appears we were saved by padding, but I fixed it regardless.
And as long as I was changing pretty much everything else, where I was touching code I also cleaned up some legacy style stuff.
Signed-off-by: dotnet-bot <[email protected]>
[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter
Main objective for reviewers: This PR shouldn't change anything for `arm64`.
Context: "Debug Mode" on the Apple Watch allows execution of regular machine code and thus is pretty similar to FullAOT on iPhone, i.e. it doesn't require bitcode, but _still_ doesn't allow `signal(3)` so cooperative suspend is required.
Apple Watch Series 4 and onward use an ARM64 chip, but with a different ABI, also known as `arm64_32`. This PR changes the AOT compiler and related trampolines so that the AOT compiler can generate all necessary code to run the interpreter on this target.
Changes:
--------------------------------------
[arm64_32] set register size to 8 in cross compiler too
-----------------------------------------
[machine] update `target_mgreg_t` definition
`SIZEOF_REGISTER` is usually the same as `TARGET_SIZEOF_VOID_P`, except when `MONO_ARCH_ILP32 is defined.
`target_mgreg_t` should represent the width of the hardware register, that is, `SIZEOF_REGISTER`.
---------------------------------------------
[arm64_32] fix AOT image layout
---------------------------------------------
[arm64_32] make trampolines bitwidth aware
* replace pointer loads/stores with bitwidth-dependent macro
* reflect `specific` trampolines so that only two instructions are used for ILP32, since the related pair in the data page only needs 2 * 32bits too
* replace some `sizeof (target_mgreg_t)` with `TARGET_SIZEOF_VOID_P` (former is hardware register size, latter is pointer size)
---------------------------------------------
These regression tests are _not_ passing: https://github.com/mono/mono/issues/16864 Also some of monotouch-tests are crashing, see https://github.com/mono/mono/issues/16819
Here is a screenshot of a debug session in VSMac:
<img width="1321" alt="Screenshot 2019-09-16 at 19 13 22" src="https://user-images.githubusercontent.com/75403/64981326-1dfbc000-d8bc-11e9-9d16-48036f36b638.png">
Contributes to https://github.com/mono/mono/issues/10641
Treat [In, Out], [In] and unspecified as input arguments. Important change from
current behavior is to allow parameter without directional attributes.
Use case example is _MethodInfo.Invoke() method called from native client.
- Factor out reptition into already existing macros.
- Remove the default for computed goto which is dead.
Computed goto has no notion of default. It is just
an unchecked array access.
Extracted from https://github.com/mono/mono/pull/16721.
* [interp] Pass rank instead to LDELEMA
It feels more intuitive and uses less computations.
* [interp] Avoid unnecessary type check
Loading element address of array requires type checks only if the elements of the array are references.
* [interp] Avoid using MINT_CALLRUN for Get intrinsic
It is very slow. Use ldelema/ldobj pair instead.
* [interp] Optimize MINT_LDELEMA
* [interp] Rename ldelema_fast to ldelema1
ldelema_fast was handling arrays with a single dimension. Rename it to better suggest this.
* [interp] Avoid using MINT_CALLRUN for Set intrinsic
* [interp] Remove some duplicated and confusing code
* [interp] Fix stack type of MINT_NEWARR result
When creating a new culture, we’ll have the equality CultureInfo.DateTimeInfo.Calendar == CultureInfo.calendar be true. After cloning such culture, this equality would not be true. The fix here is to ensure if the equality is true before cloning then should be true after cloning.
Signed-off-by: dotnet-bot <[email protected]>
* [runtime] Fix configure support for netcore+out of tree builds. Add wasm support for generating netcore/config.make.
* [runtime] Add bundle support for the netcore assembly loader.
* [netcore] Add missing linker exclusion.
* [wasm] Add netcore builds, enabled by defining ENABLE_WASM_NETCORE in Make.config.
The targets are 'package-wasm-runtime-netcore' and 'package-wasm-bcl-netcore'.
The binaries are copied to out/wasm-runtime-netcore-<CONFIG> and out/wasm-bcl/netcore.
* [wasm] Add netcore support to the build system and packager.
* Fix the build.
* Fix the dynamic build.
* Fix infrequent hangs in test-runner.
test-runner has been plagued with very infrequent hangs causing long
timeouts on CI. Turns out that there is a race in AsyncStreamReader
used by Process class for handling stdout/stderr when closing down
process. Since AsyncStreamReader::Dispose didn't make sure no pending
async read requests were still in flight before closing the stream
and underlying handle, it led to a race condition deadlocking the
complete process, hanging test-runner. A similar race has also been
observed but instead of causing a deadlock, it could also manifest as an
System.ObjectDisposedException when doing EndRead while another thread
is disposing the underlying stream. Hitting that race didn't deadlock
the process but failed to complete invoke of test-runner.
Fix is to better protect the async callback and the thread doing the
dispose call. In order to make sure we don't close underlying handle
while still having async reads in flight, fix also checks async result
for completion and if not completed when trying to dispose AsyncStreamReader
it will try to cancel outstanding pending IO and wait for completion
before closing the stream.
Since the issue has only been seen on Windows, the fix will try
to cancel pending IO and wait for completion before closing stream
on Windows. On other platforms, old behavior will be preserved, meaning
that the implementation will still be vunarable to race between pending
reads and close of stream, but since problem has not been observed on
other platforms and since there is no good way of cancel outstanding
blocking reads, old behavior is kept.
At some point in future we should look into replacing the implementation
of AsyncStreamReader and use cancelation tokens, but since we don't have
all corefx support around cancelation in Mono BCL, that currently won't
solve the issue, meaning that we need to bring in more classes. Since the
problem also occur in test-runner using the build BCL profile, even more
needs to be added to that profile in order to get similar support. But due
to the infrequency of the problem and that it has only been observed on
Windows, the isolated fix seems more reasonable.
* Build error fix.
* Review feedback.
* Fix type cast not working on linux builds.
* Adjust icall naming in icall-def.h.
* [netcore] Change an ArrayList to a List<T>.
* [netcore] Call the generic version of Array.IndexOf () in the ICollection wrappers. Update exclusions file.
Since each function has its own module (in JIT mode) it makes sense to dump the whole module for MONO_VERBOSE_METHOD instead of just LLVM::Function.
It adds metadata, attributes and global variables (so it will be possible to copy-paste it to godbolt)
Example
static int Test(int x)
{
return x / 10;
}
Diff for Unoptimized IR: https://www.diffchecker.com/NrF413Ts
Diff for Optimized IR: https://www.diffchecker.com/jbEkeFFS
So now we can see global variables and metadata for each function (and can easily paste them to godbolt.org)
NOTE: optimized IR for this case contains "dead" variables (dump_module allowed us to see such), we probably need some Module-wide optimizations to strip dead code such as -globaldce
NOTE2: why do we emit exceptions in the first place for this case at all?
This is a legacy of before the profiler was used for the trace
output; it would apparently get the raw stack pointer and try to
dereference things by recalculating the offset as needed (no for
little, yes for big). However, because the profiler returns the
actual fixed-up pointer, this recalculation isn't needed on BE,
but instead grabs garbage a bit ahead on the stack.
To fix, use what was the little endian case unconditionally.
Example before:
[1: 20.70598 14] ENTER: System.Globalization.CultureInfo:.ctor (int,bool,bool)(this:700000000408fb0[System.Globalization.CultureInfo platform.exe], 271824864, -32, -32, )
Example after:
[1: 1.93377 14] ENTER: System.Globalization.CultureInfo:.ctor (int,bool,bool)(this:700000000408fb0[System.Globalization.CultureInfo platform.exe], 127, 0, 1)
[aot] Do not put quotes around wrapped path
Should fix: https://github.com/xamarin/xamarin-android/issues/3619
As it results in double quoting, which vanishes the effect and breaks
AOT for XA on Windows.
The actual error:
[aot-compiler stdout] Stripping the binary: ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Stable\MSBuild\Xamarin\Android\ndk\arm-linux-androideabi-"strip" --strip-symbol=\$a --strip-symbol=\$d obj\Release\90\aot\armeabi-v7a\libaot-Xamarin.Android.Arch.Core.Common.dll.so.tmp
[aot-compiler stderr] '""C:\Program' is not recognized as an internal or external command,
[aot-compiler stderr] operable program or batch file.
[aot-compiler stderr] AOT of image C:\Users\peter\source\repos\App9\App9\App9.Android\obj\Release\90\android\assets\Xamarin.Android.Support.CoordinaterLayout.dll failed.
* [interp] Add flag for locals that have their address taken
The previous handling of LDLOCA was broken because if the address was taken before the instructions that would be optimized we would miss any potential changes to the local value. Right now we just skip optimizing locals that have their address taken. This is achieved simply by not pushing LDLOC on the evaluation stack, for those locals.
* [interp] Add separate counters for optimized instructions
To provide more insight.
* [interp] Propagate locals
Whenever we generate a movloc we remember what local was copied. When loading a local we check if it's currently storing the value of another local, in which case we load the original local instead.
* [interp] Kill instructions that write to dead locals
We track the liveness of a local by counting how many times the local is loaded using ldloc. When such instructions are optimized, the ldloc counter is updated accordingly.
* [interp] Don't optimize code if under debugger
* [interp] Replace frame_objref with volatile stores to non-volatile locals.
Non-volatiles subject to volatile read/write still get stack-packed.
Volatiles do not.
This will possibly conserve stack, unless MINT_NEWOBJ_FAST is critical path.
It looks like it is -- enabling this for Linux/gcc/amd64 grows
frame from 0x98 to 0xA8.
In either case, it is more efficient as the reads do not have to be volatile.
The value can be on the stack and in registers. The stack value will pin it.
* PR: Comments.
* PR: Rearrange comment for correctness, same length.
S.R.CS.Unsafe is used in number of places in Vector<T> already. This change modifies more places to use it to make the code more compact.
Updated Vector.tt template to match while I was on it
Signed-off-by: dotnet-bot <[email protected]>
* improve logging for EventSource.WriteEvent
* Fix IndexOutOfRangeException in SerializeEventArgs when incorrect arguments got passed
* simplify arg-check; remove nullable-todo
* switch from Debugger.Log to ReportOutOfBandMessage
* Remove unused flush-Paramater from ReportOutOfBandMessage
* fix parameter type nullable-check for reference-types
* fix parameter type nullable-check for nullable-types
Signed-off-by: dotnet-bot <[email protected]>
* nuspec for llvm
* Add llvm to matrix
* fix scripts/ci/pipeline-netcore-runtime.yml
* fix scripts/ci/pipeline-netcore-runtime.yml
* fix scripts/ci/pipeline-netcore-runtime.yml
* run tests with llvm
* add macOS lane
* disable llvm tests for now
* [interp] Fix buffer overreads and overwrites found by valgrind.
* Attempt to deal with inlining correctly.
* PR: Dial back IR changes. Only IL relevant.
* PR: Dial back more -- only needed changes to .NET IL manipulation, not interpreter IR manipulation.
* PR: Remove one more line.
Eventually this could contribute to stack savings. On its own, nothing.
The compiler apparently likes to create temporaries, like ip and ip - 1.
Which then have to survive functions calls, on the stack, if nonvolatile registers are exhausted.
This combats that and in a larger PR helped.
-p PORT allows easier retrieval of AOT profile from the application
running with aot profiler, using the socket connection on local PORT
-f instructs the tool to try setup adb port forwarding to/from Android
device or emulator
Example usage, retrieve the AOT profile from Android:
> mono aprofutil.exe -s -v -f -p 9998 -o my.aprof
Calling 'adb forward tcp:9998 tcp:9998'...
Reading from '127.0.0.1:9998'...
Read total 94903 bytes...
Summary:
Modules: 6
Types: 262
Methods: 1,162
Going to write the profile to 'my.aprof'
* Fix Running .NET Core Under Winndows App Compat Shim
.NET Core uses Windows features called sort handles for perf reason to speed up the collation operations (e.g. string comparisons). When enabling Windows app compat shim (e.g. Windows 7 compatibility mode), the calls uses sort handles will fail which cause all collation operations to fail.
The fix here is to detect if the sort handles work before using it to ensure successful run.
* Address the feedback
* More feedback addressing
Signed-off-by: dotnet-bot <[email protected]>
* [wasm] Add missing aot-profile/runtime.js.
* [aot] Avoid writing out a zero AOTID in deterministic mode.
* [wasm] Add --aot-profile= option to packager.
* Modify configuration flag `ENABLE_WASM_DYNAMIC_RUMTIME` to `ENABLE_WASM_DYNAMIC_RUNTIME`
* Modify configuration flag `ENABLE_WASM_DYNAMIC_RUMTIME` to `ENABLE_WASM_DYNAMIC_RUNTIME`
* Modify configuration flag `ENABLE_WASM_DYNAMIC_RUMTIME` to `ENABLE_WASM_DYNAMIC_RUNTIME`
* [wasm] stop excluding test_0_large_nullable_invoke on wasm
* [wasm] remove wasm exclusion from test_0_simple_double_casts
* Add category MultiThreaded to more of the concurrent collection tests
* Add more MultiThreaded annotations to HttpListener2Test
* Add category MultiThreaded to HttpWebRequestTest
* [wasm] flag more tests that are taking down the runtime
* [wasm] force sockets to throw PNSE in the ctor for now
* [wasm] enable corlib interpreter tests
* [wasm] Increase timeout for corlib tests
* try to fix wasm-cross-win-release-configure on macos
* [wasm] Fix several typos
* add a comment about an error in test class name
* Remove the comment about test class name because it could be passed on xunit command line
Also removes dependency on System.Range and RuntimeHelpers.GetSubArray in a simple console app such that they can be trimmed away.
Signed-off-by: dotnet-bot <[email protected]>
These are not currently supported, but marking them as simd helps llvm eliminate dead variables with these types, since
XZERO is easier to eliminate than VZERO.
* [cominterop] Add a helper to create default marshal spec for ccw arguments.
* [cominterop] Default to SAFEARRAY(VARIANT) as CCW argument for object[].
* [cominterop] Fix build with --enable-cxx.
[interp] Embrace that ip is const guint16* and remove casts to that type.
or to gint16*. Or is there a reason for this style?
Maybe could change type but still want to cast for the deref?
Before this commit, the only information associated with a local was just the offset at which it resides and instructions had this offset embedded from the start. This makes it awkward to have data structures indexed on the local, or have additional information per local, which we might care at some point (for example if it is multi basic block local, if the address of the local was taken etc). In addition to this, if we will want to remove some instructions that make some locals dead, it means that we will have to compact the whole locals space and update all the offsets referenced by all instructions. We solve all these problems by resolving (and allocating) the local offset at the latest time, while emitting the instruction in the compacted byte stream. At this point dead locals will remain dead, with no additional work needed to handle them.
For now, IL locals of the current method that we are compiling are immortal. We can address that later if needed.
Keeping these reflection enabled pulls in quite a bit of junk (generic dictionaries, standalone method bodies, bookkeeping) that adds up to 1.5% of the size of Hello World...
Signed-off-by: dotnet-bot <[email protected]>
The implementation reads the current value of the static cache field and then later overwrites that field with the originally read value. If ClearCachedData was called in the interim to clear the cached data, this will end up effectively undoing part of that clearing, as it'll end up restoring the previous cache. The fix is to write back the new reference only when we need to, which we could do when we detect it's null.
There's a secondary race condition this fixes as well. When a name and an altname are used with CultureInfo.GetCurrentCulture(string, string), the implementation was publishig the newly created instance into the dictionary under the lock, but then after the lock was released, it was setting that TextInfo to be read-only. That provides a window where another thread could see it as non-read-only and mutate it. The fix is to ensure it's marked as read-only fully before it's published.
As I was doing this, it struck me that the implementation was overly complicated, trying to merge three different code paths for three different callers, presumably to share code, but most of the code ended up not being shared anyway, which just made the code harder to follow for little gain. So, I split it back out into the three calling functions and removed the helper.
I also changed the locking mechanism. It had been using a single shared lock to protect all state, but the purpose of the lock is really just to synchronize access to an individual dictionary, so we can just lock on the relevant dictionary.
Signed-off-by: dotnet-bot <[email protected]>
* Remove stale SuppressMessage attributes (dotnet/coreclr#26501)
Signed-off-by: dotnet-bot <[email protected]>
* Use null coalescing assignment operator in more places
There's currently no auto-fix for this, so the fixes were done manually.
Signed-off-by: dotnet-bot <[email protected]>
* Fix IDE0026 (use expression-bodied members for indexers)
Signed-off-by: dotnet-bot <[email protected]>
* [jit][llvm] Track variable nullness separately from array length ranges/index ranges in abcrem.
"Nullness" is tracked via a separate field that is stored adjacent
variable/array value ranges; values may be "maybe-null" or "not-null";
the intersection of maybe-null and not-null yields not-null, the union of
maybe-null and not-null yields maybe-null. The existing graph traversal logic
is reused as much as possible, which makes the implementation of this
null value approximation slightly more complicated than it would be
otherwise.
Fixes https://github.com/mono/mono/issues/16310, which was caused by
the use of non-empty array length ranges as a way to encode non-null
values.
This also allows null check elision for zero-sized arrays.
* Fix C++ compatibility. Fix a typo in a comment.
* Add symmetric nullness relations.
* Make ldlen imply that the source register is not-null, similar to CHECK_THIS or any other null check.
Callers of mono_reflection_create_custom_attr_data_args_noalloc were leaking some of the returned information. Accessed attributes are FixedBufferAttribute and UnmanagedFunctionPointerAttribute.
* [interp] Reduce unnecessary uses of frame->ex
* [interp] Remove ex from InterpFrame
We save stack space and move the exception where it belongs, in ThreadContext. It was confusing what frame->ex really meant, it was probably not used / initialized properly. We move it now to ThreadContext where it represents the current exception being thrown during EH (when we have a resume state set).
* Disable `subdir-objects` mode in Automake
This forces creation of subdirectories' files (e.g. .deps/*.Plo) in the
parent directory listing the source file. This works around a situation
where two different files specify files in a different parent directory
(i.e. ../../support/adler32.c in mono/metadata/ and adler32.c in
support/) both emit files into the same place (support/.deps), causing
`make distclean` to try and delete support/.deps from two different
places, breaking distclean.
This unfortunately adds a pile of Automake warnings, during autogen.
The "correct" fix is to stop specifying zlib as a pile of flat .c files,
and instead put it in its own subdirectory, conditionally including
its .la files as required.
Partially fixes https://github.com/mono/mono/issues/16605
* Ship netcore/Makefile with an empty distclean rule
We need a netcore/ directory because we write to it during configure,
and we need a netcore/Makefile with a distclean rule, so top-level
recursive distclean doesn't fail. So specify both here.
Partially fixes https://github.com/mono/mono/issues/16605
* [netcore] Fix the range checks for Vector.CopyTo().
* [netcore] Fix Vector.get_Item () for u1/u2, the llvm type is a vector of i1/i2, so we need to zero extend.
GCHandle is mutable, and this type does call Free on the handle, but with it marked as readonly, the mutations performed by Free will be done on a copy rather than on the original.
Signed-off-by: dotnet-bot <[email protected]>
* [llvm] Add functions to create weighted branches.
* [llvm] Use weighted branches in GC_SAFE_POINT, some llvm passes doesn't seem to recognize llvm.expect so the LLVM JIT generates the slow inline.
* Refactor BinaryReader.ReadChars using Span (dotnet/coreclr#26325)
Avoids unsafe code and makes the code simpler
Signed-off-by: dotnet-bot <[email protected]>
* Remove unnecessary parens from `return (true);` and `return (false);` (#26488)
Just a search and replace.
Signed-off-by: dotnet-bot <[email protected]>
* Avoid some unnecessary initialization in DateTimeParse (#26487)
Signed-off-by: dotnet-bot <[email protected]>
* Update analyzer versions (dotnet/corefx#40778)
In particular to pick up StyleCop fixes related to C# 8 and nullability.
Signed-off-by: dotnet-bot <[email protected]>
1. When comparing strings, check pointer equality.
Faster when they match, slower when they do not.
2. Provide string lowercasing into a provided buffer, which can equal
the input, to avoid extra malloc/free.
3. define G_STRING_CONSTANT_AND_LENGTH(x) (x), G_N_ELEMENTS (x) - 1
e.g. strncmp (foo, G_STRING_CONSTANT_AND_LENGTH ("version"))
mono_handle_native_crash() function can actually return if the native crash has triggered or has been trigerred by more than one signal. So it is possible to reach the point of the assert
This is so that complex consumers such as Visual Studio for Mac can forego attempting to enumerate all loaded libraries, register them one at a time and potentially keep the list updated
* [Coop] ves_icall_InternalInvoke.
(Part taken from ves_icall_InternalExecute https://github.com/mono/mono/pull/16622.)
* error_init_reuse.
* Remove stars from types.
* Fixing single step inside Exception on Android...
The method is null because on ss_create_init_args the IL is -1 when calling method Mono_UnhandledException_internal what I think it's expected, because of that I ignore the single step on android if there is no method. (debugger-engine.c)
After that the sequence point cannot be found because it's calling a method of class DynamicMethodNameCounter what I think it's expected, because of that I remove the assert on android. (debugger-agent.c)
Fixes#14772
* Changing comment to make it clear...
* [interp] Add stack information for each instruction
For each instruction PopN indicates how many values from the top of the stack are used by the instruction. PushN signals how many values are pushed back. These are also used to prevent values from the stack being optimized out, since they might still be used by an instruction. VarPop and VarPush mean that the number is not constant, so we need to inspect the data fields of the instruction (typically for an imethod or csignature) to figure out the stack usage.
* [interp] Convert ldloc/stloc pairs to movloc
The movloc instruction operates directly on locals. This is faster due to avoiding dispatch and stack indirection. More important is that it makes it easy to do copy propagation of locals and it has no stack usage, which means that it could even be killed if the destination local is no longer referenced (as well as STLOC_NP). In the future we could reuse this mechanism of tracking the value of a stack slot to do constant propagation and kill even more instructions (we might need to have _IMM versions of opcodes for this to work).
* [interp] Enable disabling of interp optimization
* [interp] Add time tracking stat for cprop optimizations
* [interp] Move stloc.np transformations to the cprop pass
It makes more sense to do such transformations here and we also don't want transformations in the generate phase prevent us from detecting alternative transformations when running the full pass.
* [interp] Add counter for instructions that were optimized away
* [interp] Make it explicit that we are dealing with IR code
It can be confusing in verbose output.
* Remove MAX_PATH usage in w32process
* Fixes
* Shrink buffer temporarily
* More fixes
* Reset buffer size to 260
* Fix length check and add notes
* Actually free things
* Add tracing and zero len at start
* Typo
* Fix another leak
* Simplify logic
It turns out it's not enough to set global fast math parameters, it's also required to mark some instructions as "fast" (see https://llvm.org/docs/LangRef.html#fast-math-flags) like, for instance, clang does, see https://godbolt.org/z/U8TFST
E.g. all optimizations inside SimplifyLibCalls pass (it's a subpass of InstCombine) need it.
Remove ASP.NET sample (we currently have to download apsnet runtime everytime)
instead we can do:
dotnet new webapp
and do make patch-app APP_PATH=/path/to/myasp (works for any kind of apps/templates)
* [jit] Relax assembly checking for 64 bit targets to allow running mixed-mode MSVC code.
Fixes#37913
* STACK_PTR|I8 should be the same as I8|STACK_PTR tuple
* fix i4 to ptr conv on 64bit
* [interp] Remove some some false is_bb_start markings
Having fewer basic blocks makes potential optimizations more effective.
* [interp] Persist variables in TransformData
Thate are not used by inlined code because we don't inline code that has multiple basic blocks or clauses.
* [interp] Enable emitting of MINT_NOP instruction
This instruction will be optimized away when compacting the instruction stream.
* [interp] Clear instructions insead of removing them
Makes everything easier.
* [interp] Fix some instructions size inconsistencies
* [interp] Add more is_bb_start markings
* [interp] Add nop instead of extending bb
We should always have an IR instruction associated with an IL offset, especially when that instruction is a bb_start since we will need to branch to it and resolve the IR instruction from the il_offset.
* [interp] Simplify resolving in offset
We should always have an in_offset associated with the il_offset we are branching to.
* [interp] Add correct il_offset for all instructions
Except for special prolog instructions that will have -1 as the offset. We don't make much use of il_offset for non bb_start instructions, but they might be useful for debugging.
* [interp] Fix il_offset of some conv opcodes
[runtime] Make eglib tests run on CI
Update mono/eglib SUBDIRS to build tests after eglib is built.
Add a check-local automake rule.
Add CI steps to run the eglib tests.
* Cleanup x86_patch and amd64_patch.
amd64_patch has two incorrect looking probably unused cases.
g_assert(0) and fix them.
call and jmp indirect (one case)
move reg RIP relative
x86_patch is large-ish inline macro.
Presumably for sharing with amd64, not inlining.
Restructure as an inline function, called once.
Try to make the code a little clearer also, with same functionality and efficiency
(modulo the optimized perf of "if i == 4" vs. "if i")
i.e. speak of instruction_size and offset_size, not pos and boolean size.
Add to x86_patch the ability to patch jmp/call indirect,
as amd64_patch has, but which was incorrect.
This would seem useful for a later change (using "thunks"
to patch nearby data instead of patching aligned instructions,
indirect call/jmp vs. direct).
amd64_patch largely delegates to x86_patch.
One case asserts and delegates.
Move the assert to the x86 side, where an optimizing
compiler should know to remove it for x86 anyway.
Change some assert to g_assert.
Remove some unnecessary casts.
Fix an assert (https://github.com/mono/mono/pull/16471).
* Change g_assert back to assert except where making larger changes
and less expansion.
[mini] publish global patches after JitInfo has been added
Fixes https://github.com/mono/mono/issues/14080
Consider the following example:
```csharp
static void CommonCallTarget () { }
static void TailA () {
tailcall CommonCallTarget ();
}
static void TailB () {
tailcall CommonCallTarget ();
}
```
Since `TailA` and `TailB` are tailcalling into `CommonCallTarget`, the resolution at patch-time is a bit tricky, that is, since it's a jump-like instruction the patching machinery won't know where it was called from. That's why we maintain a global hashtable `jump_target_hash` where each jump-site is signed up to be patched. At patch-time we know the target method (in the example `CommonCallTarget`), but since we don't know where we are coming from, we will just apply all patches for that target.
This works since ages, so why did it crash on arm64 sometimes?
When the patching happens, we check if the displacement between jump-site and target fits into it (24bit). If not, which happens not very often, we have to allocate a _thunk_:
https://github.com/mono/mono/blob/36296ce291f8a7b19de3eccb7a32c7e4ed9df8f2/mono/mini/mini-arm64.c#L928-L942
So instead of jumping to the target directly, we'll branch to the thunk. This is a little trampoline that loads the full address of the target and then finally branches to it. This one will live close-by the jump-site, because during compilation we will reserve specifically for that scenario some space after the generated code. For this, however, we need the JitInfo of the jump-site. And that's where the origin of the race is. Let's say:
* Thread A compiles `TailA`, and then jumps into it. Thus one patch point is in the `jump_target_hash`.
* Now Thread B compiles `TailB`, registers the patch point but has _not_ yet registered its JitInfo.
* Then Thread A continues, does the tailcall into `CommonCallTarget`, enters the patching machinery, which sees two patches. Now assume when applying the patch for `TailB` the displacement is too large, thus it tries to allocate a thunk but can't find the relevant JitInfo for it that it needs to emit the thunk. So it crashes as reported in https://github.com/mono/mono/issues/14080
As far as I can tell this only affects ARM64, ARM and PPC.
<!--
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
-->
Revert "[android] add hardware specific workaround for Nexus9 in armv7 mode"
This reverts commit ee90fc601e (also see https://github.com/mono/mono/pull/4878 ).
The device was released November 2014. I think it's fair to assume it isn't widely used anymore.
Add F_OFD_GETLK, F_OFD_SETLK and F_OFD_SETLKW to FcntlCommand. These
commmands are similar to F_GETLK, F_SETLK and F_SETLKW but operate on a
per-open-file-description lock instead of a per-process lock and avoid the
problem that the locks are released when close(dup(fd)) is called. See
https://lwn.net/Articles/586904/ for more information.
This commit also reruns create-native-map but keeps manual changes from
ed892ccf27,
b522eab5ff and
22b6b95814.
In [create-native-map.diff.txt](https://github.com/mono/mono/files/3557077/create-native-map.diff.txt) you can see the difference between the commited `map.[ch]` and the one `create-native-map.exe` wants to create:
- Manually inserted changes for NetBSD (`MAYMOVE` is turned into a negated `FIXED`)
- `Mono_Posix_ToSockaddrIn6()` and friends get skipped for `HOST_WIN32` (not sure why, when `sockaddr_in6` exists then `Mono_Posix_ToSockaddrIn6()` should work)
- At the bottom of `map.h` some functions are reordered and the parameters change (`const char*` vs. `char*`)
Running create-native-map.exe also moved some O_NOATIME-related stuff (from 8b9033e4d2) to the correct position and added it to Mono_Posix_ToOpenFlags(), which I kept in the commit.
[configure] remove autodection of llvm-config in $PATH
Instead `./autogen.sh --with-llvm=<path>` should be used if a build from `external/llvm` is not preferred.
The old behavior was confusing when a `llvm-config` is on `$PATH`, which can be the case when you have LLVM packages installed on a Linux distribution. It picked that up when `./autogen.sh --enable-llvm` was used.
/cc @brianrob
* [interp] Compress the interpreter opcode names in the usual way, by changing
from an array of pointers to an array of 16 bit offsets into one large "string".
* PR: Make mono_interp_opname a function.
* [coop] Convert System_Runtime_Remoting_Messaging_AsyncResult_Invoke, etc.
* Remove mono_load_remote_field_checked from this PR.
* Pin ac->msg earlier (should not matter).
* Add missing barrier.
* Pin slightly earlier -- still should not matter.
Cleanup trampoline size checks.
- named `int` everywhere
- `assert` everywhere
- assert `<=` everywhere instead of `<`
- `const` almost everywhere
Names not consistent, following existing code (`size`, `buf_len`, `kMaxCode`.)
Only touching x86/amd64, granted.
Could be better -- make them two pass and avoid the presizing.
* 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
Read only memory is preferred, for efficiency and security.
Even if it requires relocation first.
If the runtime is loaded in more than one process, physical pages can be shared (at least on Windows, where the kernel does the relocation).
If there is memory corruption, writes to here will sigsegv/accessviolate.
The older code also copied the pointers. For lifetime purposes that could be useful, but generally is not. i.e. they live with the code they point to.
Writable function pointers are also particularly targets for attackers.
There's been tons of defenses put around them through the years.
Read only ones are not vulnerable -- unless the attacker escalates and calls mprotect first.
When there is a JIT, arguably there is just tons of attack surface.
But there is also AOT.
Structs of function pointers are usually read only in the wider world.
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.
[mini] do not re-AOT whole BCL for fullaotcheck targets
And enable `llvmfullaotcheck` target on CI.
Fixes https://github.com/mono/mono/issues/15999
On my armv7/linux machine with a `--with-runtime-preset=fullaot_llvm` configured build, before this PR:
```console
$ time make -C mono/mini llvmfullaotcheck -j4
[...]
real 9m42.362s
user 23m2.000s
sys 0m18.480s
```
After:
```console
$ time make -C mono/mini llvmfullaotcheck -j4
[...]
real 3m1.984s
user 4m51.648s
sys 0m8.248s
```
* [merp] Initialize hang_watchdog_path earlier; be lax if it's missing
Initialize hang_watchdog_path earlier - not just when
ves_icall_Mono_Runtime_EnableCrashReportingLog is called. That function is
only expected to be called by apps that explicitly want progress reports from
MERP when it's collecting a crash report. But we want the mono-hang-watchdog
to execute for all mono crashes (when crash reporting isn't ifdef'd out).
Also if we try to exec mono-hang-watchdog and fail for some reason, print a
nice message and then exit. We used to call g_assert_not_reached which would
kick off another MERP of the _forked child process_ which would then get
confused because it really can't run in the forked process at all.
On Unix, TransitionTimes are not used, so they are left empty. When deserializing an empty TransitionTime, it is throwing an exception because those are not normally valid. Fix deserialization to not validate empty TransitionTimes.
Fix dotnet/corefx 40578
Signed-off-by: dotnet-bot <[email protected]>
* Remove dead Boehm code.
Unity looked similarly dead.
The key points making it dead were:
create_allocator:
g_assert_not_reached() covering everything but local variables
mono_gc_get_managed_allocator:
always returning NULL, killing a bunch of code
after it
mono_gc_is_critical_method:
looking at data that was never filled in
This should have no impact, not even on Boehm.
Boehm should continue working just the same.
It is nice because it is the few/only uses of CEE_MONO_TLS.
- It _presumably_ means nothing on 32bit ARM and 32bit MIPS (was there mono/mips64?).
- Leaving only PowerPC32 and PowerPC64 (in this vicinity).
- It presumably means nothing on PowerPC32.
- Leaving PowerPC64 as the only user in this vicinity -- is it needed?
- Notice this is varyingly absent on x86, arm64, amd64, s390x.
Subject of another PR maybe.
Perhaps this was to enable the debugger to be 32bit against a 64bit target
on a biarch system, so it could do a cross-process manipulation of these pages?
That makes some sense on Windows at least.
(32bit debugger cannot debug 64bit target as of Vista, but that is using the Win32
"hard" debugger API. Mono could do otherwise).
There remains amd64 mono-codeman.c define ARCH_MAP_FLAGS MONO_MMAP_32BIT left alone.
LLVM eagerly optimizes constants such as NaN in a way that does not align with .NET behaviour. In the future we can change it so that we only do opcode emulation when LLVM is used.
Fixes https://github.com/mono/mono/issues/16411
* Fix Abbreviated Genitive Month Names Parsing
In 3.0 we have fixed the formatting to use the abbreviated genitive month names when having "d" format specifier followed by "MMM". This fix is good as original formatting specs required but we needed to support the parsing when we have such genitive names.
* Addressing the feedback
Signed-off-by: dotnet-bot <[email protected]>
While working on stack reduction, I believe I found that
the compiler could not tell how THROW_EX and/or NULL_CHECK terminate.
That is, essentially, the success paths preserve volatile registers.
They do not have to be spilled/filled.
This tweak should make it clearer to the compiler, optimized common paths, and not slow down uncommon paths.
This also cleans it up a little and reduces macro expansion, and then possibly should allow for reinlining what is now used only once.
Also add some const so it can be casted away less.
Believed to save 32 bytes of stack with Linux/amd64/clang, nothing for gcc.
And a nice cleanup.
Several SGEN_LOG entries logged usec based on result returend from TV_ELAPSED.
On SGEN's implementation of TV_ELAPSED, the result is not scaled to usec
but returned as 100ns ticks. This was not handled correctly by SGEN_LOG,
but other measures, like profile counters and SGEN binary protocol handles
it correctly.
Fix will adjust the SGEN_LOG calls currently presenting usec to correctly
scale the result. Fix also adds one additional logging measuring total
amount of time spend scanning thread data.
- Chunks do not need flags, only codemanagers do.
- Sort by size to minimize padding for alignment.
- Booleans only need one bit.
- Chunk is not spelled chunck.
- Suggest foo accessors be named foo() and set_foo(), not get_foo() and set_foo().
i.e. the more common "get" is implied.
- Allow free(0) w/o initialization.
User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.
Signed-off-by: dotnet-bot <[email protected]>
* Separate async method builder types into their own files
* Minor cleanup of AsyncTaskMethodBuilder types
* Split AsyncValueTaskMethodBuilder types into their own files
Signed-off-by: dotnet-bot <[email protected]>
The poll+select i/o selector backend can't handle file descriptor ids greater
than FD_SETSIZE. This can happen if too many files are open and we want to
wait on it.
Previously, mono would fail in the i/o selector thread by which point it was
too late to do anything.
With this change we will fail eagerly on the thread that calls IOSelector.Add
by throwing a NotSupportedException.
Addresses https://github.com/mono/mono/issues/15931
https://github.com/mono/mono/pull/16408 temporary fixed a tramp issue on
x86 (also exist on amd64). This commit fixes the underlying issue and re-enable
the use of noreturn outside of netcore.
The problem hit by the use of OP_NOT_REACHED on x86/amd64 is due to a specific
case when the address to patch happens to fall at the start of a different
managed method. Since the use of OP_NOT_REACHED can end a method
with the call instruction on x86/amd64 in combination with how patch location
(using the return address from stack) is resolved, the implementation in
mono_arch_patch_callsite didn't take this case into account, reading incorrect
patch data, triggering assert oh x86. So, based on timing we could end up with
the following code:
025715B3 call 02570D98
025715B8 push ebp
since the patch target is 025715B8, but also the start of a completely different
method, method_start == origin_code. The fix is to detect this case on x86/amd64
(done on each arch since the way origin_code is detected is arch specific)
and then use a method_start of NULL, that is already a supported scenario.
However, I'm not enabling the rule permanently, as it disagrees with VS IDE0055 about the spacing around semicolons at the end of empty while and for loops.
Because this also impacts `for (;;)` loops, I also searched and replaced those with `while (true)`, to standardize on that across the codebase.
Signed-off-by: dotnet-bot <[email protected]>
As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol:
```diff
--- /Applications/Xcode11-beta5.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h 2019-07-25 17:43:49.000000000 -0400
+++ /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/mman.h 2019-08-06 21:03:07.000000000 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@@ -145,6 +145,10 @@
#define MAP_RESILIENT_CODESIGN 0x2000 /* no code-signing failures */
#define MAP_RESILIENT_MEDIA 0x4000 /* no backing-store failures */
+#if !defined(CONFIG_EMBEDDED)
+#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only: Requires entitlement */
+#endif /* !defined(CONFIG_EMBEDDED) */
+
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
/*
```
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.
[android] remove text relocations in AOT/arm32
Remove support for "big assemblies" for AOT on Android running on ARM 32bit. This will remove relocations in `.text` which are not allowed in the upcoming Android Q release anymore.
_If_ a customer should run into this problem, the suggested workarounds are:
* Switch to ARM64, or
* Do not use AOT compilation.
Fixes https://github.com/mono/mono/issues/16369
Contributes to https://github.com/mono/mono/issues/16172.
Seen to reduce frame from 0xB8 to 0xA8 on Linux/amd64/gcc against master.
Possibly similar elsewhere.
(Possibly 8 added to a rounded 8.)
Add const, add braces, they might help compiler and/or programmer.
Without being entirely scientific about it, this case seems
to be one that uses more than typical locals and therefore
be on a sort of critical path to reduce frame size.
I have a change that reduces frame to 0x78 bytes (albeit
not yet working) and to achieve that, in this case I refetched
the locals after function calls.
This achieves similar but perhaps more elegantly.
If we rest at larger frame size then this case might not be
on the critical path.
https://github.com/mono/mono/issues/16172
* Skip one syscall per thread in garbage collection.
Specifically do not query for guard pages.
There are better ways:
1. Visual C++ specific, __try / __except, get the guard page exception,
put back the guard page. This is a little slower (exception + two syscalls),
but exceedinly rare. __try itself is cheap on x86, free on the rest.
This was also not allowed on UWP. It will be. And is VirtualProtectFromApp.
2. Record the TEB and get from it the maximum commited page and just use MAX, trivial.
The comments are also not completely clear as to what is going on here, but they were close.
Augment them.
These registers can be encountered in the unwind info for functions with a cold
cconv, like xmm0 on amd64. Since they are caller saved, they don't have to
be restored during EH.
- Move source support files for custom building the wasm runtimes to a new directory called `wasm/support`
- Modified `packager.exe` to build from this new subdir.
- Updated the README.md to document the change.
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.
Lots of various spacing issues. I say "mostly" because I explicitly undid some changes that added to rather than reduced inconsistency, e.g. region indents. We can revisit that later.
Signed-off-by: dotnet-bot <[email protected]>
This is just running the rule and auto-fixing everything. I undid changes that converted e.g. `while (...);` to `while (...) { }`.
Signed-off-by: dotnet-bot <[email protected]>
The "mostly" here is that I undid changes where it was forcing formatting around a `: this` or `: base` call for a ctor, in particular where it was moving one up from the next line to be at the end of the current line.
Signed-off-by: dotnet-bot <[email protected]>
* Avoid race condition in DiagnosticCounter
If while a DiagnosticCounter instance is being created the timer fires to process counters, the timer may end up evaluating a DiagnosticCounter whose constructor or derived types' constructor hasn't finished configuring the instance's state yet.
* Remove unnecessary #if
Signed-off-by: dotnet-bot <[email protected]>
* [corlib] Improve file:// url handling in AppDomainSetup.
WiX 3 installer toolkit uses file:/// prefix when setting ApplicationBase for newly created domain.
Currently this leads to invalid path exception:
file:///C:\... -> /C:\... -> full path expansion with current workdir on different drive -> Y:\C:\...
Later it fails check for multiple ':' -> NotSupportedException ("The given path's format is not supported.").
This patch uses logic already present in AppDomain::Load().
* [Test] Add a test for file:/// application base.
* [Test] Fix test failure on Windows.
* [corlib] Simplify file: protocol check for AppDomainSetup.
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.
This should conserve stack. I didn't verify it.
child_frame being address-taken, compiler would struggle to remove it.
So we have the same value in two places.
https://github.com/mono/mono/issues/16172
It seems the Configuration set inside of the System.Private.CoreLib.csproj is just completely ignored, making it default to "Debug".
Maybe because we're using Microsoft.NET.Sdk ?
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
* [netcore] Consolidate running tests between AzDO pipeline and Makefile
There was some unnecessary duplication between the two that we can remove.
* Add timeout to test execution
Jenkins builds are failing due to missing gettext; also realized that graphics unit tests will fail without some additional packages that will not be pulled in automatically.
Added:
`gettext-runtime gettext-tools cairo libdrm mesa-dri mesa-libs`
* Pass -fvisibility=hidden to profiler modules.
This appears to not break the profilers:
```
directhex@breakfast:/tmp$ nm -g /tmp/ponyponyponypony/lib/libmono-profiler-log.so | grep close_socket_fd
directhex@breakfast:/tmp$
directhex@breakfast:/tmp$ /tmp/ponyponyponypony/bin/mono --profile=log:report bottle.exe
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 99 bottles of beer on the wall.
[..]
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
Mono log profiler data
Profiler version: 3.0
Data version: 17
Arguments: log:report
Architecture: x86-64
Operating system: linux
Mean timer overhead: 86 nanoseconds
Program startup: Mon Aug 19 14:18:30 2019
Program ID: 17715
Server listening on: 41539
JIT summary
Compiled methods: 753
Generated code size: 228046
JIT helpers: 0
JIT helpers code size: 0
GC summary
GC resizes: 0
Max heap size: 0
Object moves: 0
Metadata summary
Loaded images: 3
Loaded assemblies: 3
Exception summary
Throws: 0
Executed finally clauses: 3
Thread summary
Thread: 0x7fcd968c9700, name: "Finalizer"
Thread: 0x7fcd966c8700, name: "Profiler Sampler"
Thread: 0x7fcd9b036780, name: "Main"
Thread: 0x7fcd964c7700, name: "Profiler Helper"
Thread: 0x7fcd954c5700, name: "Profiler Dumper"
Thread: 0x7fcd95cc6700, name: "Profiler Writer"
Domain summary
Domain: (nil), friendly name: "bottle.exe"
Context summary
Context: (nil), domain: (nil)
Counters:
Mono System:
User Time : 70.000ms
System Time : 0.000ms
Total Time : 140.000ms
Working Set : 22032384
Private Bytes : 63455232
Virtual Bytes : 449630208
Page Faults : 3004
CPU Load Average - 1min : 1.870000
CPU Load Average - 5min : 2.670000
CPU Load Average - 15min : 2.900000
Mono JIT:
Methods from AOT : 536
Methods JITted using mono JIT : 154
Methods JITted using LLVM : 0
```
* Add missing annotations and includes
Without being entirely scientific about it, this case seems
to be one that uses more than typical locals and therefore
be on a sort of critical path to reduce frame size.
I have a change that reduces frame to 0x78 bytes (albeit
not yet working) and to achieve that, in this case I refetched
the locals after function calls.
This achieves similar but perhaps more elegantly.
If we rest at larger frame size then this case might not be on the critical path.
https://github.com/mono/mono/issues/16172.
* Many updates to make it better
Too much to list by many measures. This makes sure appropriate kernel modules, file systems, build packages, supplemental packages, and directories are installed or created as appropriate. This also addresses a known failure condition in System.Security-xunit due to a missing directory resulting in ownership problems.
* Make corrections for Azure
I don't have an Azure to test with, so I missed that the script is calling with `-e` and that Azure uses a non-`GENERIC` kernel with procfs baked in (likely required for Azure drivers.)
Part of #16172 though not necessarily any gain from this change, at this time.
We might want to expose ifdef and inline mono_thread_internal_current also or instead.
debug-mono-ppdb.c ppdb_compressed_size may be used uninitialized
ppdb_size may be used uninitialized
image.c iinfo set but not used
icall.c klass set but not used
* [netcore] Use Release configuration for CI builds
Fixes https://github.com/mono/mono/issues/16308
* [ci] Ensure the artifacts/logs/Release folder exists
Some arcade steps need the path to exist and we only create artifacts/logs/Debug right now,
because that folder is created by eng/common/tools.sh used by init-tools.sh defaulting to Debug.
For purposes of stack savings, only MINT_NEWOBJ_VT_FAST w/o the "ST"
needed to be outlined, and inlining also the ST form increased
its stack use, w/o savings elsewhere.
That is, the recursive cases should generally not be outlined.
We were outlining two. We still outline one.
This is partially undoing my recent change, where I outlined both of these, but only one was justified.
We'll download it from GitHub instead of storing it in Jenkins admin config.
Trial run with FreeBSD for moving all the other provisioning scripts to the repo too.
Immediately after calling this we're going to loop around and call it again at the beginning of the while loop.
Signed-off-by: dotnet-bot <[email protected]>
* Put finally data back in locals instead of frame to save 16 bytes of stack.
Partial undo of f8fd60b5c0.
* Add comments explaining goto main_loop vs. MINT_IN_DISPATCH.
- Convert setting thread name to be coop-compatible.
- For constant thread names, just retain the constant, not a copy.
This includes producing and using constant unicode thread names on Windows.
- Make setting a thread name often non-fatal, except where mandated by public API.
- From earlier PR: mono_free (mono-publib.c) would no longer be referenced and therefore
no longer exported. That broke profilers and maybe other externals.
Choices:
1 Use it instead of g_free randomly sometimes.
2 Call it randomly sometimes.
3 include it in external-only.c or object.c
4 Mark it external only (breaks profiler).
5 Use a .def file or Unix equivalent.
5 is best, 2 is done here, the advantages/disadvantages
among most choices are subtle. 3 is probably better than 2
but is slightly bigger change, to put off -- you'd stop
compiling mono-publib.c and move it to include/extra_redist.
The advantage of not-.def file is perhaps that it is exposed
by the compiler, so maybe easy to port and work with.
People are more comfortable with obscure C extensions than
any linker options, and there are multiple linkers to contend
with. Arguably there are fewer compilers.
There is an incompatibility here.
If Mono hands off an InternalError and it is accessed
like an ExternalError, like memset(sizeof()), bad.
Hopefully nobody does that.
There is also compatability -- embedders can continue to embed MonoError
in their own data. Its size and hopefully alignment is unchanged.
* [interp] Make sure we allocate stack for MINT_LD_DELEGATE_INVOKE_IMPL
This opcode is pushing a function pointer from the delegate, so it needs to have stack reserved.
* [interp] Fix overflow of stack space
* Fix IDE0066 across corefx
"Fix all", but then manual tweaking to accommodate places the rule doesn't work quite right.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
Differences from the old versions:
- Only Vector<T> from corelib is supported.
- Only LLVM is supported.
- It uses more general opcodes like XBINOP instead of having one opcode
for every op+type combination which is not useful for LLVM.
- Convert setting thread name to be coop-compatible.
- For constant thread names, just retain the constant, not a copy.
This includes producing and using constant unicode thread names on Windows.
- Make setting a thread name often non-fatal, except where mandated by public API.
- From earlier PR: mono_free (mono-publib.c) would no longer be referenced and therefore
no longer exported. That broke profilers and maybe other externals.
Choices:
1 Use it instead of g_free randomly sometimes.
2 Call it randomly sometimes.
3 include it in external-only.c or object.c
4 Mark it external only (breaks profiler).
5 Use a .def file or Unix equivalent.
5 is best, 2 is done here, the advantages/disadvantages
among most choices are subtle. 3 is probably better than 2
but is slightly bigger change, to put off -- you'd stop
compiling mono-publib.c and move it to include/extra_redist.
The advantage of not-.def file is perhaps that it is exposed
by the compiler, so maybe easy to port and work with.
People are more comfortable with obscure C extensions than
any linker options, and there are multiple linkers to contend
with. Arguably there are fewer compilers.
* Use netcore_load_reference in mono_assembly_request_byname
* Add ALC static Resolve event code from CoreCLR
* Wire up the AssemblyResolve event
* Enable newly passing test
* Set requesting assembly in InternalLoad
* Remove infinite recursion
* Only call netcore_load_reference from mono_assembly_request_byname
* Remove test completely
* [interp] Fix more MonoError reuse (mono_object_new_checked).
* Inline mono_interp_new/mono_object_new_checked now that we are in outlined mono_interp_newobj.
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.
Alternative to https://github.com/mono/mono/pull/16197.
If you are going outline, you sometimes might as well take it all with you
instead of bouncing back and forth for a partial inlining.
1002a4de2b added Authenticode cert support on non-WatchOS. The tests,
however, were not non-WatchOS-only. Fix this, so Watch doesn't try to
run Authenticode tests.
* [jit] Disable inlining for ThrowHelper methods for non-netcore as well. Add an OP_NOT_REACHED after calls to these methods to let LLVM know they don't return.
* [llvm] Use the cold calling convention instead of the preserveall one, it has the same effect and its better supported.
* [llvm] Call the aot init function using the cold cconv.
* [llvm] Make the condition in the poll function unlikely.
* [llvm] Add a wrapper around the GC poll icall so it can be called with a cold calling convention.
* Move the noreturn check before the code which is shared with calli.
* Fix several non-visible characters in test files
* Replace Unicode surrogate pairs with escaped hex values
* Fix non-ASCII characters in most C# files
Signed-off-by: dotnet-bot <[email protected]>
Windows can still have its Unicode thread names, since we have UTF16 initially, just don't retain it.
This does penalize ves_icall_System_Threading_Thread_GetName_internal (non-netcore only),
which has to convert back to UTF16 each time.
But seems like a net win overall.
There is also a little prep work here for constant thread names and some temporary measures as multiple changes head toward the same code.
Rename `mono_thread_set_name_internal` to `mono_thread_set_name`.
Close possible race conditions.
Extracted from https://github.com/mono/mono/pull/15859.
In this variation, the exception handling and resume are split between the main function and the helper function, and no address-taken occurs on ip/sp/vt_sp.
The order is a little tangled but convincing.
The helper function returns MonoException* or checks context->has_resume_state and then returns, and then the caller does the checks again.
Based on past analysis this will conserve stack, but that was not double checked here.
i.e. due to `&valuetype_this`, though it is conditional and the code could be split up into inline and outline.
Maintain a counter and only set if the counter has changed.
This cannot be fully thread safe, so is not.
Any thread can set any other thread name at any time.
You could be atomic to do better, and loop to do even better,
but the thread name could still be changed again right after the loop exists.
The previous code was also not reliable in this way, since again the name
could be changed right away.
#16248
* Fix linking of OS-provided zlib
This is a reduced version of https://github.com/mono/mono/pull/16091
without the Z_PREFIX stuff
* Get rid of HAVE_ZLIB, be explicit about HAVE_SYS_ZLIB vs HAVE_STATIC_ZLIB
* Proposed fixes from Alex
* [metadata] Create strongly typed versions of mono_assembly_request_prepare
Addresses the family of issues similar to Coverity #1443346.
This came up as part of the Coverity review, and Coverity notices that this is
writting beyond the end of the structure. While this is correct, this requires
that the idiom be properly followed - that is, that the structure being passed
is of the given size.
Replaced instead with a method that eliminates the room for error with methods
that will initialize the whole structure, and the actual size computation is
done inside the method with the proper type sizes.
While I used methods, I feel that this should use macros.
LLVM lowering passes vt as reference to managed methods. On platforms where
the value type ABI is passing an address to the value type, either in register
or on stack (Windows x64) we must make sure we always use a temporary of
the value type or we will be breaking the value type semantics.
In JIT lowering of OP_OUTARG_VT we always make sure we use a temporary
in cases where argument storage is set to ArgValuetypeAddrInIReg/ArgValuetypeAddrOnStack.
On LLVM lowering this was currently not the case, but it still worked in many scenarios.
This was because IL load of arguments before doing a call did a
local copy and then we pass that byref. However, there are cases where this
copy could get optimized away and when that happens, we will change the
local value type in the caller’s frame, breaking the value type semantics.
Added test case in winx64structs hits such a scenario that will generate IL
breaking the value type semantics before the fix:
...
notail call monocc void @winx64_vector3Struct_Add_winx64_vector3Struct_winx64_vector3Struct
(i64 %49, %winx64_vector3Struct* %3, %winx64_vector3Struct* %16)
...
notail call monocc void @winx64_vector3Struct_Add_winx64_vector3Struct_winx64_vector3Struct
(i64 %64, %winx64_vector3Struct* %3, %winx64_vector3Struct* %15)
...
The two add calls will use the same reference (to a local value type in caller frame)
on both calls, this will break the value type semantics since they should both
be temporaries, like second argument is.
After the fix, the same code will be lowered into:
...
notail call monocc void @winx64_vector3Struct_Add_winx64_vector3Struct_winx64_vector3Struct
(i64 %55, %winx64_vector3Struct* %19, %winx64_vector3Struct* %18)
...
notail call monocc void @winx64_vector3Struct_Add_winx64_vector3Struct_winx64_vector3Struct
(i64 %72, %winx64_vector3Struct* %16, %winx64_vector3Struct* %15)
...
Each argument gets its own temporary that, according to the ABI, gets passed
by address down to function.
There will be situations where we could end up with two temporaries, one from
the load and one from the lowering of OP_LLVM_OUTARG_VT (same as we get on JIT),
this will however be detected by LLVM optimization pass, removing one of the copies.
LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
I used the auto-fix and then undid changes in areas where the fields were potentially mutated in native, e.g. I undid many of the changes in reflection. We can revisit those individually later.
Signed-off-by: dotnet-bot <[email protected]>
* [runtime] Initialize thread suspend policy at startup, inline getter
On some benchmarks we saw mono_threads_suspend_policy() using a lot of CPU
time.
Rather than doing an init-on-first-use, initialize the policy once upfront when
the JIT it starting up and make the getter method static inline.
* move mono_threads_suspend_policy_init into mono_thread_info_init
* [mini] Initialize suspend policy for `mono --version`
Need to initialize the suspend policy before printing its name. Otherwise the
suspend policy is unset since no other runtime initialization is done for `--version`.
- The eng/Versions.props was already imported by the arcade targets causing a double-import warning:
> warning MSB4011: "/Users/alexander/dev/mono/eng/Versions.props" cannot be imported again. It was already imported at "/Users/alexander/.nuget/packages/microsoft.dotnet.arcade.sdk/1.0.0-beta.19379.1/tools/DefaultVersions.props (17,3)". This is most likely a build authoring error. This subsequent import will be ignored.
- Remove BaseAddress and TRACE from the project file, this was done upstream at https://github.com/dotnet/coreclr/commit/bc430cdd2010bf7790854a60380d00c506c346a6
- Remove unecessary DebugSymbols/DebugType settings, we already set them in the global PropertyGroup
The locally unknown function, despite being small/fast, forces saving values in stack and nonvolatile registers
around calling it.
Both nonvolatile registers and stack are at a premium here, whereas usually stack is cheap.
The macro is just a read from offset 0 and checking for zero.
Prompted by mono/msbuild#126:
This includes:
- merge mono-2019-06
- SDK update to track dotnet release/3.0.100-preview8
- Roslyn updated to 3.3.0-beta2-19381-14
https://bugzilla.xamarin.com/show_bug.cgi?id=14976
Credit goes to datnhanlz for noting that removing XChangeProperty(DisplayHandle, hwnd.whole_window, _XEMBED_INFO, _XEMBED_INFO, 32, PropertyMode.Replace, atoms, 2); would also fix the bug.
Note that the type of Atom is actually unsigned long (see usr/include/X11/X.h), however the code used a C# int for the atoms. As such the code worked without a problem on 32 bit linux, but broke on 64 bit linux.
I switched to using IntPtr instead to make the code also work on 64-bit.
The issue was made visible with .NET Core WinForms. Some controls draw text with DrawTextEx to intermediate Graphics based on Bitmap, that later it's moved back to main Graphics with DrawImage. This results in a lost of transparency component along the way, making antialiased glyph bitmaps draw and B/W. Corruption is visible with gray antialiasing, but is more severe in subpixel modes.
I verified that same happens with gdiplus on Windows, code from CoreFX works correctly.
When given a null application name, CreateProcess already
searches the path and appends .exe in some cases. .NET's
Process class behaves in the same way (see
https://github.com/mono/mono/pull/16089#issuecomment-519984244).
The duplicated logic is unnecessary and broken in several ways.
Failures are ignored and the command line arguments are
executed. Relative paths are expected not to end in "exe".
Many corner cases work differently from .NET and CreateProcess.
This change makes it impossible for process_complete_path to fail,
so I removed the gboolean return and pulled out the output
parameter. Its caller wasn't handling the return value correctly
anyway.
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).
* Make mono_assembly_request_prepare take an ALC
* Typo
* Fix pedump
* Use default ALC
* Make v1 preload hook external-only
* Convert pedump and monodis
* fixup: use default ALC in netcore preload hook
trusted platform assemblies should be loaded into the default ALC
* [merp] Use a separate program as the hang supervisor.
Fixes https://github.com/mono/mono/issues/15646
macOS does not like signals being sent from the forked supervisor process, possibly towards anywhere but definitely when sent to the parent process. The following message is currently spewed after the supervisor process attempting to send a SIGSEGV to a hanged Mono process:
"The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec()."
We follow that direction and introduce a new binary that, when available in the mono executable's binary directory, is used to abort the parent process for us.
The explicit implementations of IList.Add/Insert/Set methods catch
InvalidCastException for casting input argument to type T to throw
an ArgumentException. The issue here is they put the core collection
modification operation in the try block, which could be overridden
by sub-classes and produce an InvalidCastException from user logic,
even the argument passed to IList.Add/Insert/Set is valid.
To fix the issue, we just need to move the collection modification
outside the try block, and leave the casting in try block only. In
this way, we'll get an ArgumentException when the argument type is
invalid, but propagate the InvalidCastException thrown from user
code as it should be.
dotnet/corefx#39919
Signed-off-by: dotnet-bot <[email protected]>
Mechanical/automated change. The only manual changes were a) removing the two rules from the CodeAnalysis.ruleset file, b) removing spaces from one line of a .targets file that is used to generate a .cs file, and c) reverting the changes in a few test files where the naive replacement happened in the middle of a verbatim string where the whitespace actually mattered.
Signed-off-by: dotnet-bot <[email protected]>
* make few methods used by DateTime.UtcNow inlinable to minimize the leap second performance regression impact, related to #25728
* apply suggested micro-optimizations
Signed-off-by: dotnet-bot <[email protected]>
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.
[sdb][interp] Use the interpreter's resume state to compute the IL offset in compute_frame_info.
This recovers the relevant bits of the "resume state" from the interpreter and uses that to recalculate the `il_offset` for the top frame.
Fixes https://github.com/mono/mono/issues/15687.
[llvm] Explicitly check for errors when calling LegacyIRCompileLayer::addModule.
LLVM built with LLVM_ENABLE_ASSERTIONS=On will crash if errors are not
explicitly consumed.
In the same way it is done in System.Buffer.MemoryCopy (void*, void*, ulong, ulong).
Correct what appears to be a typo in System.MemoryCopy with "long, long" size arguments.
Consequently, copy is not done byte per byte for the last int.MaxValue bytes when MemoryCopy is called with long argument (most common case). This should provide noticeable performance increase.
* [aotprof-tool] Initial import
Imported https://github.com/radekdoulik/aotprofile-tool and updated it
to use Mono.Profiler.Log
* [aotprof-tool] Added man page
* [aotprof-tool] Use the shortened name in README.md
* [trace] Use specific integer types for return value traces.
* [trace] Improve argument list formatting for ENTER lines.
Return value changes are especially visible for bools, where currently 4 bytes integers are printed.
[runtime] Fix an autoconf warning.
<!--
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
-->
* Remove some unused locals
Trying out various analyzers, including one to flag unused locals. There are more than this, but this is a first batch. Some of these are just clean-up. Others are saving unnecessary cost. At least one appears to be a real functional bug.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* Updating Math.Round and MathF.Round to be IEEE compliant so that the intrinsic and managed form are deterministic.
* Fixing the Math.Round and MathF.Round handling for values greater than 0.5 and less than 1.0
* Applying formatting patch.
Signed-off-by: dotnet-bot <[email protected]>
* Allow for interface implementations in EventSource.WriteEventVarArgs
* Also account null ref types and nullable types
* fix error in comment and simplify first part of boolean logic
* Update src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
Co-Authored-By: Noah Falk <[email protected]>
Signed-off-by: dotnet-bot <[email protected]>
The meat of this PR is what the title suggests, and with this commit all the basic ALC functionality should be working properly. Probably worth checking if this makes any new tests pass.
Additionally, this PR includes a second commit that switches over the search hook to use loaded_assemblies from the ALCs. This may break some existing tests due to remaining unimplemented ALC behavior, notably the native loading mechanism needed for Openssl in some of the cryptography tests. My inclination is to include the commit regardless and just disable the failing tests so that any future ALC work can watch for regressions in the loader, but I would appreciate input from steveisok on how important those tests are. I've not disabled anything yet in order to see exactly what new failures are introduced.
Cleaning up the `SocketAsyncEventArgs` class and preparing it for it's eventual
adaption from CoreFX.
There are a few instance fields and property accessors with `internal` visibility,
which the CoreFX version does not have. Replaced these with accessor methods.
The `PolicyRestricted` property and it's related `SocketAsyncEventArgs (bool)`
constructor is not used anywhere and the CoreFX version has a constructor with the
same signature, but different semantics.
In the CoreFX version, `Complete ()` does not call `DoComplete (this)` - renamed it
into `Complete_internal ()` to avoid any ambiguities and help the transitioning.
* Bump api-doc-tools to latest master
Disable building mdoc.exe in mcs mode since it no longer builds because of new C# features.
* Fix mcs build by disabling more mdoc invocations
* Bump monodroid_tools to compile against v4.7 reference assemblies
mdoc needs ValueTuple which is not in v4.6.
* [csproj] Update project files
* Update templates
- Add PropertyGroups for Debug and Release to set the DebugSymbols and DebugType by default.
* Allow the selection of the WebAssembly runtime version Debug | Release
- Decouple the reliance on `_DebugSymbolsProduced` to decide which runtime version to publish.
- Add support for <MonoWasmRuntime>Debug | Release</MonoWasmRuntime>
- Add validation target of the property to Mono.WebAssembly.Build.targets.
* Indentation
* Fix ordering of keywords in member signatures
* Add StyeCop.Analyzers
Most rules are disabled. Many of them we'll want to leave disabled, however there are a handful it'll be good to enable over time.
* Use built-in type alias
* Fix straggling stylecop warnings in all configurations
* Replace tabs with spaces
Signed-off-by: dotnet-bot <[email protected]>
* Make a dedicated polling thread for EventCounters
* Cleanup
* remove debug prints
* nit
* Fix comment
* addressing issues from code review
* Fix an assertion from getting fired when we have multiple listeners
* Fix a test issue
* code review feedback
* Fix a potential deadlock
* Fix another deadlock
* Allow s_sleepDurationInMilliseconds to be reset to a larger value
* More issues fix
* Let thread wake up from sleep if needed
* Some suggestions for the counters fix.
The resulting behavior should be the same as what is there now (assuming I didn't mess anything up), these are all just code simplifications that hopefully make it easier to review and maintain going forward. In total I think this reduces the change size in CounterGroup.cs by ~30%.
- With the addition of the AutoResetEvent the ManualResetEvent is no longer needed, removed it.
- Removed the various if foo != null checks for the shared state, it is all initialized once when then thread is created and then assumed to be non-null elsewhere.
- Removed a 2nd lock acquisition inside OnTimer
- Replaced an if with Math.Min in PollForValues
* fix test
Signed-off-by: dotnet-bot <[email protected]>
* Eliminate extra time zone conversions in DateTimeOffset
Revised members dealing specifically with local time by removing delegation to DateTime methods to avoid an extra call to TimeZoneInfo to determine offset:
Now
FromFileTime(long)
ToLocalTime()
* Fix DateTimeOffset.ToLocalTime(bool)
* Consolidate conversion from UTC DateTime to Local DateTimeOffset
Signed-off-by: dotnet-bot <[email protected]>
When we rewrote the async methods implementation with AsyncStateMachineBox, we neglected to call AddToActiveTasks if the debugger is paying attention to tasks. This hasn't mattered as the debugger's support for Tasks hasn't worked for other reasons in .NET Core, but there is now a renewed focus on it, and this is preventing some of that support from working.
This change is a minimal fix to ensure that we're adding the state machine box task when it's created and removing it when it completes. Post-3.0, we should look at overhauling this, e.g. to clean up a lot of this logging and tracking that's done, to use a weak table in order to avoid keeping task objects alive artificially if they're dropped without completing by the developer code, etc.
This only affects when the debugger is attached, as the s_asyncDebuggingEnabled field is only ever set by the debugger.
Signed-off-by: dotnet-bot <[email protected]>
* Typo
* Enable loaded_assemblies and lock
* Make mono_domain_assembly_open_internal ALC-aware
* Populate loaded_assemblies
Switch from prepend to append
* Some notes
* Exclude add_assembly_to_alc on non-netcore
* Cleanup appdomain.c
* Remove mono_alc_cleanup for now
* Update comment
* Disable using loaded_assemblies in the search hook
* Adjust alc cleanup
Preferable would be native only, i.e. for interpreter and for when
it is actually unused, but ok for now.
Between removing the managed and the native, managed is preserved
in case there uses of MonoError in C# other than icall wrappers.
Keep them safe.
But again ideally move it to native and remove the managed type,
pending debugging WebAssembly failure doing so.
* [llvm] Add support for llvm 9.0.
Works with this branch:
https://github.com/mono/llvm/tree/release_90
* Add support for JIT + LLVM 9.
* Don't assume that all memset targets will be aligned; fixes LLVM 6 on amd64.
Fixes regression related to floating point introduced in #15930.
This does mean we have to take a slower path instead of using the
PPC instruction, but it provides consistent results. Other CPUs
have to do this too, so it's not like PPC is impacted unfairly.
(i.e, NaN gives an inconsistent result, at least with POWER7 and
some amd64 CPUs tested)
Fixes#15990.
* Don't use clock_nanosleep on PASE
PASE exports this AIX syscall so autoconf detects it, but using it
will trigger SIGILL (for unimplemented syscall), which emits a LIC
log entry type of 4700-000F.
* Change ifdef guard for clock_nanosleep in threads
It only used clock_nanosleep on Linux, but enable it for all except
PASE. Android used to be guarded against, but the reasoning was
unknown, so @akoeplinger requested to have that guard removed.
* [netcore] Implement GetLoadContext
* [netcore] Implement ALC-aware referenced assembly resolution.
The process is described in
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext?view=netcore-3.0#usage-in-the-runtime
We try four things until one of them returns a non-null assembly.
1. Check if the assembly is already loaded in the ALC of the requesting
assembly.
2. If the ALC is not the default ALC, invoke the Load override.
3. Try the default ALC (TPA - trusted platform assemblies) loading.
4. Invoke the Resolving event of the original ALC.
The implementation borrows some managed code from
https://github.com/dotnet/coreclr/blob/8ba2e15201361402acd0ae9710bd37d50785cdfa/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs#L84-L187
It would be nice if that code was shared between the runtimes.
* [runtime] Implement mono_assembly_name_culture_is_neutral
* [netcore] Add mono_alc_invoke_resolve_using_resolve_satellite
* [netcore] Use ResolveSatelliteAssembly for satellite assembly refs
* [netcore] Some AssemblyLoadContextTest tests now pass
System.Runtime.Loader.Tests.AssemblyLoadContextTest.PublicConstructor_Default
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_NullParameter
System.Runtime.Loader.Tests.AssemblyLoadContextTest.LoadFromAssemblyName_AssemblyNotFound
System.Runtime.Loader.Tests.AssemblyLoadContextTest.PublicConstructor_Theory (with isCollectible: False)
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_ValidAssembly
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetLoadContextTest_SystemPrivateCorelibAssembly
System.Runtime.Loader.Tests.AssemblyLoadContextTest.DefaultAssemblyLoadContext_Properties
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_AssemblyNotFound
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetLoadContextTest_ValidTrustedPlatformAssembly
So currently we have two .NET Core:
1) `mono-repo/.dotnet` - we use it to bootstrap and build stuff (the SDK version is specified in `global.json`) - if you open `netcore/Makefile` it's referred there as `$(DOTNET)` variable.
2) `mono-repo/netcore/.dotnet` - it's just a runtime + CoreFX libs (it doesn't contain SDK stuff, templates, msbuild, etc) - we use it only to run tests because this runtime is synchronized with corefx tests in `eng/Versions.prop` file which is updated by a bot and `netcore/shared` sources for our System.Private.CoreLib also depend on that exact runtime version (the sources also updated by the bot).
This PR introduces a rule to copy mono bits to the `mono-repo/.dotnet` folder to be able to run real world apps (at your own risk) using mono-netcore (so when you run `mono-root/.dotnet/.dotnet run -c Release` for an app - even MSBuild will use mono runtime to build that app). However in theory we need exact SDK for the runtime version we have but I have no idea where and how to get one.
BTW, currently MSBuild crashes when it's powered by mono on `$(DOTNET) build` command for a hello world.
```
monoeg_assertion_message
mono_domain_assembly_preload
invoke_assembly_preload_hook
...
at <unknown> <0xffffffff>
at System.Reflection.RuntimeAssembly:GetExportedTypes <0x000a2>
at AssemblyInfoToLoadedTypes:ScanAssemblyForPublicTypes <0x0008e>
```
[interp] Remove unconditional branches to next instruction
These are very common, at least in debug builds. Optimize them away so it doesn't distort performance numbers.
- Provide extra definitions to the linker to ensure the type, methods and/or fields are not eliminated from your application.
* Use a <LinkDescription> item as follows:
```
<ItemGroup>
<LinkDescription Include="customlinker.xml" />
</ItemGroup>
```
This will then be added to the `WasmLinkAssemblies` step.
* Merge the `System.Diagnostics/ProcessStartInfo.cs` part into the referencesource file to avoid CS0282.
* Remove duplicate `using`.
* Fix unreachable code warning that got introduced in my last PR.
Non-Linux systems largely do not support `--binary`. Since the patch appears to be text anyway, it's probably safe to remove for all platforms.
With `patch -p0` , mdoc test now provides accurate pass/fail on FreeBSD.
* [sgen] Remove dead unpin_queue argument
* [sgen] Fix check-nursery-pinned debug option
And rename it to better reflect what is is doing now (which is to check that we don't leave any vtables tagged at the end of a collection). It used to also check that nursery objects are pinned, back when we were doing a nursery collection as part of the finishing pause of a concurrent collection.
* [jit] Align float/double Nan/Inf to uint conversion behavior with CoreCLR/LLVM
* Fix float/double -> ulong conversion for edge cases
* Fix mono_fconv_u8 / mono_rconv_u8 to also return 0 for PositiveInfinity
* Enable support for platform specific implementations of OP_RCONV_U8/OP_FCONV_U8/OP_FCONV_U4
* Restore OP emulation on WASM target
* Update tests
* Disable failing tests for now
* Adjust tests
* Adjust tests
* Fix float -> uint conversion on WASM
* Make interpreter consistent with compiled code
* Blind attempt to fix WASM test leg
* Implement remaining conversions in LLVM
* Fix ARM32
* Workaround for Windows x64 FullAOT+LLVM
* Bump AOT version
* [marshal] Always use gchandles in delegate_hash_table
Makes the code easier to follow and it also fixes race from https://github.com/mono/mono/commit/caa4a753ca8e15d43baaa01adb0f56f374b74a2b with boehm.
* [marshal] Free delegates with target that are passed to native code.
For static method delegates, we have a unique delegate_trampoline that is shared among all delegates. We always keep alive the first static method delegate passed to native, by creating a normal gchandle to it and storing it in delegate_hash_table. For instance methods, each delegate will create a separate wrapper and these wrappers are never shared (which was wrongly assumed in https://github.com/mono/mono/commit/caa4a753ca8e15d43baaa01adb0f56f374b74a2b). We shuldn't keep the delegate alive and this commit reverts the behavior for delegate with instance methods introduced in the mentioned commit.
Fixes https://github.com/mono/mono/issues/15751
We need to clearly distinguish between synchronous and asynchronous completions
and avoid any ambiguities and race conditions when it comes to error handling.
On synchronous completion, we must not invoke the async completion delegate.
In `System.Net.Sockets/Socket.cs`, the internal `BeginSConnect()` and `BeginMConnect()`
now return a `bool` indicating whether or not an async operation is pending.
If any error happens prior to starting the async operation, then we shall call
`SocketAsyncResult.Complete(..., true)` and return `false`. And since this is
a synchronous completion, it's `AsyncCallback` will not be invoked.
In `referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs`,
I compared the entire file against the CoreFX version and then copied the
`AttemptConnection()` method from their implementation to adapt their behavior.
The difference is that on synchronous completion, the `InternalConnectCallback(null, args)`
should be invoked.
* Add Roslyn maestro dependency
This should bring down the Microsoft.Net.Compilers package,
which contains the Roslyn binaries needed for mono packaging.
* Add Version to Versions.props as well
Preferable would be native only, i.e. for interpreter and for when
it is actually unused, but ok for now.
Between removing the managed and the native, managed is preserved
in case there uses of MonoError in C# other than icall wrappers.
Keep them safe.
But again ideally move it to native and remove the managed type,
pending debugging WebAssembly failure doing so.
On some operating systems, this test can take forever because the worker starves the other threads by holding the gc_lock. Bump sleeping so it doesn't rely on OS scheduling that much and guarantees other threads can progress in reasonable amount of time.
Circa 2010 to circa 2017.
Retrieved with apt-get source zlib on WSL Ubuntu 18.04.2 LTS.
This matches Debian or Ubuntu (they differ by one commit, and one of them restores a dummy function for compat).
---
* [minizip] Ensure we don't ever accidentally change calling convention
Make sure we always #define ZCALLBACK to empty so we don't change
the calling convention on windows by including a header which defines
'CALLBACK'. This will keep things as cdecl as required by the c#
pinvokes.
* Update zlib readme.
* Update zlib from 1.2.5 to 1.2.11.
* [zlib] Small fix for Visual C++.
see https://github.com/madler/zlib/pull/435/files#diff-0558e84b0c24a83ca790dcb05cd26212R1087
and https://github.com/madler/zlib/pull/435/files#diff-0558e84b0c24a83ca790dcb05cd26212R1104
* Add gzguts.h to Makefiles.
* Add .h files to Visual Studio project files just for GUI purposes.
O_NOATIME (Linux > 2.6.8): Do not update the file last access time (st_atime in the inode) when the file is read(2). Programs that merely index the existence of a file (backup programs e.g.) can reduce disk load using this flag.
* [runtime] Convert Volatile to use the same approach as the netcore version, get rid of most Volatile icalls.
* [runtime] Reduce the number of handles used by construct_culture ().
* [runtime] Convert some icalls to handles.
* Fix signature of FAMNextEvent.
* [aot] Avoid aoting the gsharedvt versions of Volatile:Read<T>/Write<T>.
* Bump API snapshot submodule
* Convert Marshal:UnsafeAddrOfPinnedArrayElement to use coop handles.
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
- Remove unused.
- Add missing that just happened to work.
- Synchronize size between netcore and regular. `#if` considered bad.
Extracted from https://github.com/mono/mono/pull/15859.
* Build System.Native.
* Disable `pthread_mutexattr_setprotocol` use, since it returns EINVAL on Haiku.
* Disable the `strerror` cache on Haiku. On Haiku, errors begin at `0x8000_0000` like a Win32 HRESULT. This means the indexing would be on negative numbers, which is a no-no. There are a few alternative ways to keep it though: hashtable, tuple array, offset...
Unfortunately, doesn't build all the way through. Has a tendency to bomb out during building `build-unix`. Will investigate why.
* [wasm] Touch the dummy .exe files created during linking if they already exist.
* [wasm] Display longer stack traces on v8.
* [wasm] Add a --native-strip option to the packager, defaults to true.
* Add targets for separate interpreter test projects. Normalize main.exe command line arguments.
We test dlopen with no library and in libdl later, without the
use of this setting.
Got the hint since I'm building for a configuration which had it set wrong.
It is racy because it is doing on-demand initialization, which is often racy.
The rewrite changes the result to be one pointer, atomically swapped, which implies a full barrier and data dependency, so no race.
It could also be fixed by copying and sorting an array of pairs, and one pointer to that.
However in order to save memory I instead use indirect data that is an array of uint16 pointing into the original data. That is a slight memory vs. time tradeoff.
Yes there is debugging code left, under #if, that I prefer to leave, both as evidence that I tested it, and to make it somewhat but ideally testable in future.
The code also was using an unnecessary somewhat risky but probably ok here way to compare pointers, that I fixed.
As well the result is marginally smaller and faster because it was inlining something like bubblesort, now reuses qsort.
* [interp] Simplify the control flow in the main loop to speed up compilation of interp.c.
Get rid of the handle_finally and main_loop labels.
* [interp] Move some rarely used locals to InterpFrame to speed up compilation and to increase the chance that the other locals end up in registers.
* Add macros for throwing exceptions to shorten the code a bit.
* Fix a previous change.
The python file was unreliable on macOS, let's see whether a simple msbuild replacement is better.
Also fixed dependencies on some of the Makefile targets so that they correctly detect when they need to run.
* boehm-gc.c:1923:14: warning: variable old_obj set but not used [-Wunused-but-set-variable]
* class-init.c:1720:1: warning: compare_by_interface_id defined but not used [-Wunused-function]
* class.c:1724:1: warning: compare_interface_ids defined but not used [-Wunused-function]
* icall.c:8190:13: warning: variable klass set but not used [-Wunused-but-set-variable]
* image.c:1063:20: warning: variable header set but not used [-Wunused-but-set-variable]
* metadata.c:2573:25: warning: right shift count >= width of type [-Wshift-count-overflow]
* sgen-dynarray.h:194:1: warning: dyn_array_int_is_copy defined but not used [-Wunused-function]
* sgen-mono.c:255:1: warning: emit_managed_allocater_noilgen defined but not used [-Wunused-function]
sgen-mono.c:238:1: warning: emit_nursery_check_noilgen defined but not used [-Wunused-function]
* sgen-tarjan-bridge.c:449:25: warning: right shift count >= width of type [-Wshift-count-overflow]
* threads.c:1451:11: warning: variable res set but not used [-Wunused-but-set-variable]
* w32process-unix-default.c:239:19: warning: variable min_dev set but not used [-Wunused-but-set-variable]
w32process-unix-default.c:239:10: warning: variable maj_dev set but not used [-Wunused-but-set-variable]
* w32process-unix.c:2107:25: warning: variable waitret set but not used [-Wunused-but-set-variable]
* aot-compiler.c:4180:1: warning: add_lazy_init_wrappers defined but not used [-Wunused-function]
* aot-compiler.c:7200:86: warning: format %lu expects argument of type long unsigned int, but argument 3 has type gsize {aka unsigned int} [-Wformat=]
* aot-compiler.c:10013:7: warning: unused variable index [-Wunused-variable]
* aot-compiler.c:10012:15: warning: variable method set but not used [-Wunused-but-set-variable]
* method-to-ir.c:4031:22: warning: variable tmpreg set but not used [-Wunused-but-set-variable]
* mini-runtime.c:2977:14: warning: variable invoke set but not used [-Wunused-but-set-variable]
* mono-rand.c:94:1: warning: mono_getentropy defined but not used [-Wunused-function]
When https://github.com/mono/mono/commit/9010d2f290d28dc97ac276e0c0d32a2932b7550f was merged we stopped including mcs/build/config.make.
However, that file set the VERSION variable which wasn't migrated to the new netcore/config.make so the nuget package missed the version.
Additionally, System.Private.CoreLib sources were moved into the netcore folder and we now seemingly need to pass `-p:IsPackable=true` for dotnet pack to build the nuget package.
* Re-enable CA1802 (use consts instead of readonly statics)
I enabled it only for privates and internals, as we've previously violated this in public surface area, and as everything goes through API review moving forward, didn't seem worthwhile fighting it and adding suppressions in various places.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
Fixes https://github.com/mono/mono/issues/10748
The calls for chown, lchown, fchown, and fchownat (from `Mono.Unix.Native.Syscall`) are all declared with unsigned integers for the `owner` and `group` parameters. This is incorrect.
Directly from the manpage
`man 2 chown`
<pre><code>
...
int chown(const char *pathname, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int lchown(const char *pathname, uid_t owner, gid_t group);
...
int fchownat(int dirfd, const char *pathname,
uid_t owner, gid_t group, int flags);
...
...
<b>If the owner or group is specified as -1</b>, then that ID is not changed.
...
</pre></code>
Emphasis added on the documentation explaining how the parameters can take the value -1, clearly not an unsigned integer. The `uid_t` struct is not an unsigned integer. I am assuming this was just an oversite on whoever re-wrote `Mono.Unix.Native.Syscall`.
The original calls from `Mono.Posix.Syscall` (now marked as Obsolete) all correctly use signed integers.
```
[DllImport ("libc", SetLastError=true)]
public static extern int chown (string path, int owner, int group);
[DllImport ("libc", SetLastError=true)]
public static extern int lchown (string path, int owner, int group);
```
Even the documentation directly from `mcs/class/Mono.Posix/Documentation/en/Mono.Unix.Native/Syscall.xml`
```
<para>
One of the owner or group id's
may be left unchanged by specifying it as -1.
</para>
```
* [netcore] Implement AssemblyLoadContext.GetLoadedAssemblies()
* No refonly on netcore
* Ifdef out AppDomain.GetAssemblies() on netcore
* Don't init the error
* Unnecessary ifdef
* [metadata] Fields whose types are gparams with a reference type constraint
aren't blittlable.
Don't try to layout the field to find out if it's blittable.
For gshared gparams, follow the blittability of the constraint.
Fixes certain recursive examples.
```
using System;
namespace TestRecursiveType
{
class Program
{
static void Main(string[] args)
{
SubClass subC = new SubClass();
Console.WriteLine(subC.GetTest());
}
}
public struct ValueTest<U>
{
// When U is instantiated with T, from BaseClass, we know it'll be a
// reference field, so we know the instantiation ValueTest<T> won't
// be blittable.
public readonly U value;
}
public abstract class BaseClass<T> where T : BaseClass<T>
{
public ValueTest<T> valueTest = default(ValueTest<T>);
}
public class SubClass : BaseClass<SubClass>
{
private String test = "test";
public string GetTest()
{
return test;
}
}
}
```
Fixes https://github.com/mono/mono/issues/15760
---
The failure is happening when we are doing mono_class_setup_fields ("BaseClass<T>") which needs to decide for each field whether it is blittable or not. So therefore we are trying to decide if ValueTest<T> (that is: the ValueTest<U> field inside BaseClass<T>) is blittable or not.
So we instantiate U with T.
Now to decide whether VaueTest<T> is blittable or not, we look at every field.
So then we look at T value.
To decide if T is blittable we first check if it's a reference type.
That check is currently inadequate for generic parameters - what the PR adds is the ability to see if theres a T : class constraint or a T : C constraint - where C is some class. As soon as we know that T's constraint will force it to be a reference type we can definitely say that T won't be blittable without having to initialize C, at all.
Previously, Mono would see that T is some kind of type for which it couldn't definitively decide that it's a reference type and it would call: mono_class_setup_fields (field_class) which would then try to setup the fields of the parent class BaseClass<T>. And that would hit the recursion check.
GNU ld accept single or double dash, means the same thing.
AIX ld warns on single dash, errors on double dash, in autoconf, and then errors on single dash later.
We want the double dash so autoconf rejects it on AIX.
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.
* Remove !s and TODO-NULLABLE comments for [DoesNotReturn]
* Remove !s and TODO-NULLABLE comments for [NotNullIfNotNull]
* Remove !s and TODO-NULLABLE comments for writes via Interlocked.CompareExchange
* Remove !s and TODO-NULLABLE comments for Debug.Assert on fields
* Update/add several TODO-NULLABLE comments
Signed-off-by: dotnet-bot <[email protected]>
If the debugger evaluates a `ValueTask<T>`'s `Result`, that counts as the "you should only consume a `ValueTask<T>`" once, and ends up breaking / hanging / throwing exceptions and other bad stuff while stepping through code in the debugger.
This commit addresses that in two ways:
1. Adds `[DebuggerBrowsable(Never)]` to `Result` to prevent it from showing up in debugger views.
2. Adds a NotifyOfCrossThreadDependency call to its ToString. This prevents the debugger from using ToString to show an implicit representation of the instance, and it forces the developer explicitly trying to access ToString (e.g. in the watch window) to click a button acknowleding the impact.
(Post 3.0, we should consider removing the `ValueTask<T>.ToString()` override altogether.)
Signed-off-by: dotnet-bot <[email protected]>
* Fix regression in Timers with long timeouts
Early in .NET Core 3.0, we added an important optimization to significantly reduce lock contention and CPU overheads in situations where lots of timers were firing. The optimization worked by splitting the set of timers into those expected to fire in the very near future and then everything else. However, for really long timers (e.g. > 24 days), due to integer overflows we can accidentally put a long timer onto the short list and cause a timer that shouldn’t fire for days to instead fire in milliseconds. This is not the first such bug we’ve had in Timer, and there is a fair amount of complicated casting (that we sometimes get wrong, obviously) in order to keep the tick count usage within the Int32 domain. This PR addresses the problem (and hopefully others in the future) by switching over to using Int64. We’re already paying to get 64-bit tick counts on both Windows and Unix, so this just removes truncation that was being performed, does a little more addition/comparison with 64-bit values instead of with 32-bit, and stores an Int64 instead of Int32 in each TimerQueueTimer. On 64-bit, this has a 0 increase in memory consumption, as it simply ends up utilizing padding space that was previously in TimerQueueTimer. On 32-bit, it increases memory allocation when creating a Timer by 4 bytes from 80 to 84 (still 3 allocations), but I believe it’s the right trade-off for reduced complexity and bug likelihood.
* Address PR feedback
Signed-off-by: dotnet-bot <[email protected]>
* [runtime] Convert locale code to use handles.
* Sort a list of defines.
* Remove a do-while.
* Fix c++-ism.
* Use mono_string_handle_to_utf8 (). Update comments.
* Re-enable test
* Parse assembly info case-insensitively
* Lowercase the parsed public key token
* Case-insensitive comparison of public key tokens
* Fix string copy
* Fix build on Autoconf 2.63
This was broken in e7f9dbe73c, because
AS_VAR_APPEND does not exist until v2.63b (?!)
* Work around autoconf for Mac not being fit for purpose
The correct way to do this is with AC_DEFUN in a special m4 file
But this dies on Mac, because reasons.
See also https://github.com/jedisct1/libsodium/issues/217
* Clarify contents of list
* Fix mono_assembly_get_alc
* Remove pointless ifdef
* Prepend to domain_assemblies
* Revert "Prepend to domain_assemblies"
This reverts commit dbe6e47b80470fa13d22d97d32721d18c4764597.
* Ditch another ifdef
* [interp] Split code for obj / vt newobj instruction
* [interp] Enable inlining of object constructors
If the ctor was inlined, the newobj instruction receives a max ushort as the data item for the index, so it doesn't execute the ctor in this case. Also, when inlining, we need to push on the stack the allocated object, once as argument for the ctor and the second needs to remain on the stack as the result of the IL newobj instruction.
* Formatting fix
* Special-case arrays of interfaces/generic parameters
* Make more generic, fix typo
* Consider class constraint and add more elucidating comment
* Fix for potential crash
* Add test
* Fix test
`Expression.Bind` should throw `ArgumentException` if called with `FieldInfo` for a global field. The exception is thrown from validation of the (null) `DeclaringType` (see https://github.com/dotnet/corefx/pull/15318).
Mono returns `"<Module>"` in this case and doesn't throw so the test fails.
Fixes#14917 .
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.
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 https://github.com/xamarin/xamarin-macios/pull/6603#issuecomment-512803082
Contributes to https://github.com/mono/mono/issues/9621
According to the manual, it is recommended to use clock_nanosleep instead of nanosleep when the sleep can be repeatedly interrupted by signals and resumed. The remaining sleep interval was greater than the original timespec.
Fixes random timeouts of finalizer-abort.exe
* Add a temporary mono_domain_ambient_alc function
Just use this to mark places where we need to pass through an ALC
* [runtime] Mark mono_assembly_loaded_full external only.
Runtime should use mono_assembly_loaded_internal.
* [loader] Add mono_install_assembly_search_hook_v2
Use it to install mono_domain_assembly_search and
mono_domain_assembly_postload_search.
The principal difference is that we can pass an assembly load context to the
hook. But also we cleanup the "requesting assembly" hack for
mono_domain_assembly_postload_search.
* [domain] Comments and mono_assembly_get_alc ()
* [debugger] Comment on suspicious loader lock
* Add property HardLimitBytes to GCMemoryInfo
This adds a new property HardLimitBytes.
Unlike TotalAvailableMemoryBytes,
this will reflect an explicitly set COMPLUS_GCHeapHardLimit.
It will also reflect the fraction of a container's size that we use,
where TotalAvailableMemoryBytes is the total container size.
Normally, though, it is equal to TotalAvailableMemoryBytes.
Fix#38821
* Remove HardLimitBytes; have TotalAvailableMemoryBytes take on its behavior
* Fix typos
* Separate total_physical_mem and heap_hard_limit
so we can compute highMemoryLoadThresholdBytes and memoryLoadBytes
* Do more work in gc.cpp instead of Gc.cs
* Consistently end names in "Bytes"
Signed-off-by: dotnet-bot <[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);
}
}
```
[interp] Use correctly-sized writes and reads in Unsafe.AddByteOffset and Unsafe.ByteOffset
The truncated store to the top of the stack in`MINT_INTRINS_UNSAFE_BYTE_OFFSET` could cause the upper bytes of the address used as the first argument to `ByteOffset` to linger, yielding inaccurate (and usually excessively large) offsets on systems where `sizeof(void *) > sizeof(guint32)`; this made
`System.Text.Unicode.Utf8Utility.GetPointerToFirstInvalidByte` return nonsense results.
The truncation in `MINT_INTRINS_UNSAFE_ADD_BYTE_OFFSET` hasn't, as far as I know, caused any test failures. But `AddByteOffset` takes an `IntPtr` as its second argument, not an `int`.
Fixes#14847.
Implement a couple of things:
1. Add a `MonoAssemblyLoadContext` opaque struct
2. On netcore Mono, use it to keep track of which `MonoImage`s are loaded. (Addresses part of #13891)
In a bit more detail:
- Add a `MonoLoadedImages` struct to hold the hash tables that we use for checking if a `MonoImage` is already loaded
- Add an opaque `MonoAssemblyLoadContext` typedef
- (Framework Mono) Add a `get_global_loaded_images()` function to get the shared `MonoLoadedImages`
- (netcore Mono) Add a `MonoAssemblyLoadContext` struct that owns a `MonoLoadedImages` and add a `default_alc` member to `MonoDomain
- Pass a `MonoAssemblyLoadContext*` to most `MonoImage`-loading functions - on Framework Mono its usually NULL and we fall back to the global loaded images, on netcore Mono it's usually `domain->default_alc->loaded_images`
- (netcore Mono) Create a default Assembly Load Context when a `MonoDomain` is created
- Add a `MonoAssemblyLoadContext*` field to `MonoAssemblyLoadRequest` and pass an ALC in a few places.
---
Remaining work:
(netcore Mono) There are still places where a `MonoAssemblyLoadRequest` or a `MonoAssemblyOpenRequest` has a `NULL` ALC - those will need to be tracked down and fixed.
(netcore Mono) Eventually `MonoAssemblyLoadContext` should keep track of the loaded `MonoAssembly`s, not just images. One goal on netcore Mono is to ifdef out `MonoDomain:domain_assemblies`.
---
* [loader] Add a MonoLoadedImages struct to own the MonoImage sharing
Initially, there's just a single global set of loaded images.
Once we have AssemblyLoadContext support, each ALC will have a separate set.
NOTE:
- Some of the existing Mono API is difficult to support with this design
since it assumes each MonoImage is loaded at most once.
* [loader] Add a MonoAssemblyLoadContext member to MonoImage for netcore
* [loader] Unregister image from its owner when closing
* [loader] Pass MonoLoadedImages to register_image
* [domain] Add mono_domain_default_alc and mono_alc_get_loaded_images
* [loader] Add an AssemblyLoadContext argument to mono_image_loaded_internal
* [metadata] Add mono_image_get_alc ()
* [loader] Pass MonoAssemblyLoadContext to mono_image_open_from_data_internal
* [loader] Pass MonoAssemblyLoadContext to mono_image_open_from_module_handle
* [loaded] Pass MonoLoadedImages to mono_image_open_a_lot_parameterized
* [loader] Pass MonoAssemblyLoadContext to mono_image_open_a_lot
* [runtime] Mark mono_image_open_full external only
Runtime should use mono_image_open_a_lot.
* [runtime] Mark mono_image_loaded_by_guid external only
Also mark mono_image_loaded_by_guid_full external only
Runtime will need some (as yet unwritten) mechanism that takes a MonoAssemblyLoadContext as an argument.
* [domain] Create a default ALC for each MonoDomain
* [netcore] Pass default ALC in mono_core_preload_hook
If the assembly name matches a trusted platform assembly, open it in the default ALC of the root domain
* [mini] Open main assembly in default ALC in the root domain
* [netcore] Don't define get_global_loaded_images()
Every assembly load request should come from an assembly load context. Each ALC has a set of loaded images. So we should never need a global list.
With this PR, we no longer share MonoImages across distinct ALCs. So in principle, each ALC can open the same assembly but resolve its references in different ways.
Fixes part of https://github.com/mono/mono/issues/13891
* [runtime] Mark mono_pe_file_open external only
* [loader] Pass MonoAssemblyLoadContext to mono_image_open_raw and mono_image_open_metadata_only
* [loader] Pass MonoAssemblyLoadContext to do_mono_image_open and set MonoImage:alc
* [loader] Add version 2 of assembly preload hook
Pass MonoAssemblyLoadContext through the preload hook. This is used in mono_assembly_request_byname_nosearch which, in turn, is called by load_reference_by_aname_default_asmctx which is used to resolve references from one assembly to another.
* [netcore] Pass native ALC ptr to AssemblyLoadContext.InternalLoadFile
* [netcore] Implement AssemblyLoadContext.InternalInitializeNativeALC
also implement mono_domain_create_individual_alc ()
* [netcore] Pass ALC to System.Reflection.Assembly.InternalLoad
Pass the domain default ALC to mono_assembly_load ()
Also pass MonoAssemblyLoadContext to mono_assembly_load_full_gac_base_default ()
* [loader] Implement MONO_LOADED_IMAGES_ASSEMBLY properly
Store the MonoLoadedImages for netmodules in the MonoImage for the main image of an assembly. This is also used by SRE - the dummy module of the AssemblyBuilder has the loaded_images that contains the ModuleBuilders.
* [loader] Use global_loaded_images for netmodules with framework Mono
The new stuff is only for ALC support in netcore
* [loader] Drop netmodule support in MonoAssemblyLoadContext
netmodules are not supported in netcore
* [loader] Spin out image hashing out of image.c
Move MonoLoadedImages support code to loaded-images.c loaded-images-global.c and loaded-images-netcore.c
Also spin out assembly-load-context.c for MonoAssemblyLoadContext functions
* Move ALC icall to assembly-load-context.c
* formatting fix
* [msvc] Add new files to .filters
* update comments
* [image] Change mono_loaded_images_remove_image to decrement the refcount
Decrement the refcount and remove the image from the loaded images hashes in
one place. Change mono_loaded_images_remove_image to return TRUE if the rest
of image unloading should proceed or not.
* [loader] Drop unused argument to mono_alc_init
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.
(cherry picked from commit d410e07d8b)
* [interp] Pass the vtable to get_virtual_method () to reduce the number of objrefs being passed around.
* No longer a prototype.
* [interp] Make the code GC safe on wasm.
* Use frame->o only on WASM.
Mono historically was quite lax in how it resolved assembly references - it
would pick the first assembly with a matching simple name. The "strict"
mode (available in framework Mono with `--assembly-loader=strict`) follows the
spec behavior: the version and public key token of the candidate assembly must
match what is requested.
* 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 it's not executing a managed code of the list that is returned when CMD_VM_ALL_THREADS is called.
Fix#13311
* 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
# Fix the runtime paths evaluation.
- If running from a master build the runtime builds path is different from the nuget paths.
- From a master build the runtime builds are found in `wasm\builds` now.
# Browser Tests modifications:
- Moved all sources to a sources directory `tests\browser\src\`.
- Create a solutions project that can be built by VSfMac or VS using the SDK
- Create separate projects for each TestSuite.
- Change makefile target for the browser tests to use `dotnet` to build instead of the `packager.exe`
# SDK modifications and fixes:
Fix sdk build to run `monolinker.exe` using `dotnet`
- Run `mono` as task tool if running from `dotnet` and not running under Windows instead of executing the `monolinker.exe` directly
- Clean up WasmLinkAssemblies code.
- Add routine to determine if build was initiated from `dotnet` instead of msbuild.
- Add common routine to find the correct monolinker.exe to execute depending on running local or nuget.
Without the previous fixes, `monolinker` step can fail with the following message when using `dotnet build`
```
.nuget/packages/mono.webassembly.build/0.1.0-preview1/build/netstandard2.0/Mono.WebAssembly.Build.targets(76,3): error MSB6006: "monolinker.exe" exited with code 8.
```
The faling msbuild target is:
```
_MonoWasmLink:
/Users/Jimmy/.nuget/packages/mono.webassembly.build/0.1.0-preview1/build/tools/monolinker.exe --verbose --exclude-feature
... the rest of the command is cut off from here to save space
```
With the fixes command above becomes the following which execute the `monolinker` with `mono`. :
```
_MonoWasmLink:
/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono /Users/Jimmy/.nuget/packages/mono.webassembly.build/0.1.0-preview1/build/tools/monolinker.exe --verbose --exclude-feature remoting --exclude-feature com
... the rest of the command is cut off from here to save space
```
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.
* 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.
According to ECMA-335 § II.15.3, calling conventions other than "default" and
"vararg" describe unmanaged methods. Accordingly they should be treated as
pinvokes so that that their calling conventions are respected.
This change allows a number of games, such as DARK, to start successfully. The games use X509Certificate.CreateFromSignedFile() to load the certificate from their assemblies in order to verify them.
* Added support for creating an AuthenticodeDeformatter for an assembly
that has been loaded into memory
* Allow importing a certificate from an assembly signed with authenticode
when using BTLS
* Allow importing a certificate from an assembly signed with authenticode
when not using BTLS
* Added a test for loading certificates from assemblies signed with
authenticode
* Partial enablement of alternate stack for AIX/i
It turns out much like macOS, AIX doesn't like to do mprotect/valloc
for the first thread's guard pages, so skip those. It seems mostly
fine except for one or two crashes causes it to grab the wrong IAR
and deadlock dumping memory. As such, leave the code and configure
script override to disable in place, just change the comment and
add support code.
* Use Qp2getifaddrs on PASE
Not sure if proper way to implement. Reuses getifaddrs code as much
as possible, since it's merely a name change based on the docs, due
to it being namespaced in case AIX gets it or something.
I'm not sure how many of these codepaths still work properly;
one had a questionable order of ifdef.
This will eventually prepare for CoreFX NetworkInterface, so test
it here.
* Add TypeForwards for:
* System.IO.Enumeration.FileSystemName
* System.Security.Cryptography.CryptographicOperations
Since these were removed in NS 2.1
* Bump API snapshot submodule
* [netcore] Don't default to mscorlib in Assembly.GetType
* Add argument for whether or not to search mscorlib
* Reorder and rename search_mscorlib argument
* Use gboolean exclusively
- Create a `Mono.WebAssembly.Templates.cproj`
- Moved the existing DotNet template to a new subfolder Templates\templates
- Add `dotnet pack` of the project to the Makefile.
* [interp] Avoid declaring MonoError's in interp_exec_method_full (), it increases the native stack frame size because the optimizer can't seem to figure out live ranges.
* Remove some unused fields from InterpFrame.
[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.
We had some inconsistency around accessing mini_debug_options in the runtime (both directly as well as through the function, mini_get_debug_options). This PR makes the access consistent through the runtime.
* [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)
...
```
* [netcore] Simplify CI build invocation
We now have build.sh as a one-stop entry to the build system.
* [netcore] Read NETCORETESTS_VERSION and NETCOREAPP_VERSION from eng/Versions.props
The Versions.props is auto-updated by Arcade so we automatically get new versions.
Advantages:
Dynamic linker gets out of the way of random function calls,
in terms of timing, in terms of locking, and in term of success,
and possibly in terms of security (readonly function pointers).
If you successfully load, then you can make function calls with impunity,
without regard as to if they are in the same .so as the caller, well,
assuming they are to a leaf like libc, or to something itself built with -z now.
The "success" is significant, as otherwise loaded LLVM has unresolved symbols lurking, depending on which code paths you send it down.
Disadvantage: Slower startup.
Mixed:
Platform consistency, since this is how Windows behaves usually (unless you say link /delayload)
This will combine well with an upcoming revision of https://github.com/mono/mono/pull/14524.
Difficult alternative: Force the binding along sensitive paths by calling their callees earlier.
Typical alternative: Ignore the matter.
Android: It is believed this switch produces a warning, which is ignored, there is no affect, and it is unclear if the behavior is actually "now" or "lazy". Logs could be checked and a test run, but neither.
Untested, but we need to do it anyway soon. This will help us to understand the situation on Xamarin.Android while finishing the work for Xamarin.iOS.
Contributes to https://github.com/mono/mono/issues/9621
* Interpreter reads last error to late after pinvoke.
This could lead to clobbered last error since interpreter loop needs to
run two additional IL instructions in order to read out the value. This works
on JIT since the lowering saving the last error will happen right after
pinvoke.
This fix makes sure interpreter will get needed information to read out
last error right after pinvoke (if requested).
It adds a new IL prefix issued in managed->native wrapper that will tell
codegen (and interpreter) that upcoming calli instruction needs to save
last error, meaning that it could be done right after issuing the call,
no need to run any additional IL instructions to do that work, closing
the gap between the return of pinvoke call and save of last error.
Should fix, https://github.com/mono/mono/issues/15541.
* Optimize emit_get_last_error.
- Installs the required packages to run
- Modify make target `run-threads-sample` to use npm to install and run the test.
- There are two targets in the package.json file one for `test` and another 'start`
* [netcore] Make System.Reflection.Tests.TypeTests.GetEnumUnderlyingType Pass
* Remove recursive name parsing in case of "+" character; remove if condition for nested names
Before this commit, we were creating the array class from the element class during run time, also taking a lock in the meantime. This makes array allocation 2x faster. (on multithread much faster)
When a preemptive suspend fails, state machine will get into an invalid
state and the thread is in an unknown state (running/self-suspended). In case of
failure in mono_threads_suspend_begin_async_suspend, a new method should be
called, mono_threads_transition_abort_async_suspend making sure state machine
reflects correct thread state as well as reporting correct result to initial
caller of mono_threads_suspend_begin_async_suspend.
i.e. so it can be used in C instead of make.
i.e. so it can actually work.
The lone use is here:
```
C:\s\mono2\mono\utils\mono-dl.c(271):#if MONO_DL_NEED_USCORE
```
* [wasm] Avoid AOTing mscorlib if the input file haven't changed.
* [wasm] Store the wasm builds in a builds/ subdir.
* [wasm] Add a run-chrome- target to run test suites under chrome using a puppeteer script.
* [wasm] Link with -O0 in debug mode.
* [wasm] Add a runtime-threads make target.
* [wasm] Compile driver.o etc. with -Oz. Make the build-native -> packager.exe dependency order only.
* [wasm] Run the threads sample using chrome.
* Bump emscripten to 1.38.37.
* Fix the build.
* Fix the tests.
* Fix the tests.
* Add support for TLS callbacks on Windows.
Mono runtime depends on DllMain to be called by OS in order to correctly
detach threads from the runtime. If this doesn't happen,
threads from native thread pools (not owned by runtime) and attached
using native->managed callback, won't detach resulting in attached
threads no longer running. Since threads are still attached
to runtime, next GC will try to suspend the thread and that will fail
and that in turn will put the state machine in an incorrect state,
bringing down the runtime at next GC (when the thread state is revisited).
This problem is currently handled by DllMain, but since DllMain only exist
in DLL's, statically link Mono runtime will get us into the above scenario.
This commit add support to hook up a TLS callback using the same mechanism
used by MSVC linker and c-runtime (also available under MINGW). The
callback will be included in a section/segment of an object file and included
in final image (DLL or EXE) by linker and called by OS loader, solving the
problem with static linked Mono runtime not being able to detach terminating
threads.
The commit keeps current DllMain method when building a DLL but
includes a mechanism making sure we only use one of the callback techniques
at runtime, if both have been included in final image. This will simplify the build
of libmini since we can always build the object including the callback, regardless
how the library will be consumed.
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.
#4484 broke Windows mingw build due to new dependency, zlib1.dll not available in PATH on build bots. Disabling for now until we know how this should be handled (and also fixed for MSVC build runtime).
We were missing methods that got added for 3.0. The only LoadContext that works is the default one though.
Signed-off-by: dotnet-bot <[email protected]>
Enum.HasFlag generates bigger IL and depends on complex JIT optimization for a good code.
The classic bit check is strongly preferred accross CoreCLR and CoreFX.
Signed-off-by: dotnet-bot <[email protected]>
ICU map the C locale to en-US_POSIX which has a non desired collation behavior as it doesn't support case insensitive comparison.
This change is to force mapping C locale to Invariant instead.
Signed-off-by: dotnet-bot <[email protected]>
* Updating Dragon4 to ensure the number buffer always provides a significant digit if one exists.
* Changing System.Number.RoundNumber to not round up floating-point numbers.
* Re-enabling the RealFormatterTestsBase CoreFX tests
* Updating Number.RoundNumber to take a isCorrectlyRounded parameter and to use IEEE compliant rounding for floating-point numbers.
* Change SinglePrecisionCustomFormat to 7, ensuring it matches the value used in netcoreapp2.1
Signed-off-by: dotnet-bot <[email protected]>
Based on conversation with Levi, I don't think this flag is needed.
The flag currently controls two things:
* Disqualifies the method from precompilation
* Disables Tier-0 JIT for the method
Removing the attribute allows us to precompile some of the methods (not all, because of `Vector<T>`). It measurably helps improve startup time because many of the attributed methods are complex and take a while to compile.
Once tier-1 JIT kicks in, the generated code should be identical to what we were getting before.
Signed-off-by: dotnet-bot <[email protected]>
proxy the version response through our logic so that we match
the actual protocol versions. Refactor the mapping logic so we
just rewrite specific keys that we understand and pass the rest
along.
We want to avoid throwing inside ErrorDataReceived on unexpected
input because tends to hang the process in a bad state. Instead
we return null from extract_conn_url and let the normal cleanup
process happen.
- Add a central versioning file `common\Versions`
- Modify projects to use the central version file
- Auto generate a versions file for the SDK versions so that they can be updated automatically.
* Emitting bad image exception when a non virtual call is calling an abstract method.
* Fixing side-effect.
Implementing the same thing on interpreter.
Adding unit test.
According to documentation of mono_threads_suspend_begin_async_suspend:
"If begin suspend fails the thread must be left uninterrupted and resumed."
Current implementation on Windows didn't resume thread in case GetThreadContext
fails, leaving a thread in suspended state on failure.
Fix is to resume thread if GetThreadContext fails.
* Went through the majority of corefx tests that were being skipped in CoreFX.issues.rsp.
For each failure, a github issue was logged and if possible, a more expanded
failure reason was specified.
Part of the https://github.com/mono/mono/issues/14787 epic work
* Cleaned up header that no longer had tests in it
* Pesky -method still around. It'll ignore now
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]>
* [configure] Cosmetic AC_MSG_WARN fix
* [runtime] Mark mono_file_map_error as MONO_API, always
Fixed the `--with-static_mono=no` build on non-Win32
* [sdks] dynamically link libmonosgen to mono-sgen for monodroid host builds
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.
Calc_section mutex is meant to be a lower level mutex used only for synchronization on InterpMethod contents. Before this commit we were taking the loader mutex which was leading to deadlocks.
* [netcore] Revert changes to build.sh
It appears to have accidentally been changed in #15215, and the script no longer works correctly as a result, so revert
* Strip call to make
* Revise monolite due to memory model change.
* Fix tarball builds wrt netcore/config.make.
* Remove System.Private.CoreLib from mcs/class/Makefile, it was moved to netcore/
* Bump min_mono_version in basic-profile-check
The new MONO_DEBUG=clr-memory-model runtime option isn't available in earlier Mono versions.
* Add cooperative suspend aware threads for hybrid suspend.
When running in hybrid suspend and having threads in blocking mode, GC Safe
mode, threads will still be preemptive suspended. This is done to make sure
compatibility is kept with embedders since current embedding API is not coop
aware. If, however the external attached threads promise to follow the coop
rules for a thread in Safe mode, it could still be possible to have them
running, making sure they won't be preempted when running STW. Unlocking this
possibility could have large performance wins if embedding threads runs a lot
of native code on threads attached to runtime.
This commit adds support for a new pair of API's where an external thread can
mark itself as cooperative suspend aware. Doing that guarantees the runtime
that it will follow all rules as dictated by cooperative suspend when a thread
is in safe mode. The change only goes one way since this is a lifetime commitment
for a thread. Once’s set, thread will be kept running when in safe mode.
* [debug] Refactor the code in mono-debug.c.
Store the domain->debug info table mapping in MonoDomain to avoid a hashtable lookup.
Rename MonoDebugDataTable to DebugDomainInfo to better reflect its meaning.
* Remove some mono_ prefixes from static functions, along with the full/internal prefixes.
* [aot profiler] Listen for commands on given port
Extended the aot profiler so, that it can receive commands over the network.
Added new option `port=PORT`, which enables command server and specifies
the port the server should listen at.
We have 2 commands so far.
save ... save the profile data to socket and close it
quit ... quit the profiler. it also saves the profile to the file
in case the output option was specified.
It makes the aot profiling much easier to use on Android as we don't need to
save the profile to a file on the device. That means we don't need to set
`<application android:debuggable="true"/>` flag, which changes the Android
app behavior and thus influence the profile itself. It is also convenient way
for IDEs to retrieve the aot profiles.
Example use for Xamarin.Android. Save and receive the profile data:
adb shell setprop debug.mono.profile aot:verbose,port=9999
adb forward tcp:9999 tcp:9999
nc -v 127.0.0.1 9999 > profile.aotprof
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif lo0
src 127.0.0.1 port 50398
dst 127.0.0.1 port 9999
rank info not available
TCP aux info available
Connection to 127.0.0.1 port 9999 [tcp/distinct] succeeded!
save
Check what we received:
aotprofile-tool -sd profile.aotprof
Modules:
132475FF-85AA-430D-913C-7642CBD8587E mscorlib
F7BDCAB5-83D3-4A0A-A33D-BBE94284667D Mono.Android
22897151-27C9-4064-B001-8A04F5847812 System
AA3FC224-D486-4304-A8C9-EBF316556B26 Java.Interop
00D98403-051B-4168-A391-F3F601637CBD System.Core
FD06519A-C321-426C-BDD8-C97777452057 xat_latests_and_greatest_vsmac_8._1
9ECB003E-D449-438B-BE35-58810DCBC917 Xamarin.Android.Support.v7.AppCompat
11659962-EFAC-400D-9F8D-AF925B26AE41 Xamarin.Android.Support.Fragment
48C436F7-611D-470D-9949-AC13FFDCF613 Xamarin.Essentials
2792D10D-7E13-46E6-BB4A-933C25635F48 Xamarin.Android.Support.Design
Summary:
Modules: 10
Types: 221
Methods: 932
* Try to fix WIN32 compilation
* Add helper.c to mono-profiler-log.vcxproj
* Add helper.c to mono-profiler-log.vcxproj.filters as well
We hit the following assert when doing full AOT of some assemblies:
wrong maximal instruction length of instruction localloc (expected 96, got 99)
Assertion: should not be reached at mono\mono\mini\mini-amd64.c:6801
Turns out that that size could be hit when a couple of things happens as part
of lowering OP_LOCALLOC and OP_LOCALLOC_IMM:
sreg1 is not RAX, RCX or RDI
dreg is not RAX, RCX or RDI
cfg->param_area is bigger than 127
Fix is to increase max size of the instruction, from 96 -> 120 (same as x86).
* Force secondary await continuations to run asynchronously
For performance reasons, await continuations have been invoked synchronously, meaning they're invoked as part of the antecedent task's completion (as long as that task allows it, as long as there's sufficient stack space, etc.) This generally works out well in the case where there's a single await continuation, which is far and away the common case. However, it can cause problems in situations where there are multiple await continuations, as those continuations will end up being serialized, which can lead to slowdowns and deadlocks in niche situations. To address that, this commit backs off a bit. The first await continuation is still invoked synchronously, but subsequent await continuations are invoked asynchronously, such that they are not blocked by a previously registered await continuation.
* Fix nits
Signed-off-by: dotnet-bot <[email protected]>
Enable using a system-supplied message while also providing an argument/parameter name by passing in a null message. Made to match the behavior of FileNotFoundException.
Signed-off-by: dotnet-bot <[email protected]>
* Address nullable feedback for System.Diagnostics.Tracing and StackTrace
* Disable corefx tests that need to be updated
Signed-off-by: dotnet-bot <[email protected]>
When the _metadata dictionary contains a single key/value pair, the method ends up allocating an unnecessary StringBuilder, char[] beneath it, and input string.
When the _metadata dictionary contains more key/value pairs, the method ends up allocating an unnecessary string per key/value pair.
Signed-off-by: dotnet-bot <[email protected]>
- Improving performance calling only once mono_wasm_get_var_info.
- Adding support to debug local vars in async methods. They are special in the way that local variables can be lifted to generated class fields.
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.
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
mono_aot_init_gshared_method_this
mono_aot_init_gshared_method_mrgctx
mono_aot_init_gshared_method_vtable
Update comments that refer to them, to refer to the renames.
mini_llvm_init instead of mono_aot_init.
See 80bc0069e4 and 04d65f2986.
I'm here because I broke something nearby in a work-in-progress PR
and the existance of these functions made me look into them.
* Add basic implementation of Environment.FailFast
* Add comment about __failfast on Windows 8+
* Re-add some test exclusions and clarify the comment around them
* Update icall.c
* [api] Add mono/metadata/profiler-legacy.h header
Add a header with the legacy Mono profiler API. New code should use the API
from mono/metadata/profiler.h.
* [profiler] Mark the legacy profiler API with MONO_DEPRECATED
* [runtime] Don't install the profiler-legacy.h header
Make the decision later whether these should be in the set of public API headers
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]/
Previously, using TransactionScope would always produce transactions
that use serializable isolation level even when user specified another
level (like ReadCommited).
fixes#13945
* Address nullable feedback for System.Threading.Overlapped
* Address nullable feedback for System.Memory
* Address nullable for System.Runtime.InteropServices
* Update xml comments and make CultureInfo nullable to match String.ToLower/Upper feedback
* PR feedback: revert accepting null comparer in BinarySearch
* Disable test that needs to be updated in corefx
Signed-off-by: dotnet-bot <[email protected]>
* Change ArgumentException message to one line
* Disable 2 tests
* Remove duplication in AggregateException.ToString()
* Inner exceptions on new lines
* Caps letter
* Typo
Signed-off-by: dotnet-bot <[email protected]>
By default when called through macros like MONO_ENTER_GC_UNSAFE
code will always dump current registers into stack space on hybrid/coop.
The registers will be scanned but only when hitting a GC and when running
in GC unsafe, that will only happen when we block in the enter or hit a safe
point at a later point in time. There are currently a couple of frequent
scenarios where we go into GC safe when thread won't be suspended and in
that case the copy of the registers will only reflect the state when
entering GC unsafe.
Commits add option to enable/disable copy_stack_data support in configure step:
--enable-copy-stack-data, --disable-copy-stack-data.
copy_stack_data is enabled by default on all platforms except desktop platforms
macos, linux and windows (both 32/64-bit), since these platforms already support
full context as well as capabilities to scan the stack of a running thread.
* 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
* [jit] Move value storing in a new write barrier emitting method
Brings together ref storing and the write barrier generation.
* [jit] Add debug option to attempt using the CLR memory model
Which prevents reordering of stores. Part of the way this is done on CoreCLR is by adding memory barriers to the write barrier, so we attempt a similar behavior.
This is not a complete implementation.
* [build] Add memory model flag to csc when building the bcl
This should prevent random crashes during the build
* [build] Add memory model flag to compiler server
* [build] Add memory model flag to test building
Add support to run full interpreter test suite on CI for Windows x64 Full AOT.
Since Windows x64 Full AOT uses a different full AOT profile WinAOT a separate
testing profile was setup for the interpreter testing. NOTE, this profile is
pure for testing, inline with the other testing profiles. It is also reusing
most of its sources from other sources files (mainly WinAOT) to reduce maintenance
of the profile.
Commit also includes some smaller adjustments needed in order to get full
pass rate for Windows x64 Full AOT + Interpreter on CI.
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.
runtime.
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.
* Correctly set ReflectionType with inherited generic methods
* Allow ValueType
* Re-enable relevant test
* Switch to mono_class_from_mono_type_internal
* Update the checks for ByRef return type in reflection invocation to also check for IsByRefLike types. This was missed as part of #13901 and noted in the description.
Fixes#14959, #14960, #14961, #14963
* Modify the reflection checks for IsByRef/IsByRefLike to check for same conditions as CoreCLR
* Handle reflection invocation with ref void return type
* Update test-ref-07 to have Main method that is valid to invoke through reflection (as the test runner does)
* Update expected IL
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)
Fixes#14724
This may need to be reverted if customers are relying on the existing behavior, but we can cross that bridge when we come to it.
The larger issue of incompatibility with .NET Core should be addressed later.
- Use the Headers `entries{}` iterator object.
- This replaces the `foreach` delegate call where the object returned in the delegate was being disposed of too early.
- The foreach delegate takes three objects name, value, other. The `other` being disposed was causing a problem when calling back into the delegate later.
- Removes the lamda expression called by the delegate without the worry of a memory leak if the finally is removed.
This reverts commit bf2f1abe01978102c22d76b4a10996e8d8b50b0f.
The logic is not clear as to if there is a bug, so leave the warning.
There are two uses of the possibly uninitialized variable.
One is guarded and not a bug.
The other is not clear, and don't want to blindly use 0.
tramp-arm64-gsharedvt.c:217:54: warning: variable 'callee_stack_area_offset' set but not used [-Wunused-but-set-variable]
int caller_reg_area_offset, callee_reg_area_offset, callee_stack_area_offset;
^~~~~~~~~~~~~~~~~~~~~~~~
interp/mintops.c:87:37: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'long int' [-Wformat=]
g_string_append_printf (str, " %lld", (gint64)READ64 (ip + 1));
object.c: In function 'mono_class_proxy_vtable':
../../mono/metadata/profiler-private.h:191:4: warning: 'pvt' may be used uninitialized in this function [-Wmaybe-uninitialized]
mono_profiler_raise_ ## name args; \
^~~~~~~~~~~~~~~~~~~~
object.c:2338:19: note: 'pvt' was declared here
MonoVTable *vt, *pvt;
^~~
w32file-unix.c:4994:19: warning: 'length_hi' may be used uninitialized in this function [-Wmaybe-uninitialized]
return length | ((gint64)length_hi << 32);
^~~~~~~~~~~~~~~~~
interp/interp.c:1847:3: warning: 'orig_domain' may be used uninitialized in this function [-Wmaybe-uninitialized]
mono_threads_detach_coop (orig_domain, &attach_cookie);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
os-event-unix.c:195:12: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
elapsed = mono_msec_ticks () - start;
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
from os-event.h:9,
from os-event-unix.c:11:
../../mono/eglib/eglib-remap.h:146:25: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
#define g_ptr_array_add monoeg_g_ptr_array_add
^~~~~~~~~~~~~~~~~~~~~~
os-event-unix.c:121:19: note: 'data' was declared here
OSEventWaitData *data;
^~~~
marshal.c:2662:8: warning: 'sig_cache' may be used uninitialized in this function [-Wmaybe-uninitialized]
res = (MonoMethod *)g_hash_table_lookup (sig_cache, sig_key);
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sgen-dynarray.h:331:1: warning: 'dyn_array_ptr_set_all' defined but not used [-Wunused-function]
dyn_array_ptr_set_all (DynPtrArray *dst, DynPtrArray *src)
^~~~~~~~~~~~~~~~~~~~~
dyn_array_ptr_set (DynPtrArray *da, int x, void *ptr)
^~~~~~~~~~~~~~~~~
sgen-dynarray.h:202:1: warning: 'dyn_array_ptr_init' defined but not used [-Wunused-function]
dyn_array_ptr_init (DynPtrArray *da)
^~~~~~~~~~~~~~~~~~
sgen-dynarray.h:194:1: warning: 'dyn_array_int_is_copy' defined but not used [-Wunused-function]
dyn_array_int_is_copy (DynIntArray *da)
^~~~~~~~~~~~~~~~~~~~~
sgen-dynarray.h:188:1: warning: 'dyn_array_int_copy' defined but not used [-Wunused-function]
dyn_array_int_copy (DynIntArray *dst, DynIntArray *src)
^~~~~~~~~~~~~~~~~~
sgen-dynarray.h:182:1: warning: 'dyn_array_int_ensure_independent' defined but not used [-Wunused-function]
dyn_array_int_ensure_independent (DynIntArray *da)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sgen-dynarray.h:168:1: warning: 'dyn_array_int_get' defined but not used [-Wunused-function]
dyn_array_int_get (DynIntArray *da, int x)
^~~~~~~~~~~~~~~~~
sgen-dynarray.h:161:1: warning: 'dyn_array_int_add' defined but not used [-Wunused-function]
dyn_array_int_add (DynIntArray *da, int x)
^~~~~~~~~~~~~~~~~
sgen-dynarray.h:147:1: warning: 'dyn_array_int_size' defined but not used [-Wunused-function]
dyn_array_int_size (DynIntArray *da)
^~~~~~~~~~~~~~~~~~
sgen-dynarray.h:141:1: warning: 'dyn_array_int_uninit' defined but not used [-Wunused-function]
dyn_array_int_uninit (DynIntArray *da)
^~~~~~~~~~~~~~~~~~~~
sgen-dynarray.h:135:1: warning: 'dyn_array_int_init' defined but not used [-Wunused-function]
dyn_array_int_init (DynIntArray *da)
^~~~~~~~~~~~~~~~~~
../../mono/metadata/reflection-cache.h:43:1: warning: 'free_reflected_entry' defined but not used [-Wunused-function]
free_reflected_entry (ReflectedEntry *entry)
^~~~~~~~~~~~~~~~~~~~
w32handle.c:1146:13: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
elapsed = mono_msec_ticks () - start;
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-mmap.c:401:82: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 5 has type 'guint64 {aka long unsigned int}' [-Wformat=]
*error_message = g_strdup_printf ("%s failed file:%s length:0x%zX offset:0x%lluX error:%s(0x%X)\n",
threadpool.c:571:91: warning: 'end' may be used uninitialized in this function [-Wmaybe-uninitialized]
res = mono_coop_cond_timedwait (&tpdomain->cleanup_cond, &threadpool.domains_lock, end - now);
* Make DisplayUnits string.Empty by default instead of null
* PR feedback on DisplayName and setter validation
Signed-off-by: dotnet-bot <[email protected]>
which is meant to be all about handling race conditions.
1. Less severe:
Add missing read barrier to mono_lazy_initialize().
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.
2. Change `status` to `*lazy_init` to fix severe race condition.
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
```
* [mini] Move some MONO_API functions to public header
And mark them all MONO_RT_EXTERNAL_ONLY.
mono_set_use_llvm is new - Xamarin.Android previously assigned to mono_use_llvm
directly.
We can hit the following deadlock when loading assemblies (using reflection)
together with bundling:
One thread calls mono_assembly_open_from_bundle, that will take assemblies lock
and then try to load assembly. If this race with a different load of the
same assemblies, one will lose, and that method will call mono_image_close that
in turn will call unload hook (mono_class_unregister_image_generic_subclasses)
that will take loader lock.
If we at the same time have a different thread that calls mono_class_create_from_typedef
, it will take loader lock and then it might end up calling mono_assembly_load_reference
that will take assemblies lock, but since that thread takes the locks
in different order compare to first thread, they could deadlock.
Looking into the use of assemblies lock in mono_assembly_open_from_bundle it
uses a static variable, bundles, that is not protected in other scenarios
and only set by mono_register_bundled_assemblies, normally called during
boot. The method called in the loop mono_image_open_from_data_internal is called
at several places without locks (and looks internal using image lock), so that
doesn't need to be protected. The rest is local data access and the only thing the
lock could do is serialize the whole loop between threads (but that shouldn't be needed).
Fix will remove the locking and also eliminating the incorrect lock order
causing the deadlock.
Don't create a cycle when translating IL `break` to IR.
`mono_emit_jit_icall` adds the instruction it generates to the current
basic block, and the redundant use of `MONO_ADD_INS` on an instruction
that has already been added to a BB will create a cycle in the `prev`
link chain.
Fixes#9706.
* Add internal version of mono_unicode_to_external to propagate error
* Migrate things to _error version where sensible
* Remove redundant goto
* Print input string when conversion fails
* Remove todos
* Switch everything to MonoError
* Naming: err -> error
* Actually print out *filename correctly
The following warning is generated when building master for interpreter as well as during AOT build of driver.c
```
driver.c:346:31: warning: initializing 'const MonoBundledAssembly **' with an expression of type 'MonoBundledAssembly **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
const MonoBundledAssembly **bundle_array = g_new0 (MonoBundledAssembly*, assembly_count + 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Mono issue: https://github.com/mono/mono/issues/13804
The hypothesis is that at reconfigure using the configure cache file, the lack of explicit setting of the host somehow breaks the build process.
Current steps:
- Call MONO.mono_wasm_init_aot_profiler (null) before calling MONO.mono_load_runtime_and_bcl ().
- Call WebAssembly.Runtime.StopProfile () from the c# code to stop profiling.
- The profile data will be in Module.aot_profile_data.
Our run-step logic uses `bc` to calculate step times, so `bc` is
needed to avoid ugly things on the console like:
```
../scripts/ci/./run-step.sh: line 59: echo: write error: Broken pipe
```
This was removed accidentally as part of overhauling the async infrastructure in 2.1. VS depends on it for some task tracking logic.
Signed-off-by: dotnet-bot <[email protected]>
* [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.
mono_image_open_metadata_only and its callees all dupe the filename string, so free the string after mono_image_open_metadata_only is done with it:
```
1 (128 bytes) ROOT LEAK: 0x7fb07f086c80 [128] length: 105 "/Users/therzok/Work/md/md-addins/external-addins/MonoDevelop.MonoDroid/build/Xamarin.Installer.Common.pdb"
```
* [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).
We need to revise our use of nullable for `IComparable<T>` and `IEquatable<T>`:
- For reference types that implement `IComparable<T>`, the implementation should use `IComparable<T?>`, e.g. `String : IComparable<String?>`, so that the type can be used in methods with a `where T : IComparable<T>` constraint: `IComparable<T>`'s contravariance then allows both `T` and `T?` to work as generic type arguments.
- For reference types that implement `IEquatable<T>`, we can't take advantage of such contravariance, as by design `IEquatable<T>` is invariant (it would be a breaking change to make it contravariant, and even if it wasn't doing so is of questionable design given that equality and inheritance don't mix well). Given the current language design, we have little option but to explicitly make any reference type implementations of `IEquatable<T>` be oblivious, and also make all `where T : IEquatable<T>` constraints be oblivious. Otherwise, regardless nullable annotations, a developer will get a warning for using either or both of `T`/`T?` with any given method employing such a constraint.
Signed-off-by: dotnet-bot <[email protected]>
* Debug.Print should call Debug.WriteLine
- to behave similar to .NET Framework
* temporarily disable tests
- Waiting for coreclr/fx changes to propagate
Signed-off-by: dotnet-bot <[email protected]>
* [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).
* Work toward removing JIT icall hashing by address.
* Remove JIT icall hashing by address.
* Cleanup amd64 emit_call use.
* Move MonoJumpInfoTarget to among types, not functions.
If mini.h includes mini-runtime.h, then can move it nearer MonoJumpInfo.
Or if returned by out parameter (pointer) instead of struct by value.
Or pair of out parameters instead of struct.
* Closer to historical semantics, at least to avoid assertion failure, will try to refine in a later PR.
* Remove new comments about partial barriers, I think the comments are wrong and the code is correct (except that lock/unlock probably need to be full barriers, if they are not.)
* PR: Don't worry about size of MonoCallInst.jit_icall_id. Let it be 32 or 64 bits instead of 9.
* [runtime] Add some options to the aot profiler:
- write-at-method=<METHOD> Write the data when <METHOD> is compiled.
- send-to-method=<METHOD> Call <METHOD> with the collected data.
* [wasm] Fix profiler support in the packager.
* [wasm] Add prototype for generating aot profile data.
* Fix indentation.
After this change, CoreRT only uses S.P.Interop to host the interop hashtable readers. Those can't move to CoreLib because they call into the type loader.
I didn't touch ProjectN's version of Marshal and I left the `PInvokeMarshal` class in place to help with that. I guess we'll need to make a call at some point on what to do with S.P.Interop since without MCG the code in it is kind of useless.
Signed-off-by: dotnet-bot <[email protected]>
And it is reasonable to expect that to remain the case, as C compilers
do not generate code as would occur with the last parameter = TRUE.
They allocate the room for their maximum outgoing parameters at function entry,
and keep a constant stack, except for functions that call _alloca,
and this code risks but not necessarily breaks ABI compliance.
In particular, the rsp adjustment either needs unwind codes, or needs
to only occur in a function with a frame pointer other than RSP.
And the uwind codes for adding to RSP are very tricky to impossible.
Normally you only ever subtract from RSP. There is an unwind code for that.
But there isn't really for add.
You might be able to simulate it with chained unwind, making these
regions look kinda like end of function.
But this is all most unlikely.
Fix for issue where NamedPipeServerStream.GetImpersonationUserName() throws unexpected InvalidationOperationException("The operation completed successfully") when impersonation is not allowed, when in fact it should simply return an empty string.
The fix will call GetNamedPipeHandleStateW once. If it fails, it will try to load sspicli.dll if it was not loaded, and will reattempt the call to GetNamedPipeHandleStateW.
This fix is only for Win32: UAP does not allow calling LoadLibraryEx, and Windows Nano says denies access to GetNamedPipeHandleStateW even after attempting to load sspicli.dll.
Signed-off-by: dotnet-bot <[email protected]>
* [wasm] Switch to the llvm wasm backend.
* [wasm] Packager changes for the wasm backend.
* -s EMULATED_FUNCTION_POINTERS=1 no longer needed.
* Run wasm-strip on the final binary.
* Run opt during AOT.
* Disable the dynamic build for now, it doesn't seem to work with the wasm backend.
* [wasm] Use STACK_MAX instead of STACK_BASE for the bottom limit of the stack.
* [aot] Handle llvmopts= in llvmonly mode as well.
* [wasm] Disable an assertion which is no longer true with the wasm backend.
* [wasm] Disable computed gotos in the interpreter, the wasm backend doesn't support it.
Fix llvm target layout so its compatible with clang compiled code.
* [wasm] Pass llvm-path to the cross compiler.
* [wasm] Fix some problems with the dynamic build, still doesn't work. Fix packaging.
* [wasm] Pass -s DISABLE_EXCEPTION_CATCHING=0 to the runtime build, otherwise catch clauses are not generated in llvm-runtime.cpp.
* [aot] Allow llvmopts= argument multiple times.
* Bump emscripten version to 1.38.34.
* [wasm] Add https://github.com/emscripten-core/emscripten/pull/8457 as a patch.
* [wasm] Compile the aot .bc files to .o in a separate step using emcc, this will help with incremental compilation later.
* [wasm] Source emsdk_set_env.sh instead of emsdk_env.sh the latter calls emsdk construct_env to construct emsdk_set_env.sh which is racy.
* Allow using SysV-style sonames on AIX/PASE
This uses a far saner naming convention with libtool, and is
consistent with the official PASE RPM repository. However, some
loader changes are required to make it "just work" and workaround
some real dumb behaviour on AIX's part.
Note that while Mono works when built without the different soname
tweak, it won't when installed, because the convention is strange
and the libtool .la archives won't be installed. It's recommended
as such that installation of Mono keeps the libtool files or just
uses SVR4 sonames like the rest of the world, even if they're made
strange like AIX.
* Specify a specific version of unixODBC, make an include
A workaround against PASE RPMs of unixODBC not including the just
"libodbc.so" except in the development version. If a platform needs
a specific version (the macOS reference not changed in the DllMap)
then it can be specified in the configure script.
AIX doesn't need a special name because both AIX Toolbox and Perzl
include non-archive libraries in /opt/freeware/lib - unexpected.
* Don't try to use shm_open on PASE due to it not being implemented
All this will do is cause a coredump if running the script on PASE,
and write an entry to the SLIC diagnostic logs. This test could be
re-enabled if i 7.4 supports it properly.
* fix ODBC include
* Check for what library to use for libintl when dlopenning on AIX
These checks are for the benefit of the DllMap. The construct used
is kinda hacky, IMHO, but it resolves the concerns of hardcoding.
In the event that this doesn't work (it does for me), it falls back
to what the IBM RPMs seem to use for linking gettext et al.
Not sure of the utility for other platforms, since they usually
use sane soname conventions and the one-liner here depends heavily
on an AIX developer tool and its output format.
The use of cut/awk should work with the stock AIX utils, no GNU
necessarily needed.
* Implement RSACertificateExtensions.CopyWithPrivateKey(). #14152.
* RSACertificateExtensions.CopyWithPrivateKey(): implement.
Since `RSACertificateExtensions` lives in `System.Core` and only `mscorlib`
internals (but not `System` internals) are visible to it, we need to use a
little trick here:
* System.Security.Cryptography.X509Certificates.X509CertificateImpl:
add new abstract methods CopyWithPrivateKey() and CreateCertificate().
* System.Security.Cryptography.X509Certificates.X509Certificate2Impl:
sealed implement them here.
The `httpcfg` tool, only checks whether the key is valid, so we don't really
need to call `CopyWithPrivateKey()` (which requires us to take a dependency
on `System.Core`).
* Do the same thing in HttpListener.
* [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
* Marking Vector128<T>.Count and Vector256<T>.Count as [Intrinsic]
* Fixing NI_Vector128_Count and NI_Vector256_Count to use clsHnd when getting the simdSize and baseType
* Applying the formatting patch.
* Changing some comments to just be "vector element count".
* Fixing impBaseIntrinsic to set the baseType so Vector128_Count and Vector256_Count don't return nullptr
Signed-off-by: dotnet-bot <[email protected]>
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.
Fixes#14555
The NULL check alone is not enough, because interfaces are also parented to NULL for some reason, and so I've moved `class_kind` out from the bitfield section to make it accessible from IR. The beginning of the struct is going to be padded to 32 bits anyway at the least, so this move should save space if anything.
Our type checking overall is not very robust, and in particular the supertype comparison doesn't work well for anything that isn't an object, so it's possible there are some other weird corner cases. As far as I can tell looking through the array of objects stuff though, we should have reasonable coverage with the existing tests + the stuff I added.
Fixes#12141
Switched to a list because in theory any number of tags can be present. Old behavior was to put them into an array of size 3 and zero the byte following them, which was causing the crash with more than two tags. There's no null check for the default runtime because that should never happen, and the list is reversed to preserve the order from the XML. Changing the signature of `get_runtimes_from_exe` should be fine because it's static and only called in the one place.
* [wasm][bcl] Use zlib for DeflateStream on WASM profile
- Add `-s USE-ZLIB=1` flag for the emscripten build of `mono.js`
- Add new `zlib-helper` module build that is included in the `mono` wasm build.
- This adds roughly 300 kb to the size.
* Add zlib calls to `icall` for `WASM` profile
* Address comments use `TARGET_WASM` instead of `HOST_WASM`
* Hack around JS exception: RuntimeError: indirect call signature mismatch
- Instead of using the function pointer from DeflateStream (Marshal.GetFunctionPointerForDelegate) obtain the callback functions from the object itself.
* Update error messages and add exception parameter to `mono_runtime_invoke`.
* Add `mono/support` zlib include sources files to make `package` target.
* Add `zlib-helper` build to packager.
- Note: Right now only supports zlib build from mono tree build.
- Add `zlibtest.cs` scenario to compress and uncompress using DeflateStream and GZip.
- Add test to make file to build and run aot version of ziplibtest.
* Add copy of zlib header support files to `package-wasm-runtime`
- The support library is not built for wasm but the zlib include files are needed to build support during wasm build.
- See mono.js build and the use of the `-s USE_ZLIB=1` flag.
- The include files will be used in packager.exe to build zlib support for wasm.
* Use the zlib includes from support to build the zlib support.
* Setup base tests for testing System.IO.Compression integration
* Formatting
* Add more ziparchive tests
* Formatting and indentation
* Add more Zip tests
* Add more tests.
- Add more tests for ZipArchive.
- Add tests for Deflate - small, large and very large strings.
- Add tests for GZipStream - small, large and very large strings.
* Fix merge of EMCC_FLAGS
* Add new option to packager to enable the use of zlib
- --enable-zlib (enable the use of zlib for System.IO.Compression support)
type: bool default: false
- update packager doc
* Address review comments
- Change `enable-zlib` to `zlib`
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].
* [interp] Add support for inlining methods with locals
For each local in the inlined method we allocate a new local in the parent method.
* [interp] Enable inlining of methods using ldarga opcode
* [interp] Don't inline methods that do localloc
Inlining localloc in a loop leads to stack overflows. JIT has same behavior.
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
* Treat ternary operations as non-constant... (#13873)
...during constant evaluation and propagation.
* Move ternary SSA cfold test from basic.cs to objects.cs.
* [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
Additional background information
=================================
The original lucky, "good" behavior worked as follows 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 just 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/
* reduce frame size
INTERP_PUSH_LMF_WITH_CTX_BODY is not fully supported under Windows MSVC
since that compiler doesn't support taking address from a label, needed
by current implementation to correctly resume after unwinding exceptions
happening in native frames as tested by install_eh_callback.exe.
This fix add support to restore to a known location and use a flag
indicating if we have been resumed to the location or just passing by
for the first time. If we resume it will transfer control to specified label.
This will mimic the behavior of taking the address of a label and use that
address as the restore point and works like how setjmp/longjmp work.
I also considered switching to setjmp/longjmp but that would have had a bigger
impact on all platforms and needed changes into the resume context
machinery as well.
While doing the implementation I also found an interesting issue with
MONO_CONTEXT_GET_CURRENT under Windows x64. On most other platforms it is
implemented as inline assembler, but on MSVC x64 inline assembler is not
supported so it is implemented as a function. Problem with that is how IP
was resolved, since it won't be resolved to the last instruction in the
expanded macro, but to the IP within the mono_context_get_current. This has
not had any visible effects in the past since it will just do the ret and get
back to the call site, but when this was used in INTERP_PUSH_LMF_WITH_CTX_BODY
it caused some issues. This was fixed to make sure rsp and rip reflect location
in caller frame and not within mono_context_get_current, similar to how
it works on all platforms with inline assembler support.
* Clean the `managed` directory files on `/t:Clean` build target
* Modify the `CleanManaged` target to `_CleanManagedOutputDir`.
- Address comments by Mikayla.
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]>
* Download and use local .NET Core SDK
* depend on 'all' rule in nupkg
* fix build error
* Windows support
* use InitializeToolset function
* ouput full path of dotnet in init-tools.sh
* remove init-tools
* Add init-tools.ps1 (Windows)
* fix / issue on cygwin
* address Jo's feedback
* add powershell to PATH for make nupkg
* add netcore/build.sh
* handle pack and test commands
* Update tools.ps1
* Update tools.ps1
* follow the ICU User Guide recommendation to optimize the perf of InvariantCultureIgnoreCase on Linux:
1. try to guess the max size and call ucol_getSortKey just once
2. if the buffer is not big enough, call the method again providing the actual sort key length
* handle 0 case
* handle integer overflow
* shorten the time the buffers are pinned
* use the cheapest pinning
* code review fixes: don't use variable length stackalloc, don't copy text from docs (licensing) + don't try to go with the fast path when it would require allocating more managed memory for big strings
* simplify the condition
Signed-off-by: dotnet-bot <[email protected]>
On Windows default thread stack size has been 1MB for a long time
(both 32/64-bit). When starting to use interpreter some of the tests
include deep recursions that will hit stackoverflow on Windows
(ackermann.exe as one example). This commit adjust the default reserved
stack size to 8MB for debug builds and 1.5MB (same as coreclr), for main
thread only. All other threads will still default to 1MB stack size
(both debug/release).
* Removing the TestAllOnes, TestAllZeros, and TestMixOnesZeros methods from the Sse41 class
* Removing JIT support for the SSE41_TestAllOnes, SSE41_TestAllZeros, and SSE41_TestMixOnesZeros intrinsics
* Removing tests for the Sse41.TestAllOnes, Sse41.TestAllZeros, and Sse41.TestMixOnesZeros methods
Signed-off-by: dotnet-bot <[email protected]>
* Update TPN with Mono entry
* Update THIRD-PARTY-NOTICES.TXT
Add additional notice for Mono
* Update THIRD-PARTY-NOTICES.TXT
Update the Novell MIT-specific license
* Update THIRD-PARTY-NOTICES.TXT
Group various patterns of Mono license together
* Improve fatal err msg
* Match SO format
* a
* Remove dead define
* More adjustments to ex msg
* And PAL
* Remove special case for SOE
* Remove excess Debug.Assert newline
* Remove excess newline
* typo
* New format
* Remove DebugProvider redundancy
* Adjustments
* Remove preceding newline
* Make other SOE and OOM consistent
* Tidy up assertion msg
* Fix missing newline after inner exception divider
* CR when no inner exception
* ToString never CR terminated
* disable corefx tests temporarily
Signed-off-by: dotnet-bot <[email protected]>
* [arm64] Set a llvm target layout. Assert in llvm if the target layout is not set, the defaults used by 'opt' are not correct.
* Add a llvm target layout for amd64.
Flush() behaves like Flush(false) and writes out any buffered data but doesn't P/Invoke to FlushFileBuffers/FSync to flush the OS buffers.
But whereas FlushAsync() is supposed to just be an async equivalent of Flush(), it's actually behaving like Flush(true). This makes FlushAsync() inconsistent and much more expensive. (This is separate from FlushAsync not actually being async, which is an impactful problem to be solved separately.)
This changes FlushAsync to behave like Flush()/Flush(false) rather than Flush(true). If someone wants the FlushFileBuffers/FSync behavior, they can call Flush(true).
Signed-off-by: dotnet-bot <[email protected]>
* Add support for marshalling DateTime and DateTimeOffset
* Add type checking to Runtime.GetDateValue
- Update to use clr ToUnixTimeMillisecons and FromUnixTimeMilliseonds to replace manual calculations.
- Moved magic numbers to managed side to address comments left by Katelyn and Jay.
If this was not possible due to them being called during runtime initialization, a short comment was left noting the specific reason why.
Fixes#14377
This includes a couple other random fixes I noticed on the way, most notably replacing SEE_MASK_FLAG_DDEWAIT with SEE_MASK_FLAG_NOASYNC as the former is deprecated.
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.
https://github.com/mono/mono/pull/14607 broke LLVM build on Windows MSVC.
This is just a quick fix falling back to old behavior on Windows MSVC. Since
all LLVM tools will be available in the same folder as mono runtime binary
there is no specific need to point out other build folders hosting LLVM tooling.
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.
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
endif
# Keep in sync with SUBDIRS
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
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 netcore/corerun
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 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."
# Sets VSS_NUGET_EXTERNAL_FEED_ENDPOINTS based on the "darc-int-*" feeds defined in NuGet.config. This is needed
# in build agents by CredProvider to authenticate the restore requests to internal feeds as specified in
# https://github.com/microsoft/artifacts-credprovider/blob/0f53327cd12fd893d8627d7b08a2171bf5852a41/README.md#environment-variables. This should ONLY be called from identified
# internal builds
functionSetupCredProvider{
param(
[string]$AuthToken
)
# Install the Cred Provider NuGet plugin
Write-Host"Setting up Cred Provider NuGet plugin in the agent..."
Write-Host"Getting 'installcredprovider.ps1' from 'https://github.com/microsoft/artifacts-credprovider'..."
# Create the JSON object. It should look like '{"endpointCredentials": [{"endpoint":"http://example.index.json", "username":"optional", "password":"accesstoken"}]}'
# Create the JSON object. It should look like '{"endpointCredentials": [{"endpoint":"http://example.index.json", "username":"optional", "password":"accesstoken"}]}'
<!-- 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. -->
# Source for this file was taken from https://github.com/microsoft/azure-pipelines-task-lib/blob/11c9439d4af17e6475d9fe058e6b2e03914d17e6/powershell/VstsTaskSdk/LoggingCommandFunctions.ps1 and modified.
# NOTE: You should not be calling these method directly as they are likely to change. Instead you should be calling the Write-Pipeline* functions defined in tools.ps1
$script:loggingCommandPrefix='##vso['
$script:loggingCommandEscapeMappings=@(# TODO: WHAT ABOUT "="? WHAT ABOUT "%"?
Write-Host"There was an error while triggering subscription '$subscriptionToTrigger'"
Write-Host$_
Write-Host$_.ScriptStackTrace
$failedTriggeredSubscription=$true
}
}
if($subscriptionsToTrigger.Count-eq0){
Write-Host"No subscription matched source repo '$normalizedSourceRepo' and channel ID '$ChannelId'."
}
elseif($failedTriggeredSubscription){
Write-Host"At least one subscription failed to be triggered..."
ExitWithExitCode1
}
else{
Write-Host"All subscriptions were triggered successfully!"
}
Loaded 100 of 6044 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.