* [interp] Remove unop conditional branch applied to constant
Convert it to unconditional branch
* [interp] Enable more optimization
If we failed to emit stloc.np we no longer track stack contents or try other optimizations
* [interp] Fix emit_store_value_as_local
mint_type for a native type is i4/i8 while we were loading the address of this local using LDLOC_VT. This was wrong. Passing a valuetype this is done with LDLOCA.
* [interp] Fix incorrect cond branch opcodes
We didn't emit correct conditional branch opcode, because we didn't check the new stack types, after the addition of the implicit conversion opcodes.
* [interp] Remove binop conditional branch applied to constant
Convert it to unconditional branch
Xamarin-Android will need this for the net6 migration, so might as well add it before I forget about it. They currently use `mono_image_open_from_data_with_name`. cc: @grendello
Co-authored-by: CoffeeFlux <[email protected]>
Recent debugger test runs were showing lot of
`CWL: Failed to lookup sequence point` messages.
These are being shown for cases like:
`CWL: list_frames: Failed to lookup sequence point. method: runtime_invoke_direct_void, native_offset: 56`
This is a warning, and doesn't need to be emitted by default.
Co-authored-by: radical <[email protected]>
* Only set basepath to the source directory if useSourcePath is set.
* Fixes a regression from mono 4 that happened when changing the code
to not use reflection.
Co-authored-by: MarkS <[email protected]>
* Look for "xmonkeysloveplay" also at the end of LC_SYMTAB section, for signed Mac OS X binaries
This extends Miguel de Icaza's previous work on allowing mono to load embedded
assemblies / shared libraries, which was in turn a workaround on recent
Mac OS X's increased security (and stopping LD_LIBRARY_PATH and friends from
working). Miguel de Icaza came up with the idea of appending all of those
embedded assemblies / shared libraries to the end of mono's main executable,
and getting it to look at its own file and unpacking resources from an offset
number + "xmonkeysloveplay" written to the end of file.
Even more recent Mac OS X starts to prefer /require binaries to be code-signed.
Code signing appends a "LC_CODE_SIGNATURE" section to the binary, thus breaking
mono's embedded resource-loading. Also code-signing requires that the binary
has no unknown parts.
To make mkbundle / mono embedded resource-loading work in a code-signing
situation, two parts are required:
- adjust mkbundle to extend the LC_SYMTAB section to cover the appended
assemblies / shared libraries, so code-signing can happen.
( addresses https://github.com/mono/mono/issues/17881 )
- adjust mono's main executable to also look at the end of the LC_SYMTAB
section for the magic offset + "xmonkeysloveplay" token to find the embedded
resources.
( addresses https://github.com/mono/mono/issues/18826 )
This change addresses the 2nd of the above. I also tried looking for the
presence and beginnig of the LC_CODE_SIGNATURE section, but that proves
unreliable: Code-signing can pad a few null bytes after "xmonkeysloveplay"
to align the LC_CODE_SIGNATURE section to an 8(?)-byte boundary.
* saving offset before read, so later lseek does not need to backtrack on the read
This is a small simplification of the previous commit on this part of code.
* fixes wrong drop-through from mis-positioning of #endif
* Update mono/mini/main.c
Adding spaces for clarity
Co-authored-by: Ryan Lucia <[email protected]>
* Update mono/mini/main.c
Adding spaces for clarity
Co-authored-by: Ryan Lucia <[email protected]>
* Update mono/mini/main.c
Adding spaces for clarity
Co-authored-by: Ryan Lucia <[email protected]>
* Update mono/mini/main.c
Adding spaces for clarity
Co-authored-by: Ryan Lucia <[email protected]>
* Update mono/mini/main.c
Added comment about what's going on.
Co-authored-by: Ryan Lucia <[email protected]>
* Adding comments for clarity
* rename variable "h" to "bin_header", for clarity
* Limit Apple code-signing work around to only the desktop OS (vs iDevices/TV)
* remove stylistic "else"; no change in functionality
Co-authored-by: Ryan Lucia <[email protected]>
We previously had a weird split between the domain and loader headers/files. This makes fewer things public, moves the useful ALC functions to loader-internals.h with the implementation in assembly-load-context.c, and cleans up the flow for some unloading behavior.
Co-authored-by: CoffeeFlux <[email protected]>
This PR:
* Enables `-Wc++-compat` on all platforms: we support building the runtime as C++, so this helps catch errors before they're found in CI and will help keep the netcore build C++-compatible
* Sets `-Werror` on netcore CI for OSX
It also fixes various warnings currently present in the build.
`-Werror` should probably be extended to cover all CI platforms eventually. Adding a new platform is as simple as adding to the line in mono.proj whitelisting platforms and fixing the warnings.
Not sure if there's a better way to handle the cpuidex function, but if we're using that from mini it should definitely be in a header somewhere.
Co-authored-by: CoffeeFlux <[email protected]>
* Catch attempts to create enum types with an underlying type that is itself an incomplete enum type.
Previously, only non-enum types containing fields with incomplete enum
types were forbidden.
* Permit static constant fields with incomplete types if the incomplete type is the type currently being defined
Co-authored-by: Alexis Christoforides <[email protected]>
* Avoid following invalid pointers in mono_w32process_get_modules on Darwin.
`_dyld_get_image_name` and `_dyld_get_image_header` can return pointers
to data that will be freed or unmapped by concurrent calls to `dlclose`.
Avoid this by using `_dyld_register_func_for_add_image` and
`_dyld_register_func_for_remove_image` to install callbacks that
maintain a runtime-internal set of loaded dynamic libraries.
Some notes:
- dyld doesn't provide a public "app store friendly" API (like
`dl_iterate_phdr`) to traverse a snapshot of all loaded dynamic
libraries in a process. There are two alternative private APIs that do
this: one uses `_dyld_process_info_create` and friends and is present in
macOS 10.12 and above, and the other depends on
`_dyld_get_all_image_infos`, which is documented by Apple (... in a WWDC
video) to "go away" at some point in dyld3.
- `dladdr` linearly scans the dyld loaded image array (and each image's
segment set) for a matching address, so `image_added` will get slower as
more dynamic libraries are loaded in the process. But dyld3's
implementation of dlopen already scales linearly in time with the number
of loaded libraries. The use of `dladdr` can be avoided by using
`_dyld_register_for_image_loads` or
`_dyld_register_for_bulk_image_loads`, but those are both private APIs.
- The callbacks registered with `_dyld_register_func_for_add_image` and
`_dyld_register_func_for_remove_image` can never be unregistered, so
this is yet another thing that makes it impossible to safely unload an
embedded mono.
- `MonoW32ProcessModule::inode` only seems to be used to avoid dupicates
in other implementations of w32process; sorting the returned module list
in `mono_w32process_get_modules` wouldn't be necessary if the
`mono_dyld_image_info`s were also kept in an intrusive circular doubly
linked list.
- It looks like `mono_w32process_get_modules` in `w32process-unix-bsd.c`
has a similar race condition.
Also see: https://github.com/mono/mono/issues/20107
* Formatting.
* Make `image_added` and `image_removed` non-blocking.
It is theoretically possible for `mono_w32process_get_modules` to cause
a deadlock if either `image_added` or `image_removed` is waiting for the
image table mutex to be released and if `g_new0`, `g_strdup`,
`g_hash_table_iter_next`, or any of the symbols they depend on are
lazily bound and haven't already been resolved.
Only one thread may iterate over the image table and only one thread may
add/remove entries to/from the image table.
The writer thread attemps to lock a mutex to block readers from
iterating over the table. If the writer successfully acquires this lock,
then no readers are concurrently iterating over the image table and it
is safe to eagerly free stale data.
If the writer doesn't successfully acquire this lock, then the reader
thread is running concurrently with the writer; if this happens, the
writer pushes stale data into a limbo list. Readers opportunistically
clear this list.
Use `mono_mutex_t` instead of `MonoCoopMutex`. Hand-roll the necessary
GC state transitions inside `mono_w32process_get_modules`.
Add `mono_conc_hashtable_foreach_snapshot` to mono-conc-hashtable.{h,c}.
`MonoConcurrentHashTable` depends on the hazard pointer table
(`hazard_table` inside hazard-pointer.c), which is initialized lazily on
the first call to `mono_thread_small_id_alloc`. Perhaps this should be
explicitly initialized early during `mono_init_internal`.
* Revert "Make `image_added` and `image_removed` non-blocking."
This reverts commit a22a4440df5f0f13da29b1b90e80a3420223c2b9.
* Use mono_mutex_t instead of MonoCoopMutex
* Explicitly load symbols not used by `image_added` before `mono_w32process_get_modules` runs
When this experiment is enabled, the GC doesn't scan stack or registers. This mode is meant to disable scanning of native frames. This implementation only makes sense in full interpreter mode, where the interp stack is scanned separately from the thread stack. Longer term we could use this mode to scan only the managed stack, also in jit mode.
The point of this mode is to be able to stress test the GC in a wasm like environment, where stack can't be scanned. We can more easily reproduce and investigate GC crashes in this configuration, that would also happen on wasm.
Co-authored-by: BrzVlad <[email protected]>
This mostly completes support for the attribute. Our algorithm differs a bit from CoreCLR right now, so we don't support the legacy behavior flag since it makes less since in the context of our algorithm, but this should be good enough for most cases.
Co-authored-by: CoffeeFlux <[email protected]>
Similar logging was added to the managed loading algorithm when it proved extremely useful for debugging a Blazor crash, so the equivalent is probably useful for the unmanaged library algorithm as well
Co-authored-by: CoffeeFlux <[email protected]>
The important change here is not leaking the coop handles, the other is because I'm too lazy to create two separate PRs for this.
Co-authored-by: CoffeeFlux <[email protected]>
Fix https://github.com/mono/mono/pull/19494 adds missing array ctor needed by several tests currently failing as described by https://github.com/dotnet/runtime/issues/34068.
This PR fixes an additional problem hit by the IL array tests using an lbound != 0. Current Mono codegen for Set/Get/Address array methods didn't adjust index with regards to lbound causing failures in several of the array tests. NOTE, this scenario should only be hit when directly calling Set/Get/Address using IL on an array with an lbound != 0. It shouldn't affect regular szarray's at all since that code paths should never be used and the codegen currently looks up the lbounds unconditionally in the array, so if that code path ever gets hit by a szarray, it will imdediate crash, so shouldn't be causing any performance impact on szarrays. There is also an additional check on the array type as well as an additional precaution, so only arrays of type MONO_TYPE_ARRAY, hitting codegen for Set/Get/Address array method calls will adjust index based on lbound.
This PR fix the lbound index codegen for that specific code path and re-eanbles the tests currently listed in https://github.com/dotnet/runtime/issues/34068.
Co-authored-by: lateralusX <[email protected]>
Make EventSource call static version of EventActivityIdControl in EventPipeEventProvider instead of direct calling low level
EventPipeInternal (now only called from EventPipe* sources). Doing it that way will also keep EventPipeEventProvider.EventActivityIdControl in S.P.C meaning that tests like eventactivityidcontrol won't risk
of using methods that has been trimmed away by linker.
Added missing case into Mono's EventPipeInternal::EventActivityIdControl implementations.
Enabled eventactivityidcontrol test on Mono runtime. Adjusted test to use static EventPipeEventProvider.EventActivityIdControl version.
Co-authored-by: lateralusX <[email protected]>
Implement `BitScanForward` and `BitScanReverse` as intrinsics.
Implement `__cpuidex` as a netcore-only icall. Rename `cpuid` (in
mono-hwcap-x86.c) to `mono_cpuidex`, give it extern linkage, and add
support for extended CPUID.
Related: https://github.com/dotnet/runtime/pull/40167
Co-authored-by: imhameed <[email protected]>
* Reformatting files.
Merging dotnet/runtime to mono/mono
* Removing testharnessstartup from browserdebughost.
Fix format of EvaluateOnCallFrameTests.
* Fix package.
This change means we will handle bundles consistently across platforms and ensures that the MonoImageStorage is keyed by the in-memory location rather than the assembly name, which seems less error-prone.
Co-authored-by: CoffeeFlux <[email protected]>
Replace them with the current URL after the redirect.
Similar to @stephentoub's PR: https://github.com/dotnet/runtime/pull/2063.
This is a mechanical find/replace, I did not check whether the references are still accurate or issues are already fixed.
Co-authored-by: akoeplinger <[email protected]>
Changing some console.log to console.debug to not pollute the console.
Changing printf to DEBUG_PRINTF to follow the debug level chosen by user.
Remove unnecessary console.log.
Fixdotnet/runtime#40721
Co-authored-by: thaystg <[email protected]>
The attributes need to be ignored as with the other types, otherwise gsharedvt wrappers for signatures with
parameters like double f = default will not be found.
Fixes https://github.com/mono/mono/issues/20195.
`mono_type_get_object_checked` will return the `MonoReflectionType`
referred to by `MonoDomain::typeof_void` if present. If a byref
`System.Void` is stored in this field, then
`get_ContainsGenericParameters` applied to `System.Void` will loop
indefinitely, because our implementation of
`get_ContainsGenericParameters` expects `GetElementType` to yield a
`MonoReflectionType` with one layer of "type function application"
removed.
Fixes https://github.com/dotnet/runtime/issues/37489.
Co-authored-by: imhameed <[email protected]>
We need to set these defines so we don't use obsolete ICU functions and cause warnings, just like we do in the CMakeLists.txt version..
Co-authored-by: akoeplinger <[email protected]>
* Fix __asm__ specs to work with clang
* 1. No need for USE_STRING_INLINES anymore
2. Code around clang bug where %r0 is being rejected from BASR instruction
* Fix a couple of more __asm__ specifications for clang
* [riscv] add ELF machine definition
* [riscv] add mono_arch_get_cie_program to fix the build
* [interp] remove unused pointer
* [riscv] add offsets for MonoContext members
* [riscv] add pattern to nop_stub, so it is easier to spot in the debugger what caused the hang
* [riscv] minimal exception handling support
Also adds a minor improvement to line wrapping, by not updating the wrap
position when it can only move it earlier. This means when processing
end-of-wrapped-line whitespace that it doesn't get adjusted every time.
Also doesn't update the previous wrap position, but that shouldn't be
used in this situation as it is only for wrapping after dashes.
The real problem that this fixes is that wrapping a line at a point such
that there was whitespace including a tab after the wrap position could
cause an infinite loop. Without the fix, with a wrap_pos > 0 (normal),
it only split the line after reaching non-whitespace. In most situations
that was OK as we norwally wrap after whitespace. However a tab is
whitespace we wrap before. Once pos was equal to wrap_pos it stopped
incrementing pos as it was now at the split position and therefore it
shouldn't change. But it didn't set split_tag, so didn't split, and
therefore didn't exit the outer loop.
EDIT: Simple test case to trigger an error:
```csharp
ThreadPool.QueueUserWorkItem((_) => {
throw new Exception("test");
});
var t = typeof(System.Threading.ThreadPool);
var m = t.GetMethod("PumpThreadPool", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
m.Invoke(null, null);
```
Co-authored-by: kg <[email protected]>
* Fix configure check for arm64+osx.
* Add mono_codeman_enable_write/disable_write functions.
* Use clang --shared for linking aot images.
* Fix eglib remapping.
* Make code memory writable during code generation.
* Enable/disable writable code around dlmalloc operations, dlmalloc allocates from code memory.
* Fix some defines.
* Fix set/clear_breakpoint.
* Fix llvm jit support.
* Fix gsharedvt.
* Force float32 to be enabled on osx/arm64.
* Add codegen macros for arm64e.
* Disable some crash tests if --disable-crash-reporting is used.
* Disable btls. Disable boehm by default.
* Fix a warning.
* Fix vararg calls, the vararg icalls assume every argument is in in own stack slot, but the default osx/arm64 calling code is the same as ios which allows small arguments to share a stack slot.
* Fix formatting.
* Fix the build.
* Use aarch64-darwin-ios as the target triple when cross compiling to ios so configure can distinguish between osx/arm64 and ios.
* Assume ios when cross compiling to aarch64-darwin.
* [wasm] Use interp-only instead of interp-llvmonly as the default execution mode.
interp-llvmonly caused mono_llvm_only to be set, causing bad behavior like
stack walks not working.
* Address comments.
After adding the ICU shim code to the runtime we hit an issue when e.g. compiling for "desktop" mono in a working directory that already had Browser wasm artifacts in it.
This is due to automake putting the intermediate compilation artifacts at the same location where a file was referenced from.
This means that e.g. when using `../../../libraries/Native/Unix/System.Globalization.Native/pal_icushim.c` in the Makefile.am we'd get the intermediaries in `artifacts/obj/mono/libraries/` instead of somewhere in `artifacts/obj/mono/OSX.x64.Debug`.
Later on we'd get the following error because it was reusing the existing .o file from another architecture:
```
Undefined symbols for architecture x86_64:
"_gPalGlobalizationNative", referenced from:
_c_qcalls in libmonoruntimesgen.a(libmonoruntimesgen_la-native-library-qcall.o)
```
Fix this by symlinking the source files into the build directory.
Co-authored-by: akoeplinger <[email protected]>
Bumps bockbuild to get the changes from mono/bockbuild#162
BigSur's CoreGraphics seems to need a copy of the data to stick around longer than the surface,
so we provide it a copy of the data instead.
Backport of https://github.com/mono/mono/pull/20154 to master
* Changed debugger-agent to allow for the Debugger Attributes to not exist.
* Removed the Debugger Attributes entries from the Descriptors.xml file.
Fixmono/linker#1355
Co-authored-by: eerhardt <[email protected]>
This disables several debugging features in sgen, helps the compiler remove some unused code related to concurrent collector and disables more assertion messages, but also some other logs. We might have to reenable some of them if this is problematic.
Saves about 60k on wasm
Co-authored-by: BrzVlad <[email protected]>
MonoClass-es created for ftnptr types have an implicit pointer field so their size is not
the same as the computed size.
Co-authored-by: vargaz <[email protected]>
Recognize `get_AllBitsSet` instead of `get_AllOnes`; this internal
intrinsic was renamed in https://github.com/dotnet/runtime/pull/36579
(1c66ad1b71bb84a16b71bb5efcef1fa999c1c8bc).
Implement `Vector<T>.One` as an intrinsic.
Co-authored-by: imhameed <[email protected]>
It was missing a few signatures in wasm_m2n_invoke.g.h that caused it to fail with `WASM-ERR: CANNOT HANDLE INTERP ICALL SIG IIILIIII`
Co-authored-by: akoeplinger <[email protected]>
Delegate callback can be held in native event pipe provider instance and called multiple times during provider lifetime (enable/disable sessions). Store a weak GC reference to delegate to correctly handle case where delegate gets moved by GC. It should not be collected since delegate should be held alive by managed event pipe class.
Co-authored-by: lateralusX <[email protected]>
The previous method of returning interp_no_native_to_managed doesn't work:
* The runtime expects different function pointers for different methods, returning
the same pointer leads to all kinds of weird errors.
* On wasm, the native caller expects the function to have the right signature, so
calling interp_no_native_managed () will leads a to signature mismatch error which is
hard to debug.
Co-authored-by: vargaz <[email protected]>
- coreclr/build-test.sh now has a new subcommand: 'mono_aot', which builds a
new target, named 'MonoAotCompileTests', added to
coreclr/tests/src/runtest.proj. This target compiles the runtime tests using
Mono LLVM AOT in a simple configuration where the host platform is identical to
the target platform. Parallel compilation happens via a hack: actual
compilation happens in mono/msbuild/aot-compile.proj, a single-target msbuild
file, and runtest.proj invokes this single-purpose project and target using
batching to create multiple parallelizable instances of this project. Future
work: use the MonoAOTCompiler custom task currently used to build the iOS
sample program.
- Avoid using the runtimeVariant string when defining
coreClrProductArtifactName in mono/templates/xplat-pipeline-job.yml. There are
no "runtime variants" of CoreCLR configured with this parameter; instead,
depend on a shared non-runtime-variant build of CoreCLR.
- Mark function DISubprograms as local definitions--this is an LLVM 9
compatibility fix.
- Use --tag=CXX when linking libmonosgen-2.0.so via libtool when LLVM is linked
into Mono.
This makes libtool use the C++ compiler driver when linking Mono--which uses
whatever platform-specific flags are necessary to link against the C++ stdlib.
Previously, libtool would use the C compiler driver, which didn't do this and
would produce shared objects with no explicit dependency on libstdc++.
This problem is normally masked because of the very lax dynamic linking
semantics on ELF, but Mono on our CI setup is built in a CentOS 7 image (which
does not contain a C++11 libstdc++) that has a GCC 7 compatibility package
installed, along with a clang 9 installation that detects headers from the GCC
7 compatibility package. This compatibility package includes a libstdc++ linker
script that links C++11 libstdc++ components statically into the target while
dynamically linking against components present in pre-C++11 libstdc++. The end
result of all of this is that Mono built with this configuration will
dynamically depend on C++11 libstdc++ symbols that should have been statically
linked into the library, and will outright fail to run on machines without a
newer version of libstdc++ available.
- Add tests that fail after LLVM AOT compilation to issues.targets.
These are mostly around string operations and are meant to be a quick boost in performance for some common blazor scenarios, around rendering and json parsing, before interp optimizations catch up. Even if the interpreter will have more advanced optimization passes, it is likely that it would still be much slower on these low level operations. Long term we would have methods like these AOT-ed, but, depending on how easy to maintain and how effective these turn out to be, we could also stick to intrinsifying some bcl code in the future.
Co-authored-by: BrzVlad <[email protected]>
`silent` argument for `callFunctionOn` should not cause errors to be
suppressed. According to the protocol docs:
`In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.`
- so, the result returned should have the error, if any.
- Added corresponding JS test, so that we know we are matching the
correct behavior.
* [marshal] Add mono_method_has_unmanaged_callers_only_attribute
* [marshal] Allow calls to mono_marshal_get_managed_wrapped without a delegate class
In that case, create a wrapper based on the signature of the method itself.
* [aot] Allow decode_method_ref to decode NATIVE_TO_MANAGED wrappers without a delegate class
Bump the AOT file format
* [interp] ldftn will return a native-to-managed wrapper to UnmanagedCallersOnly methods
* aot: emit byte when we don't expect a class
* jit: create wrapper creation for ldftn in method-to-ir
Do it at IR generation of the caller, not every time the ldftn is executed
* jit: don't create a jump trampoline for ldftn of a native-to-managed wrapper
The wrapper might be called from a thread that's not attached to the runtime, and the jump trampoline will look at TLS vars that are not initialized
* interp: transform LDFTN into LDC of a create_method_pointer for UnmanagedCallersOnly method
* marshal: throw invalid program exception for instance and generic methods
* Emit IPE throw instead of aborting JIT or interp compilation for bad UnmanagedCallersOnly methods
Instead of throwing while JITing (or transforming), throw when the LDFTN is executed.
* disallow delegate constructor calls on UnmanagedCallersOnly methods
* throw IPE if UnmanagedCallersOnly method has non-blittable args
* disallow DllImport and UnmanagedCallersOnly together
throw NotSupportedException
Co-authored-by: Ryan Lucia <[email protected]>
Co-authored-by: lambdageek <[email protected]>
Due to issues on some platforms related to mono_delegate_to_ftnptr_impl, switch to use mono_runtime_delegate_invoke without need for delegate wrapper generation currently not supported on all platforms.
Co-authored-by: lateralusX <[email protected]>
After https://github.com/dotnet/runtime/pull/38793 tweaked the license header on ~30K files, this cleans up after it, handling another ~1300, and adding license headers where they were missing in .cs files under libraries. It also adds a default license header to the .editorconfig.
cc: @jkotas
Co-authored-by: stephentoub <[email protected]>
The `MonoMethod:slot` width was accidentally changed in https://github.com/dotnet/runtime/commit/8465be73eb40a9c409dc8974b9d6b235a1b5158f
To compensate, we move 3 bits out to image properties
* `verification_success` - rarely used nowadays, protected by the image lock (like all image properties)
* `is_reabstracted`, `is_covariant_override_impl` - infrequently used features of newer C# language features (default interface methods and covariant returns). Setting these assumes the loader lock is held.
Co-authored-by: lambdageek <[email protected]>
* [wasm] Refactor the wasm tuner.
Move the pinvoke table generation code into a new PInvokeTableGenerator.cs file,
to be similar to the corresponding code in WasmAppBuilder in dotnet/runtime. NFC.
* [wasm] Implement support for pinvoke callbacks in the interpeter.
* Modify the tuner to generate a table of trampoline functions which
have the same signature as the pinvoke callback methods.
* These functions transfer control to the interpreter.
* Modify the interpreter/wasm runtime to look up the functions
corresponding to the pinvoke callback methods.
* [csproj] Update project files
* Fix license.
* Remove leftover debug code.
Co-authored-by: monojenkins <[email protected]>
* [wasm][debugger] Send var names also, to `mono_wasm_get_variables`
- this will be useful in upcoming commits, which will need to use the
names for local pointer vars
* [wasm][debugger] Add support for deref'ing pointers
* [wasm][debugger] Dereference the pointer in js, instead of debugger.c
Based on suggestion from @vargaz
* [wasm][debugger][tests] Fix setting async methods when setting
.. breakpoint by method name. Async methods themselves don't have the
debug information. Instead, that can be found on the generated async
implementation type/method. Here, we just look for a type name
starting with `{original_type_name}/<{async_method_name}>`, and use the
method `MoveNext` from that.
* [wasm][debugger][tests] Update to set bp by method name+lineoffset
* Address review comments from Katelyn Gadd (@kg)
* Add test to check deref'ing invalid pointers
- We should really be handling invalid object ids, and report errors for
those, where appropriate. This will be done in a future PR
- For this PR, I'm adding tests that just check that invalid objects, or
trying to deref regular objects, doesn't blow up
* Remove old unused test code
* [wasm][debugger] Use JsonConvert instead of manually building the json string
- addresses review comment from @lewing
* [interp] Make args part of called method stack frame
This also compacts stack usage. A new frame starts at the location of the first pushed argument.
* [interp] Remove ldarg/starg opcodes
We replace them with opcodes that operate on locals instead. This also enables additional optimizations that were applying to locals.
* [interp] Kill stack_args
It is now redundant
* [interp] Actually allocate filter frame in separate space
By mistake, the filter frame was using the same stack space as the original frame. This means that the filter clause could corrupt frames from which we still need to run finally clauses. This also refactors the code a little bit, moving frame copying outside interp_exec_method, which is already overly complex.
The top-level .gitignore has `[Dd]ebug*/` - which matches `sdk/wasm/DebuggerTestSuite/*`;
to override, we need to add `!DebuggerTestSuite` to sdk/wasm/.gitignore
This can by used by the xharness xunit runner to make sure async tasks are executed.
We also need to tweak how `ThreadPoolTaskScheduler` handles `TaskCreationOptions.LongRunning` since the usual mode of starting a new thread doesn't work, instead we treat it like the option wasn't set and queue the task on the threadpool.
Co-authored-by: akoeplinger <[email protected]>
Continuation of https://github.com/dotnet/runtime/pull/34600, adding BufferManager into the library including unit tests, merging source files and additional library restructuring.
- Port EventPipeBuffer.
- Port EventPipeBufferList.
- Port EventPipeManager.
- Merge internals source files. Changed GETTER_SETTER to only mandate use of inlined functions when calling betweeen source files for different types. Upgraded all use within each source file for direct struct access.
- Changed function entry error checkin strategy. Only apply active checks on outer library API, ep.h, and use EP_ASSERT for all other functions.
- Dropped requires_lock_held in function naming, switch to comment in header or in forward declare for functions that validates that lock is held.
- Removed currently unused GETTER/SETTERS.
- Moved more comments into sources from corresponding CoreCLR EventPipe sources.
- Add EventPipeBuffer/EventPipeBufferManager unit tests.
Next step after this PR will be to enable a file session during runtime and add more unit tests and then start getting diagnostic server component over to Mono.
Co-authored-by: lateralusX <[email protected]>
https://github.com/mono/mono/pull/19794 broke on iOS. Analyzing the result showed that, while the assembly was generated as expected, the linked result was different. Analyzing the LLVM code (which triggered the original fix) seems to imply that, on Apple platforms, they will not generate a label for it, only doing the 0-offset as we were doing before. Therefore, match the LLVM behavior by bringing back our previous logic when targetting Mach, otherwise use the new way of doing things.
Fixes https://github.com/mono/mono/issues/8806 (again)
* [wasm] Optimize interp->native transitions.
* Generate tables of signatures/transition functions.
* Add mono_wasm_get_interp_to_native_trampoline () function to look up the transition function
for a signature.
* Cache the transition function in a imethod->method_data slot.
Previously, we were calling a mono_wasm_interp_to_native_trampoline () function and a generated
icall_trampoline_dispatch () function which added a lot of overhead.
* Avoid sharing cache entries.
This is an enhanced version of mono_exception_get_managed_backtrace()
that takes an optional `const char *prefix` argument (to indent the
stack-trace) and returns FALSE with a NULL backtrace on error.
* [cominterop] Don't leak the MonoMethodBuilder in cominterop_get_ccw_checked().
* [cominterop] Support ClassInterfaceAttribute.
* [cominterop] Factor out cominterop_get_ccw_method().
* [cominterop] Implement auto-dual class interfaces.
* [tests] Add tests for ClassInterfaceType and auto-dual class interfaces.
When we call a delegate that was bound to a specific function, don't do a virtual call.
Fixesmono/mono#19964
Co-authored-by: lambdageek <[email protected]>
Covariant return implementation for Mono.
---
There are also a couple of general Mono fixes in here, too:
1. Interpreter support for `MONO_TYPE_FNPTR` in `mint_type()`
2. a "signature assignment" mode for `mono_class_is_assignable_from` that doesn't treat `IntPtr[]` and `long[]` (or `int[]`) as interchangeable
3. support for unmanaged pointer comparisons in `mono_class_is_assignable_from`
4. Factor `mono_byref_type_is_assignable_from` out of `ves_icall_RuntimeTypeHandle_type_is_assignable_from` and make it generally usable.
---
For covariant returns, there are a couple of pieces here:
1. Method overrides come in two flavors: implicit (matching by name and sig) and explicit (using a `.override` directive).
* for explicit overrides, we have to check that the override has a signature that is subsumed by (its return type is a subtype of the return type of) the previous override, if any, and the declared method.
* for implicit overrides, we have to check that the override has a signature that is subsumed by the previous most derived override (not just the one that we happened to find with a precisely matching signature).
2. If any override is marked by `[PreserveBaseOverridesAttribute]` then we need to find all the other slots that may have methods from the override chain and update them. (The attribute is expected to be applied to a `newslot virtual` method that is an explicit `.override` of some other method).
There's an interesting test case where a class has _both_ an implicit and and explicit override for the same slot, arrived via different methods - in this case, the implicit one is supposed to be ignored. We implement this by doing the implicit slot filling first, then the explicit, and saving the covariant return checking until after both are done.
---
Because the method (`MethodImpl`) is both an override of another virtual method,
and is itself a `newslot`, it will occupy (at least) 2 slots in the vtable -
its own newslot and the `MethodDecl` that it is overriding.
If a third class subclasses the class with the `MethodImpl` or one of its
descendents and itself overrides either the `MethodDecl` or (one of the)
`MethodImpl` (either implicitly or with another explicit .override) the
`PreserveBaseOverridesAttribute` is a signal to apply the new override that it
should apply to all the slots.
The way this works is when processing the overrides, we walk up the class
hierarchy looking at the contents of the impl slot and if any of them have the
attribute, we make sure to add a mapping to the "`override_map`" to replace any
occurrences of a previous impl with the newest (most derived) impl.
An (existing) later pass goes through the vtable and applies the override_map.
Contributes to dotnet/runtime#37509
* [metadata] Implement support for PreserveBaseOverridesAttribute
The attribute is expected to be applied to a `newslot virtual` method that
is an explicit .override of some other method.
Becuase the method (MethodImpl) is both an override of another virtual method,
and is itself a `newslot`, it will occupy (at least) 2 slots in the vtable -
its own newslot and the MethodDecl that it is overriding.
If a third class subclasses the class with the MethodImpl or one of its
descendents and itself overrides either the MethodDecl or (one of the)
MethodImpl (either implicitly or with another explicit .override) the
PreserveBaseOverridesAttribute is a signal to apply the new override that it
should apply to all the slots.
The way this works is when processing the overrides, we walk up the class
hierarchy looking at the contents of the impl slot and if any of them have the
attribute, we make sure to add a mapping to the "override_map" to replace any
occurrences of a previous impl with the newest (most derived) impl.
An (existing) later pass goes through the vtable and applies the override_map.
* add FIXME for dynamic images
* scan entire chain of inheritance, don't stop at the class with the attribute
Makes OverrideMoreDerivedReturn.il pass
* UnitTestDelegates is also passing
* [metadata] Add mono_metadata_signature_equal_no_ret
* inflate signature->ret when doing covariant checking
* [class] Add mono_class_signature_is_assignable_from_checked
In ECMA I.8.7.1 "assignment compatability for signature types" we need to
distinguish IntPtr[] from int32[] and int64[]. The ordinary cast_class for an
array type in Mono implements the "intermediate type" relation from I.8.7.3
"general assignment compatability" - IntPtr[] gets treated as inter-castable
with int32[] or int64[], depending on platform pointer size.
The new mono_class_signature_is_assignable_from_checked function does the finer
relation for signatures, while the old mono_class_signature_is_assignable_from_checked
preserves the existing behavior used elsewhere in the runtime.
* Check every method previously in the slot against the new impl
* UnitTest_GVM passes
* [metadata] Don't infinite loop in mono_class_get_flags for a FNPTR
When a MonoClass is a MONO_TYPE_FNPTR, the element_class is itself. We should
probably not do that, but meanwhile, make `mono_class_get_flags` return
something else for function pointer types.
Makes mono_class_is_interface not overflow the stack
* [metadata] Set MonoClass:cast_class for pointer types to the intermediate type
Ignore signedness differences and set cast_class to the storage type, same as
for arrays. This is used by mono_class_is_assignable_from when comparing
IntPtr* vs ulong*, for example.
* [metadata] Make mono_class_is_assignable_from work for unmanaged pointer types
The issue is that we need to compare intermediate type or the reduced type of
the element type, depending on whether we're doing compatability or general
assignment compatability (upshot: ulong* and long* are always inter-assignable,
but IntPtr* is not in signatures, but is for general storage)
* [metadata] Pull mono_type_byref_is_assignable_from out of ves_icall_RuntimeTypeHandle_type_is_assignable_from
Make it a separate internal function
* [metadata] mono_type_byref_is_assignable_from for valuetypes and class types should check for identity
X& and Y& where both are either a reference types or valuetypes are only
assignable if X and Y are identical. The old code was checking for identity
for valuetypes, but for reference types it would allow any two reference types
at all, which is incorrect.
* [class-init] Check for byref types in covariant return signatures
Lets us pass Loader/classloader/MethodImpl/CovariantReturns/UnitTest/CompatibleWithTest.il from the CoreCLR testsuite
* [interp] handle MONO_TYPE_FNPTR in mint_type
It's just a pointer-sized integer, as far as the interpreter's type discipline is concerned
* [class-init] Use a bit for covariant return method impls
Allows us to check implicit overrides against previous impl's sig when the previous impl potentially had a covariant return type.
Also use the bit to decide if we need to check signatures of the entire impl chain for explicit instantiations
* ReturnTypeValidation unit tests work on Mono now
* [class-init] check covariant vtable slots after overloads are applied
The check has to be done after both implicit and explicit overrides have been
applied because some implicit overrides must be ignored. If the check is done
as soon as we detect that a covariant return method override is needed, we will
incorrectly check implicit overrides that are to be ignored because a later
explicit override applied to the same slot.
* [metadata] Fix byref IsAssignableFrom
The reflection API has an interesting behavior, whereas the ECMA definition is
stricter.
```
public interface I {}
public class B {}
public class D : B, I {}
public struct S : I { }
class Program {
static void Main(string[] args)
{
var tb = typeof (B).MakeByRefType ();
var td = typeof (D).MakeByRefType ();
var ti = typeof (I).MakeByRefType ();
var ts = typeof (S).MakeByRefType ();
Console.WriteLine ($"{tb.FullName} is assignable from {td.FullName} ? {tb.IsAssignableFrom (td) }");
Console.WriteLine ($"{td.FullName} is assignable from {tb.FullName} ? {td.IsAssignableFrom (tb) }");
Console.WriteLine ($"{ti.FullName} is assignable from {td.FullName} ? {ti.IsAssignableFrom (td) }");
Console.WriteLine ($"{td.FullName} is assignable from {ti.FullName} ? {td.IsAssignableFrom (ti) }");
Console.WriteLine ($"{ti.FullName} is assignable from {ts.FullName} ? {ti.IsAssignableFrom (ts) }");
Console.WriteLine ($"{ts.FullName} is assignable from {ti.FullName} ? {ts.IsAssignableFrom (ti) }");
}
}
// Expected Output:
// B& is assignable from D& ? True
// D& is assignable from B& ? False
// I& is assignable from D& ? True
// D& is assignable from I& ? False
// I& is assignable from S& ? False
// S& is assignable from I& ? False
```
* rename mono_class_signature_is_assignable
No need for _checked suffix
* rename mono_byref_type_is_assignable_from
* [class-init] Move vtable setup to a separate file
The code is getting quite long, move it to a separate file
* [jit] Add a fastpath to fill_runtime_generic_context ().
This is needed in llvmonly mode, since that mode doesn't use the
fastpath lazy rgctx fetch trampolines.
* Fix method_rgctx_array_size ().
With this change, `mono_post_native_crash_handler` chains the crashing signal directly, instead of that having to happen after `mono_handle_native_crash` returns (which created a fragile repetitive code pattern). Finally, this way `mono_post_native_crash_handler` can also re-raise the signal right after chaining it. Since we remove our crashing signal handlers in `mono_handle_native_crash`, this should allow the OS to handle the signal as the final action.
Fixes https://github.com/mono/mono/issues/19860
Register a JS callback when a work item is queued, the callback will call into the runtime/bcl to execute the work item.
Co-authored-by: vargaz <[email protected]>
Summary:
* wire `$(Compiler)` in `mono.proj`, that comes from `eng/build.sh`.
* add configurations for illumos cross-compilation.
* set `-Werror=strict-prototypes` for `madvise` and `posix_madvise` introspection, which is used during the compilation.
* implement `mono-threads-sunos.c`.
* add some solaris-specific thread priority levels.
With this set of changes, `dotnet hwapp.dll` works with mono flavored `System.Private.CoreLib.dll` and `libcoreclr.so` on SmartOS 2020.
Contributes to: dotnet/runtime#34944.
Co-authored-by: am11 <[email protected]>
* [interp] Allocate a single continous stack region
Makes things easier, slightly improving call perf, and enables us to statically know the exact offset of any local / instruction result. We allocate localloc sections separately for this reason.
* [interp] Add allocator for localloc sections
It mostly reuses the original stack fragment allocator. When allocating memory for an interp frame, we remember the original state of the allocator before we started allocating for this frame. When we finish executing the frame code and we pop back the stack, we do the same with this allocator, restoring the previous allocator state.
* [interp] Remove unreachable code that makes no sense
Probably, in ancient times, we had a separate InterpFrame that we were executing for pinvoke / icall methods.
* [interp] Add separate opcodes for returning from methods with localloc
Just to avoid the slight overhead of calls for the common scenario.
* [interp] Add separate memory accounting for interp stack
* [interp] Switch locals and execution stack order
The order before was execution stack, vtstack, locals. The order now is locals, vtstack, execution stack. The reason for this is that in the future we would like to access arguments as locals, so the args pushed by the caller will end up being locals in the new frame. Additionally, this enables us to further compact the stack use in the future since a new frame will be allocated immediately following the current stack top. This also provides a small reduction in call overhead.
* [interp] Add stricter assertions for debug build
* [interp] Don't inline vararg calls
They have some weird call semantics
* [interp] Fix failure to align vt result to the vt alignment
* [interp] Remove pointless check
We already know we have a managed pointer on the stack, since we have the constrained prefix. We were actually losing the STACK_TYPE_MP state when storing/loading from a local, which can only be MINT_TYPE_I, and could underflow the vtstack.
* [interp] Replace warnings with asserts
The mono version has an extra type argument since it uses copy functions which are type specific.
Also add an elementCount > 0 check to avoid icall overhead if possible.
Co-authored-by: vargaz <[email protected]>
We had frame->ip used by EH and debugger and frame->state.ip used to save the ip of the next instruction to be executed when we return from the call. Since both represent more or less the same thing, unify them and avoid duplicate storing inside InterpFrame for each call. Because we use this ip with exception handling, we need to subtract 1 (similar to the jit) so the ip ends up being in the call instruction and not the next.
* [wasm] Throw PlatformNotSupportedException instead of NotSupportedException when starting threads/waiting on monitors.
* Preseve PlatformNotSupportedException.
Fixes#7167
The PR 3e8108ea65 introduced a deadlock on Alpine, making it impossible to even build mono. This PR reverts the setting of PTHREAD_PRIO_INHERIT when on Alpine.
Since GCC on Alpine doesn't provide a builtin macro to detect Alpine, I also added a #define in configure.ac.
Fixes https://github.com/mono/mono/issues/16246
Contributes to https://github.com/mono/mono/issues/14788
The commits here should be reasonably chunked up, but a summary of what this accomplishes:
* Wires up OnResourceResolve
* Fixes our corlib satellite assembly check in netcore_load_reference (we were previously comparing "System.Private.Corelib" to "System.Private.Corelib.resources", which does not work)
* Adds some useful classes to mono_defaults
* Removes legacy events from MonoDomain and prevents calling them on netcore
* Fixes UnhandledException to call the correct event
* Wires up FirstChanceException
`AppDomainTests.AssemblyResolve_FirstChanceException` is now failing because of the exception type, so it should work once I sort out https://github.com/dotnet/runtime/issues/34030. Until then, keep it disabled.
Co-authored-by: CoffeeFlux <[email protected]>
* [mono] Move culture-info-tables.h to a separate directory
We'd like to remove culture-info-tables.h from the dotnet/runtime copy of mono since we use ICU
there for globalization like the rest of .NET 5.
The plan is:
1. We move the file (and some others) to a separate directory (this PR)
2. We tell the sync bot to skip `culture/` in the future
3. We delete the files (or make them empty) in dotnet/runtime
* Also move locale.c and culture-info.h
* Also move mono_w32process_ver_language_name
* [msvc] don't compile locales.c if it doesn't exist
It exists for now, but won't after we stop syncing culture/ to dotnet/runtime
The intrinsic expansions for Unsafe.ReadUnaligned and
Unsafe.WriteUnaligned now use mini_emit_memory_load and
mini_emit_memory_store.
stind is now implemented in terms of mini_emit_memory_store; when used
during compilation of the the sgen nursery check wrapper,
mini_emit_memory_store will no longer longer emit a release fence when
storing a reference under the CLR memory model.
mini_emit_memory_load and mini_emit_memory_store also no longer
decompose unaligned loads/stores to explicit byte-wise memcpy move
sequences; the LLVM IR backend already converts
MONO_INST_UNALIGNED-flagged OP_LOAD*/OP_STORE* operations to LLVM memory
movement operations with alignment 1.
Should fix https://github.com/mono/mono/issues/19142.
* [interp] Optimize do_jit_call ().
* Move the JIT call related fields to a separate JitCallInfo structure.
* Compute calling convention information and store it into JitCallInfo
to avoid most type processing at call time.
* Address review comments.
`libruntime-android.so` was just a random name I used for our test runner but since we need some name for `dlopen` (we can't use dlopen(NULL)) and to be shared between the test runner and Xamarin.Android let's switch to the XA name.
We could add an API for mono embedding to set desired name but 'm not sure if it's worth an effort now.
Co-authored-by: EgorBo <[email protected]>
Our normal custom attribute lookup method may trigger loading. This is undesirable during class initialization, for example. For this reason, we have `mono_class_metadata_foreach_custom_attr` that scans a class for custom attributes without triggering loading.
This PR adds `mono_method_metadata_foreach_custom_attr` that does the same thing - looks for custom attributes on methods without causing any loader activity.
This PR also reorganizes the code in `class-init.c` that uses these metadata custom attribute lookups to be a bit easier to use.
Finally we add a convenience method (unused so far) to look for `PreserveBaseOverridesAttribute` which is defined in dotnet/runtime#35315 and which will be necessary to implement covariant returns.
Co-authored-by: lambdageek <[email protected]>
* [interp] Remove saving of clause_args from interp state
clause_args can be set only from EH. This means that clause_args can be set only in the first executed frame, so there is no need to save it in the interp state. Also make sure we never check for it in the main_loop block, for normal calls and returns. Added exec_frame to the clause_args so we can detect whether a frame is the first frame invoked from EH. We can no longer use clause_args for this purpose because we no longer save it in the interp state.
* [interp] Remove error argument to interp_exec_method
We were doing this to avoid having a MonoError local in interp_exec_method, which is no longer relevant. Avoid reiniting the error with each interp call.
This PR checks in recent string marshaling work and enables a subset of tests that now run successfully. It's possible that this fixes or changes the failure on other tests, but I've only checked the StringMarshalling ones.
Status of string marshaling of this PR:
* AnsiBStr - tests pass
* BStr - tests pass
* LPStr - failure with StringBuilder
* LPTStr - immediate failure
* UTF8Str - crash with invalid malloc in StringBuilder code (??)
* LPWStr - no tests
* TBStr - no tests
Followup work:
- [ ] Fix UTF8 crash (probably corruption, the crash used to be in a free call)
- [ ] Clean up StringBuilder code (lots of issues, some caught by the tests, in progress)
- [ ] Add TBStr and LPWStr tests (in progress)
- [ ] Fix LPTStr to properly handle both ANSI and UTF16 text (or maybe change the test to align with our historical behavior? currently the test uses LPWStr on all platforms)
- [ ] Add a wall of text on string marshaling behavior for classic and netcore Mono at the start of `conv_to_icall`
Co-authored-by: CoffeeFlux <[email protected]>
This adds AppLocalIcu switch support on Mono. I also refactored GlobalizationMode to share the sources in between Mono and CoreCLR to avoid duplicating all the AppLocal and UseNls switches logic.
cc: @jkotas @thaystg @akoeplinger @tarekgh @ericstj
Co-authored-by: safern <[email protected]>
When returning from a method we used to save the return value into frame->retval. We would then have separate opcodes for normal and void call and, depending on the type of call, we would access the retval and push it on the stack. In case of valuetype returns, the value is not returned in the proper space so we have an additional MINT_VTRESULT that copies the return around in the caller frame. In addition to this we had retval, is_void locals, saved as part of the current frame state which just make things confusing and are not needed.
This commit simplifies the call procedure by completely moving the responsability of the return to the called method. Simply put, once a method is ready for the call, it will leave its stack and vtstack to the state after pop-ing the arguments. The called method will then directly push the result to the parent frame's stack/vtstack. This means the calling code doesn't care about the type of the return anymore, the IL instructions after the call will just expect the return on the stack, if any, and use it naturally.
We still make use of frame->retval for interp entry frames (since we don't have a parent frame to push to), for pinvoke and jit_call frames out of convenience, but we should consider removing this variable to further trim down InterpFrame.
Co-authored-by: BrzVlad <[email protected]>
`Xamarin.Android` native runtime calls `mono_reflection_type_from_name`
and passes `NULL` as the `image` parameter. The parameter is then
propagated all the way to `_mono_reflection_get_type_from_info` where,
in case the assembly isn't loaded yet, it is used to obtain base
directory of the assembly. However, since the `image` parameter is
`NULL` in our case, attempt to dereference it causes a segfault:
libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
/system/bin/tombstoned: received crash request for pid 11029
crash_dump64: performing dump of process 11029 (target tid = 11029)
DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
DEBUG : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
DEBUG : Revision: '0'
DEBUG : ABI: 'x86_64'
DEBUG : Timestamp: 2020-05-25 14:45:29+0200
DEBUG : pid: 11029, tid: 11029, name: ompanyname.app3 >>> com.companyname.app3 <<<
DEBUG : uid: 10134
DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
DEBUG : Cause: null pointer dereference
DEBUG : rax 000000000000002f rbx 0000000000000001 rcx 0000000000000000 rdx 0000000000000030
DEBUG : r8 0000000000000003 r9 000000000013e2e2 r10 0173eed800000000 r11 0000000000000206
DEBUG : r12 0000000000000000 r13 00007478530343c0 r14 00007478075eda33 r15 000074780763efb0
DEBUG : rdi 0000000000000000 rsi 00007478e2cb14d0
DEBUG : rbp 00007ffef3a35680 rsp 00007ffef3a355d0 rip 0000747807a4066a
DEBUG :
DEBUG : backtrace:
DEBUG : #00 pc 00000000003ba66a /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
DEBUG : #01 pc 00000000003ba3d1 /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
DEBUG : #02 pc 00000000003ba26d /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
DEBUG : #03 pc 000000000000ddb5 /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
DEBUG : #04 pc 000000000000def3 /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
DEBUG : #05 pc 0000000000069532 <anonymous:5ad25000>
Even though this happens in `Xamarin.Android`, the error may occur for
any embedding application which passes `NULL` for the `image` parameter
in situation when the assembly isn't in memory yet.
PR handling port of EventPipe C++ library from CoreCLR into a C library that can be shared between Mono as well as CoreCLR runtime.
Due to dependencies and current time line it has been decided to initially target Mono runtime (since it doesn't have event pipe functionality at the moment), but library is still designed to integrate into other runtimes, replacing current C++ library implementation, when time permits.
Until that happens, we will need to make sure changes done in C++ code base gets ported over to C library. The amount of changes going into the native library should however be small and if major changes needs to be done, we should first make sure to move over to use the shared version of event pipe C-library in CoreCLR and then only do changes into shared version of the library.
Port is currently mapping existing C++ code base, no focus on rewrite or change current implementation (unless needed to port code over to C).
Library source files are currently placed into mono/eventpipe folder and build as a separate library, linked into runtime, but will be moved when ready to be shared between runtimes. We might also move all code into a loadable library and p/invokes, depending on size, at least for Mono runtime targeting mobile devices.
There is also a unit test runner under mono/eventpipe/tests using eglib test runner, running through a set of unit tests covering the eventpipe library implementation.
Library is split up over a couple of source files closely mapping corresponding coreclr source files. Most code could be shared between runtimes and artifacts that are runtime specific, like locks/lists/maps/strings/pal layer etc, a shim API is defined in `ep-rt.h` and `ep-rt-types.h` that gets implemented by the targeted runtime consuming the event pipe C library, like `ep-rt-mono.h` and `ep-rt-types-mono.h`. All function in the shim API is small and should be inlinable. For example, locking the configuration lock is declared like this in `ep-rt.h`:
```
bool
ep_rt_config_aquire (void);
```
and in `ep-rt-mono.h` it is implemented like this:
```
static
inline
bool
ep_rt_config_aquire (void)
{
ep_rt_spin_lock_aquire (ep_rt_mono_config_lock_get ());
return true;
}
```
and CoreCLR should implement the function using its corresponding locking primitives. NOTE, since we primarily target Mono in initial port there might smaller adjustments needed to the shim API once bringing it over to CoreCLR, but those changes/adjustments can be done when needed.
Since library could be shared, it tries to standardize on common C99 data types when available. If there are runtime specific types needed, they are declared in `ep-rt-types.h` and implemented by each runtime in corresponding file. Most of library is currently following Mono coding guidelines.
For shared types naming is done like this, `EventPipe[Type]`, like `EventPipeProvider`. This naming follow naming of other types in Mono as well as CoreCLR. There is one exception to this rule, types that are runtime specific implementation, naming is following function naming with a _t prefix, like `ep_rt_session_provider_list_t`, that is a list specific type, implemented by each runtime. This is done to make it easier to see difference of types implemented in the runtime specific shim and types implemented in the shared library API surface.
Since library shim implemented by targeted runtime will be called by C code, it can't throw exceptions, the C library should however compile under C++, meaning that CoreCLR's shim should be able to use C++ constructions as long as it don't throw any exceptions.
Library function naming follows the following pattern, for "public" functions included in `ep-*.h` , ep_ + object + action, so for example, `ep_config_create_provider`, corresponds to `EventPipe::Configuration::CreateProvider` in C++ library. For "private/internal" functions not, ep_ prefix is dropped, but object + action is still preserved, for example `config_create_provider` and function is marked as being static when possible. If a function assumes a lock is held when getting called, it is using _lock_held (similar to SAL annotations) postfix to indicate that function doesn't claim lock and if function needs lock to be held by caller, it will assert that condition on enter (similar to `PRECONDITION(EventPipe::IsLockOwnedByCurrentThread())`).
Library uses asserts internally to validate state and conditions. This is a debug/checked build assert that should be excluded in release builds. It is defined in `EP_ASSERT` and should be redefined by targeted runtime. Private/internal functions asserts incorrect input parameters and state, while "public" functions return back error to caller when detecting incorrect input parameters. Incorrect state can still be assert in all kinds of functions.
Getters/Setters are setup for accessing type members. All functions except a type's own alloc/init/fini/free implemented in `ep-*.c` are not allowed to use direct type member access and should go through available inlinable getter/setter functions. There is also a way to build the library that catches incorrect use of members at compile time (not in `ep-*-internals.c` since it include alloc/init/fini/free implementations, but in other source files).
Types that can be stack allocated offers a init/fini function pairs. Types that should only be heap allocated, alloc/free, and types supporting both stack/heap, implements alloc/init/fini/free. Since C can't prevent incorrect usage patterns, the implementation needs to follow correct life time management patterns. Types allocated using alloc should be freed with corresponding free function. For example, `ep_event_alloc` should be freed by `ep_event_free`, the init/fini methods are then called by the alloc/free implementations. For types supporting stack allocation and allocated on stack or aggregated within other types, init must be called before first use and fini before going out of scope.
Ownership of allocated objects is only considered complete on successful function calls. If a function fails, caller still owns resource and need to take actions.
Library uses UTF8 strings internally, mainly since Mono runtime already uses that and it is more portable. Number of strings in the library is limited, and in cases where stream protocol uses UTF16 strings, a prealloc string is stored on the type, reducing need to do multiple UTF8 -> UTF16 conversions over the lifetime of the type.
NOTE, this is first PR setting up most of the direction of the library and (as part of doing that) ported a great deal of eventpipe code and added ~40 native unittests. It is however not complete, or fully working, so there will be several follow up PR's building on top of this work in order to get complete library. Next component to integrate into the library, once this PR is merged, is BufferManager.
* [jit] Return the compiled method and an unbox trampoline from ldvirtftn when calling ldvirtftn on a valuetype method.
Fixes https://github.com/dotnet/runtime/issues/34379.
* [runtime] Add some caching to mono_aot_get_unbox_trampoline (). Register unwind info for trampolines.
* Add a 'method' field to MonoTrampInfo to be used by unbox trampolines.
* Refactor delegate initialization code.
Also handle unbox trampolines during the addr->method lookup.
* Merge mono_delegate_ctor () and mono_delegate_ctor_with_method ().
* Move the actual logic to mini_init_delegate ().
* Remove callbacks.create_jump_trampoline, its not used any more.
* Fix the build.
* Remove an interpreter workaround.
* Avoid leaking the amodule->unbox_tramp_per_method array.
* [wasm][debugger][tests] Move the test files to `tests/debugger`
- Also, rename `class Math` to `class SampleMath` in `sample.cs`,
to allow building sample.dll, with all the tests added.
(cherry picked from commit dc265710139d7c3a63f714e4b19bdb60014b5bcb)
* [wasm][debugger][tests] Add back missing dependency
(cherry picked from commit 2bc6482bb3049b34da918e2dc91df459774873c9)
* [wasm][debugger][tests] move *datetime-test.cs to `tests/debugger`
(cherry picked from commit 2b43270a42a599fe2bdb460018460e32571bbc79)
* [wasm][debugger][tests] Move CFO test to debugger-cfo-test.cs
(cherry picked from commit aba95ffddad94a613a9a12eaf0dddcc9dd661b58)
* [wasm][debugger] Allow invoking property getters for objects
- These can be invoked interactively by the user from the IDE/chrome
debugger
- Getters on valuetypes are not supported right now
* [wasm][debugger] Fix warnings
* [wasm][debugger][tests] Fix DateTimeLocale test to await getting
.. properties for a DateTime object. Required after rebasing on master.
Unity has a pdb with zero sequence points somehow. If a user added a reference to the library and then attempted to set a managed breakpoint mono would hit an assert and crash when it would attempt to decode this pdb.
Call stack would look like:
```
> mono-2.0-boehm.dll!mono_ppdb_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 508 C
mono-2.0-boehm.dll!mono_debug_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 1093 C
mono-2.0-boehm.dll!get_source_files_for_type(_MonoClass * klass) Line 6920 C
mono-2.0-boehm.dll!get_types_for_source_file(void * key, void * value, void * user_data) Line 7003 C
mono-2.0-boehm.dll!monoeg_g_hash_table_foreach(_GHashTable * hash, void(*)(void *, void *, void *) func, void * user_data) Line 364 C
mono-2.0-boehm.dll!mono_de_foreach_domain(void(*)(void *, void *, void *) func, void * user_data) Line 95 C
mono-2.0-boehm.dll!vm_commands(int command, int id, unsigned char * p, unsigned char * end, Buffer * buf) Line 7341 C
mono-2.0-boehm.dll!debugger_thread(void * arg) Line 10323 C
mono-2.0-boehm.dll!start_wrapper_internal(StartInfo * start_info, unsigned __int64 * stack_ptr) Line 1241 C
mono-2.0-boehm.dll!start_wrapper(void * data) Line 1315 C
kernel32.dll!00007ffc12017bd4() Unknown
ntdll.dll!00007ffc121ece51() Unknown
```
Adding a check to ignore pdbs like this prevents the crash and debugging can continue normally.
Related unity issue: https://issuetracker.unity3d.com/issues/macos-editor-crashes-on-mono-log-write-logfile-when-attaching-a-debugger-and-then-setting-a-breakpoint
The linker was removing the icu shim functions even exporting them. The unique solution that we found until now is to force the linking using the -u flag.
This is a temporary fix until we don't implement QCalls.
Fixes https://github.com/dotnet/runtime/issues/36685
Co-authored-by: thaystg <[email protected]>
* [interp] Add separate opcode for pop vt
Before this change, pop-ing a vt from the stack was done in 2 opcodes, a MINT_POP (decrementing the stack) and the weird MINT_VTRESULT (decrementing the vtstack). However, optimizations could have removed both the initial loading of the value type on the stack as well as the MINT_POP, leaving MINT_VTRESULT underflowing the vtstack. Fix this and cleanup the code by pop-ing a value type from the stack in a single instruction.
* [interp] Re-enable optimizing away loading of unused value type on the stack
* [interp] Refactor calli code
Previous code was very confusing.
* [interp] Extract string creation into separate opcode
For speed and simplification of code.
* [wasm][debugger] Reduce debugger-tests timeout to 40m
- And run that before the system tests since the debugger is more likely
to fail at this point.
Based on @lewing's suggestion
* [wasm][tests] Allow overriding which browser to use
.. via the envvar `WASM_TESTS_ChromePath`.
This can also be set in an `appsettings.json` file next to the test
binaries, like:
```
{ "ChromePath": "</path/to/chrome/binary>" }
```
Also, prefer stable Chrome over Canary.
Co-authored by @lewing
The only call site of RuntimeThread.InitializeThreadPoolThread() is in
ThreadPoolCallbackWrapper, and it needs to return a valid RuntimeThread
reference to prevent a NullReferenceException later on. So return
`new RuntimeThread (null)` instead of a null reference.
This fixes a wine-mono crash I have encountered in "ZUSI 3 - Aerosoft
Edition" (in ZusiDisplay), and it might fix mono bug #17994.
* [interp] Don't share interp_in signatures for different valuetypes
We share interp_in wrappers for different types of signatures if the corresponding params are equivalent. This was added in https://github.com/mono/mono/commit/5cbe93884798684efbb81abd79e0e2a170544b75. This was reusing some sharing mechanism used by gsharedvt. Those wrappers are shared with regard to managed->managed transitions so it takes additional freedoms, converting all valuetypes to ValueTuples instances. These can end up being marshalled differently from the initial struct so we can't use this valuetype sharing infrastructure in the interp_in_wrappers which can operate on native structs.
Fixes test_0_marshal_struct_delegate from pinvoke3.cs
* [interp] Keep sharing interp_in signatures with VT if not pinvoke
As suggested by zoltan
Fixes https://github.com/dotnet/runtime/issues/35908
This adds a new function `mono_native_thread_main_thread_known` which returns `TRUE` when the `MonoNativeThreadId` (`pthread_t` on Linux) of the main thread is known. On Linux the main thread is the one where `gettid () == getpid ()`. There are two complications:
1. `pthread_t` and `pid_t` are distinct tokens, so knowing the `pid_t` ("os id" in Mono) of the main thread doesn't tell us its `pthread_t` (`MonoNativeThreadId`)
2. In an embedding scenario, the main thread may never interact with Mono (for example all the calls to `mono_jit_init`, etc might be happening on a helper thread).
So the solution is to augment `register_thread` (responsible for initializing a `MonoThreadInfo`) to check for `getpid () == gettid()` and to save `pthread_self()` as the "main thread" when it becomes available.
Co-authored-by: lambdageek <[email protected]>
* [wasm][debugger] Clear valuetypes cache on Debugger.resume
- This fixes:
1. Check valuetype properties
2. Debugger.resume, over some code that updates that valuetype
3. That valuetype's properties show older values
* [wasm][debugger] Send mono_wasm_debugger_resume only if stopped on
.. a managed frame.
* Removing some asserts and returning err_invalid_argument with an error message when it's possible.
* if we don't find method get_ObjectIdForDebugger we try to find the property Task to continue async debug.
```
/Users/alexander/dev/runtime/src/mono/mono/mini/aot-runtime.c:5647:13: warning: unused variable 'image' [-Wunused-variable]
```
```
/Users/alexander/dev/runtime/src/mono/mono/mini/simd-intrinsics-netcore.c:11:1: warning: no previous prototype for function 'mono_simd_intrinsics_init' [-Wmissing-prototypes]
```
```
/Users/alexander/dev/runtime/src/mono/mono/utils/mono-state.c:1230:1: warning: no previous prototype for function 'mono_crash_save_failfast_msg' [-Wmissing-prototypes]
/Users/alexander/dev/runtime/src/mono/mono/utils/mono-state.c:1236:1: warning: no previous prototype for function 'mono_crash_get_failfast_msg' [-Wmissing-prototypes]
```
Co-authored-by: akoeplinger <[email protected]>
* [wasm][debugger][tests] Rework SetBreakpointInMethod, to get the
.. location info from the proxy, and then use `setBreakpointByUrl` to
set the breakpoint.
* [wasm][debugger] Bump timeout for debugger tests, since we are not running
.. tests in parallel now.
The llvm.x86.sse41.pmuldq intrinsic is no longer available as of
https://github.com/dotnet/llvm-project/commit/254ed028a4bd4fa81d0049d90e6ab23d704dd366.
This also adds a convenience wrapper for creating constant LLVM IR
vectors, up to 16 elements long, of arbitrary integral type.
Finally, fix a latent bug in init_function_pass_manager;
llvm::StringRef::size returns a value of type size_t, but the printf
precision specifier requires a value of type int.
Co-authored-by: imhameed <[email protected]>
When outputting DWARF code to start a compilation unit in .debug_info, the standard expect a 4-byte offset from the .debug_abbrev code. Mono has always output an offset of 0.
However, this doesn't work in every cases. When we have linux+fullaot, we link two object files (one from Mono, one from LLVM). Both have their .debug_abbrev section. If we use 0 as an offset, it seems possible that the linker will keep thinking that our offset is 0, no matter the circumstances. Since the offset is always 0, it can be using the wrong abbreviation table (i.e. the one from the LLVM assembly instead of the one from the Mono assembly). The consequence of this is that the linked file is not valid DWARF (dwarfdump and objdump will complain about invalid offsets). At best, some tools will be able to work with a part of what we have, but any program requiring entirely valid DWARF will fail.
To fix this, we generate a label for the start of our debug_abbrev section and we instead generate it by generating a long with that label. This matches existing behavior seen in the LLVM generated code, and makes dwarfdump and objdump react properly to the linked product.
Fixes https://github.com/mono/mono/issues/8806
* [interp] Disable fullaotmixed suite on x86
* [interp] Small cleanup of disabled tests
Enable a bunch of tests on arm (which I thought I enabled 2 years ago). Avoid duplication by moving some arch specific disabled tests to all platforms. Enable a few tests that seem to have been fixed in the meantime.
* [interp] Aling data to 8 bytes
On x86 linux, double doesn't guarantee 8 byte alignment, which we need since all objects on the vt stack need to be 8 byte aligned. Use padding instead to achieve this.
* [interp] Add x86 support
This mainly consists of a trampoline that is used when calling from interp into native code, as well as the call convention logic that initializes the CallContext structure (which is passed to the trampoline). On other platforms we also have a single trampoline used when entering interpreter code. That trampoline works in a similar way and its purpose is to avoid compilation of all possible interp entry signatures, which is problematic on full aot scenarios. Given the interp x86 support is currently provided for android, we can avoid using that trampoline for now and use the per signature jit compiled interp_in_wrappers instead.
The few disabled interp tests are the same as on amd64.
We only support pinvoke into cdecl functions.
* [wasm][debugger] Only send resolved events on load
* Add the request to the context after potentially loading the store
* improve the resolution logic
* Disable per-collection parallelism in debugger tests because moving tests out into more classes has created more collections, causing test failures
* Fix typo
* [master] Bump msbuild to track xplat-master
* [master] Bump msbuild to track xplat-master
* Update nuget.exe to 5.6.0-preview3
- closest version that I could find, to the one in msbuild (`5.7.0-preview.1.6592`)
In get_call_info, IS_HARD_FLOAT is checked to switch between using the FP registers and the GP registers. This was not done in arg_get_storage, which was always using the hard float registers. This would mean parameters to the native trampoline wouldn't get copied correctly, and return values would be incorrect as well.
I can't find a way to add this to tests, since no softfp test systems seem to be built. I'm working on testing the use cases I can think of on my softfp system just to be sure.
Any assignments to type RegTypeHFA were locked behind a IS_HARD_FLOAT check as well, so I think its safe to modify that case too.
Fixes#14591
* [wasm][debugger][tests] add tests for multiple breakpoints
* [wasm][debugger][tests] Update CheckBreakpoint with more descriptive name and use CheckLocation
* [wasm][debugger][tests] More descriptive test name
* [wasm][debugger][tests] Combine two tests in one using [Theory]
Co-authored-by: tqiu8 <[email protected]>
* Add soft debugger support to s390x
- Implement the sdb trampoline
- Big-endian fixes for ppdb debugger:
- Fix utf16 strings
- Fix decoding of ImageDebugDirectory structures
- New implementation of OP_SEQ_POINT
- Enable successful unwind by defining markpoints
- Implement mono_arch_setup_resume_sighandler_ctx
- Implement unwind ops in epilog
* Fix delegate-invoke processing
- Handle up to 10 parameters
- Use sigparam information to correctly "slide" parameters
* Fix floating point negative zero for s390x
- Add a new instruction for use in OP_RxCONST -0
- Check for -0 in constant
* Minor indentation fixes
* Fix atomic add implementation
* Check for additional hardware facilities
We can't have GLib types in public headers. Oops.
There is potentially still an issue with `mono_alc_get_default_gchandle` not being exported, but that can wait for later.
cc: @garuma
Co-authored-by: CoffeeFlux <[email protected]>
Wasm has control flow limitations which don't go well with gotos. Move label outside of main loop because it translates to very poor wasm code. Other gotos don't seem to negatively impact instruction dispatch code, so leave them alone, for now ..
Co-authored-by: BrzVlad <[email protected]>
* [wasm] Integrate the m2n-gen.cs tool into mcs/tools/wasm-tuner.
It should be ran as:
mono wasm-tuner.exe --gen-interp-to-native <output file name> <extra assemblies>.
The <extra assemblies> will be searched for pinvoke methods, and their signatures
will be added to the set of supported signatures.
* [csproj] Update project files
Co-authored-by: monojenkins <[email protected]>
Fixed#10435
HttpListener already closes the Response object, closes the HTTP Client connection, and then sets the value of Response.StatusCode again. If so, an ObjectDisposedException is thrown.
```
Unhandled Exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
at System.Net.HttpListenerResponse.set_ContentLength64 (System.Int64 value) [0x00013] in <b4473693dd3c4d45883c574a53529fbe>:0
at MonoConsoleApp1.Program.Main (System.String[] args) [0x000f8] in <a66f6d7d417445dc9f89c691941ca70b>:0
at MonoConsoleApp1.Program.<Main> (System.String[] args) [0x0000c] in <a66f6d7d417445dc9f89c691941ca70b>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
at System.Net.HttpListenerResponse.set_ContentLength64 (System.Int64 value) [0x00013] in <b4473693dd3c4d45883c574a53529fbe>:0
at MonoConsoleApp1.Program.Main (System.String[] args) [0x000f8] in <a66f6d7d417445dc9f89c691941ca70b>:0
at MonoConsoleApp1.Program.<Main> (System.String[] args) [0x0000c] in <a66f6d7d417445dc9f89c691941ca70b>:0
```
If an error is sent to the HTTP client while processing a request, it is patched so that the next process is not executed anymore.
* [wasm][debugger][tests] Move helper methods to base class
* [wasm][debugger][tests] Extract EvaluateOnCallFrame tests to new file
* [wasm][debugger][tests] Extract Array tests to a new file
* [wasm][debugger][tests] Extract CallFunctionOn tests to a new file
* [wasm][debugger][tests] Extract Delegate tests to a new file
* [wasm][debugger] Don't inherit from another test class
.. as that ends up running all the tests of the base class too.
* [wasm][debugger][tests] Improve retries in TestHarnessStartup
Sometimes `/json/list` seems to return an empty array (`[ ]`). Treat
that also as a case for retry.
* [wasm][debugger][tests] Bump timeout from 2s to 5s
* [wasm][debugger][tests] Launch chrome in incognito mode
* debugging
* [wasm][debugger] TestHarnessStartup - don't share `ProcessStartInfo`
.. instances. Instead, create one for every use.
We seem to run into cases where the `get_Environment` is modifying it's
`_environmentVariables` field, concurrently from multiple threads,
causing exceptions like:
```
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Diagnostics.Process.CreateEnvp(ProcessStartInfo psi)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at WebAssembly.Net.Debugging.TestHarnessStartup.LaunchAndServe(ProcessStartInfo psi, HttpContext context, Func`2 extract_conn_url) in /Users/radical/dev/w1/sdks/wasm/ProxyDriver/TestHarnessStartup.cs:line 82
at WebAssembly.Net.Debugging.TestHarnessStartup.<>c__DisplayClass10_0.<<Configure>b__1>d.MoveNext() in /Users/radical/dev/w1/sdks/wasm/ProxyDriver/TestHarnessStartup.cs:line 167
```
* [wasm][debugger] Fix regression in debug.html
Fixes https://github.com/mono/mono/issues/19653 .
Consider the following IL code pattern:
```
stloc.np 0
dup
stloc 1
```
When `stloc 1` instruction is processed, we know we have local 0 on the top of the stack so we can replace `dup/stloc` with `movloc 0 -> 1`. However, we need to make sure that the refcount for local 0 is increased so we don't prematurely kill instructions that store into this local (the `stloc.np` from above). This is needed because we remove a dependency from the stack but add one from the locals. If the local 0 would have been explicitly pushed with a ldloc, the refcount is updated when we handle the ldloc, and no other updates are necessary.
Co-authored-by: BrzVlad <[email protected]>
* Fixes to s390x ABI to support roslyn
- Add new instructions
- Fix outarg_vt processing
- Add new hardware capabilities check
- Add mono_trace_tail_method() to properly support traceing of tail events
* Further s390x enhancements:
- Support altstack
- Rework localloc
- Fix tail processing
-- Restoration of registers dependent on paramater use and RGCTX
-- Restoration of FP registers
* Reset the debug flag to FALSE
* Fix tabbing etc. to conform with standard
When a new thread is attached to the VM, the debugger will add it to the
`thread_to_tls` hash table. When that thread detaches, it will be
removed. Once the thread is attached, if a client is debugging, the
client can use the `CMD_THREAD_GET_FRAME_INFO` command to ask for
details about that thread.
This is a possibility that the thread detaches before the
`CMD_THREAD_GET_FRAME_INFO` command is processed, so the thread may not
exist the the `thread_to_tls` hash table any more.
This is a race condition, but is a valid state, so instead of asserting,
the debugger agent should indicate to the client that the thread no
longer exists, using `ERR_UNLOADED`.
Prevents NullReferenceException in SurrogateProviderAdapter which occurred when SurrogateProviderAdapter is constructed with a null ISerializationSurrogateProvider instance, which results in NullReferenceException in GetDataContractType, GetDeserializedObject and GetObjectToSerialize.
Also formatting fixes to the unstable header.
We can just return the stored GCHandle for the default ALC because it's both strong and should never change.
cc: @garuma
Co-authored-by: CoffeeFlux <[email protected]>
When ListView.VirtualMode = true GetItemAt should not access items collection directly to
get bounds of ListViewItem. Otherwise, method OnRetrieveVirtualItem will be called.
Which costs a lot of time.
During json serialization, if the key was an enum type, then it would fail trying to cast into an XmlDictionaryString.
The fix is to treat the enum value like a string.
I've adopted the v2 convention instead of attempting a more descriptive name, with the hope that it makes iteration easier in the future and simplifies opt-in obsoletion.
cc: @vargaz @garuma
Co-authored-by: CoffeeFlux <[email protected]>
On all platforms, OP_TAILCALL copies the arguments (that are passed on the stack) from the param area in the current frame, to the param area in the caller frame, meaning that it expects the arguments to be passed normally on the stack. However, on amd64, mono_arch_emit_call was storing these arguments directly in the param area of the caller (EMIT_NEW_ARGSTORE), instead of the param area of the current frame. OP_TAILCALL would then override the already set stack parameters with random data from the uninitialized param area of the current frame.
Fixes https://github.com/dotnet/runtime/issues/34376
Co-authored-by: BrzVlad <[email protected]>
* [wasm][debugger] `mono_wasm_call_function_on` - remove unncessary
.. parameter, since it is already present in the `args` object.
* [wasm] MonoProxy - convert cfo calls to MonoCommands
* [wasm][debugger] Fix enumerating `this` properties for a valuetype
* [wasm][debugger] `evaluateOnCallFrame` - fix `this` for valuetypes
* [wasm][debugger] Remove MonoCommands no longer used
* [wasm][debugger] Fix showing the name for generic methods
- We were using `method.Name` from Cecil, but that we want to the name
with the type arguments for the generic instance.
* [wasm][debugger] send failed evaluations to the browser
Make sure that we allways either send a single result or return
false from Accept Command to ensure that we don't leave
messages spinning.
* [wasm] Reenable the managed collation code, link it out by default, add a packager option to enable it.
* Disable some xunit tests which fail because the test runner can't handle the [SkipOnTargetFramework(TargetFrameworkMonikers.Mono)] attribute.
* [csproj] Update project files
Co-authored-by: monojenkins <[email protected]>
- This was prompted by vscode/vs requiring this for array expansion.
- It runs a given js function string, on a given object id.
- We handle the case for dotnet object ids.
Implementation:
- We build a proxy object that reflects the details of the real dotnet object/array
- And run the js function on that proxy object
- Then if `returnByValue` was requested, the result is returned as-is
- Else we cache that object, with a new special object id (`dotnet:cfo_res:..`),
and return that id in the response.
- Subsequently, we would get `Runtime.getProperties` request on this new object id
- And a `Runtime.releaseObject` request, to free that function result.
- All this is handled currently
Tests:
- A few tests were added which invoke `callFunctionOn`, on JS objects, and checks the result
- And the same checks are performed on equivalent dotnet objects, with the same js function
- This should help stay in sync with what we think `callFunctionOn` should work as
- These tests have an additional parameter - `roundtrip`, which calls a simple function
`function () { return this; }`
.. on a dotnet object, and gets the result object id. If `roundtrip == true`, then it
runs that same function on the result object, and gets a new result object id. And the
tests run their checks on that.
- this helps to check that outside of the proxy, the result object behaves same as any
other dotnet object.
- Also, most of the tests were modified to support an additional mode (`use_cfo`).
- With this, whenever a test wants to run `Runtime.getProperties on an object, we pass that
object through the earlier "identity" function, and then run `getProperties` on that
resultant object.
- This helps to take advantage most of the existing tests, and use them for `callFunctionOn`
testing too, by ensuring that the results of CFO returns results same as any other object.
Fixes#19229Fixes#19531
Helps fix issue: https://issuetracker.unity3d.com/issues/unity-crashes-when-opening-the-project
We were hitting a crash were a corrupted dll would get loaded and then hit an assert later on when something tried to use it. The verifier suite would correctly identify the dll as corrupt but it was impossible to turn on just the PE verification. I've added a new PE only mode above "off" to allow for just the PE verifier to be used instead of the larger verification suite.
* [mono] Fix multidimensional array construction when using programmer-specified lower bounds.
mono_array_full_new_checked and mono_array_full_new (which is marked as
a MONO_API function) both take two pointers to buffers containing
lengths and lower bounds. mono_array_new_n_icall can split the incoming
parameter list in two before forwarding the results to
mono_array_full_new_checked, so mono_array_full_new_checked was
receiving two buffers containing interleaved lower bounds and lengths.
ECMA-335 states that array constructors that specify both lower bounds
and lengths interleave these values. Deinterleave these
in method_to_ir.
Add some tests to iltests.il that verify that multidimensional arrays
with custom lower bounds work.
Fixes https://github.com/dotnet/runtime/issues/34377.
Fixes https://github.com/dotnet/runtime/issues/34378.
Fixes https://github.com/dotnet/runtime/issues/34381.
* Deinterleave lower bounds and array lengths in the interpreter.
Also make the condition in which the deinterleaving code path is taken
more precise. Perhaps this branch should be marked as unlikely.
* Fix a typo.
After talking with @lambdageek , we decided we wanted the public API for ALCs to just use gchandles instead of a native struct and to handle conversion within the runtime.
This PR takes that approach, exposing the managed ALC fields to the runtime for cheap conversion and adding `mono_assembly_load_full_alc` and preload hook V3 to the unstable headers.
I considered trying to do something fancier with conversion for the preload hook but decided against it in the end; making a V3 that's intended for embedder usage is straightforward and should work fine. When invoking it, we create a new strong gchandle to keep the managed ALC pinned and then free it after the call is done.
I went with `MonoManagedAssemblyLoadContext` instead of `MonoReflectionAssemblyLoadContext` since ALCs aren't really part of reflection, but I have no strong attachment to the name and can change it if preferred to maintain consistency.
cc: @vargaz @mdh1418 @garuma
Co-authored-by: CoffeeFlux <[email protected]>
* [wasm][debugger] Simplify the interface between debugger.c and
.. library_mono.js .
* [wasm][debugger] Show pointer type+address
* [wasm][debugger] Address review feedback
* [wasm][debugger] Small cleanups, from review feedback
* [wasm][debugger] declare mono_wasm_add_typed_value as extern
* [wasm][debugger] Show signature for delegate, or target, if available (#19505)
* [wasm][debugger] Show signature for delegate, or target, if available
- As object properties, we return a `Target` which has the signature of
the delegate target.
Fixes https://github.com/mono/mono/issues/19382
* [wasm][debugger] Some tidying up
* [wasm][debugger] Remove unused `sig_desc`
* [wasm][debugger] Simplify code, avoid extra allocations
.. as suggested by @lewing
(cherry picked from commit 4eca12e794)
* [wasm][debugger] Fix tests broken because unused vars are not null
.. anymore, which is because we disabled optimizations in the
interpreter when debugging.
* [wasm][debugger][tests] Add tests to also check delegates in previous
.. frames.
* [wasm][debugger] Disable a test that tried to look at previous async
.. frames. This just happened to work. Currently, the trace has details
of the async machinery, instead of one reflecting what it might have
looked like for a non-async case. So, we can't reliably find the
previous method to inspect it's locals.
* [wasm][debugger] Fix test
These opcodes have the same effect as their non-_un_ counterpart, since floats are always signed. This means that applying a fconv.ovf.i8.un to a negative float, will result in a negative integer, despite the unsigned suffix (tested against coreclr).
Fixes https://github.com/dotnet/runtime/issues/34084
Co-authored-by: BrzVlad <[email protected]>
With embedded pdbs we have to try to load symbols even when the
pdb is missing then handle ArgumentException if there is no embedded
pdb. This restores the intended error path and added an explanation
while still logging unexpected errors
* [wasm][debugger] Rework source loading
Add logic to support embedded sources and
add all the documents from multi-doc methods
Add logic to check source hashes against
pdb hash.
* [wasm][debugger] Fix breakpoints on delegates
Only add methods to a source once by RID
When column is != 0 specified the fronted only wants results
that match that column exactly.
* Allow checking pdb hash and remove source cache
* Fixup typesByName merge
Remove the assert because we don't need to stop the debug if we cannot create the object when calling the constructor using invoke_method, if it's a DebuggerTypeProxy, we are not able to show the value of the DebuggerTypeProxy, but we still can show the Raw View, if it's not the case of DebuggerTypeProxy, we just cannot evaluate this expression, but we can continue the debug session.
Fix#19492
* Disable the Loaded: messages, they are not very useful.
* Add a Dotnet-test.setBreakpointByMethod protocol extensions to the proxy to set breakpoints in specific methods during testing.
* Add a new sample debugger test using the setBreakpointByMethod API.
* Remove some unrelated changes.
* Restore logging.
* Disable a log message which is printed when a pdb file is missing.
Fix class loader to identify when the class has a field overlapped by a non-object field.
Fix method-to-ir to forward the TypeLoad error.
Fix transform to forward the TypeLoad error.
Fix unit test that has a class with a field that is overlapped by a non-object field.
Fixesdotnet/runtime#34388
According to ECMA, VES should add the following methods to arrays:
* A constructor that takes a sequence of int32 arguments, one for
each dimension of the array, that specify the number of elements
in each dimension beginning with the first dimension. A lower bound
of zero is assumed.
* A constructor that takes twice as many int32 arguments as there are dimensions
of the array. These arguments occur in pairs—one pair per dimension—with
the first argument of each pair specifying the lower bound for that
dimension, and the second argument specifying the total number of elements
in that dimension.
* Get.
* Set.
* Address.
In Mono's case we only added the ctor (int32, int32) for rank 1 arrays
if they were "jagged" array. Array with rank 1-4 executed an optimized
code path always using the one int32 per rank constructor.
This doesn't work in cases where the array is constructed using both
a length and a lower bound pattern, like:
newobj instance void int32[10000...10005]::.ctor(int32, int32)
this would trigger a method not found exception, since its not a jagged
array, Mono wouldn't add the ctor(int32, int32) constructor for this type.
Fix will make sure we follow ECMA's definition of this and fix code
to use right instance methods of arrays. Code also adds an assert
to trap if a jagged array is created through this code path
(shouldn't happen) since current implementation would have handled it as
a 2 ranked array.
Fix also adds several tests into iltests.il allocating different
variations of arrays using lower/upper bounds and validating length, rank,
upper/lower bounds of allocated arrays.
* [wasm] Remove netcore build support from builds/wasm.mk, its not used anymore.
* [wasm] Fix netcore support.
Currently, only local development with a separate dotnet/runtime repo works. The mono runtime, corelib, and the bcl will be taken from that repo.
AOT doesn't work.
* Fix running xunit tests.
* Fix some tests.
* Revert some unrelated changes.
* Fix infrequent/random crashes on Windows x64 due to use of GC forwarded objects.
Hard to repro and very infrequent crash. Have been analyzing a couple
of crash dumps from retail devices getting different crashes related to
vtable "corruption" on Windows x64. After some deeper analysis it turns
out the object instance has been forwarded by GC
(object vtable pointers lowest bit set to 1), but object still holds
tagged vtable. This will then cause misaligned reads, getting back random
values and pointers from vtable on next object access.
After some further analyzing it turns out that LLVM codegen and some
specific generic vt arrays lowering can cause optimized mem copies
using XMM registers. I have also identified scenarios where vt copies
gets lowered into a c-runtime memcpy that in turn uses XMM registers
as an optimization. Since Windows x64 currently don't include XMM
registers in context, any references in XMM registers will not be
visible and pinned by GC, meaning that they will point to potentially
forwarded objects after completing GC, restarting threads, leading
to these infrequent random crashes.
Fix includes xmm0-xmm15 into MonoContext on Windows x64, making sure
GC will see all references that could be held in those registers,
regardless if getting into those registers due to LLVM optimization
or other native code, like memcpy.
* [wasm][debugger] Fix up `value.description` for local vars too
- Local vars, when being enumerated in `mono_wasm_get_variables` don't
have an associated `name`, and so `_fixup_name_value_objects`
*incorrectly* ends up not fixing up the `value.description` field for
them.
* [wasm][debugger] For some types, use `ToString()` for their ..
.. `description`.
- `System.DateTime`
- `System.DateTimeOffset`
- `System.Decimal`
- `System.TimeSpan`
- `System.Guid`
* [wasm][debugger] Invoke all property getters, for some types
- `System.DateTime`
- `System.DateTimeOffset`
- `System.TimeSpan`
* [wasm][debugger] Show char symbol along with the code
Fixes https://github.com/mono/mono/issues/19381
* [wasm][debugger] Fix DateTime tests, don't use hardcoded strings for
.. description. Instead, use a `DateTime` object in the test to create
the expected string for the test. This should ensure that the expected
and actual were created in the same environment.
* [wasm][debugger] Special case `System.Guid` to use
.. `mono_guid_to_string`, instead of calling `ToString()` on it.
* [wasm][debugger] Don't box valuetypes for calling `ToString()`
Co-authored by @vargaz .
* [wasm][debugger] `System.Guid` is special-cased, so remove it from the
.. allowed list.
* [wasm][debugger] simple cleanup
* [wasm][bcl] Handle correctly backslash in file name
- Modify IO file to assign backslash to alternate directory separator by default
- Add tests for issue https://github.com/mono/mono/issues/18933
* [wasm][tests] Skip two tests for wasm
- After internal discussions decided to skip these two tests on wasm
1. GetDirectories_Backslash
1. GetFiles_Backslash
* [wasm][tests] PathIsRooted tests failing
- skip subtest #9 if WASM
- To fix issue https://github.com/mono/mono/issues/18933 we set the AltDirectorySeparatorChar as well. This causes the `Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");` to fail. Path.IsPathFullyQualified Method handles paths that use both the DirectorySeparatorChar and the AltDirectorySeparatorChar characters.
* [wasm][tests] PathIsRooted tests failing
- skip if WASM
* [wasm][debugging] pass enable_debugging as debug engine log level
enable_debugging was already an int, with this change log_level
will remain at 1 by default but passing -1 will disable the log
spew
* Change the default debug level of 'Failed to lookup sequence point'
* Add BeginRead/BeginWrite/EndRead/EndWrite overloads back to SslStream and underlying implementation. Unlike the default implementation in Stream it allows parallel read along with parallel write using the standard TaskToApm pattern (https://github.com/dotnet/runtime/issues/33447). This reverts part of https://github.com/mono/mono/pull/17393 which could lead to deadlocks as reported in https://github.com/mono/mono/issues/18865.
* Move the TaskToApm pattern from MobileAuthenticatedStream to SslStream
* Bump API snapshot submodule
Co-authored-by: monojenkins <[email protected]>
MeasureCharacterRanges handles the alignment correctly by itself.
This may have been to handle poor behaviour in libgdiplus, particularly
when Pango text layout was not default.
1. Fix the height calculated by Line.RecalculatePasswordLine(). Would
have been roughly double what it should have been - line spacing
includes the height of the line.
2. In RichTextBox, insert a character for the Quote special character
tags rather than just printing a message on the console.
3. In TextControl Document.Draw(), fix the criteria for skipping the
last line. Could probably be improve further, but the previous had a
problem because it could check with a point well off the bottom of
the second to last line instead of its bottom. This probably arose
because I had used line.Height for just the height of the text in the
line, and later decided that it should be the entire height including
all spacing, and added line.TextHeight. The earlier behaviour would
have been wrong too, because it would have pointed to the bottom of
the text, not the bottom of the line.
When using implemeted ICustomTypeDescriptor with overrided SetValue(object component, object value) and there value reference will be changed even if new object`s fields will be equals then in line
current_changed = Object.Equals (properties[i].GetValue (propertyOwners[i]), value);
will not detected change cause of references of object in operands are not equal.
In usual ways references will be equal. So we compare old value ref with new value ref earlier.
In .net winforms do same. And also original winforms did not check CanConvertFrom whith type of editable object. So we do not need block with
converter.CanConvertFrom ((ITypeDescriptorContext)this, valueType))
Fixes#18606
If we use PropertyDescriptor with Converter like this
public class MyConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destType)
{
return false;
}
}
GridEntry will not show text of Value which uses MyConverter.
In .net they do not check CanConvertTo, they call ConvertToString directly.
pkg has been updated to 1.12+ which has an incompatible metadata format.
Fix this by force bootstrapping pkg when necessary. Also perform some
general cleanup and go back to the python3 metaport as 2020Q1 uses a
sufficiently current Python for the metaport.
* [llvm] Define a separate symbol for the aot method info for every method. Pass this symbol to the init functions instead of the
method index.
This removes a dependency the generated code has on the method index, hopefully allowing separate compilation etc. in the future.
* Put the method flags into a separate AOT table so they can be accessed without decoding the method info structure, which is not available to the runtime for LLVM methods.
* Make the LLVM methods set the init flag themselves. This will allow the init flag to be changed to a per-method scalar later to remove
a dependency on the method index.
Also rename init_icall_wrapper to init_func, it does much more than just calling the icall.
* - Adding tests to evaluate expression
- Adding a cache to local vars and object properties
- Fixing evaluate expressions like "this.a"
- Fixing evaluate expressions like "d + d"
Share more code between LLVM 6 and LLVM 9.
Mangler::getNameWithPrefix takes a Twine, not a std::string, so use a
StringRef to avoid an unnecessary allocation.
InstructionCombiningPass grew a dependency on
ProfileSummaryInfoWrapperPass in
https://github.com/dotnet/llvm-project/commit/09e539fcaebb6362795d352cdcf4a818cf4d0d6a,
which depends on the enclosing FunctionPassManager having a valid
reference to a module. This commit adds a dummy module to satisfy this,
instead of recreating a new FunctionPassManager on every compilation.
(See also
http://lists.llvm.org/pipermail/llvm-dev/2019-March/130690.html.)
I changed the frame_id, so we will follow the frame_id from callstack even if we don't add all of them into the CallStack list in MonoProxy.
I also added a test.
Fixes#19379
* [wasm][bcl] TimeZoneInfo implementation for WebAssembly to read from WASM VFS `/zoneinfo`.
- Remove `TimeZoneInfo.WebAssembly.cs` file
- Remove source dependencies on `TimeZoneInfo.WebAssembly.cs`.
- Modify TimeZoneInfo for specific WASM functionality
- Default root directory is `zoneinfo`
- Add icall `mono_timezone_get_local_name` for WASM in CreateLocal
- Add icall implementation
- ves_icall_System_TimeZoneInfo_mono_timezone_get_local_name
* [wasm][build] Add `-s FORCE_FILESYSTEM=1` to mono wasm runtime build
- Required so that it includes support for loading pre preload packages
Message when generating the zoneinfo data.
> Remember to build the main file with -s FORCE_FILESYSTEM=1 so that it includes support for loading this file package
* [wasm] zoneinfo data and support files.
- Three files for zoneinfo VFS support.
- `mono-webassembly-zoneinfo-fs-smd.js.metadata` - This is the separate metadata output by emscripten file-packager. Used to parse the zoneinfo data in non browser environments. See `runtime-tests.js`
- `mono-webassembly-zoneinfo-fs.js` - Output by emscripten file-packager that will be referenced by browser environments to load the zoneinfo data into the VFS at `/zoneinfo`
- `zoneinfo.data` - The binary file output by emscripten file-packager. The file contains the actual zoneinfo data loaded into the VFS and parsed by `TimeZoneInfo`.
* [wasm][driver] Add backing support for icall `mono_timezone_get_local_name`
* Add TimeZone info test.
* [wasm][packger] Add `-s FORCE_FILESYSTEM=1`
- Required so that it includes support for loading preload packages
Message when generating the zoneinfo data.
> Remember to build the main file with -s FORCE_FILESYSTEM=1 so that it includes support for loading this file package
* Fix AOT tzd test
* Remove commented code lines for `TimeZoneInfo.WebAssembly.cs` module
* Regenerated zone info without --no-heap-copy as it causes problems. This will create a warning in browser for now.
* Add zoneinfo support files to package
* Fix TimeZoneInfo tests to use the `--enable-fs` packager parameter
* Add back icall implementation after rebase
- ves_icall_System_TimeZoneInfo_mono_timezone_get_local_name
* Add back backing support for icall `mono_timezone_get_local_name` after rebase
* Fix build error
* Add back zoneinfo tests to Makefile after rebase
* Fix packager zoneinfo sample builds.
* Address review comment about volatile not needed
* Address review comment about volatile not needed
* Address review comment about volatile not needed
* Address review comment volatile not needed
* [wasm][debugger][tests] Refactor test support methods
.. which will help in the upcoming changes.
* [wasm][debugger][tests] Add tests for arrays
- These don't include the broken cases which are fixed in the next
commits
* [wasm][debugger][tests] Fix enumerating locals in async method on a
.. struct.
* [wasm][debugger] Support ValueTypes in arrays
- ValueTypes in array elements are not expanded by default. Instead,
they get an object id like `dotnet:array:{arrayObjectId}:{index}`
- And these get expanded on request
* [wasm][debugger] Fix calls to `mono_wasm_add_null_var` from js
- when being called from `library_mono.js`, with a native string like -
`MONO.mono_wasm_add_null_var ("string");`
.. which when passed to `Module.UTF8ToString (className)`, returns
`null`. So, if the result of that call is null, then use the `className`
argument as-is.
* [wasm][debugger][tests] Add test for local structs in an async method
* [wasm][debugger][tests] Add `TEST_ARGS` and `TEST_FILTER` arguments to
.. control `dotnet test` arguments.
Example use:
`make run-debugger-tests TEST_ARGS="--filter FullyQualifiedName~ArraysTests"`
or
`make run-debugger-tests TEST_FILTER="ArraysTests"`
* [wasm][debugger][tests] Make `label` the last argument, consistently.
* [wasm][debugger] Address review comments
- Return a `Result` response, instead of throwing an exception
* dummy commit to kick the pr
* [debugger][wasm] Implement evaluate in wasm debugger.
-> evaluate expressions with constant values and variable values are working
-> evaluate expressions with methods not working yet
-> evaluate expressions with assignments not working yet
* removing extra ;
* Update sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
Co-Authored-By: Larry Ewing <[email protected]>
* Update sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
Co-Authored-By: Larry Ewing <[email protected]>
* Update sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
Co-Authored-By: Larry Ewing <[email protected]>
* Fix what was suggested by @radical.
* Changing what @radical suggested
* Changing what @radical suggested
Co-authored-by: Larry Ewing <[email protected]>
* When we run an invoke in a thread and after this we do a set_value and then a get_value, when we call set_value we consider restore_state, but when we call get_value we are not considering the restore_state.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1077790
…asses
Follow CoreCLR's example and add the RTSpecialName type attribute to any class field with the 'value__' name when , used as the value store for enumeration class instances.
Second part of the "RTSpecialName fix" that started with https://github.com/dotnet/runtime/pull/33389 - before, our behavior was to add the RTSpecialName immediately, as soon as the EnumBuilder was constructed.
Contributes to https://github.com/dotnet/runtime/issues/2389
Co-authored-by: alexischr <[email protected]>
Since 3 days ago, Mono WebAssembly no longer works on Firefox. The error is `ReferenceError: SharedArrayBuffer is not defined`.
This PR adds a trivial fix.
This is needed by Xamarin.Android to be able to round-trip with names fetched via reflection, as the only public API for this (`mono_type_get_name`) uses the IL format instead.
Fixes https://github.com/mono/mono/issues/19377
Co-authored-by: CoffeeFlux <[email protected]>
* [loader] Add append option to loader hook installation functions
Fixes https://github.com/dotnet/runtime/issues/34273
While this specific issue only affects the preload hook, I've added the append option to all the installation functions since this seems like a generally useful capability, both for internal use and embedders.
@BrzVlad tested locally and confirmed this patch solves the problem.
* Update callers in pedump and monodis
Co-authored-by: CoffeeFlux <[email protected]>
Co-authored-by: Ryan Lucia <[email protected]>
* [wasm][debugger] Move some of the variable name/value pairs fix up to
.. library_mono.js from MonoProxy.
* [wasm][debugger] Handle invalid scope id
- this would throw NRE, and the request would fail, and so the test
passed.
* [wasm][debugger][tests] Check functionName at breakpoints
.. and fix up tests.
* [wasm][debugger][tests] Remove unnecessary `ctx` arg
* [wasm][debugger] Add support for visualizing valuetypes
- Valuetypes are expanded into json, and cached. That gets used to
answer any `getProperties` request for them.
- When a valuetype is a local var, it's whole value expansion is
returned in `members` json field. This gets cached by MonoProxy, and
used to answer any `getProperties` requests for it's members.
- When a valuetype is part of an object, it is *not* expanded. Instead,
it gets an objectId of the form `dotnet:valuetype:containingObjectId:fieldOffset`.
- Later, when the debuggers asks for that special id, we expand *all*
the valuetypes in that containing object, and cache it.
- For properties, the property "number" as they are enumerated, is
used instead of the fieldOffset.
- this cache gets cleared whenever we step/resume the debugger.
* [wasm][debugger] Add support for visualizing enums
TODO: Flags
* [wasm][debugger] Don't invoke property getters when enumerating object
.. members.
* [wasm][debugger] Override `ToString` for `Result` class
sets.
Making associated change to type_in_image to also check the constrained type for a match. Re-adding asserts now they they no longer trigger.
fixup, accidentally used old function
adjusting coding convention to K&R
Starting with https://github.com/mono/mono/pull/16907 , the runtime ends in GC-Safe state (mode) after mono_jit_init_version() is called. mono_gc_init_finalizer_thread() expects the GC to not already be in safe mode.
Turns out `llvm::Triple(llvm::sys::getDefaultTargetTriple()).getArchName()` doesn't work as expected on all targets so the only option is to set arch via defines.
NOTE: it accepts "x86-64", not "x86_64
Co-authored-by: EgorBo <[email protected]>
`EB.selectTarget ();` used to return `NULL` on arm64 (and hit an assert later)
Turns out it needs MArch on arm (e.g. `"aarch64"`) set. No idea why it doesn't use host arch by default on arm (but works on x86).
Co-authored-by: EgorBo <[email protected]>
Cygwin now ships libssl 1.1 which removed OpenSSL_add_all_ciphers so the xar configure fails.
Replace the configure check with another existing function to fix it.
Fixes: https://github.com/dotnet/runtime/issues/34304
@tannergooding @davidwrighton
Now it fully matches clang/LLVM behavior, e.g. even `-mattr=+avx2` (or `-mavx2` in clang) doesn't enable `pcmul` and `aes`. However, `-mattr=+sse4.2` (`-msse4.2`) enables `popcnt` (see https://godbolt.org/z/RWAp_D). The intel manual says

So is there a CPU with AVX set but without `popcnt`? The instruction is pretty useful (it is used in BCL) users might forget to define it when they use `mattr=avx` (or `mattr=avx2`).
However in C++ world programmers use named groups e.g. `mcpu=haswell` rather than listing these sets via attributes.
Co-authored-by: EgorBo <[email protected]>
Improve LLVM 9 compatibility.
Several intrinsics were removed in LLVM 7 and above; replace them with
IR sequences that generate the desired instructions.
Fix some type mismatch problems with the generated IR (in
Sse2.StoreAlignedNonTemporal, Vector128.CreateScalarUnsafe, and
Sse2.MaskMove); these were caught by running the coreclr hardware
intrinsic JIT tests.
Support the two-argument forms of Sse.SqrtScalar, Sse.ReciprocalScalar,
and Sse.ReciprocalSqrtScalar.
llvm::linkCoreCLRGC(), in llvm/CodeGen/GCs.h, was removed and replaced with
llvm::linkAllBuiltinGCs(), in llvm/CodeGen/BuiltinGCs.h.
In mono_llvm_dump_value and mono_llvm_dump_module, flush the c library's
stdout stream before using (and flushing) LLVM's own buffered output
functions.
Co-authored-by: imhameed <[email protected]>
* [Wasm] Fix string_decoder when running with threading enabled
Avoids the following error message:
```
Failed to execute 'decode' on 'TextDecoder': The provided ArrayBufferView value must not be shared.
```
* [Wasm] Cache text decoder
* [wasm] Throw an exception from Monitor.Wait () in non-threaded mode.
* [wasm] Throw an exception when waiting for unsignalled events in non-threaded mode.
* [wasm] Bump emscripten to 1.39.11.
* [wasm] Build the debug runtime using -g, -g4 disables dwarf.
* Add runtime debugging docs.
* Avoid copying the dotnet.wasm.map file its not generated anymore with dwarf.
* fix clean target
* Upgrade project to netstandard2.1 and change to not append framework when publish
* Move projects to netstandard2.1
* Remove code referencing framework paths
This should enable creation of a collectible ALC from managed, though it will not actually unload properly when Unload is called. This should be enough to unblock Xamarin porting work.
If you think the `mono_alc_cleanup` work is just noise I can remove that, but I thought it helpful to check in to make future diffs clearer as I split it up with the LoaderAllocator work.
Co-authored-by: CoffeeFlux <[email protected]>
When hitting stackoverflow on Windows, the amount of stack available to exception handler is too small. Windows doesn't support alt stack as other platforms, but there is a way to guarantee a certain amount of available stack during stack overflow exceptions using
SetThreadStackGuarantee.
Fix add support on Windows platforms including SetThreadStackGuarantee API to reserve space needed to handle stack overflow exceptions. On Windows debug build the size needs to be larger since we might end up calling JIT that could have quite deep callstack that, on unoptimized
builds, will need more stack.
Co-authored-by: lateralusX <[email protected]>
There was a race where a domain was being unloaded while debugger would access it. A domain was only removed from the 'appdomains_list' as a very last step. The domain was already invalid to access at this point (locks freed for example).
Worse, images would be unloaded if only referenced by that domain. All places the debugger iterates domains hold the loader lock. The loader lock is acquired by the domain unloading process, so as long as a domain is not unloading when we access it inside of the loader lock we are safe.
include domain unloading check in collect_domain_bp
Co-authored-by: Jonathan Chambers <[email protected]>
On windows, remote end point client will not return file name, but socket address size still isn't `0x02`.
So check empty file name after bytes readed.
* [wasm][sdk] Add functionality to override the bindings framework location
- Facilitate testing of intree build during the browser tests.
* white space
* Implementing step through multithreaded code.
* Fixing concurrency in the case that more than one thread will run the same code, then when the jit is finished, the thread which jitted the code calls jit_done and the others that were waiting don't call, in this case, the other threads can run before the thread which is calling the jit_done set the breakpoint, so the other threads will not stop in the breakpoint.
As I understood we don't need to check if the try_suspend_runtime is returning false or true when we hit a breakpoint from context, so removed the call.
Fixes#14456
Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
Co-authored-by: monojenkins <[email protected]>
* Reenable a bunch of disabled iOS Mono SDKs test suites
System, System.Net.Http, System.Web.Services, Mono.CSharp and Mono.Data.Sqlite test suites are running now.
Also tweaks the test UI so you can query it via Xcode's UITest in an automated way.
* Switch to APIs from public headers added in 1425b4d4d0
See https://github.com/dotnet/runtime/pull/33633 and https://github.com/xamarin/xamarin-macios/blob/master/runtime/exports.t4
* `mono_install_load_aot_data_hook` was already a `MONO_API`, but it was not in a public header.
It is added to `mono/jit/mono-private-unstable.h`
* `mono_gc_init_finalizer_thread` was [used by Xamarin.iOS](https://github.com/xamarin/xamarin-macios/blob/63ab48e679716264b33af00f86c24426da1d9f97/runtime/mono-runtime.h.t4#L278) for a long time without being in any public header. It's one of the reasons we have to compile Mono for XI with `--disable-visibility-hidden`. Make the function a proper `MONO_API` unconditionally - but make it do nothing if the runtime is compiled without `--with-lazy-thread-creation` (the default). It is now a public Mono API function.
* `mono_trace_init` was a `MONO_API` function in a non-public header that was already used by embedders that need to set up logger hooks. It is now not necessary to call this before calling the logger functions to set up logger hooks such as `mono_trace_set_log_handler`
Co-authored-by: lambdageek <[email protected]>
* [interp] Move INDIRECT flag to a separat counter variable
We will optimize away some ldlocas, so a local can stop being indirect at a future cprop iteration.
* [interp] Replace ldloca + ldfld/stfld pairs with ldloc/stloc
If loaded/stored field is the only field of the valuetype. This is meant to mainly optimize IntPtr accesses.
* [interp] Add counter for removed LDLOCA
CoreCLR static link vcruntime140.dll, but dynamic link rest of C-runtime using ucrt.lib in release build. Commit align Mono runtime to follow same pattern, removing dependency on vcruntime140.dll.
Co-authored-by: lateralusX <[email protected]>
Current implementation always returned true for Windows/Linux/Android. There are however use of this API in Task library to make sure recursive tasks won't hit stackoverflow. There are several tests in System.Threading.Tasks that currently hit this, at least on Windows, causing test failures.
Fix use stack limits already setup in register_thread and used by GC when doing conservative stack scan. If the limits have not been setup or is not supported on platform, we will use old defaults, always assume there is enough stack space available. Heuristics around size of minimum execution
stack needed are picked from corresponding CoreCLR implementation.
With this fix all tests run in System.Threading.Tasks.Tests pass on Windows using Mono runtime:
```
=== TEST EXECUTION SUMMARY ===
System.Threading.Tasks.Tests Total: 682, Errors: 0, Failed: 0, Skipped: 3, Time: 11,419s
----- end 2020-03-20 13:43:35,72 ----- exit code 0 ----------------------------------------------------------
```
Before fix the following tests hit stackoverflow:
LongContinuationChain_ContinueWith_DoesNotStackOverflow
LongContinuationChain_Unwrap_DoesNotStackOverflow
LongContinuationChain_Await_DoesNotStackOverflow
RunStackGuardTests
Co-authored-by: lateralusX <[email protected]>
unbox tramp method addresses are emitted as a table of calls and read
at runtime by get_call_table_entry. This is problematic on platforms
that doesn't allow data to be read from instruction stream.
Fix follow same pattern as we method address table emitted as function
pointers into table in data segment when using MONO_ARCH_CODE_EXEC_ONLY.
We have functions that are de-facto part of the Mono embedding API that are
used by Xamarin.iOS or Xamarin.Android that are not in a state where we want to
commit to supporting them forever in their current form.
Nonetheless, we would like to make sure that the symbols for these functions
are visible even if we otherwise compile the runtime with
`-fvisisibility=hidden`, and we would like to discourage declaring the
functions in the embedder's own headers.
The functions that go into the
`mono/{utils,metadata,jit}/mono-private-unstable.h` headers will all be marked
with `MONO_API MONO_RT_EXTERNAL_ONLY` but we will not guarantee that the
functions will be there from one release to the next or that they will not
change their signatures or their behaviors.
Co-authored-by: lambdageek <[email protected]>
* [jit] Perform inlining earlier during call processing to avoid loading vtable/rgctx args which are not needed.
* Avoid inlining calls marked with .tail.
* [llvm] Use the _typed version of get_aotconst () everywhere. Lowercase aotconst variable names.
* [llvm] Unify the emission of GOT access. NFC.
* [llvm] Unify the mini_llvm_init_method icalls, use only 1 icall.
MINT_TYPE_P is equivalent to the integer versions. By removing it we reduce the number of interpreter types and instructions, making it also easier to apply optimizations on instructions targeting these types.
Previously it would print a warning, only, because otherwise we would get a
second assert in the same place while the crash machinery would run from the
current thread from the abort in `mono_fatal_with_history`
The solution is to turn off the "no safepoints" bit since we know we're
definitely going to assert here.
Also record the current state in the checked mode state transition history to
make it a bit easier to diagnose where the problem surfaced.
Also fixed up a pair of other debugging/tracing messages so the message strings
accurately reflect the state.
- Changed the behavior on debugger-agent, if we can't parse the new behavior is to return invalid_argument and not assert and stop debugging
- Changed the mono_domain_set_fast before return from assembly_commands.
- Add error message when return INVALID_ARGUMENT
Fixes#19146
Resolves#18528 in for both detection and compiling. This should backport cleanly to next release.
Tested on 12.1-RELEASE with libinotify; configure detects features correctly, compiles successfully, resolves some observed issues during run.
```
#define HAVE_SYS_INOTIFY_H 1
#define HAVE_LIBINOTIFY 1
#define HAVE_INOTIFY_INIT 1
#define HAVE_INOTIFY_ADD_WATCH 1
#define HAVE_INOTIFY_RM_WATCH 1
#define HAVE_INOTIFY 1
```
All these functions are MONO_RT_EXTERNAL_ONLY and they all allocate managed
objects.
Fixes a coop state machine assertion if an embedder calls the function and it needs to take the GC
lock to do a collection.
Co-authored-by: lambdageek <[email protected]>
Running System.Runtime.Serialization.Xml test suite triggers calls to mono_code_manager_reserve with 0 size code block. On Windows, allocating code regions from code manager will also add callback for code region into unwinder function table, but since region could be 0 length, it will be causing a crash in RtlInstallFunctionTableCallback OS call.
Fix hardens code to not try to register callbacks for code regions of size 0, since that is considered a critical error by Windows OS API.
Co-authored-by: lateralusX <[email protected]>
* [interp] Extract nint/nfloat intrisifying code into separate method
* [interp] Optimize out intptr ctor
We avoid the newobj_vt opcode and the ctor's contents by emitting a conversion opcode directly.
Fix makes sure runtime checks also report that SIMD has been disabled. Returning FALSE from is_simd_supported will turn of MONO_OPT_SIMD and disable all SSE/AVX cpu features will prevent code checking cpu capabilities to emit SIMD instructions.
Co-authored-by: lateralusX <[email protected]>
browser tests were failing with node command not being found if the other tests were not run before. This makes sure that the NPM command can be found by installing it if not there.
This also separates out the npm version that is being installed.
Current implementation didn't convert the JIT flags into options on cfg
meaning that code currently checked JIT_FLAG_CODE_EXEC_ONLY never
executed. Fix handles the new JIT flag in same way as other JIT flags,
converted into bit field on cfg.
* [jit] Transition the SIMD code to use the MONO_CPU_... set of flags instead of the SIMD_VERSION_... flags.
* Enable SIMD version checking when targeting llvm.
* AOT test assemblies using -mcpu=native.
* Remove unused mono_arch_cpu_enumerate_simd_versions (). Move the SIMD_VERSION_ constants to simd-intrinsics.c.
* Use -mcpu=native for aot testing.
* [metadata] Change mono_trace levels from info to debug
* [mini] Change mono_trace level from info to debug
* [sgen] Change mono_trace levels from info to debug
* Amended metadata changes
* Amended mini changes
* Amend assembly.c no special case
* Amend sgen-mono.c elevate to warning level
Co-authored-by: Mitchell Hwang <[email protected]>
Implement all `Ssse3` and `Sse42` intrinsics for LLVM back-end.
`Sse41` is left over (that's why `Sse42.IsSupported` still returns false always outside of corelib)
Godbolt: https://godbolt.org/z/7cd7q5
Co-authored-by: EgorBo <[email protected]>
https://github.com/dotnet/runtime/pull/33465 implemented 99% of them but a few were missing. This PR implements the missing pieces and unlocks `Sse2.IsSupported`.
@vargaz I hope I didn't step on your toe (feel free to close if you already have it locally).
Co-authored-by: EgorBo <[email protected]>
* [interp] Add support for the coverage profiler.
* [runtime] Add 'write-at-method' and 'send-to-method' options to the coverage profiler, they work similarly to options in the AOT profiler.
* Fix c++-isms.
If the runtime is shutting down, instead of creating a new thread, or throwing
an exception on the current thread, just shut down the current thread.
This takes advantage of `mono_threads_set_shutting_down`'s behavior that if you
call it after shutdown is already started, it will suspend, detach and exit
from the current thread.
Fixes https://github.com/dotnet/runtime/issues/31842
Co-authored-by: lambdageek <[email protected]>
That call ends up in mono_debugger_agent_send_crash which does all kinds of questionable stuff like trying to take the loader lock. Eventually it ends up calling socket_transport_send which tries to do a transition to GC Safe mode.
I inserted a MONO_ENTER_GC_UNSAFE in mono_debugger_agent_send_crash function and this fixes the assert.
Fixes#18794
store a converter object for each type string passed in
use that object to simplify the marshalling step. do one allocation
for arguments and exceptions.
* [corlib] Capture the ExceptionDispatchInfo when rethrowing from TaskContinuation
In `task.GetAwaiter().OnCompleted(action)` if `action` throws, the
`TaskContinuation.RunOrScheduleAction method will catch the exception and then
call `RuntimeAugments.ReportUnhandledException`. We must not simply throw the
exception again - in that case we will lose all the frames leading up to the
`catch` in `RunOrScheduleAction`. Instead use ExceptionDispatchInfo to
caputure the original throw.
Addresses https://github.com/mono/mono/issues/19166
* [test] Add regression test
For annoying reasons we can't run this as a simple NUnit test because the
exception is unhandled on some arbitrary threadpool worker thread, and those
don't show up within an NUnit setup.
Additionally because the unhandled exception in the root domain would normally
terminate the application, we need to run this in a new appdomain.
SDK builds done under WSL was done like Cygwin in order to be a
Cygwin replacement going forward. This has caused issues when building
sdk's under WSL when Linux is the assumed build host.
Adding an additional define where WSL build host can be overridden to
Windows, but default will now be Linux. This can in future be used
from configure scripts, setting it in sdks/Make.config when needed,
but will be an opt in feature to override Linux as default build host
for WSL.
First set of changes needed in order to start sharing managed EventSource/EventPipe code between CoreCLR and Mono runtime. Shareable code has been moved into S.P.C library project and split into runtime specific source files when needed, kept within each runtime specific S.P.C project files.
Mono runtime has been extended with a set of icalls needed by EventPipeInternal, just to make sure EventPipe can be initialized, current Mono runtime implementation returns dummy values.
Current change also enables ETW provider support on Mono Windows runtime.
NOTE, this is just initial changes needed in order to share managed EventSource/EventPipe code between runtimes. Future changes will incrementally add EventPipe native code into Mono runtime.
Co-authored-by: lateralusX <[email protected]>
* [interp] Add missing intrinsics for double Math operations
* [interp] Add math intrinsics for float operations
* [interp] Add more math intrinsics
With different type of signature
* [interp] Remove intrinsic for Round for now
Which has different semantics from the libc's round
This adds an option the standalone-benchmark runner to extract the package zips created with the package target and available from jenkins for commits to master.
Followup to https://github.com/mono/mono/pull/19126 and
https://github.com/mono/mono/pull/19169.
Bring arm64 `mono_arch_get_call_target` in line with other platforms by
returning NULL on failure instead of asserting. Bits 30-26 in an arm64
unconditional branch are exactly 0b00101, so 0x1f (0b11111) is used as a
mask to determine if the branch uses an immediate target--0x7 (0b111)
would incorrectly match against branches using register targets. The
extracted immediate is now sign extended in a branch-free way.
Avoid following blx entries in the method address table; ld64 can emit 4
different instruction sequences for islands involving thumb, and I'd
rather not implement support for them all now because 32-bit iOS is old
and large unlinked assemblies seem rare.
Whenever there must be a loop that goes indefinitely, there are either return statements or break statements in the code.
However, in this codebase, there are "infinite loops" that appear as such until the next line is checked, which is an if statement saying to break if a condition is true.
This unneeded complexity can be resolved by inverting the condition and making that the while-loop condition.
Co-authored-by: pi1024e <[email protected]>
/s/mono2/mono/mini/interp/transform.c:3166:25: note: place parentheses around
the '&&' expression to silence this warning
if (mt >= MINT_TYPE_I1 && mt <= MINT_TYPE_I4
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Kind of a silly warning.
mono/sgen/sgen-protocol-def.h:102:1: warning: adding 'unsigned long' to
a string does not append to the string [-Wstring-plus-int]
BEGIN_PROTOCOL_ENTRY_HEAVY2 (binary_protocol_block_alloc, TYPE_POINTER, addr, TYPE_SIZE, size)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/sgen/sgen-grep-binprot.c:394:2: note: expanded from macro
'BEGIN_PROTOCOL_ENTRY_HEAVY2'
BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/sgen/sgen-grep-binprot.c:291:26:
note: BEGIN_PROTOCOL_ENTRY3 (binary_protocol_world_stopping,
TYPE_INT, generation, TYPE_LONGLONG, timestamp, TYPE_POINTER, thread)exp
mono/sgen/sgen-protocol-def.h:102:1: note: use array indexing to
silence this warning
This is subtle and not actually misleading,
because it tends to be space tab or space tab, not wrong
number of tabs or significant wrong number of spaces.
/s/mono2/mono/metadata/class.c:4010:6: warning: misleading indentation;
statement is not part of the previous 'if' [-Wmisleading-indentation]
if (mono_class_implement_interface_slo...
/s/mono2/mono/metadata/class.c:4039:3: warning: misleading indentation;
statement is not part of the previous 'if' [-Wmisleading-indentation]
if (m_class_is_delegate (target) && mono_class_has_variant_gener...
/s/mono2/mono/mini/driver.c:1780:4: warning: misleading indentation; statement
is not part of the previous 'if' [-Wmisleading-indentation]
if (strncmp (argv [i], "--debugger-agent=", 17) == 0) {
This just handles systems (mac) without realpath installed and with a version of bash
that doesn't support &>>. It also trims path information from the benchmark name
Current implementation embedded critical runtime information directly
into PLT slot. It also depends on finding call site in generic trampoline
reading call target from instruction stream in order to locate PLT slot
in use and then read GOT offset as well as PLT info offset from PLT slot
instruction stream.
This is problematic on platforms where code is execute only. Fix changes
how the metadata needed in order to correctly patch PLT is discovered.
Instead of depending on reading instruction stream, it is loaded into
RAX (free to be used when calling through PLT on AMD64) in PLT slot
before jmp takes place that moves control over to generic trampoline.
The PLT slot is the only place where we have access to both GOT index
(used in jmp), PLT info offset (currently embedded after jmp instruction)
and emitted PLT slot index. Since PLT slot index can be used to recover
GOT offset used by PLT slot as well as PLT info offset at runtime,
PLT slot index will be emitted into instruction stream and loaded into
RAX (prepared to be configurable to other reg if needed) before doing the
jump over to generic trampoline. Size of emitted imm constant is optimized
based on number of total PLT slots used in image, meaning that 1, 2, or 4
bytes could be used to store PLT slot index as an imm constant in
instruction stream. The additional jmp should have minimal to no
performance overhead since it should complete within 1 cycle, reading
imm constant from instruction stream that shouldn’t incur additional
cache misses and sine there is no data dependency between mov and jmp,
there should be options to pipeline both instructions. Since mov has
smaller latency than indirect jmp, mov should be complete once control
gets into the generic tramp (if pipelined).
In order to resolve plt info offset at runtime, needed information is
now emitted as part of got_info_offsets, increase table with 4 bytes/plt
slot, same size currently emitted into the PLT slot instruction stream.
Code size of PLT slot is currently 10 bytes (6 bytes jmp and 4 byte PLT
info offset). Since PLT info offset has been moved into got_info_offset
table, size of PLT slot will be 2, 4, 5 byte mov (depending on needed imm
size) and 6 bytes jmp instruction. As an example, mscorlib can emit all
its PLT slots using 2 byte imm constant, meaning that the PLT slot will
still be 10 bytes, but since PLT info offset of 4 bytes is moved into
got_info_offset, total image increase will be 4 bytes/PLT slot. This is
however still cheaper than alternatives that would burn 1 trampoline/PLT
slot (at least 10 additional bytes/slot) or setup lookup tables in image
or calculate more info at runtime, all-consuming more memory in total.
Note, using this approach is optional and runtime needs to be built using
MONO_ARCH_CODE_EXEC_ONLY in order to enable it since it’s only an opt in
features on platforms that can't read from instructions stream.
Current implementation is AMD64 only, but same pattern could be applied
to other architectures when needed.
* Add generic OP_XOP opcodes for opcodes which the JIT doesn't care about.
Add a SimdOp enum to list the operations performed by these opcodes.
* Add a SimdIntrinsic struct so the mapping between the .net methods
and the JIT opcodes can be specified declaratively.
* Add all intrinsics from the Sse class.
Co-authored-by: vargaz <[email protected]>
Fixes https://github.com/mono/mono/issues/18612; `aot_code_low_addr` and
`aot_code_high_addr` were set to a range that included only first-level
branch islands, so `find_aot_module` would fail early when passed a
genuine function address.
This change only affects monotouch for now.
Why not use relative offsets stored in a read-only section? One reason
is that llvm-as cannot handle a `.long` directive containing a
subtraction expression involving externally-defined symbols. The AOT
method address table and AOT LLVM-generated code are currently emitted
in separate object files, so the method address table would include
expressions with undefined symbols.
Related: https://xamarin.github.io/bugzilla-archives/70/707/bug.html
* [wasm] Convert MonoString to string without utf8
Previously when converting strings from mono objects to js we used a utf8 intermediate buffer, this change builds the js string from the mono string without an intermediate.
* Remove redundant mono_gc_collect during domain unload
Ifdef out mono_gc_collect when Boehm GC is present as it doesn't use remsets
* Fix trailing whitespace
Co-authored-by: Rares Sebastian Popa <[email protected]>
* [corlib] Suppress finalization of underlying console FileStreams
We already suppress the finalization of the CStreamReader and CStreamWriter,
but during shutdown, the underlying FileStream may be finalized which
invalidates its access field which can lead to a crash.
Addresses https://github.com/mono/mono/issues/19005
* [llvm] Move intrinsics definitions into a template header file llvm-intrinsics.h.
* [llvm] Add a call_intrins () helper function.
* [llvm] Add globals for the SSE vector types to make code more compact.
* [llvm] Refactor the registration and lookup of intrinsics.
* Use the Intrinsics class from LLVM to register intrinsics.
* Identify intrinsics using an id instead of their name.
* Disable the wasm intrinsics on older llvm versions.
* Simplify mono_llvm_register_overloaded_intrinsic ().
numOperands is an unsigned integer. In addition, getArgOperand has unsigned int arguments. As a result, I have no idea why i is an int, but to fix compiler warnings, I made it an unsigned int.
Co-authored-by: pi1024e <[email protected]>
As analysed by @jstedfast and me the only way to get this exception with this callstack below is 2 threads call GetThreads at same time, so while one of them is filling the items in the array, the other one is already trying to use the array with null items.
```
System.NullReferenceException: Object reference not set to an instance of an object
at Mono.Debugging.Soft.SoftDebuggerSession.GetId (Mono.Debugger.Soft.ThreadMirror thread) [0x00000] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:3227
at Mono.Debugging.Soft.SoftDebuggerSession.OnGetThreads (System.Int64 processId) [0x0002c] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:879
at Mono.Debugging.Soft.SoftDebuggerSession.GetThread (Mono.Debugging.Client.ProcessInfo process, Mono.Debugger.Soft.ThreadMirror thread) [0x00008] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:902
at Mono.Debugging.Soft.SoftDebuggerSession.HandleBreakEventSet (Mono.Debugger.Soft.Event[] es, System.Boolean dequeuing) [0x00501] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:2038
at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet (Mono.Debugger.Soft.EventSet es) [0x0005b] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:1687
at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler () [0x0005d] in /Users/runner/runners/2.164.6/work/1/s/monodevelop/main/external/debugger-libs/Mono.Debugging.Soft/SoftDebuggerSession.cs:1625
```
PR on mono/debugger-libs -> https://github.com/mono/debugger-libs/pull/300
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1070384/
Should fix https://github.com/mono/mono/issues/19115. This bug was
introduced in https://github.com/mono/mono/pull/18824, which
conditionally initalized an LLVM JIT-related TLS slot while preserving
unconditonal stores to that same slot.
The value stored in this TLS slot should only be used during JIT
compilation, so set/reset it in `mono_llvm_compile_method` instead of
during IR construction in `mono_llvm_emit_method`. No non-JIT code
should depend on the existence or presence of this TLS variable, so
remove `mono_llvm_jit_set_tls_cfg`.
Try to follow CDP ordering constraints by not responding Debugger.enable until
we've fired scriptParsed events for any already loaded assemblies.
Send Debugger.scriptParsed asynchronously as we load assemblies instead of
waiting for them all to load first and fix some of the sequence point processing
to speed up debugger initialization time.
Rework breakpoint request handling by always passing the request to the browser
then storing both the request and the resultant id for use in when any new scripts
are loaded.
Pass any previous breakpoint requests to the new execution context on page reload.
This cleans up three components of assembly loading that could potentially cause races/crashes.
First, both `add_assemblies_to_domain` and `add_assembly_to_alc` now ignore resolved references on netcore. We were seeing a crash on CI related to an assertion in here that resulted from two threads using the same MonoImage simultaneously as one is being loaded in with LoadFile, and this should solve that. Fixesdotnet/runtime#2305
Second, we take both the domain and ALC loaded assemblies locks simultaneously around the assembly being added to both lists, ensuring they stay in sync.
Finally, MonoImage now takes the image lock when writing to references instead of using the global `assemblies_mutex` in assembly.c for all images. This potentially helps reduce contention. Work here is not complete, but for this PR it's good enough. See dotnet/runtime#32889
Co-authored-by: Ryan Lucia <[email protected]>
In a current shipping Visual C++, 19.21.27702.2,
there is a bug involving const member data in structs, where for example:
static const struct a { // const on this line in either case
const int b; // const on this line
} c = {1};
will have a static initializer, run usually reliably before main, but:
static const struct a { // const on this line in either case
int b; // no const on this line
} c = {1};
will not.
The semantic difference is minuscule, so much so, that the first form
is relatively rare, and the bug shipped.
Just always use the second form.
The difference is that if you have a non-const a, b is still const, I guess.
If you have a const a, then no difference.
You can find these easily:
cd ...
for %a in (*.exe *.dll) do link /dump /disasm %a > %a.txt
findstr /c:"dynamic initializer" *.txt
Which could be automated and tested in CI.
This probably not an actual problem, but it is needlessly inefficient,
and potentially a problem. The timing/ordering of the initializers
is a bit not deterministic. You get writable data where you expect
read only.
It is in fact a compiler bug, fixed in later releases.
But it has been shipping for a while, I first noticed it over two years
ago, in code of mine that it caused to not work (a delayload implementation
which runs before main).
It should now validate against ICollection or any other type that has a Count property for that matter.
We're still relying on the reference source implementation because corefx strips some types out.
Fixes https://github.com/mono/mono/issues/19022
@vargaz noticed I used an incorrect opcode for ConvertScalarToVector128*
I will add a sort of fuzzy tests later (which use all kind of SRI APIs and compare results with CoreCLR) something like this: https://github.com/mono/mono/blob/master/netcore/tests/HwIntrinsics/Program.cs
Also, add signed version of ConvertScalarToVector128*.
Co-authored-by: Egor Bogatov <[email protected]>
Changes done in object-offsets.h adding offsets for TARGET_AMD64 exposed
a build configuration error in the Mono Tool MSVC debug build due to
incorrectly setting both X86 and AMD64 defines causing compile errors
when including object-offset.h. Release configuration didn't have this
configuration error, meaning that CI builds wouldn't trigger build error.
Fix makes sure all MSVC build configurations for Mono Tools
(genmdesc, monodis, pedump) matches the build configuration for other
binaries and that debug build configuration is inline with release build
configuration.
* [aot] Rename acfg->opts to acfg->jit_opts.
* [aot] Add support for emitting the method address table as a table of normal pointers in the data segment.
* [amd64] Obtain the trampoline argument in the generic_trampoline in the AOT case without decoding the call instruction.
* [amd64] Unify the aot specific trampolines so they have the same size/layout, so its easier to compute the address before the call.
For now we only implement intrinsics used by corlib internally to optimize code.
Fixes https://github.com/dotnet/runtime/issues/32510 crash.
`ConvertScalarToVector128UInt32/64` is expanded into LLVM's `insertelement`
`ConvertToUInt32/64` is expanded into LLVM's `extractelement`
Co-authored-by: Egor Bogatov <[email protected]>
Xamarin.Forms calls this _constantly_ during startup, to the point where the malloc calls were actually showing up in the profile. This should help with that, and gives us some ms back during startup.
There are also a bunch of calls that return empty arrays, which in theory could be created in managed for a perf boost. However, it seems the Xamarin.Android team has mostly gotten rid of those calls and that optimization would complicate the code and require changes to our managed CustomAttribute implemented for both legacy and netcore, so I've opted to not check it in for now. If the empty calls continue to show up down the line, I can dig the code back up from my local branch and PR it separately.
If this is producing huge arrays and malloc continues to show up in the profile, consider https://github.com/dotnet/runtime/issues/32972. Even without that, this is a substantial improvement.
Co-authored-by: Ryan Lucia <[email protected]>
I don't think you can create a root domain without reaching the thread info attach call, so this should be safe to change outright.
Fixesdotnet/runtime#32177
We should complete https://github.com/mono/mono/issues/18915 and then convert over other locks as needed, but this fixes the immediate CI hang.
Co-authored-by: Ryan Lucia <[email protected]>
Subject to configuration, spawn has three widely divergent behaviors:
succeed but do nothing
print and exit
do what it sounds like
Rather than mislead the callers, provide only option 3 and let the caller decide what to do otherwise.
PNSE coverage of wasm bcl has shown that only three public members of `System.Net.NetworkInformation.NetworkInterface` class throw `PlatformNotSupportedException`.
Now all public members throw PNSE on WASM.
Relates to https://github.com/mono/mono/issues/18735
Co-authored-by: monojenkins <[email protected]>
* [runtime] Use pointer size gchandles
This would enable in the future to use CoreCLR's GC with mono. This doesn't change the current embedding api, but, in the future, we will end up aligning with coreclr on an embedding api that uses pointer sized gchandles.
* [gc] Change format of gchandles to be netcore compatible
On netcore, the GCHandle class assumes the lowest bit to be usable, for perf improvements. Move the responsability to have this bit available down to the GC implementation, since for CoreCLR GC we shouldn't do any shifting above the gc interface.
* [wasm][debug] use console.trace instead to init runtime
Using a `debugger` breakpoint in Mono.mono_wasm_runtime_ready has
unfortunate side effects, this changes the logic to use console.trace
and checks the stackTrace when the event is arrives.
* add a console.trace stub to runtime-test.js
* Use console.debug with a magic number instead
If LLVM build is done using different build configuration, Mono build
will fail to static link LLVM libraries due to incompatibility between
release and debug C++ runtime library, generating a lot of linker errors
like this:
error LNK2038: mismatch detected for 'RuntimeLibrary':
value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug'
in mini-llvm-cpp.obj
error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL':
value '0' doesn't match value '2' in mini-llvm-cpp.obj
This is normally not a problem when doing local builds of LLVM but
when using an external provided build, like netcore Mono build,
this problem is more likely to occur.
This fix adds an additional check to make sure build configuration reported
by llvm-config.exe --build-mode matches current Mono build configuration
and if not give a more specific msbuild error:
error : LLVM build Configuration=Release doesn't match current Mono
build Configuration=Debug
Fixes https://github.com/mono/mono/issues/19009.
https://github.com/mono/mono/pull/18505 made PLT initialization occur at
image load time. When initializing the PLT for mscorlib,
`mono_defaults.corlib` is not yet initialized.
This change works around this by using `mscorlib_aot_module`--which is
initialized relatively early--instead of `mono_defaults.corlib`. PLT
initialization is also moved slightly later: it now happens after
`use_page_trampolines` has been initialized. The `USE_PAGE_TRAMPOLINES`
macro has also been changed to dereference `mscorlib_aot_module`.
This commit also removes an unused parameter from
`mono_aot_create_specific_trampoline`.
* [wasm][debugger] Always pass failed breakpoint requests to target
Originally we had a simple way to detect that breakpoints were
meant for the runtime but that is no longer true. Now if we
can't location a breakpoint we need to pass the request on to the
target so it can make an attempt.
* Fix test byUrl is a logical breakpoint and should not fail
Currently, the Mono WebAssembly debug proxy logic is treated as "shared source" with ASP.NET Core. Each time we update by copying the sources from this repo into the ASP.NET Core repo, we need to make some updates to avoid problems. The intention of this PR is to make the updates here at source, so we can simply copy the sources as-is and don't need to update them each time.
The changes are:
Making everything internal, since this is not intended as public API surface for ASP.NET Core developers. It's an internal implementation detail of the framework.
To retain convenience for the ProxyDriver and Mono test code, this PR also adds a simple public entrypoint called DebuggerProxy. This exposes nothing except the ability to connect a debugger proxy instance to a websocket. In the ASP.NET Core code, we'll simply omit this file since it's not needed, but even if we did get it in the future when the proxy feature is published as a package, it would still be fine since it doesn't expose any public API that would be expensive to support and maintain.
Replacing all the Console.WriteLine calls with use of ILogger from the standard Microsoft.Extensions.Logging package, as used by most .NET Core-based application frameworks including ASP.NET Core.
This allows external code to control what happens with log output, what severity levels are filtered in/out, etc. In ProxyDriver and Mono test code, I've configured it to behave just like before: it logs to console, and doesn't filter out anything.
This has the benefit that various bits of commented-out logging code no longer need to be commented out. Instead, when calling the logger.Log* methods, each call site can specify a severity level and then (for example) the filter level could be set to Debug so that all Trace items are filtered out by default.
Current hook compares TPA list file names using case sensitive compare. On Windows, the TPA list, when passed from CoreRun.exe makes all file paths lower case, meaning that our checks fails to find assemblies in TPA list.
Since CoreRun.exe is used for both CoreCLR and Mono, removing the tolower on file paths added to the TPA list in CoreRun.exe could be an option, but that might introduce regressions in CoreCLR, so this fix isolate the change to Mono's netcore preload hook.
Co-authored-by: Johan Lorensson <[email protected]>
Adds a basic set of standalone benchmarks from multiple sources, along with simple infrastructure for running them in mono, netcore and node.js wasm. A couple of them also have original JS versions you can run from a JS shell.
When compiling for Mono, Apple's compiler gives a warning saying to put braces around the 0 as it is a subobject. To silence the compiler, I put braces around the 0. Simple fix.
Co-authored-by: pi1024e <[email protected]>
- async local field names don't start with `<`, surface those
- `this` for the actual async method is in a field named like
`<>4__this`, surface it as the `this` object
* [llvm] Remove loaded llvm support, the startup perf penalty doesn't seem to exist any more.
* Fix the windows build.
* Remove more mini-llvm-loaded.c references.
* Remove more --enable-loadedllvm references.
* Make --enable-loadedllvm the same as --enable-llvm.
* Fix run-jenkins.sh.
* Address review comments.
Return address of local (deliberate).
Pointer cast to different size.
Function parameter and declaration badly mismatch (pid_t vs. void*).
Unused locals.
Top level volatile is ignored.
Negative shift undefined.
Call to undeclared function (getpid).
Some are fixed, some are disabled temporarily.
When compiling, Visual Studio gives two compiler warnings in the sysmath.c file about FPILOGB0/-2147483648 being converted into an unsigned integer.
The standard library math.h states that FPILOGB0 be INT_MIN, so I replaced -2147483648 with the INT_MIN macro so the behavior is much more clear as well as stifling the compiler warnings.
Changes tested manually and automatically.
Co-authored-by: pi1024e <[email protected]>
.. breakpoints. Chrome tries set the breakpoints from previous sessions
when the debugger starts up. And we set that in mono, if the runtime is
ready.
But in `MonoProxy.RuntimeReady`, we mark the runtime ready *before*
clearing the breakpoints. So, we end up setting the breakpoints, as
asked by chrome debugger, but then subsequently clearing them!
This manifests as previously set breakpoints in managed code not getting
hit, but if we reset the breakpoint manually then it gets hit.
`mono_wasm_get_var_info` didn't correctly reset the `data.cur_frame`
required for `mono_walk_stack_with_ctx`, as the stack is walked
repeatedly to get the variables.
* [corlib] Invoke TypeBuilderInstantiation.MakeGenericType through a delegate created in the TypeBuilder ctor to break a linker dependency between RuntimeType and TypeBuilderInstantiation.
* [corlib] Update linker descriptor.
* UnmanagedMarshal is not used from native code at all.
* AssemblyName is not used from native code at all.
This is needed because the required='false' field in
```
<type fullname="System.Reflection.Emit.TypeBuilder" required='false' preserve="fields" feature="sre">
<method name="SetCharSet" feature="sre" />
<!-- reflection.c mono_reflection_call_is_assignable_to () -->
<method name="IsAssignableTo" feature="sre" />
```
Fails to preserve the IsAssignableTo method.
* [wasm][debugger] Store more per session state and force some event ordering
Register a DebugStore and ExecutionContext per session and force some commands
to block on source loading so that scripts are loaded before attempting to use
them. This should populate the sources in vscode-js-debug properly.
This fixes https://github.com/mono/mono/issues/17140; intermittent incorrect results from GetTotalBytesAllocated for current thread. uint64_t and a pointer difference are not the same type/width on all architectures, so incorrect results can happen with out the parenthesis.
Co-authored-by: Nathan Ricci <[email protected]>
Correct values fort HighMemoryLoadThresholdBytes, MemoryLoadBytes. I looked in the code for CoreCLR and spoke with Maoni Stephens and Jan Kotas about the values used in CoreCLR, so I am confident they are all correct now.
HighMemoryThresholdBytes is a system wide memory usage threshold at which CoreCLR changes its compaction strategy. There is no direct correspondance to anything in mono-sgen. But since it used by software caches to determine when memory in the system is "nearly" exhauste, mono-sgent will use .9 * total physical memory as an acceptable value.
Co-authored-by: Nathan Ricci <[email protected]>
Code like this:
```
using System;
class Program
{
static byte[] bla = new byte[] {1,2,3,4,5};
static void Main()
{
}
}
```
Compiles to a private field declaration for the array with a compiler generated
name, that name should be quoted if it starts with a digit. For example:
```
IL_0007: ldtoken field valuetype '<PrivateImplementationDetails>'/'__StaticArrayInitTypeSize=5' '<PrivateImplementationDetails>'::'74F81FE167D99B4CB41D6D0CCDA82278CAEE9F3E2F25D5E5A3936FF3DCEC60D0'
```
Fixes https://github.com/mono/mono/issues/18750
1. This wasn't generally conserving the important stack.
2. Larger mechanisms are in place now.
Granted, tuning out rare paths could still be valuable.
A few weird here, esp. for string, but CI passes.
Acknowledged but skipped for now, a request to also refactor the opcode -- it doesn't seem like much throwaway work to go in either order, even if the code is dead (which I don't know).
Also amend recent nonrecursive PR to simulate stack +2 instead of +1.
* [wasm] Improve locals visualization in the debugger
- improves handling of generic types, null objects, delegates
- improves getting the name for nested types, arrays, generic types
top todos from this:
- Remove arity in "foo`2<int, int>" from the type name
- Convert nested type names from `foo/bar` to `foo.bar`.
* [wasm] Fix scoping for `mono_wasm_add_null_var`
- which caused runtime uncaught exceptions
* [wasm] Fix possible lost exception in GetScopeProperties
- An exception, eg., because of an invalid scope id just ends up
uncaught instead of showing up as a failed Result.
* [wasm] Address review feedback
- Replace `stringify_type` with `mono_type_full_name` which does exactly
the same thing!
* [wasm][debugger] Fixup nested class, and generic type names
```
// Fix up generic names like Foo`2<int, string> to Foo<int, string>
// and nested class names like Foo/Bar to Foo.Bar
```
To fix the issue of enabling embedded pdb everywhere the problem was that when the roslyn tests are compiling sources it creates embedded pdb with source file "", and before enable reading the embedded pdb we don't read this information, and now we read and our StackTrace file written in our corlib doesn't expect a source file "", it's okay if it's NULL but not "".
I could fix in corlib or in mono, I prefer to fix on mono because I don't know if there is any other place that doesn't expect source file "".
The test will be moved to XA's `src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs`
It only works if
```xml
<AndroidHttpClientHandlerType>System.Net.Http.MonoWebRequestHandler, System.Net.Http</AndroidHttpClientHandlerType>
```
is set in `Xamarin.Android.Bcl-Tests.csproj` and we don't want it (other tests expect SocketsHttpHandler to be default one). As an alternative we can add it to the `Xamarin.Android.Bcl-Tests.csproj`'s Linker exceptions but `/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs` is a better place for it.
The real goal is to make it not recursive.
This is just a step along the way.
Note that the actual not-recursive change has *not* yet been developed,
so this *might* amount to nothing useful.
The managed allocator included in a full aot image does not support canaries, leading to inconsistent object layout.
Fixes https://github.com/mono/mono/issues/18925
We never don't track the value of locals who have their address taken in a method, since their value can change without the pass detecting it, leading to propagation of incorrect values. We failed to check for this when doing a stloc.np optimization.
Fixes System.Reflection.Metadata.Tests.ImmutableByteArrayInteropTest.DangerousCreateFromUnderlyingArray
Enable more interp tests, which don't seem to fail on my machine.
This includes some other minor cleanup to the netcore hosting functions.
Setting `assemblies_path` with `APP_PATHS` despite it also being set by `MONO_PATH` doesn't scare me too much because:
1) Anyone using `MONO_PATH` is probably not going through the hosting API and is using `mono-sgen` directly
2) The default host doesn't set `APP_PATHS` (and we've worked fine without it being set at all up until now
3) This is a temporary measure; we will have to refactor our preload hook when we want to properly support the other loader properties anyway
Co-authored-by: Ryan Lucia <[email protected]>
The code is fine, and we should put it back at some point,
but I want things to be clearer regarding https://github.com/mono/mono/issues/18827.
i.e. That this does not cause it.
I don't know what does cause it, granted.
Maybe a preexisting race condition/deadlock, I don't know.
Repro is run a loop like:
```
type \s\1.cmd
for /l %%a in (1 1 999) do echo %%a && C:\s\mono2\msvc\build\sgen\x64\bin\Release\mono-sgen.exe \s\mono2\mono\tests\bug-10127.exe
```
Make MONO_API_DATA clearer, its old form -- MONO_API extern.
extern "C" { } should be added around it not within it, for clarity.
I've always found extern "C" without braces unclear, esp. for data.
i.e.
```
extern "C" {
1 extern void function(); // redundant but clear
// same as void function();
2 extern int data; // not redundant, and clear
}
```
vs.
```
3 extern "C" void function(); // I guess clear.
4 extern "C" int data; // unclear -- is it extern or extern "C" or both?
```
This PR in particular turns 4 into 2.
2 is clearly a declaration, not a definition.
4 is unclear as to if it is a declaration or definition.
I was looking into https://github.com/mono/mono/issues/18827.
This does not actually change anything but makes things clearer.
This is similar/related in spirit to https://github.com/mono/mono/pull/18891.
It should not make a difference.
In this case, `#if __cplusplus` remains, but the meaning of it is clearer.
It becomes *only* about the common `extern "C" { }` and not even the less clear `extern "C"`.
* [interp] Make newobj_vt_fast non-recursive.
* PR feedback: Attempt to provide similer primitive increase_max_stack_height
that is not so roundabout as move_stack (n) + move_stack (-n).
* [interp] Make newobj_vtst_fast not recursive.
This is builds upon https://github.com/mono/mono/pull/18875
and is easiest reviewed after it is merged.
Or, perhaps, this replaces it.
* comment-smithing
* [merp] Capture Environment.FailFast message in crash report
* [test] merp-crash-test refactor crasher data; add optional validator
Switch from a Tuple<T1,T2> to a struct for the crash items. Add a third
optional validator field which is an action to run on the json blob that we get
back.
Not updating existing tests to do any json validation, yet.
* [test] Add new MERP crash test for Environment.FailFast
Check that the resulting json blob includes the failfast message.
This wastes about 24 static const bytes which I think is ok.
6 bytes per struct, plus 2 padding, and there are 3 of them.
I was looking into https://github.com/mono/mono/issues/18827
and wanting to rule out #if __cplusplus.
The linker can completely link away some assemblies, but the rest of the ninja
build still requires them. Previously they were generated by running csc, but
thats too slow, so generate them using Cecil from wasm-tuner.
* [llvm] Disable X86 call frame size optimization.
Fixes https://github.com/mono/mono/issues/17285.
For calls that require parameters passed in stack memory,
X86CallFrameOptimization can sometimes replace a sequence of movs to
prologue-reserved stack memory with a sequence of pushes and a compensating sub
rsp after the call. LLVM accumulates an OpAdjustCfaOffset MCCFIInstruction for
each push and and records the ephemeral parameter space consumed by the call
using an OpGnuArgsSize MCCFIInstruction (i.e. DW_CFA_GNU_args_size).
MonoException doesn't support encoding OpGnuArgsSize MCCFIInstructions, and
attempting to encode this instruction can cause unpredictable behavior, due to
our use of llvm_unreachable with assertions disabled [1]. Moreover, even if
MonoException happens to emit valid call frame instructions despite the UB
induced by llvm_unreachable, Mono's exception handler will restore the stack
pointer to the value it contained at the time right before the protected call
instruction was made, without compensating for any ephemeral parameter space.
The stack pointer could be fixed before the jump to the EH handler by
supporting DW_CFA_GNU_args_size or by executing call frame instructions for the
EH handler's frame all the way to the end of the protected instruction address
range--which will include a sub rsp with an appropriate immediate--to determine
an appropriate delta. But it's easier to just disable this optimization. We
already disable it for AOT [2]. It's sometimes disabled by LLVM on Darwin [3].
Also, this commit adds a test (which is a nearly verbatim copy of laszk's
reproduction sample in #17285) for EH failures caused by the interaction of our
EH code and X86CallFrameOptimization.
See also [4], [5], and [6].
[1] https://github.com/dotnet/llvm-project/blob/adeaa08e7bbc9aba5d67cb16c2b348be12deb000/llvm/lib/CodeGen/AsmPrinter/MonoException.cpp#L209-L210
[2] https://github.com/mono/mono/blob/1317cf06da06682419f8f4b0c9810ad5d5d3ac3a/mono/mini/aot-compiler.c#L9872-L9875
[3] https://github.com/dotnet/llvm-project/blob/adeaa08e7bbc9aba5d67cb16c2b348be12deb000/llvm/lib/Target/X86/X86CallFrameOptimization.cpp#L146-L152
[4] https://bugs.llvm.org/show_bug.cgi?id=24792
[5] https://reviews.llvm.org/D13132
[6] http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151005/304074.html
* Address feedback: add an explanatory comment.
* [jit] Run static cctors for inlined methods, the cctor might not have ran in AOT mode.
* Emit the class init code later since it contains a branch.
* Emit the class init in the first code bblock.
* [abi-details] add explaining comment for macro magic
I think the fallback was added because "let's get it back to work quickly", back in the dark times without CI: https://github.com/mono/mono/commit/b655fb35c61fd3422003de01eed8e634d46b4186
* add constant version. to be used when offset is needed for static array sizes
* missing offset for windows
* windows define fix
mini\mini.c(1253,59): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3100,43): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3273,49): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3281,49): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3480,51): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3490,49): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3626,48): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3664,48): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3722,48): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini.c(3944,47): warning C4390: ';': empty controlled statement found; is this the intent?
mini\mini-runtime.c(549,64): warning C4390: ';': empty controlled statement found; is this the intent?
mini\method-to-ir.c(11838,2): warning C4065: switch statement contains 'default' but no 'case ' labels
metadata\sre.c(2286,11): warning C4309: '=': truncation of constant value
metadata\sre.c(2179,11): warning C4309: '=': truncation of constant value
metadata\sre.c(2204,11): warning C4309: '=': truncation of constant value
metadata\sre.c(2232,11): warning C4309: '=': truncation of constant value
mini\method-to-ir.c(11838,2): warning C4065: switch statement contains 'default' but no 'case
mini\type-checking.c(167,3): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
tracing was a mix of:
- sometimes ifdef out, sometimes not; make it always ifdefed
- sometimes int, sometimes gint, sometimes gboolean; make it always int
Much of this PR will end up deleted when the multiple nonrecursive calls are
consolidated, but two will remain -- entry and call: label.
https://github.com/mono/mono/pull/18825 is where this is going but it was deemed
too large and requested to be split up. This is part of it.
https://github.com/mono/mono/pull/18825 was deemed too large so this breaks
it down into smaller pieces.
To consolidate the multiple nonrecursive call sites requires they share the smae
retval variable. Go ahead and share them all.
Fixes
```
fatal error C1083: Cannot open include file: '../../support/libm/complex.c': No such file or directory
```
when `mono-netcore.sln` is opened in vs2019
Also, add `CopyMonoRuntimeFilesFromArtifactsToDestination` target to mono.proj to be able to copy mono runtime bits to any folder (needed for the performance team, cc @fanyang-mono)
Co-authored-by: Egor Bogatov <[email protected]>
https://github.com/mono/mono/pull/18825 was too large.
This starts by replacing imethod with cmethod which is a necessary
part of the consolidation of multiple non-recursive call sites to just one.
* [runtime] Add a few m_method_is_... inline functions.
* [llvmonly] Allow direct calls to tls accessors, its not a problem in llvmonly mode.
* [llvmonly] Allow direct calls to icalls/pinvokes/generic instances in the same module.
* Fix the loaded llvm build.
We currently reuse LLVM's command line parsing system to configure and
enable passes. When using the default code generator pass configuration,
the `ImplicitNullChecks` and `X86CallFrameOptimization` passes can only
be enabled or disabled via the command line argument parser: the
`cl::opt`s controlling these (and many other) passes are private to
their translation units, and `TargetPassConfig`/`X86PassConfig` read
from these `cl::opt`s with no other means to override these values.
Unfortunately, some LLVM command line options have restrictions on the
number of times they may be set, and running the LLVM command line
argument parser more than once can fail, because the 'number of
occurrences' counter is stored in each global `cl::opt`. This causes
several tests to fail--one such test is unhandled-exception-7.cs.
This change:
- removes the lazy LLVM JIT initialization logic and instead
runs this initialization once during `mini_init`,
- moves some stray JIT-only code from mini-llvm.c to llvm-jit.cpp,
- wraps the declarations in domain-internals.h with a
`G_BEGIN_DECLS`/`G_END_DECLS` pair, so that they avoid name
mangling when included in C++ source, and
- removes `exception_cb` and `emitted_cb`: neither were actually used
by live code.
When executing a filter we create a new interp frame, that is a duplicate of the original frame that contains the filter. Once the execution of the filter is finished, we were copying the stack contents back to the base frame. The problem with this is that when the filter is run, the stack is not completely unwinded, meaning that later we can still run a finally block in a frame called by the base frame. This finally block can access the stack arguments, which would reside on the stack of base frame. This means that we must not override the stack of the base frame, only the locals.
Fixes some tests from System.Linq.Expressions suite.
Emit a stub for methods which failed llvm compilation. Currently the stub will
throw a MissingMethodException, later it can fall back to the interpreter etc.
This is required for cross-assembly direct calls, since the caller doesn't
know that the callee has failed llvm compilation leading to missing
symbols during linking.
Fixes MSDN blogs links throughout our docs and source code comments that were broken during the great MSDN migration of 2019.
Note: I am changing the contents of the _davbr Blog Archives_ folder by fixing the broken links. If we need to keep these files exactly as they were when they were copied from the blog, I can revert.
Co-authored-by: Levi Broderick <[email protected]>
* Bump linker submodule
* Use -o instead of -out for linker output
The arguments changed in linker.
Co-authored-by: Alexander Köplinger <[email protected]>
The Xamarin.Android team prefers that we ship two different `libmonosgen-2.0.so` for each target, e.g. for arm64 we will have with this PR:
* `./sdks/out/android-arm64-v8a-release/lib/libmonosgen-2.0.so`
* `./sdks/out/android-interpreter-arm64-v8a-release/lib/libmonosgen-2.0.so`
As the names indicate one has the interpreter enabled.
This is contrary to what we do for Xamarin.iOS. There, `--enable-minimal=interpreter` has the side-effect that the build will produce a `libmono-ee-interp.dylib` that can be linked next to `libmonosgen-2.0.dylib`. We _could_ do the same for Android, but that would require us to
* Add `--disable-visibility-hidden` to the Android Mono runtime builds. There are concerns however that this will slow down `dlopen (libmonosgen-2.0.so)` on the Xamarin.Android side.
* Do some changes to the interpreter infrastructure, because `--disable-minimal=interpreter` is designed to be used with a cross compiler in mind. For example, we would need a different solution for this: https://github.com/mono/mono/blob/d7e6fcbda82639fd5afe106b0e7a65a2a72a4f63/mono/mini/tramp-arm64.c#L631-L634
Made minor fixes to the preload hook in the process.
The runtime will still crash if you don't specify the TPA paths and include corlib in that list, but it will at least hit an assert that makes clear it can't find corlib instead of attempting to dereference a null pointer in the preload hook.
The monovm header functions are exported for testing purposes, but the file is intentionally not made public as of now.
Co-authored-by: Ryan Lucia <[email protected]>
* [wasm] Avoid compiling release configuration with -s ASSERTIONS=1 in AOT mode, it generates a lot of extra code.
* Update sdks/wasm/packager.cs
Co-Authored-By: Bernhard Urban-Forster <[email protected]>
Co-authored-by: Bernhard Urban-Forster <[email protected]>
Storing uninitialized locals in a managed object shouldn't crash the runtime, so they should be zeroed. This doesn't seem to regress performance on wasm since the initlocals flag is always set, currently. We should be able to remove it most of the time, once we add some multi basic block support to the cprop phase. This will enable us to further reduce call overhead.
Fixes https://github.com/mono/mono/issues/18527
Libgdiplus will fail when attempting to delete a Graphics object
that has an unreleased HDC. This allows Dispose to succeed in
that case.
This more closely resembles the behavior of corefx.
* [interp[wasm] Make newobj_fast not recursive.
This contributes to https://github.com/mono/mono/issues/18646,
and against master might even fix it.
Though much recursion remains in the interpreter/transform.
* [interp] Cleanup redundant code and child_frame vs. frame.
Only the recursive paths need child_frame separate from frame.
Callers of method_entry tended to duplicate parts of it.
Notice it is marked MONO_ALWAYS_INLINE.
And if that isn't right, it should be split into fast and slow forms,
i.e. regarding frame->imethod->transformed.
* Need to EXCEPTION_CHECKPOINT more often -- when transform occurs but does not raise an exception.
* Preserve prior faster paths.
* Making call_vararg added the following to all calls:
storing is_void in a larger scoped local
save is_void
restore is_void
check is_void, along with preexisting check of retval == null
Because retval must be set even for void call_varargs,
because the arglist is found from it.
This removes the check of retval == null, it should be redundant with is_void.
* A little cleaner -- unlikely is in method_entry.
* Comma to make comment easier to read.
Traditionally, Mono is build with native compilers (i.e. "build for this architecture" running in an ARM or ARM64 chroot on an ARM64 server), but to align with CoreCLR, let's go the cross-compile way.
This enables cross-compiler support, by passing a whole bunch of extra info to `./configure`, some of which is set in the common YAML (like the `--sysroot` value)
Co-authored-by: Jo Shields <[email protected]>
This change is motivated on two main fronts. The first is maintainability - the current managed implementation is difficult to understand and I worry diagnosing any potential issues would be a massive time sink. The second is performance - the current implementation appears to suffer from significant lock contention when running the TechEmpower plaintext benchmark. My hope is that the simpler, cleaner native implementation here will avoid both problems, but I don't want to merge it until we have benchmarking data. However, even if the numbers are similar, I still think it's worth merging just from a maintainability perspective.
The native LifoSemaphore implementation has only ever been tested on posix-like platforms, so Windows behavior is unknown. Currently the Windows implementation of LowLevelLifoSemaphore is very different, so unless we have need for the LifoSemaphore elsewhere in the runtime this isn't a concern.
Many thanks to @filipnavara for the initial implementation.
Co-authored-by: Ryan Lucia <[email protected]>
* Use clearer Bash conditionals, since we force Bash anyway
* Add libmono-native.so to bundle
* Add logic to add a etc/mono/config without $mono_libdir to bundle
Mostly resolves: #16991
* [master] Bump msbuild to track xplat-master
* Bump roslyn to 3.5.0-beta3-20111-03 .
* Update nuget.exe to match xbuild
- the closest version available right now, to `5.5.0-rtm.6422` is
`5.5.0-preview2`, so using that for now.
At least on my machine, this is the only warning we have when building netcore in the default configuration.
Co-authored-by: Ryan Lucia <[email protected]>
Mono currently supports a limited subset of **Sse1**-**Sse42** intrinsics used only by CoreLib internally. So once a new API is used to optimize things there we also have to implement it in Mono. So it recently happened in https://github.com/dotnet/runtime/pull/32036 (`Sse2.AddSaturate` was used for the first time).
So this PR implements it for mono (with all Sse2 overloads) using named LLVM intrinsics. It turns out it's different between LLVM6 (we currently based on) and LLVM9 (we plan to migrate to soon).
for `Vector128<byte>` overload it emits
```llvm
%result = call <8 x i16> @llvm.x86.sse2.paddus.b(<16 x i8> %left, <16 x i8> %right)
```
which is then emitted as `vpaddusw`
Co-authored-by: Egor Bogatov <[email protected]>
* [interp] reclaim stack fragments when not used.
When a requested frame size doesn't fit in an already allocated stack fragment, we instead allocate another, larger fragment.
When doing this we missed to free the existing stack fragment, and in combination with a second problem (`current->next` not being cleared when unused) it can accumulate to a lot of unused stack fragments and in worst-case to OOM, as it happened on Linux corlib xunit tests.
Thanks to Jay for tracking it down.
* be cautious for GC
* add barrier
When locating AppContext.BaseDirectory on netcore, if APP_CONTEXT_BASE_DIRECTORY is not set we call into the runtime for a fallback location, which checks domain->entry_assembly. On legacy this is fine because we set that property in `prepare_thread_to_exec_main`, but on netcore the new managed assembly loading algorithm will call into managed and check the property before that function is run, which will result in AppContext.BaseDirectory returning an empty string. The solution is to set entry_assembly a bit earlier in initialization. This is the appropriate location because it's what embedding API users will call to run an assembly.
In the process, I got rid of some code that would bypass the usual lookup algorithm unnecessarily.
Fixesdotnet/runtime#31800
Co-authored-by: Ryan Lucia <[email protected]>
The default handlers for SIGTRAP, SIGSYS on macOS and Linux crash the process, so we now have Mono report this.
This patch also changes how the name of the signal is acquired for passing on to the crash reporting functions, allowing code reuse on crashing signals.
[interp] Make call_vararg non-recursive.
[interp] Remove recursion from call_vararg.
This contributes to https://github.com/mono/mono/issues/18646 but is not enough to fix it. The interpreter still recurses a lot.
Calling a method compiled using full AOT from interpreter can lead to
stack corruption if signature include a ValueTuple without fields on
compilers where MONO_ZERO_LEN_ARRAY is not 0 (msvc, clang). This is due
to doing memset on memory allocated using MONO_SIZEOF_GENERIC_INST but
then memset using sizeof (MonoGenericInst). Fix makes sure we allocate
and memset the same size of memory since otherwise it will lead to an
overwrite of allocated memory when type_argc is 0.
Use of `access_token` is now deprecated, switching to HTTP header
```
Please use the Authorization HTTP header instead, as using the `access_token` query parameter is deprecated.
```
1) Delete `src/mono/netcore/corerun/` folder, we can build/use coreclr's corerun (it has `--clr-path`)
2) Add `RunSample` to build & run HelloWorld with mono runtime.
Co-authored-by: Egor Bogatov <[email protected]>
[interp] Remove goto for code_type unknown | interp | compiled.
[interp] Remove goto for code_type unknown | interp | compiled.
The goto kinda implies a loop, but it is really just handling one case
before the other, but the source misorders the checks, perhaps for perf,
which maybe, can be done equivalently with G_UNLIKELY, and also remove
some possible extra memory reads.
[interp][wasm]Use per-call recursive functions in interpreter to aid debugging.
When the interpreter does recurse, use a different function
for each call site, so you can tell from a WebAssembly stack
which case it is. i.e. with function names but no line numbers.
With this, we can see that call_varargs contributes to the problem
here: https://github.com/mono/mono/issues/18646
Also, do not inline the interpreter, it probably/hopefully never was.
* [mini] Add optional method name to --stats (#18387)
* Implement parsing for optional method name to --stats command line argument.
* Implement parsing for optional method name to --stats command line argument.
Co-authored-by: Kyle Markland <[email protected]>
Co-authored-by: Rene Garcia <[email protected]>
* Respond to PR feedback.
* Refactored away helper functions.
* Refactored counter setup into separate function. Moved stats optional method into its own condition.
Co-authored-by: Kyle Markland <[email protected]>
Co-authored-by: Rene Garcia <[email protected]>
* Renamed mono_setup_counters->mono_enable_counters. Restore whitespace to 0a51d89c42
Co-authored-by: Kyle Markland <[email protected]>
Co-authored-by: Rene Garcia <[email protected]>
* [mini] Print header for stats. (#18442)
* Add an enum for dumping stats at points in time. Print header before dumping stats in mini_cleanup.
* Make print_stats_header private.
* Remove unused variable.
* Refactored print_stats_header to better accomodate optional methods for stats
* Change printf calls to g_printf in response to feedback.
* Undo changes in response to @CoffeeFlux 's feedback. Add g_printf calls to mini_cleanup
* Avoid always printing stats at shutdown.
* Condition on `mono_stats` instead of `mono_jit_stats`.
* [mini] Global JIT Stats Printing (#18483)
* Make print_jit_stats global to enable interp and JIT-triggered stat dumps.
* Rename some functions for consistency.
* Add a comment to clarify the necessary locking in different contexts.
* Rename mono_print_jit_stats to mono_runtime_print_stats and make it more generic.
* Rename runtime_cleanup_stats back to jit_stats_cleanup.
* Fix a line that was indented with spaces.
* [mini] parse fully qualified method name using mono_method_desc_new (#18499)
* Make print_jit_stats global to enable interp and JIT-triggered stat dumps.
* Rename some functions for consistency.
* Add a comment to clarify the necessary locking in different contexts.
* Use MonoMethodDesc struct and associated helpers to parse from command
line args. Remove unused stats_method_name and setter function.
Squashed commit of the following:
commit de7410696dab10723c76f545076522daa17e85d1
Author: Rene Garcia <[email protected]>
Date: Thu Jan 16 23:01:23 2020 -0500
Utilize new stats printing function.
commit 1e5038adfec06c670dbaced771a8ff9344502d17
Author: Rene Garcia <[email protected]>
Date: Thu Jan 16 22:37:53 2020 -0500
Remove unused stats_method_name and setter function. Use mono_method_desc_full_match instead of mono_method_desc_match.
commit 04f86c66c139e064bc35738f955f960232eb6cbb
Author: Rene Garcia <[email protected]>
Date: Thu Jan 16 18:11:37 2020 -0500
Modify mono_method_desc_match to actually match namespace and class. Add global MonoMethodDesc, and parse it from command line args. Leave TODO print statement in mono_jit_compile_method_inner.
* Move mono_method_desc to mini-runtime header. Fix whitespace.
* Cherry pick @KyleMarkland 's changes, and resolve merge conflicts.
* Fix leak. Give better error message when parsing empty method name.
* Move freeing of mono_stats_method_desc.
Co-authored-by: KyleMarkland <[email protected]>
* Add a conditional to transform.c to enable stat dumping from the interpreter. (#18540)
* [mini] Use g_printerr instead of g_printf before exiting (#18574)
* Rename g_printf -> g_print
* Use g_printerr on errors instead of g_printf.
* Pass NULL to mono_counters_dump. Revert g_printf to g_print.
* Update manpage
* Feedback
Co-authored-by: rgarc <[email protected]>
Co-authored-by: KyleMarkland <[email protected]>
I fear this causing packaging problems, but as-is we require Python 3 for most of our Python files but don't actually check for that in configure. We should be consistent about this. Some projects (notably wasm) also use the Python version detected here, so bumping this will also bump the version used in those cases (a good thing, since there are some known bugs when using the scripts with Python 2).
The original fix back at #18554 did not work quite right, which was missed for lack of CI.
Reworked this check to instead test for `-mminimal-toc` on all powerpc hosts, and to only do the ELF version check on FreeBSD.
Fixes#18554#18578 current CI build failures on AIX
* [aot] Handle '|' during symbol mangling.
* [aot] Clean up the construction of the linker command line.
* [aot] Pass -Wl,-install_name to the linker on osx, otherwise the shared object will be named based on the output file name i.e. <assembly>.dylib.tmp.
* [llvm] Pass the MonoAotFileInfo pointer to the init functions, not used yet.
* [jit] Add support for direct calls between methods in different AOT images in LLVM mode.
* Add a 'direct-extern-calls' AOT option.
* Initialize the PLT/GOT during method initialization,
this normally happens in load_method () but that is
not called when a method is directly called.
* Add self initialization support for JITted methods, they can be
called directly since they are fallbacks if LLVM fails.
* Fix the build.
* Avoid calling BeginInvoke etc. directly, its implemented by the runtime.
* Unify some cases.
* Init PLT at image load time since directly called methods without initializers might make calls through it.
* Fix a startup problem.
* Make the mono_is_corlib_image () check for during startup.
* Check for is_inited in the init icall wrappers, since they might be called from JITted code which doesn't check it.
* Address review comments.
When calling a generic class we need to make sure it has been inited.
This is done by calling generic_class_init. Since this call happens
frequently, but will only run once, it should be put out of line, assisting
branch predictor, preventing misspredictions (in all places but the first).
Currently this is not the case, since we will generate code like this:
0000000000000484: cmp byte ptr [rcx+2Dh],0
0000000000000488: jne 000000000000048F
000000000000048A: call p_3_plt_EmptyGame__jit_icall_mono_generic_class_init_llvm
000000000000048F: mov rax,qword ptr [mono_aot_EmptyGame_llvm_got+0C8h]
Where we will always (except for first call) take the forward branch.
Instead we should mark the call to the method as out of line, at least
giving the code generator the information so it can move it out of line
and preventing a jmp, unless when it needs to init, the slow path. Doing
that will generate the following code:
0000000000000484: cmp byte ptr [rcx+2Dh],0
0000000000000488: je 00000000000004C1
000000000000048A: mov rax,qword ptr [mono_aot_EmptyGame_llvm_got+0C8h]
...
00000000000004C1: call p_3_plt_EmptyGame__jit_icall_mono_generic_class_init_llvm
00000000000004C6: jmp 000000000000048A
decode_patch_info () would not decode patches if their corresponding GOT entry
was already set, causing half initialized MonoJumpInfo entries to be returned
to callers. Set the type of the MonoJumpInfo entry to MONO_PATCH_INFO_NONE
in these cases, and have the callers handle it.
Co-authored-by: Zoltan Varga <[email protected]>
When stepping out of a c# breakpoint into the runtime (or JS... Not sure if that's accurate),
multiple single step requests can be created when the breakpoint is hit again. In order to handle this scenario for wasm,
we just cancel the existing one.
NOTE: The debugger args addition seemed a better way to handle this than outright canceling in debugger-engine. If there
are implications to doing this, I can take it out.
Use -j with all example make invocations, mention Ninja dependency, mention raising ulimit, recommend py3 for running the server (when using py2, the port isn't properly released).
* [merp] MONO_DEBUG=no-gdb-stacktrace shouldn't disable MERP
Only prevent `gdb` or `lldb` from being invoked.
MERP is controlled by separate mechanisms --- configure flags for crash
reporting and an explicit opt-in icall.
The existing code collects crashed process data in-process, but it writes the
data out (using mono_merp_invoke) in the forked child process. This is a bit
surprising, but in the interest of not disturbing the code too much, this PR
doesn't change that. We should revisit `dump_native_stacktrace` again in the
future and rationalize these decisions.
Addresses https://github.com/mono/mono/issues/18565
* [interp] Enable virtual calls to compiled code
If we have an aot-ed version of a method we should always go through it, because the IL for that method could be stripped.
* [interp] Disable jit call for wrappers
Some generic wrappers don't seem to work in mixed mode, probably due to the fact that the transition already reuses a gshared wrapper.
Assume we have the following form `MyForm`:
```
using System;
using System.Drawing;
using System.Windows.Forms;
namespace test_TreeView
{
public class MyForm : Form
{
TreeView treeView = new TreeView()
public MyForm()
{
treeView.Nodes.Add("root node");
treeView.Nodes[0].Nodes.Add("first child node");
treeView.BackColor = Color.Gray;
treeView.LineColor = Color.Yellow;
treeView.DrawMode = TreeViewDrawMode.OwnerDrawText;
treeView.DrawNode += treeView_DrawNode;
Controls.Add(treeView);
}
private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
var brush = new SolidBrush(Color.FromArgb(100, 255, 0, 0));
e.Graphics.FillRectangle(brush, e.Bounds);
}
}
}
```
The displayed result is

One can see couple drawing issues:
* White rectangles under each `TreeNode`.
* The area of custom drawing (red rectangles) is shifted with respect to this white rectangles.
Current PR proposes the fix of this issues.
Co-authored-by: monojenkins <[email protected]>
* Fix Return handling. Ensure correct ClientSize.
When pressing Return / Enter, ensure any target button is both visible
and enabled.
In CreateHandle(), ensure the ClientSize is correct if set. If not,
update it to make it right. Suspend layout while changing it so that
child controls with anchors other than Top Left are not moved.
* Select active control. PerformLayout after updating for client size.
Select the active control with SendControlFocus to avoid upsetting what
is currently selected.
* Improve Form window decoration adjustment handling
Reverts the incorrect attempted fix contained in previous commits.
Basically, when a property is changed that affects window decorations,
ensure the client size stays the same.
* Use UpdateFormStyles on FormBorderStyle too.
When the user types a letter or digit, KeySearch looks for and selects
an item starting with that character. However, it should not if
SelectionMode is None.
* [WinForms] Make `ContextMenuStrip` behavior closer to the reference one
* Bump API snapshot submodule
Co-authored-by: monojenkins <[email protected]>
I've implemented a heap of missing RTF and RichTextBox stuff, and also made some improvements or fixes to various aspects of it. I'm sorry this is so big...
To give an overview of the changes, here's a list:
- Removed the RTF Charcode / Charset handling that wasn't actually used, had a lot of missing functionality and was basically reimplementing character encoding handling, and replaced it with ensuring the correct character encoding is being used (changing when needed).
- Improved RTF handling of objects with object results (process the given object result). Sometimes pictures can be like this.
- Improved line wrapping and alignment
- Added or greatly improved support for:
- paragraph spacing
- line spacing
- paragraph indents (left, right, hanging)
- tabstops (left, centre, right, decimal)
- text background colour (like highlighting)
- superscript / subscript
- character offset (vertical)
- text visibility
- Significantly improved RichTextBox RTF generation
- Cache DPI, rather than doing `CreateGraphics()` every time it is needed
- A variety of other fixes and improvements, with a few I can think of relating to:
- caret position
- replacing text
- invalidation and drawing
- when tags are added or deleted
BreakpointRequest commands can come out of order and before the runtime is ready (RuntimeReady). A null check for the DebugStore was added to guard against this since these requests seem to be for JS breakpoints. These seem to be able to be safely ignored.
Fixes https://github.com/mono/mono/issues/18584
Current versions of the mono return a null pointer as address of the first
element for empty arrays, i.e.
fixed (byte* ptr = new byte[0]) Console.WriteLine (ptr == null);
will print "true". This causes a problem in the UnixEncoding class where it
triggers a check for null pointers. Fix this by allowing null pointers when
the number of elements is zero.
Whenever mono opens an X11 window, the application opens a tcp socket for controlling the (non-tcp)-connection to X11. This is bad practice, as a tcp socket is not needed.
This pull request cleans the logic, by replacing the tcp socket with a fifo. That way this loopback connection is not visible from outside the .NET application, and all logic surrounding it should remain unchanged.
The real change here is, in `XplatUIX11.SetWindowPos()`, simply moving the `SendMessage` call to the end instead of earlier. The problem with it earlier is that any change in bounds from any of the bounds-related events (OnLocationChanged / OnMove, OnSizeChanged / OnResize, OnLayout, OnClientSizeChanged) will be overridden. When `SendMessage` is called, `UpdateBounds` is run, and that raises those events as relevant. After those events finish, `SetWindowPos` continues with setting the size of the window to the value originally specified – which is now potentially wrong. So send the message later on.
There is also no point that I can see in writing the values to `hwnd` twice, because as far as I can see the only one that can be changed is `hwnd.ClientRect` (set by `PerformNCCalc`).
Fixes#18524
The `tt.xml` and `tt_RU.xml` files were added in CLDR 34: http://cldr.unicode.org/index/downloads/cldr-34
Upgrading to v34 (or the latest v36) introduced a larger number of new cultures. I went with the smallest change possible to have Tatar added.
Fixes#18554 by making autoconf actually check if `-mminimal-toc` works instead of assuming on powerpc. Tested with FreeBSD 12.x and 13.x on powerpc64 ELFv2.
While we are in here, also enable BTLS which has passed testing.
* Validate the address that came from IDE using PointerValue. The IDE can send an invalid address and it was crashing mono.
Fixes#18191Fixes#15612
Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
* [wasm] Fix netcore build.
Add a DOTNET_REPO_DIR variable to Make.config which should point to the dotnet/runtime repo. Compile
the netcore runtime and corelib from this repo.
* Disable wasm+netcore on CI.
compile-runtime-tests is looking for python3, but $(env python3) will return error (no `/usr/local/bin/python3`); if this is the case, create a symlink from 3.6 or 3.7 to /usr/local/bin/python3 so it works. We already have this listed in `SHEBANG_FILES` for the port.
Found more occurrences of the typos in dotnet/runtime#2061
The work done here is made by simple search & replace.
I'll point to replaces that needs attention in a review.
Co-authored-by: Youssef Victor <[email protected]>
- roslyn's shared compiler server hashes it's pipename on the path to
the assembly.
- On macOS, this looks like `/Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Roslyn/VBCSCompiler.exe`
- When installing a new mono, with that same `x.y.z` version, this
process will effectively be out of sync with the new updated
mono/msbuild/roslyn
- This manifests as:
```
Using shared compilation with compiler from directory: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Roslyn
/Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Roslyn compiler server reports different hash version than build task. [/Users/builder/azdo/_work/3/s/xamarin-android/build-tools/xaprepare/xaprepare/xaprepare.csproj]
```
- See https://github.com/xamarin/xamarin-android/pull/4108
- So, we kill any running roslyn shared compiler servers
* If a thread was suspended and doesn't have any managed stack, it was considered as terminated, but it wasn't really terminated because it can execute managed code again, and stop in a breakpoint so if the execution arrives in debugger_agent_breakpoint_from_context we reset the flag terminated to FALSE.
* Adding terminated = FALSE in single_step_from_context.
This causes an additional dependency of mono on libintl which we didn't have before.
Reported by a user on gitter, it's problematic on macOS since it makes the mono binary depend on the libintl we ship in the Mono .pkg.
It was introduced in Mono 6.6 by https://github.com/mono/mono/commit/18e0ebfe89be0a175d2f904b9bb1ec6816daa318
[prof] remove wrong cast for format string
Fixes this warning:
```
CC mprof-report.o
mprof-report.c:408:62: warning: format specifies type 'char *' but the argument has type 'guint64' (aka 'unsigned long long') [-Wformat]
snprintf (format, sizeof (format), "%s : %%" PRIu64 "\n", (guint64)key_format);
~~ ^~~~~~~~~~~~~~~~~~~
%llu
/Applications/Xcode112.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro
'snprintf'
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
^~~~~~~~~~~
```
mistake in refactoring commit https://github.com/mono/mono/commit/07402062541fa9555bef99dbaac84cfb587926cd#diff-c825627ea9ddb3fa753fa3617eaec7c8R408
* [aot] fix warnings on linux (gcc 8.3.0)
Fixes these warnings:
```
aot-compiler.c: In function ‘emit_trampolines’:
aot-compiler.c:7675:28: warning: ‘_e’ directive writing 2 bytes into a region of size between 1 and 256 [-Wformat-overflow=]
sprintf (end_symbol, "%s_e", symbol);
^~
aot-compiler.c:7675:4: note: ‘sprintf’ output between 3 and 258 bytes into a destination of size 256
sprintf (end_symbol, "%s_e", symbol);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
aot-compiler.c:753:1: warning: ‘link_shared_library’ defined but not used [-Wunused-function]
link_shared_library (MonoAotCompile *acfg)
^~~~~~~~~~~~~~~~~~~
aot-compiler.c:558:1: warning: ‘mangle_symbol_alloc’ defined but not used [-Wunused-function]
mangle_symbol_alloc (const char * symbol)
^~~~~~~~~~~~~~~~~~~
aot-compiler.c:535:1: warning: ‘mangle_symbol’ defined but not used [-Wunused-function]
mangle_symbol (const char * symbol, char * mangled_symbol, gsize length)
^~~~~~~~~~~~~~~~~~~
```
* [amd64] fix warnings on linux (gcc 8.3.0)
Fixes this warning:
```
tramp-amd64.c: In function ‘mono_arch_create_generic_trampoline’:
tramp-amd64.c:242:65: warning: variable ‘ex_offset’ set but not used [-Wunused-but-set-variable]
int i, lmf_offset, offset, res_offset, arg_offset, rax_offset, ex_offset, tramp_offset, ctx_offset, saved_regs_offset;
^~~~~~~~~
```
* [lldb] fix warnings on linux (gcc 8.3.0)
Fixes these warnings:
```
lldb.c:243:1: warning: ‘buffer_add_buffer’ defined but not used [-Wunused-function]
buffer_add_buffer (Buffer *buf, Buffer *data)
^~~~~~~~~~~~~~~~~
lldb.c:215:1: warning: ‘buffer_add_id’ defined but not used [-Wunused-function]
buffer_add_id (Buffer *buf, int id)
^~~~~~~~~~~~~
lldb.c:208:1: warning: ‘buffer_add_long’ defined but not used [-Wunused-function]
buffer_add_long (Buffer *buf, guint64 l)
^~~~~~~~~~~~~~~
lldb.c:188:1: warning: ‘buffer_add_short’ defined but not used [-Wunused-function]
buffer_add_short (Buffer *buf, guint32 val)
^~~~~~~~~~~~~~~~
```
* [interp] fix warnings on linux (gcc 8.3.0)
Fixes these warnings:
```
interp/interp.c:3425:1: warning: ‘g_error_xsx’ defined but not used [-Wunused-function]
g_error_xsx (const char *format, int x1, const char *s, int x2)
^~~~~~~~~~~
CC interp/libmono_ee_interp_la-mintops.lo
CC interp/libmono_ee_interp_la-transform.lo
CCLD libmono-ee-interp.la
ar: `u' modifier ignored since `D' is the default (see `U')
CC libmono_dbg_la-debugger-agent.lo
CC libmono_dbg_la-debugger-state-machine.lo
CC libmono_dbg_la-debugger-engine.lo
CCLD libmono-dbg.la
ar: `u' modifier ignored since `D' is the default (see `U')
CCLD mono-sgen
AR libmain.a
ar: `u' modifier ignored since `D' is the default (see `U')
CC interp/libmaintest_a-whitebox.o
In file included from interp/whitebox.c:3:
interp/transform.h:163:12: warning: ‘stack_type’ defined but not used [-Wunused-variable]
static int stack_type [] = {
^~~~~~~~~~
interp/transform.h:155:20: warning: ‘stack_type_string’ defined but not used [-Wunused-variable]
static const char *stack_type_string [] = { "I4", "I8", "R4", "R8", "O ", "VT", "MP", "F " };
^~~~~~~~~~~~~~~~~
```
* [thread state] fix warnings on linux (gcc 8.3.0)
Fixes these warnings:
```
CC libmonoutils_la-mono-threads-state-machine.lo
mono-threads-state-machine.c:33:1: warning: ‘get_thread_no_safepoints’ defined but not used [-Wunused-function]
get_thread_no_safepoints (int thread_state)
^~~~~~~~~~~~~~~~~~~~~~~~
mono-threads-state-machine.c:26:1: warning: ‘get_thread_suspend_count’ defined but not used [-Wunused-function]
get_thread_suspend_count (int thread_state)
^~~~~~~~~~~~~~~~~~~~~~~~
```
* [domain] fix warnings on linux (gcc 8.3.0)
Fixes these warnings:
```
appdomain.c:2415:1: warning: ‘get_app_context_base_directory’ defined but not used [-Wunused-function]
get_app_context_base_directory (MonoError *error)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC libmonoruntimesgen_la-assembly-load-context.lo
CC libmonoruntimesgen_la-domain.lo
domain.c:135:1: warning: ‘mono_domain_alcs_lock’ declared ‘static’ but never defined [-Wunused-function]
mono_domain_alcs_lock (MonoDomain *domain);
^~~~~~~~~~~~~~~~~~~~~
domain.c:138:1: warning: ‘mono_domain_alcs_unlock’ declared ‘static’ but never defined [-Wunused-function]
mono_domain_alcs_unlock (MonoDomain *domain);
^~~~~~~~~~~~~~~~~~~~~~~
domain.c:2129:1: warning: ‘mono_alc_free’ defined but not used [-Wunused-function]
mono_alc_free (MonoAssemblyLoadContext *alc)
^~~~~~~~~~~~~
domain.c:2108:1: warning: ‘mono_domain_create_default_alc’ defined but not used [-Wunused-function]
mono_domain_create_default_alc (MonoDomain *domain)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
domain.c:2084:1: warning: ‘create_alc’ defined but not used [-Wunused-function]
create_alc (MonoDomain *domain, gboolean is_default)
^~~~~~~~~~
```
* [native library] fix warnings on linux (gcc 8.3.0)
Fixes this warning:
```
CC libmonoruntimesgen_la-native-library.lo
native-library.c:295:1: warning: ‘mono_loader_register_module_locking’ defined but not used [-Wunused-function]
mono_loader_register_module_locking (const char *name, MonoDl *module)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
* [sample] fix warnings on linux (gcc 8.3.0)
Fixes this warning:
```
CC libtestlib_la-test-mono-embed.lo
In file included from test-mono-embed.c:7:
../../samples/embed/teste.c:20:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
gimme () {
^~~~~
```
* fix for checked builds
* [runtime] NOHANDLES for ves_icall_System_Threading_Thread_GetCurrentThread
This function (and its call to mono_handle_new) was showing up in the
flamegraph for some async-heavy benchmarks
HashTableTests.Ctor_Int_Int_GenerateNewPrime and BitConverterTests.ToString_ByteArrayTooLong_Throws allocate a lot of memory and this causes issues on Windows i386 and other platforms.
* Do not `printf` `long long` or `unsigned long long`.
*Do* printf `gint64` or `guint64`.
Do not printf %ll.
Do not printf %z.
gint64 == int64_t, which could be long, or long long, or maybe other
guint64 == uint64_t, ditto
For printing gint64/guint64, use PRId64, PRIx64, etc.
For printing gsize/gssize, use `G_GSIZE_FORMAT` (seems like excess `G`).
%z definitely would warn for every single use, with Mingw.
And %ll might also, since on 64bit platforms, gint64 tends to be
long, not long long, and would merit %l not %ll.
(No matter that %ll is merited on 32bit, and the behavior
would then be correct on both.).
If there becomes a system w/o PRId64 etc., and it is a 64bit system,
then we could use %l under a portable name.
Or %I64. This appears unlikely (unless reach is extended to older Windows runtime).
Note that PRIxPTR for gsize/intptr_t may be a good idea too.
CoreCLR has a managed cache surrounding this, but for the moment the naive implementation will suffice. We can later move their managed cache to shared on top of this PR with minimal trouble.
We can't guarantee the id will be [0..CpuCount) for a variety of reasons, and a followup PR to the dotnet docs will clarify this. I've chosen not to intentionally add an offset, but no one should be relying on that behavior, and if someone thinks adding an offset would drive the point home the perf cost is irrelevant.
* [sgen] Don't subtract twice the nursery size from max_heap_size
We were subtracting the nursery size when initializing max_heap_size as well as adding it to the allocated_heap when allocating the nursery (alloc_nursery).
* [sgen] Trigger collection if failing to allocate los section
If the memory governor says we are exceeding the max_heap_size by allocating a los section (1MB) for a new los object, attempt to clear some space by triggering a major collection, before completely bailing out.
There are pluses and minuses here:
+ Minimize externC.
+ Maximimze typesafe linkage.
- Minimize configuration-sensitivity.
- Maximize commonality across all configurations, so that
success in one configuration maximally but not 100% implies
success in others (which is why to avoid `#if` in general,
to contribute toward compilation success).
+ Use higher level macros to explain reason.
Even if ICALL_EXTERN_C was always externC (presently not),
using it instead of plain G_EXTERN_C offers a builtin comment.
Add mono_gc_thread_detach callback for Boehm
Use under Boehm to detach without threads lock as Boehm will take it's own lock internally.
Note in `on_gc_notification` we take threads lock after Boehm already has it's own lock. For consistency and to prevent deadlocks always take lock ordering of Boehm then threads lock.
* [cxx] dlmalloc remove extern "C" and remove NO_MALLINFO.
* [cxx] Move CallInst bitfields to the end to minimize padding for alignment
and fix an unexplained LLVM problem.
1. Update `build.sh` to use `--enable-checked-build=private_types` which forces the use of getter methods to access `MonoClass` fields.
2. Fix up some places that were accessing MonoClass directly.
3. Get rid of a spurious comma operator usage from an earlier refactoring:
```c
z = a, b, c;
```
is the same as
```c
z = a; b; c;
```
which is the same as just `z = a;` if `b` and `c` have no side-effects.
GroupBox's GetPreferredSize() is not great. I've simply copied the code from Panel, and used that. It uses LayoutEngine.GetPreferredSize(), which does things a lot better than the code this used.
Previously, if the Label wasn't quite high enough nothing would be drawn as the line didn't quite fit. It should draw the line anyway, clipped if necessary.
- Ignore key events with vkey == 0. They won't match a real key code so don't try. Besides, trying can cause segfaults on ChromeOS Linux mode.
- Check special-case keys (numpad) before looping to get them. No point leaving them for afterwards...
- Make the state of Control.CanSelect depend on whether the control is visible and enabled.
- When setting Control.Visible to false, if this control is focused, move the focus to the next control.
Fixes https://xamarin.github.io/bugzilla-archives/20/20233/bug.html
Previously, on Linux, setting Control.Region just set the clipping for painting, but didn't influence the visibility of other controls behind the one it was set on. This implements this correctly via X11 Shape extension.
Two small fixes to X11 keyboard handling here:
- For Xutf8LookupString, use the actual buffer size rather than the starting buffer size. Using the previous fixed size made the buffer overflow handing code immediately after the change pointless.
- For XLookupString, handle similar to Xutf8LookupString, getting a byte array. The old was sometimes causing problems where input on the numeric keypad didn't enter text. I believe using a StringBuilder similar to how it was _should_ work, but for some reason I could not get it to work reliably. So I changed it to this, which seems to work well for me. The only question I have is whether it should be Encoding.ASCII like I used, Encoding.Default, or another specific encoding.
- Use alternative names as a fallback if present.
- Use the untagged name (\fname, name that doesn't
identify charset ) if present.
- Use font codepage or charset correctly to get the correct encoding.
Rip out the old nonfunctional RTF charset handling.
This was not used, and furthermore was fundamentally flawed.
I have replaced it by simply using the correct text Encoding, mentioned
above.
CharCount / length was inconsistent about counting line endings. Fixed
to include them all, as that was much easier than the other way.
When shortening a wrapped line, it is necessary to start the recalculate
at the previous line, in case the wrap point has changed.
In CharIndexToLineTag, if there is a line boundary at the specified
index, return the line starting at the index.
Fixed a few other things too.
RTF paragraph controls override earlier instructions, rather than
keeping the maximum.
Emit \nosupersub between superscript and subscript text. Missing it out
technically gives a superscript (or subscript) of the subscript (or
superscript), which is not what we want.
rather than keeping the maximum.
* RTF.cs: Add support for JPEG and EMF pictures.
Allow for attribute etc. groups inside the picture group.
* Line.cs: In InsertString, ensure that the tag passed in is currently
in the line – not necessarily valid when the passed tag is the
cursor, for instance.
* LineTag.cs: Only break tags for formatting when needed.
* TextControl.cs: Fix invalidating text that isn't left-aligned.
Fix caret stuff:
Positioning after the line ending no longer happens
Up and down when not left-aligned
Tag used when moving left to start of line
Page up / down
Remove empty tags when navigating away from them
Change tag background draw location – I think it is a correction!
When inserting at a position without being given the tag, choose an
empty tag at that position if one exists.
Change ReplaceSelection order back (corrected some formatting and
similar stuff), and format the new text to match the tag.
Change IncrementLines to transverse the tree (using a new function)
rather than repeatedly call GetLine.
* RichTextBox.cs: Don't streamline the line in case it removes tags we
want to keep – we'll skip them ourselves instead.
Emit pictures.
* TextBoxBase.cs: Remove redundant check – a previous check means
value != acutal_border_style, therefore at least one of them !=
BorderStyle.Fixed3D, therefore the if condition was always true.
The dpi isn't likely to change during the lifetime of the object, so is relatively safe to cache.
Creating a Graphics object each time the dpi is wanted when reading RTF is also rather silly performance-wise.
Even worse, when generating RTF it can cause a recalc, which can mean that some lines <= end_line don't exist.
In GenerateRTF, check tag != null before trying to generate anything based on it. Not sure
why it hasn't been a problem before, but either way I was getting NullReferenceExceptions
because of it today.
Run ContentSizeChanged() when either width or height changes, irrespective of Multiline status.
This fixes various problems with stuff jumping around vertically.
Correct ContentSizeChanged to consider the left and right margins instead of the left margin twice.
Was probably a typo at an earlier stage, otherwise would have been a * 2.
* LineTag.cs: Added support for visibility. Corrected handling of tabs
and added tabstop support.
* RichTextBox.cs: Added support for text visibility, indents,
tabstops.
* TextControl.cs: Make invisible text work correctly. Fixed a bug with
tag backcolor. Added support for indents.
Native methods can be run in gc safe mode, meaning we can be in gc safe mode while setting/getting the arguments for a native transition. Call context computation requires us to be in unsafe mode.
Fixes https://github.com/mono/mono/issues/16969
[memory barrier] use pagesize determined by helper
`limits.h` doesn't always define `PAGESIZE` properly (e.g. iOS), so it would fall back to `0x1000` (4096) but it's really `0x4000` (16384) on iOS. We already have a helper in the runtime to determine the pagesize, so let's use that instead.
Fixes https://github.com/mono/mono/issues/18273
This was prompted by https://github.com/mono/mono/issues/18339, which seems to be failing to locate a native library and then hitting an assertion. We should propagate the error instead, so that if others run into something similar they can see what's actually going wrong instead of just getting a runtime crash.
The base image appears to have perl5.26 which conflicts with perl5-5.30, resulting in the /usr/local/bin/perl binary not being placed by perl5-5.30, which results in failed builds. The `perl5.26` appears to be part of the base image and has no packages actually dependent on it.
* [sgen] Include also derived classes as bridges
When using `MONO_GC_DEBUG=bridge=` debug option
* [sgen] Fix xref computation with tarjan bridge
Between C# and java (on android) there are objects that live on both worlds. This means that there exists a C# object with a corresponding java object. The relationship between them is strong, meaning if C# object is alive then java object must stay alive, and vice-versa. We keep java bridge objects always alive through a GCHandle (on the java gc). When doing a C# collection we select all bridge objects that appear to be dead on the C# side. These objects are candidates for collection, assuming the java side has nothing against it. Before triggering a collection on the java side (following the mono gc) we switch all the strong gchandles to the java objects to be weak (for these objects that are candidate to be collected) and we recreate the reference graph from the C# side to the java side (if C# Bridge1 can reference C# Bridge2 then, on the java side, we add a reference from Java Bridge1 to Java Bridge2; this is done by adding to an array of references inside Java Bridge1). In order to minimize the amount of work that needs to be done on the java side, we compute the minimal amount of references that need to be added, by computing the strongly connected components of the object graph.
An optimized way to construct the SCCs and the xrefs is by using the tarjan algorithm (https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm). Our algorithm is non recursive (scan_stack emulates the recursive order of traversal in a dfs algorithm, while loop_stack is the stack used by the algorithm). A color represents an SCC. We have some optimizations in place where we might merge colors if they don't contain bridges, since the client only cares about SCCs containing bridge objects and the links between them. color_merge_array is used to keep track of all neighbors of a node until we are creating the scc for that node. It is populated when scanning all the refs inside an object (compute_low). All the colors in the color_merge_array will be cross references with that scc.
Before this commit we were only clearing the color_merge_array when creating an SCC. This is problematic because we could end up with xrefs inside of an SCC that belong to another SCC. Consider the simple graph of nodes 0,1,2,3 where 0 <=> 2, 0->1, 2->3. Assume we start scanning with node 0. When creating the SCC for node 3 the followed path is 0 -> 2 -> 3, while the loop stack will contain (0,1,2,3). After creating SCC for node 3, we will finish scanning node 2 which would detect the xref to Bridge3, which would have been added to the color_merge_array. Because node 2 is not the root of the SCC it belongs to (its lowlink points towards node 0 which has a lower index), we are not creating an SCC with it, and the link to node 3 remains in color_merge_array. Because the next node from the scan_stack is node 1, which is also the root of the SCC that it belongs to, we will create an SCC for it and wrongly add the node 3 reference from color_merge_array to it. In order to fix this issue, we will always clear the color_merge_array once we finished scanning the xrefs for a node. If the node in question is not the root of an scc, then we will remember them as xrefs pointing out from this object. When we finally reach node 0 (which will be the root of the SCC containing nodes 0 and 2), we will then know that all xrefs for this color are the union of the xrefs of all objects belonging to this color (which represents the objects that we are popping from the loop_stack until we encounter the root node).
Even though this change adds required bookeeping for xrefs, I didn't notice any change in performance on the bridge tests that we have in mono/tests.
* [sgen] Some logging improvements in tarjan bridge
* [sgen] Disable optimization when comparing bridge outputs
When this optimization is enabled, the tarjan bridge will create more SCCs in order to reduce amount of xrefs in the graph. This would render the `bridge-compare-to` debug flag unusable with tarjan bridge.
* Set thread pool thread name just based on string pointer check.
When the generation-based solution went in, there were not
yet constant thread names, so a pointer based approach could fail
due to reuse. We can do slightly simpler now.
* Remove the generation field which is no longer needed.
Remove the duplicated knowledge of how to set a constant and put
it behind a funny sounding but perhaps reasonable flag.
Revise corlib version.
* Add SignedCms to the typeforwards in the System.Security.Cryptography.Pkcs facade
* Added additional missing types from System.Security.Cryptography.Pkcs.
* It would be nice if the files I added had namespaces ;-)
* Bump API snapshot submodule
* [csproj] Update project files
Co-authored-by: monojenkins <[email protected]>
Fixes https://github.com/mono/mono/issues/18323
* [System.Private.CoreLib] Cleanup intrinsic tracking
1. Removed icalls where intrinsic version for the method exists
2. Add [Intrinsic] attribute to methods which have runtime intrinsic
to make them easier to track and to tell linker not to analyze them
3. Use recursive syntax for any intrinsic which can be called via
reflection to correctly apply the intrinsic when invoked.
```c#
public static bool IsSupported { get => IsSupported; }
```
When one calls X86.IsSupported, the call gets replaced by an
intrinsics. When one calls it with an Invoke, the body of IsSupported
gets replaced by intrinsics. It's just a hack to get Invoke support for free.
* [interp] implement System.Type::op_Equality
* Undo changes which are not yet supported by interpreter
* [interp] Implement System.Runtime.CompilerServices.RuntimeHelpers::OffsetToStringData
Co-authored-by: Bernhard Urban-Forster <[email protected]>
* [jit] Avoid passing a vtable argument to DIM methods when making calls out of gsharedvt methods.
Fixes https://github.com/mono/mono/issues/18276.
* Fix compilation with mcs.
* [metadata] Size 0 Blob heap is ok when resolving assembly refs
Sometimes ILasm can produce images with a Blob heap of size 0. In cases where
we're loading assembly references from such an image, the hash (which is
optional) can be at index = 0 and the Blob heap size is also 0.
Also: add the hash value to the output of `monodis --assemblyref`
* [metadata] Add a separate assertion for the index == size == 0 case
And a comment explaining how it is likely to be triggered. If the assembly is
reasonable the caller of mono_metadata_blob_heap should be updated to use
mono_metadata_blob_heap_null_ok instead
* [bcl] Allow Mono's ILASM to produce a size 0 Blob heap
ECMA 335 II.24.2.4 says that the user string and blob heaps should have an
entry at index 0 consisting of the single byte 0. However .NET Framework (and
.NET Core) ilasm will entirely omit the Blob heap (that is, create a blob heap
entry of size 0) if it is not needed. This PR changes Mono's ILASM to emit the
initial byte on demand only if one of the MetaDataStream.Add() methods is
called. Otherwise we will also emit a stream of size 0.
This is needed to compile some test cases.
* [tests] Add regression test for loading assemblies with size 0 Blob heap
Depends on ILASM that can emit a size 0 Blob heap
* [loader] Rename assembly name check strictness flag
* [loader] Add predicate for assembly name matching on netcore
* [loader] Enable LoadInDefaultContext test
* Make mono_assembly_names_equal external, change flags in domain search
* Move ifdef inside mono_loader_get_strict_assembly_name_check
* Fix pedump
* No reason to make this external
* Feedback
-> throw in a async task with a try catch in the caller -> don't stop
-> throw in a new thread with a try catch in the caller -> stop
-> throw in the main thread without any try catch -> stop
Including a new test to test the fix of #17601.
Fixing #16588, create a while 1 to stops the program execution when an exception is thrown and no try catch is found and MONO_DEBUG=suspend-on-unhandled.
Fixes#17601Fixes#16588
Also when iterating over the runtimes, actually look at the current element,
not the first element.
Also mention the unsupported runtime version in the warning message when it is
passed to mono_init_internal.
Fixes https://github.com/mono/mono/issues/17916
They cannot deal with large test assemblies so we need to split them.
We're doing this by introducing a new `#skip <PROFILE>` directive in the .sources format which defines where to split the assembly.
The logic is very simple: files up until the first `#skip` are common files which get included in each part, subsequent files are only in the respective part assembly.
Fixes https://github.com/mono/mono/issues/18213
This assert fails when the trampoline code size worst case is realized.
Observed on a Android device with HWASan [1] enabled, where heap
addresses have a non-zero tag in the most significant byte, and thus
require 4 instructions to materialize in emit_imm64.
[1] https://source.android.com/devices/tech/debug/hwasan
Remove handles/MonoError from some marshal icall functions.
This does some small other things.
In particular, if a function is not static for some platforms, make it not static for all.
static historically was valuable, because of default linker semantics around visibility.
I believe it is less important now, since visibility is default constrained.
Also being consistent across platforms seems good.
Maybe split off a separate PR for that.
* [Wasm] Enable dynamic runtime tests
- Add dynamic runtime browser tests in CI
- Change `release-dynamic` to `dynamic-release` to align with other runtimes
- Add `-dynamic-runtime` flag for packager.exe
- Add debug configuration for dynamic runtime
- Fix invalid MAIN_MODULE=2 flag, which forces the emscripten linker to pass even on exported functions.
Fix locating Python interpreter when it isn't "python"
The "python" interpreter is specified by PEP-394. In it, an OS
can decide not to ship a "python" executable, and instead only
ship python2/3, providing some ambiguity for scripts that are
version-neutral, like the one Mono uses.
This uses an automake macro to locate a suitable Python, and
changes the makefile to use the located Python, whatever it may be.
A compiler barrier generates no code.
It "only" inhibits certain compiler optimizations, which I do not consider
particularly worrisome, as most code is "fully" optimized, and
compiler barriers are relatively rare.
It could be a concern in code paths that greatly benefit
from compiler optimizations and for which barriers greatly
inhibits the compiler.
I would further suggest, though it is not here, that any compiler
half barrier (read, write) be a compiler full barrier instead,
as they sound pretty cheap, so simplify.
Similar cannot be said about CPU barriers.
They do not always generate code, but when they do, it can cost.
This is follow-up from https://github.com/mono/mono/pull/17849#issuecomment-556273801https://github.com/mono/mono/pull/17849#issuecomment-557661604.
* [cominterop][test] Calling QueryInterface from an unattached thread asserts
If we pass a managed COM object to native code and the native code calls one of
the IUnknown methods, we assert because the thread is not attached but we want
to enter GC Unsafe mode.
* [cominterop] Attach to runtime from IUnkown and IDispatch methods
If the COM objects for a managed object is passed to a thread that hasn't
interacted with Mono before, we need to attach before doing GC thread state
transitions.
Addresses https://github.com/mono/mono/issues/18137
* [test] Call managed method through COM wrapper from unattached thread
This works, but I don't think we had a test previously. Call a managed method
via a COM interface from a thread that is not attached to the runtime, to
ensure that it is attached.
* Relax faultcode parsing for Soap11 message errors.
The mono implementation was reading the faultcode content as an XmlQualifiedName, which applied the rule where you could not
start a name with a number. This caused interoperability problems with the .net framework because their parsing just looks
for <namespace>:<name>, where name can be any string.
Example:
<faultcode>s:1</faultcode>
On mono, a soap response that contains a fault code name of 1 will throw an error. If you run the same code on the .net framework, it will not.
Fixes https://github.com/mono/mono/issues/12995
* [csproj] Update project files
* [wasm] Add linker substitutions in netcore mode.
* Enable non-netcore mode as well.
* Disable conditionals which are not true in threaded mode for now.
I don't remember why this wasn't enabled originally, but it seems to be passing now. I probably accidentally fixed it back when I made changes to our assembly name parsing.
Also partial undo recent and append _icall to end.
This is verbose, but maybe worthwhile to aid search.
This is extracted from https://github.com/mono/mono/pull/17978.
On Linux, neither flag being specified will result in a default of RTLD_LOCAL. Unfortunately, on MacOS it's the opposite - the default is RTLD_GLOBAL. This means currently there is no way to set RTLD_LOCAL on Macs, so despite the potential for this to break someone it directly contradicts our documentation and needs to be changed.
After https://github.com/mono/mono/pull/18040 we now have InternalsVisibleTo for the Mono.Android assembly.
This exposed the internal LogLevel enum in BCLDebug which causes an issue when consumed in XA:
```
Java.Lang/Object.cs(119,18): error CS0104: 'LogLevel' is an ambiguous reference between 'Android.Runtime.LogLevel' and 'System.LogLevel'
```
To fix this we rename the internal enum in corlib since it's not really used.
This can lead to problems on big endian.
```
result.i = (int) 1;
--> 0x0000_0001_XXXX_XXXX;
result.l = (long) 1;
--> 0x0000_0000_0000_0001;
```
On little endian it's always `0x0000_0000_0000_0001`, so it doesn't matter.
* [utils] Make mono_dl_open default to RTLD_LOCAL
The exception is for fallback handlers added via the embedding API, in which case we convert the flags over to preserve legacy behavior
* Convert flags properly for embedding API use
* Changes
* Turn off -fvisibility=hidden temporarily
TESTING
* Undo some previous crimes, maybe fix failure
* Leave legacy mono unchanged, defaulting to RTLD_GLOBAL
* [mini] Fix delegate trampoline virtual call via delgate Invoke
If we need to jit the Invoke method of a delegate, we get tramp_info with a
NULL method.
Background: normally when we create a delegate around a virtual method,
handle_delegate_ctor will just create a virtual invoke trampoline with
mono_arch_get_delegate_virtual_invoke_impl which doesn't get here. But if
we're asked to compile the delegate's Invoke method, then compile_special ()
will create a tramp_info with a null method, and return a delegate trampoline.
That's the case here - we had
var del = SomeDelegate(obj.VirtualMethod);
var invoke_method = del.GetType().GetMethod ("Invoke");
invoke_method.Invoke (del, args);
or
var del = SomeDelegate(obj.VirtualMethod);
var another_del = OtherDelegate (del.Invoke);
another_del (args);
in both cases, we end up in mono_delegate_trampoline with tramp_info->method ==
NULL.
in the second case the IL is like this:
newobj instance void Derived::'.ctor'
ldvirtftn instance void class Base::VirtualMethod()
newobj instance void class SomeDelegate::'.ctor'(object, native int)
So delegate->target is a derived instance but delegate->method is some base
class method.
Addresses https://github.com/mono/mono/issues/17718
* [tests] Add tests for compiling delegate's Invoke method
Where the delegate calls a virtual method
* [WinForms] Fix wrong behavior when calling ComboBox.Items.RemoteAt() with index equals to SelectedIndex
* [WinForms] Fix#10643 No event should be triggered when calling ComboBox.Items.RemoteAt()
Fixes#10643
Add the ability to initialize a `WebAssembly.Net.WebSockets::ClientWebSocket` from `System.Net.WebSockets.ClientWebSocket`.
`System.Net.WebSockets.ClientWebSocket` will delegate all calls to the WebAssembly ClientWebSocket.
- Add support for marshaling `Uri` class correctly. This was a cause of failures.
- Add bindings tests for `Uri` marhaling.
* Add some missing barriers when dealing with global caches
accessed from multiple threads without locks.
This is based on earlier PR https://github.com/mono/mono/pull/17849.
Read-side barriers are removed.
More analysis is needed to determine if they are needed (which pointer
read vs. written).
Write-side barriers are compiler barrier + store-release instead of full barrier.
Note all candidates are converted to new form yet.
Cases that do motivate read-wide barriers are skipped.
e.g.
`mono_arch_start_dyn_call`
`get_agent_domain_info`
`init_jit_info_dbg_attrs`
* PR: Remove 'Try one more time..'
* [utils] Add back mono_threads_attach_tools_thread
In https://github.com/mono/mono/commit/a5da7b21f4b6dbc5eaa09c2addee91b84dc1dbd5
we got rid of "tools" threads internally to the runtime.
However since the API was previously marked with MONO_API it was an internal
API that some embedders depended on.
This PR adds back an (external-only) limited form of tools thread.
The runtime is aware of the Tools thread in that FOREACH_THREAD_* macros will
iterate over them, and the thread has a coop thread state machine. (That is,
mono_thread_info_current() and GC Safe and GC Unsafe transitions all work.)
However the thread is:
1. Not stopped by the GC
2. Is not interrupted by profiler sampling.
3. Does not have a "current domain"
4. (As a consequence of the above) cannot call managed methods or touch managed
objects.
Such threads are useful for low-level interaction with the runtime such as
querying metadata, the JIT state and other coordination.
mono_threads_attach_tools_thread should be called no more than once. It should
not be called on a thread that is already attached with mono_thread_atach, and
vice versa.
Addresses https://github.com/mono/mono/issues/18011
* [threads] Make mono_threads_attach_tools_thread into a public API
[cxx] Remove use of register keyword.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm/19408/parsed_console/log_content.html
```
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
4 warnings generated.
```
Remove handles/MonoError from two socket icalls.
Ongoing removal of handles() icalls.
This is small, to pause and remove `mono_class_get_field_from_name_full` from w32socket.c.
* [netcore] Remove ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni and _len icalls.
They are implemented in C#.
The C# is equivalent to the C, and could be used for classic runtime, except for the treatment of large/negative lengths.
* Remove a few more icalls.
Instead of ifdef and leaving them uncompiled when compiling netcore,
declare them and put asserts in them.
* [amd64] align application stack pointer in signal handler
16byte stack pointer alignment is only required in certain places by the ABI, so the assumption that it holds all the time is wrong (though, it passed CI 😅). We have to setup the frame properly, i.e. we have to ensure the stack pointer is properly aligned. That's what we have done previously too.
Regression of https://github.com/mono/mono/pull/17922
Fixes https://github.com/mono/mono/issues/18006
* add ALIGN_DOWN_TO macro
* remove unnecessary ifndefs
Otherwise we'll run into issues because in configure.ac we update submodules _after_ we try to call external/bdwgc/configure (which won't be there if autogen.sh didn't run).
This would manifest itself as `*** No rule to make target 'all'.` in external/bdwgc when you build as there's no Makefile.
* [corlib] add InternalsVisibleTo for Mono.Android
Context: https://github.com/xamarin/xamarin-android/pull/3991
In Xamarin.Android, we have a bit of System.Reflection usage on
startup:
https://github.com/xamarin/xamarin-android/blob/bbbe2ed36e6eeb7cce0905dcbfdaeaa30754070f/src/Mono.Android/Android.Runtime/UncaughtExceptionHandler.cs#L47-L67
These methods are in `mscorlib.dll` and `internal`. If we had
`[assembly: InternalsVisibleTo ("Mono.Android")]` we could avoid the
System.Reflection.
This is already done for `Xamarin.iOS`, `Xamarin.Mac`, etc. so
hopefully it's OK to add one more?
We could then, just call these methods directly:
* `System.Diagnostics.Debugger.Mono_UnhandledException`
* `AppDomain.CurrentDomain.DoUnhandledException`
The results are possibly a 100-250ms improvement to startup:
Before:
12-03 14:27:51.450 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s727ms
12-03 14:27:57.310 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s723ms
12-03 14:28:03.216 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s703ms
12-03 14:28:09.054 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s679ms
12-03 14:28:14.953 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s711ms
After:
12-04 09:13:18.248 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s608ms
12-04 09:13:24.087 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s570ms
12-04 09:13:29.997 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s566ms
12-04 09:13:35.805 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s498ms
12-04 09:13:41.670 1876 1898 I ActivityManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +3s475ms
This was the Xamarin.Forms integration project in xamarin-android.
Running a `Debug` build on a HAXM x86 emulator on Windows.
https://github.com/xamarin/xamarin-android/tree/master/tests/Xamarin.Forms-Performance-Integration
* Bump API snapshot submodule
* [wasm] Modify to use -s USE_ZLIB=1 instead of zlib support headers
- This will remove the dependency on the mono zlib header files.
- Moves the zlibtest.cs to tests/src directory to help clean up the main directory.
* [wasm][packager] Remove the zlib headers from the zlib build
- use `-s USE_ZLIB=1` instead when building.
* [android] don't probe directories for .config files
In Xamarin.Android, on startup we see logging like this for every .NET
assembly:
12-03 14:27:42.104 26842 26842 D Mono : Prepared to set up assembly 'FormsViewGroup' (/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll)
12-03 14:27:42.104 26842 26842 D Mono : Assembly FormsViewGroup[0xebcee9c0] added to domain RootDomain, ref_count=1
12-03 14:27:42.104 26842 26842 D Mono : Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll'.
12-03 14:27:42.104 26842 26842 D Mono : Config attempting to parse: '/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll.config'.
12-03 14:27:42.104 26842 26842 D Mono : Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/sdks/out/android-x86-release/etc/mono/assemblies/FormsViewGroup/FormsViewGroup.config'.
In most cases, no `.dll.config` file exists and so it probes this
macOS-looking path:
/Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/sdks/out/android-x86-release/etc/mono/assemblies/FormsViewGroup/FormsViewGroup.config
It looks like this is happening because nothing in Xamarin.Android
calls `mono_set_dirs` or `mono_set_config_dir` and so it falls back to
using `MONO_CFG_DIR`. `MONO_CFG_DIR` is set to a path on the build
machine.
Even if Xamarin.Android *did* call `mono_set_config_dir`, the code
appends `mono/assemblies`:
cfg = g_build_filename (cfg_dir, "mono", "assemblies", aname, cfg_name, (const char*)NULL);
So it doesn't seem useful to use this fallback at all, there would
never be a file found.
I wrapped the appropriate code in `#ifndef TARGET_ANDROID` blocks.
I was able to see a minor *maybe* ~20ms performance improvement on
startup:
Before:
12-03 14:27:48.494 26903 26903 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:601::443900
12-03 14:27:54.356 26963 26963 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:587::495400
12-03 14:28:00.263 27021 27021 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:586::147100
12-03 14:28:06.135 27074 27074 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:593::639100
12-03 14:28:11.988 27129 27129 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:571::194900
After:
12-03 14:46:50.590 27737 27737 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:503::918700
12-03 14:46:56.517 27794 27794 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:570::533600
12-03 14:47:02.368 27850 27850 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:537::435000
12-03 14:47:08.289 27904 27904 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:587::830900
12-03 14:47:14.130 27965 27965 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:555::593400
This was the Xamarin.Forms integration project in xamarin-android.
Running a `Debug` build on a HAXM x86 emulator on Windows.
https://github.com/xamarin/xamarin-android/tree/master/tests/Xamarin.Forms-Performance-Integration
* Add --enable-minimal=cfgdir_config
* This also defines `DISABLE_CFGDIR_CONFIG`
* Used this setting for android
* Added Obsolete to AppDomain.CreateDomain for monodroid. The intent is to be helpful for when .NET 5 comes along
* Changed AssemblyLoadContext link to a better doc
* Bump API snapshot submodule
Fix security identifier parsing error with the following SDDL:
```
O:S-1-5-21-1356517589-3987021482-2501375073-1001G:S-1-5-21-1356517589-3987021482-2501375073-513D:(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;S-1-5-21-1356517589-3987021482-2501375073-1001)
```
Allocation of thread objects usese the mono_object_new_mature API. These objects are allocated before the thread is finished attaching to the runtime. This means that a collection can happen on an unattached thread as well as all its callbacks, which is a counter-intuitive behavior.
On android this is problematic because at the end of the SGen collection we need to call the java collection, which needs to have the thread attached. This could probably be fixed instead from the Xamarin.Android side, but this approach seems simpler and saner.
Fixes https://github.com/mono/mono/issues/17878
* [WinForms] Fix#17980 Prevent from crashing when DataGridView is null.
Reproducer:
DataGridViewLinkColumn links = new DataGridViewLinkColumn();
links.UseColumnTextForLinkValue = true;
* [WinForms] Fix#17980 The field useColumnTextForLinkValue of DataGridViewLinkCell was not cloned.
* [WinForms] Fix#17980 the Text property was not set for every cell in the column when UseColumnTextForLinkValue is true
Fixes#17980
The only difference in the copies, was that one had an infinite timeout
so implied TRUE result unless interrupted.
Where the other copy had a timeout and could return FALSE as a result.
They both used the same underlying, with timeout, so it wasn't really an optimization,
just duplicated code.
Also there is subtelty around having a return value or an out parameter.
That is carefully preserved.
Also, coop is fixed, by creating a frame only in a slow path.
Presumably creating a thread is quick and stateless enough such that this
is not too late.
Hangs runtime; prevents CI from completing run. (Another test can
also hang the runtime, but is hard to reproduce and inconsistent
about that.)
This should be fixed eventually, but...
* [jit] Implement beginnings of SIMD support for WASM.
* [wasm] Add a DISABLE_WASM_NO_NETCORE Make.local conditional to disable non-netcore builds during development.
* [wasm] Add a --simd argument to the packager.
* Remove some duplicate defines.
* Fix an windows assertion.
[interp] track valuetype stack for CEE_RET too
Usually the stack depth is determined via basic block predecessors, but that only works for forward branches.
Fixes https://github.com/mono/mono/issues/17924
* [wasm] Handle more exceptions in the xunit runner.
* [wasm] Add more corefx test suites.
* Add more icall signatures.
* Add support for running the System.Compression test suites.
use `objdump` arguments to reduce verbosity (no raw bytes, etc) and make the dasm more diff-friendly.
On Linux all functions have a random prefix (address) - replace it with `0xD1FFAB1E` constant). On macOS it's fine by default.
Also, allow to generate diffs for a single assembly via `dump-asm-lib` rule.
There is a race condition on Safari as a result of using TaskCompletionSource that causes a stack exceeded error being thrown during Blazor startup.
Safari throws the following error:
```
[Error] Unhandled Promise Rejection: RangeError: Maximum call stack size exceeded.
step (blazor.webassembly.js:2530)
fulfilled (blazor.webassembly.js:2500)
promiseReactionJob
```
- Modify `WebAssemblyHttpMessageHandler.cs` to create the TaskCompletionSource to run continuations asynchronously.
- `TaskCompletionSource<HttpResponseMessage>(TaskCreationOptions.RunContinuationsAsynchronously);`
- There is a second part to this on AspNetCore in `Renderer.cs` to process it's pending startup tasks to run continuations asynchronously to compliment the TaskCompetionSource of the Http response message.
The following link discusses the potential stack/race problem that can occur when using TaskCompletionSource: https://devblogs.microsoft.com/premier-developer/the-danger-of-taskcompletionsourcet-class/
This is optional.
The real problem was -enable-cxx not actually compiling some files as C++.
This is still reasonable, to ward off the danger of that occuring again.
If `byte[] data` has additional data at the end `Decode` will try to parse it and will generate incorrect tags or throw an exception. This fix makes `Decode` to use only `nLength` bytes from `byte[] data`.
[threadpool] Decrement max_working when worker times out
The corresponding code in CoreCLR:
https://github.com/dotnet/runtime/blob/bf88f146412d1e2d41779422337184a802f186c9/src/coreclr/src/vm/win32threadpool.cpp#L2156-L2164
The issue is that counter._.max_working is only ever changed by:
1. the monitor_thread when it detects starvation (increment by 1).
2. the hill climbing algorithm (increment or decrement).
Creating a periodic load of creating many workers at once followed by a minute
or more of quiescence increases the variable worker.counters._.max_working in
monitor_thread(). Once that counter matches worker.limit_worker_max,
monitor_thread() keeps looping without unparking or creating a thread, even
though the actual number of threads/workers is small. If the existing threads
are all waiting on work that needs a new thread, then a deadlock occurs.
With this change, when a parked worker times out, it will lower max_working to
the number of active (working + parked + starting) threads minus itself (but no
less than limit_worker_min). As a result, monitor_thread will only increment
max_working as long as none of the already running workers are timing out.
Attempt to address https://github.com/mono/mono/issues/17833
---
Also allow monitor_thread to start workers if there aren't enough active, even if the max worker limit has been reached.
Work around a pathological condition where the work_item_count is non-zero, and
the max_working limit has been reached, but the number of active threads is
still below the max. In that case, unpark some workers and start some new
threads.
May address http://work.azdo.io/827206
The method InstalledInputLanguages() always returned InvariantCulture. Now, installed input languages are detected properly on Windows.
Reproducer:
`Console.WriteLine(InputLanguage.CurrentInputLanguage.Culture.TwoLetterISOLanguageName.ToUpper());`
Related issue: #13552
## Background
In Mono 5 and earlier, the active GTK or KDE theme would be sourced for system colors, allowing dark themes to be obeyed:

This allowed WinForms apps to blend in and look more like native apps.
## Problem
In Mono 6, this capability was lost (as noted in passing in #14325). WinForms apps now only look like this, regardless of the system color settings:

This looks somewhat jarring and worse than previous Mono releases, for users with a dark system theme.
## Cause
During load of the system settings (in the static constructor of `X11DesktopColors`), `Theme.SetSystemColors` passes system color data to `System.Drawing.KnownColors.Update`, which populates them into `System.Drawing.KnownColors.ArgbValues`. In Mono 5 and earlier, this flowed through to the visible UI.
It seems that as of Mono 6, this table no longer affects the visible WinForms UI (although it is still being updated!). Instead, a same-but-different table in `System.Drawing.KnownColorTable` drives the system colors now. I was not able to identify the commit in which this change was made.
## Changes
Now `Theme.SetSystemColors` accesses `System.Drawing.KnownColorTable.s_colorTable` instead, and WinForms apps once again obey GTK and KDE themes:

FixesKSP-CKAN/CKAN#2881.
These runtimes are configured with `--with-lazy-gc-thread-creation=yes` so they don't start a GC finalizer threads by themselves.
XI does this because they want to delay creating that thread for some time after startup.
We can just do it immediately, the important part is that it _does_ exist.
We need to check whether the assembly name passed to us already contains .exe/.dll and append it otherwise.
Fixes loading of assemblies via the hook, we were falling back to the usual path resolving logic (which doesn't work in netcore mode).
[arm] if mtriple is provided, do not set -march
E.g. when passing `-march=arm -mtriple=armv7s-ios`, `-march` will win and thus ignore `armv7s`.
Fixes https://github.com/mono/mono/issues/17931
* Caused by 5e318afd2e
* Related with 4cd5068230
* Almost fixed by e431093f73
Hopefully we are done with it.
### Backstory
This test is failing in the interpreter (ONLY on Debian9/amd64. Not Ubuntu/amd64. Not macOS/amd64):
https://github.com/mono/mono/blob/0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mcs/class/Mono.Debugger.Soft/Test/dtest.cs#L2484-L2499
Where the debuggee is just some unsafe code that tries to read from unmapped memory, thus causing a segfault.
So the test expects the runtime to send a CRASH event via the managed debugger interface. This happens very late in the crash handling machinery:
https://github.com/mono/mono/blob/0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mono/mini/mini-posix.c#L1105
However, the runtime would never reach that, because it silently crashes when calling `backtrace`:
https://github.com/mono/mono/blob/0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mono/mini/mini-posix.c#L939
At the point where the SIGSEGV happens, the native stack trace looks like this:
```
Thread 1 "mono-sgen" received signal SIGSEGV, Segmentation fault.
interp_exec_method_full (frame=0x555555c51f18, context=0x555555c38350, clause_args=clause_args@entry=0x0, error=0x555555c53f18, error@entry=0x7fffffffd8b0) at interp/interp.c:4463
4463 sp[-1].data.i = *(gint32*)sp[-1].data.p;
(gdb) bt
%0 interp_exec_method_full (frame=0x555555c51f18, context=0x555555c38350, clause_args=clause_args@entry=0x0, error=0x555555c53f18, error@entry=0x7fffffffd8b0) at interp/interp.c:4463
%1 0x000055555569237a in interp_runtime_invoke (method=<optimized out>, obj=<optimized out>, params=<optimized out>, exc=0x0, error=0x7fffffffd8b0) at interp/interp.c:1900
%2 0x0000555555590745 in mono_jit_runtime_invoke (method=0x555555bfdc38, obj=<optimized out>, params=0x7fffffffd858, exc=0x0, error=0x7fffffffd8b0) at mini-runtime.c:3001
%3 0x0000555555778c4c in do_runtime_invoke (method=0x555555bfdc38, obj=<optimized out>, params=<optimized out>, exc=<optimized out>, error=0x7fffffffd8b0) at object.c:3052
%4 0x000055555577b7d0 in do_exec_main_checked (method=0x555555bfdc38, args=<optimized out>, error=0x7fffffffd8b0) at object.c:5184
%5 0x000055555559a2aa in mono_jit_exec_internal (argv=0x7fffffffdcb8, argc=1, assembly=0x0, domain=0x555555bf9d40) at driver.c:1320
%6 mono_jit_exec (domain=domain@entry=0x555555bf9d40, assembly=assembly@entry=0x555555c66ae0, argc=argc@entry=1, argv=argv@entry=0x7fffffffdcb8) at driver.c:1265
%7 0x000055555559b8e2 in main_thread_handler (user_data=<synthetic pointer>) at driver.c:1402
%8 mono_main (argc=<optimized out>, argv=<optimized out>) at driver.c:2622
%9 0x000055555558b757 in mono_main_with_options (argv=<optimized out>, argc=<optimized out>) at main.c:52
%10 main (argc=<optimized out>, argv=<optimized out>) at main.c:434
```
Stepping into the crash handling machinery, the picture looks a bit different:
```
Thread 1 "mono-sgen" hit Breakpoint 1, altstack_handle_and_restore (ctx=0x7fffffffd2d0, obj=0x0, flags=0) at exceptions-amd64.c:871
871 {
(gdb) bt
%0 altstack_handle_and_restore (ctx=0x7fffffffd2d0, obj=0x0, flags=0) at exceptions-amd64.c:871
%1 0x00005555556957de in interp_exec_method_full (frame=0x555555c53f08, context=0x555555c38350, clause_args=0x0, error=0x555555c53f18) at interp/interp.c:4461
%2 0x0000000000000000 in ?? ()
```
So it looks like we messed up in the transition from altstack back to the program stack.
### The fix
The problem is that `backtrace` consults the unwind information emitted at the point where SIGSEGV happens in `interp_exec_method_full ()`. However at that given program code, there is no function call that allocates space to pass arguments on the stack. Still, we massage the stack to do that in the signal handler, which does not add up with the emitted unwind information by the C compiler.
Note that without the fix, crashing in `backtrace` is the worst case. In other cases we might (1) get still a correct stack trace, or (2) we get a wrong stack trace, and `backtrace` will not crash. So this PR might improve the crash experience overall.
This also reverts commit cff400f3fae9775ac734f8a691339e59a272872c.
* Aling alloca_size to 8.
* Prevent some false pinning in the monitor-resurrection.cs test when using the non-recursive interpreter.
* [runtime] Add a mono_compiler_barrier () function.
* Add a MONO_GET_SP opcode to pass to enter/exit_gc_safe_region, ldloca might not return a native stack address with the interpreter.
* Add an interpreter/gc callback to mark the interpreter stack.
* Copy only an integer in ENDFILTER.
* Add a native_stack_addr field to InterpFrame so the EH code has something to compare against native stack addresses.
* Add a FrameStack structure to allow allocation of InterpFrame structures and stack data outside the native stack.
* Allocate InterpFrames/stack data from a frame stack instead of the native stack.
* Make some calls non-recursive.
* Remove an assert.
* Use non-recursive calls in CALLVIRT_FAST as well.
* Fix stack size allocation for vararg calls.
* Add some micro optimizations to the calling code.
* Add more micro optimizations.
* [dtest] disable Crash test on interpreter
* Add some implicit conversions to STSFLD to fix a corefx test failure.
* Disable the new test.
Fix BinaryReader on BE
The ints passed into the int array ctor needed to be endian swapped.
Interestingly, the BinaryWriter implementation currently being used
(not refsrc AFAIK) does this on write just fine.
Fixes ReadDecimal test on AIX, and adds another test to ensure that
Write(decimal) can be read back by ReadDecimal in case.
After https://github.com/mono/mono/pull/16832 was merged the run-msbuild.bat
script has an additional required parameter for specifying the GC.
However the script only passed the MONO_TARGET_GC property to msbuild
if the script had no additional parameters which doesn't make sense.
Always pass the parameter, this should fix the boehm build on Windows i386.
Mono SDB's debugger agent takes a `host:port` parameter to specify the host and
port on which to listen for debugger connection. `host` is passed, via
`mono_get_address_info`, to the `getaddrinfo(3)` standard library call which
does the job of translating the name to the IP address. However, there's no
special treatment for situations when `host` is already an IP address. In this
case `getaddrinfo` takes a lot of time to perform at least two DNS lookups (if
there's just a single DNS server configured) which will time out as the IP
address in `host` will not be resolved by any of the servers.
`getaddrinfo` takes a "hints" parameter where caller can specify some
information about the `host:port` pair to make the lookup faster/easier.
However, Mono doesn't specify the address family in the `hints` parameter, thus
forcing the slow path of DNS lookups on `getaddrinfo`.
This commit adds a new hint named `MONO_HINT_NUMERIC_HOST` (which maps to
`AI_NUMERICHOST` for `getaddrinfo`) which will allow, if set, `getaddrinfo` to
take a faster route in address discovery. Debugger agent will, in most cases,
get an IP address to instead of host name so we call `mono_get_address_info` up
to 3 times (IPv4, IPv6 and unspecified) in order to make the lookup faster.
Fix flawed BufferTest on big-endian
Test ignored byte order when considering integer comparison. This
tests different cases for each endian, and explains why the byte
order is different.
* Implement validation for signature and argument count consistency.
- throw error `Parameter count mismatch.` when arguments and signature counts are not consistent.
* Fix tests that have Parameter count mismatch.
* Add browser binding tests for `Parameter count mismatch
* Allow runtime to be built with C++ on AIX
Many AIX/PPC/BE specific codepaths didn't do casting properly,
since C++ is much stricter than C about pointer typing.
Also specify the C99 format macros early as possible, since
inttypes may get included before eglib gets a chance to set the
macros.
Also explicitly use -pthread, since not using it is the cause of
many libstdc++ crashes on AIX.
* Oops, should have been that define instead
* Suggested changes from Jay on style
* Remove unneeded cast
It's used for the zlib compression helpers used by System.IO.Compression in the old Mono BCL.
On corefx this is handled differently so we don't need it there.
To avoid automake complaining about missing files we include the .c files directly instead of in the Makefile.
Those folders won't be present in the dotnet/runtime repository.
We need to factor out AC_OUTPUT into a separate file so we can continue
to share configure.ac but not the list of files in AC_OUTPUT since
autotools doesn't support variables there.
2019-11-22 22:48:11 +01:00
1249 changed files with 83572 additions and 43619 deletions
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 netcore netcore/corerun
if!ENABLE_NETCORE
all:$(update_submodules)
@@ -116,30 +94,10 @@ mcs-do-compiler-tests:
bootstrap-world:compiler-tests
$(MAKE) install
ifINSTALL_MONOTOUCH
monotouch-do-build:config.h
@list='$(MONOTOUCH_SUBDIRS)';for subdir in $$list;do\
<!-- 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.
@@ -95,10 +95,15 @@ function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Password) {
}
if(!(Test-Path$ConfigFile-PathTypeLeaf)){
Write-Host"Couldn't find the file NuGet config file: $ConfigFile"
Write-PipelineTelemetryError-Category'Build'-Message"Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile"
ExitWithExitCode1
}
if(!$Password){
Write-PipelineTelemetryError-Category'Build'-Message'Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. Please supply a valid PAT'
ExitWithExitCode1
}
# Load NuGet.config
$doc=New-ObjectSystem.Xml.XmlDocument
$filename=(Get-Item$ConfigFile).FullName
@@ -121,7 +126,16 @@ if ($creds -eq $null) {
# Insert credential nodes for Maestro's private feeds
<!-- 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"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."
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.28-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
__ApiLevel=28# The minimum platform for arm64 is API level 21 but the minimum version that support glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h
__BuildArch=arm64
__AndroidArch=aarch64
__AndroidToolchain=aarch64-linux-android
@@ -53,13 +53,20 @@ for i in "$@"
done
# Obtain the location of the bash script to figure out where the root of the repo is.
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"CodeName - optional, Code name for Linux, can be: trusty, xenial(default), zesty, bionic, alpine. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
echo" for FreeBSD can be: freebsd11 or freebsd12."
echo"lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FReeBSD"
echo"--skipunmount - optional, will skip the unmount of rootfs folder."
Write-PipelineTaskError-Type'warning'-Message"Channel $id is not present in the post-build YAML configuration!"
}
}
Write-Host'done.'
}
catch{
Write-Host$_
Write-PipelineTelemetryError-Category'CheckChannelConsistency'-Message"There was an error while trying to check consistency of Maestro default channels for the build and post-build YAML configuration."
Write-PipelineTelemetryError-Category'MaestroVars'-Message"MaestroApiVersion does not match a version string in the format yyyy-MM-DD. '$MaestroApiVersion'"
ExitWithExitCode1
}
}
catch{
Write-PipelineTaskError"Error: Variables `MaestroApiEndPoint`, `MaestroApiVersion` and `MaestroApiAccessToken` are required while using this script."
Write-PipelineTelemetryError-Category'MaestroVars'-Message'Error: Variables `MaestroApiEndPoint`, `MaestroApiVersion` and `MaestroApiAccessToken` are required while using this script.'
Write-Host"No subscriptions found for source repo '$normalizedSourceRepo' in channel '$ChannelId'"
ExitWithExitCode0
}
if(!$subscriptions){
Write-PipelineTelemetryError-Category'TriggerSubscriptions'-Message"No subscriptions found for source repo '$normalizedSourceRepo' in channel '$ChannelId'"
[string]$Repository=$env:BUILD_REPOSITORY_NAME,# Required: the name of the repository (e.g. dotnet/arcade)
[string]$BranchName=$env:BUILD_SOURCEBRANCH,# Optional: name of branch or version of gdn settings; defaults to master
[string]$SourceDirectory=$env:BUILD_SOURCESDIRECTORY,# Required: the directory where source files are located
[string]$ArtifactsDirectory=(Join-Path$env:BUILD_ARTIFACTSTAGINGDIRECTORY("artifacts")),# Required: the directory where build artifacts are located
[string]$ArtifactsDirectory=(Join-Path$env:BUILD_ARTIFACTSTAGINGDIRECTORY('artifacts')),# Required: the directory where build artifacts are located
[string]$AzureDevOpsAccessToken,# Required: access token for dnceng; should be provided via KeyVault
[string[]]$SourceToolsList,# Optional: list of SDL tools to run on source code
[string[]]$ArtifactToolsList,# Optional: list of SDL tools to run on built artifacts
@@ -22,79 +22,93 @@ Param(
[string]$TsaCodebaseAdmin,# Optional: only needed if TsaOnboard is true; the aliases which are admins of the TSA codebase (e.g. DOMAIN\alias); TSA is the automated framework used to upload test results as bugs.
[string]$TsaBugAreaPath,# Optional: only needed if TsaOnboard is true; the area path where TSA will file bugs in AzDO; TSA is the automated framework used to upload test results as bugs.
[string]$TsaIterationPath,# Optional: only needed if TsaOnboard is true; the iteration path where TSA will file bugs in AzDO; TSA is the automated framework used to upload test results as bugs.
[string]$GuardianLoggerLevel="Standard",# Optional: the logger level for the Guardian CLI; options are Trace, Verbose, Standard, Warning, and Error
[string]$GuardianLoggerLevel='Standard',# Optional: the logger level for the Guardian CLI; options are Trace, Verbose, Standard, Warning, and Error
[string[]]$CrScanAdditionalRunConfigParams,# Optional: Additional Params to custom build a CredScan run config in the format @("xyz:abc","sdf:1")
[string[]]$PoliCheckAdditionalRunConfigParams# Optional: Additional Params to custom build a Policheck run config in the format @("xyz:abc","sdf:1")
Write-PipelineTelemetryError-Force-Category'Sdl'-Message"Guardian tsa-onboard failed with exit code $LASTEXITCODE."
ExitWithExitCode$LASTEXITCODE
}
}else{
Write-PipelineTelemetryError-Force-Category'Sdl'-Message'Could not onboard to TSA -- not all required values ($TsaCodebaseName, $TsaNotificationEmail, $TsaCodebaseAdmin, $TsaBugAreaPath) were specified.'
Write-PipelineTelemetryError-Force-Category'Sdl'-Message"Guardian tsa-publish failed with exit code $LASTEXITCODE."
ExitWithExitCode$LASTEXITCODE
}
}else{
Write-PipelineTelemetryError-Force-Category'Sdl'-Message'Could not publish to TSA -- not all required values ($TsaBranchName, $BuildNumber) were specified.'
Write-Host"Guardian tsa-onboard failed with exit code $LASTEXITCODE."
exit$LASTEXITCODE
}
}else{
Write-Host"Could not onboard to TSA -- not all required values ($$TsaCodebaseName, $$TsaNotificationEmail, $$TsaCodebaseAdmin, $$TsaBugAreaPath) were specified."
@@ -215,8 +262,11 @@ function InstallDotNet([string] $dotnetRoot,
&$installScript@installParameters
}
catch{
Write-PipelineTelemetryError-Category"InitializeToolset"-Message"Failed to install dotnet runtime '$runtime' from custom location '$runtimeSourceFeed'."
Write-PipelineTelemetryError-Category'InitializeToolset'-Message"Failed to install dotnet runtime '$runtime' from custom location '$runtimeSourceFeed'."
ExitWithExitCode1
}
}else{
ExitWithExitCode1
}
}
}
@@ -238,16 +288,16 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
Write-PipelineTelemetryError-Category"InitializeToolset"-Message"-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'."
Write-PipelineTelemetryError-Category'InitializeToolset'-Message"-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'."
ExitWithExitCode1
}
@@ -431,9 +489,9 @@ function GetNuGetPackageCachePath() {
# Use local cache on CI to ensure deterministic build,
# use global cache in dev builds to avoid cost of downloading packages.
@@ -33,4 +33,4 @@ Visit http://lists.ximian.com/mailman/listinfo/mono-list for details.
.SHWEBSITE
Visit http://www.mono-project.com for details
.SHSEEALSO
.BRmono(1)
.BRmono(1)
Loaded 100 of 1249 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.