* [jit] Add support for accessing method arguments in the profiler in llvmonly mode, by generating code to store them into the MonoProfilerCallContext.args array.
* [jit] Use ctx->args instead of ctx->context for accessing arguments in the profiler.
* Update after review comments.
* [jit] Switch --trace to use the profiler infrastructure.
* Fix a rebase problem.
* Fix c++ failures.
* [wasm] Fix the creation of runtime.js in ninja mode.
* [wasm] Exit with an error code if the emscripten runtime hits an abort.
* [wasm] Error out when mono_wasm_load_runtime () fails too.
* [wasm] Wrap some code in ENVIRONMENT_IS_SHELL.
* [aot] Emit runtime invoke wrappers for up to 40 parameters for bitcode, newly added tests depend on it.
* [aot] Fix a buffer overflow in mini_get_gsharedvt_out_sig_wrapper_signature ().
* [wasm] Remove some filesystem code which is no longer needed.
* [wasm] Disable coop gc on the cross compiler, it effects the generated code.
* [wasm] Use a different random device under wasm so we can override its behavior. This is needed because /dev/random no longer works in emscripten 1.38.13 in JS shells.
* [wasm] Bump emscripten to 1.38.13.
* [wasm] Print a stack in one more abort case.
* [wasm] Add putchar to EXPORTED_FUNCTIONS, llvm-lto seems to create references to it after linking.
Since we've started embedding test resources inside of the test assembly
we've sometimes seen a strange error on Jenkins during the test run:
```
Msg: Error initializing task StringTestTask: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Msg: Error initializing task StringTestTask: System.TypeLoadException: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
at (wrapper managed-to-native) System.RuntimeType.GetConstructors_native(System.RuntimeType,System.Reflection.BindingFlags)
...
```
However this was from an xbuild_12 run so how come it tried to load xbuild 14 stuff?
The reason is there's a race condition between when TestTasks.dll gets
built and when it's embedded inside of the test assembly.
If we're building the xbuild_12 and xbuild_14 profile at the same time
we could end up embedding the xbuild_14 version of TestTasks.dll instead
of the correct one since we're copying it to the same file name.
The fix is to remove the unnecessary copying logic since we can just tell
the compiler to embed the file under the correct name.
This is an alternative or precursor to https://github.com/mono/mono/pull/10212.
- Removes the dependency of some ABIs passing a pointer and a pointer in a struct the same.
- Therefore gives all platforms the same type safety.
- *If* we move to C++, allows us to have member functions in coop handles.
- Having the coop signatures available in C can provide benefits, though we should
probably generate them from reading metadata -- though they won't match w/o more changes,
since we mixup types in several places, like IntPtr vs. pointers.
JIT now traffics in old type-unsafe handles, and wrappers are generated with C preprocessor to trivially convert.
This way the JIT doesn't have to pass structs by value here, which was tried/failed.
The C preprocessor machinery can/should be extended for additional gains.
In particular driving managed/native coop icall transitions from 3+ per call to 1 (like https://github.com/mono/mono/pull/10212).
That will require better verification of the signatures in icall-def.h, either automated and en masses or gradually manually. Embedders will likely do something else, or at least have to independently invent similar.
Whereever a native function was exposed via multiple managed names, wrappers are reused.
* [wasm] Sample program in wasm sdks does not run.
- Add `mono-config.js` reference to html file.
resolves: https://github.com/mono/mono/issues/11239
* Fix `runtime.js` to reference `mono-config.js` variables.
* Fix packager.exe where it deletes the `runtime.js`.
- Replaced the File Delete and Copy with a Copy if new call.
- re-add the generation of a skeleton `runtime.js` file if one can not be found.
Flags to DrawText never reached MeasureText therefore strings with '&' were measured incorrect when drawn with flag TextFormatFlags.NoPrefix.
Fixes#6352
* [System] Don't throw NIE for ServicePoint.ConnectionLeaseTimeout and .ReceiveBufferSize
Instead return a no-op value. This is the same behavior as .NET Core.
Fixes https://github.com/dotnet/standard/issues/642
* Bump API snapshot submodule
* [tests] Renumber duplicate return codes
* [metadata] Fix crash related to custom attributes (#10737)
When a class doesn't contain the desired custom attribute we used
to return the last available attribute. This prevented
`cominterop_ccw_queryinterface()` to detect that the interface
isn't implemented and lead to a crash.
This change fixes#10737.
* [cominterop] Switch to GC Unsafe in IUnknown and IDispatch impls
These methods can be called directly from embedding APIs.
They require the additional files:
- mono/eglib/eglib-config.h: that's to build `libmonodroid`
- mcs/build/Consts.cs: that's to build `Mono.Posix` and `Mono.Data.Sqlite`
This should help get information on native crashes that happen in hard-to-debug environments.
To quote https://github.com/mono/mono/issues/10157 :
When a mono runtime is attached to a managed debugger and the debugged runtime is induced to cause a crash, the state of that crash is not communicated to the managed debugger. This, combined with the difficulty in having the debugged runtime both attached to the managed debugger and lldb, makes this type of crash difficult to interactively debug.
When the managed debugger is the only connection someone has with the runtime because it is embedded in a way that is resistant to unmanaged debugging (watchOS application on-device, for instance), this is an even more difficult problem.
By adding an SDB protocol event that sends a type of "runtime death" and a blob of opaque json (version dependent, no protocol guarantees), people can report these crashes without having to assist a mono runtime engineer in observing a crash on device.
In the case that spurious bugs in this manner are submitted, it will require less effort as well to spot stack frames that indicate misuse of mixed managed-unmanaged APIs (which offer the ability to drive a segfault or g_assert
* [arm64] Remove the limitation on the number of nullable arguments for dyncalls.
Fixes https://github.com/xamarin/xamarin-macios/issues/4984.
* [amd64] Remove the limitation on the number of nullable arguments for dyncalls.
* [jit] Add tests for dyncalls with lots of nullable arguments.
* Mark AddRefInternal as NOHANDLES(). Its signature was incorrect.
* Change ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal to NOHANDLES.
* Mark ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal NOHANDLES.
* ves_icall_System_Runtime_InteropServices_Marshal_BufferToBSTR to nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR to nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal nohandles().
* ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem nohandles().
* Fix the signature of ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMemSize.
* [coop] Remove most uses of out_of_memory_ex.
We only build it if we're explicitly building the monodroid profile and for the
monodroid_tools profile we only build the test assembly but not dtest-app.exe
## Problem
`MessageBox` displays as black-on-dark in a dark theme:

This can be difficult to read.
## Cause
The text is drawn with a hard coded color of `Color.Black`. This assumes that the background under the text will be light to contrast with black.
## Changes
Now the color is `SystemColors.ControlText` instead, to match the background of the popup.
In a normal theme this will still be black.
* [bcl] Run System.Windows.Forms.DataVisualization tests
* [bcl] Run Mono.Messaging.* tests
* [bcl] Use correct label for mdoc tests
* [runtime] Skip verifying an xunit-binaries assembly
* [corlib] Import System.IO.IOException/FileLoadException from CoreFX
* [corlib] Remove unused string
* [corlib] Remove another test assert for BadImageFormatException
Exception message no longer includes the file name
During the code refactoring this summer, support for native apple certificates
has been dropped on watchOS.
* add `apple-certificates.sources` and move all certificate-related code from
`appletls.sources`.
* move non-network related code from `MacProxy` into a new `AppleTypes`.
* add the `MONO_FEATURE_APPLE_X509` magic to `System/Makefile` where it was missing from.
* [sdks] Build BCL profiles without configure flags
* [sdks] Add BclTemplate to build BCL profiles
This is to avoid building all the profiles in a single `sdks/out/bcl` directory which will be shared between android, ios and wasm.
* [sdks] Simplify call to BclTemplate
* [mcs] Make directory dependency as order-only
We would otherwise always rebuild the target since the directory is updated whenever something is added to the directory. This is a common Makefile technique.
* [sdks] Build tests for BCL targets
* [runtime] Fix the signature of some native type tests.
* [runtime] Add stubs for the ves_icall_System_Net_NetworkInformation_MacOsIPInterfaceProperties_ParseRouteInfo_internal () icall, needed for AOT.
* [wasm] Print a native stack trace on asserts.
* [wasm] Avoid mmaps with zero length, it leads to an exception under emscripten.
* [bcl] Preserve CustomAttributeData:.ctor (), its called from the runtime.
* [wasm] Print out full test names in the test runner.
* [wasm] Preserve System.Threading.WasmRuntim.
* [wasm] Rename config.js to mono-config.js
* [wasm] Add targets to build aot versions of the test suites.
* [wasm] Exit with a nonzero exit code in case of a failure.
* [wasm] Disable crash reporting.
* [wasm] Use mono headers for public functions.
* [wasm] Enable building AOT tests on CI.
* [wasm] Run some AOT test suites on CI.
* [runtime] Make MonoBundledAssembly.size non-const.
* [wasm] Add a --setenv=VARIABLE=VALUE argument to runtime-tests.js which allows the setting of environment variables.
* [wasm] Update cross compiler executable name.
* [wasm] Remove unused aot-driver.js file, runtime-tests.js has the same functionality.
* [wasm] Run mini tests with AOT on CI.
* [wasm] Error out if the linker fails.
* [wasm] Fix building the AOT tests from another directory.
* [wasm] Use a matching Mono.Cecil.dll for the linker.
* [wasm] Fix running aot tests on CI.
* Revert "[sdks] Switch the invocation of the offsets too to 64 bit on osx. (#10903)"
This reverts commit 2989a83f23.
This seems to cause failures on linux+webassembly.
The VS4M team is making a tool that makes a symbolication lookup table. This enables symbolication without access to the relevant binary.
For unmanaged, it's much harder to precompute things because we were presenting the instruction address. From the address, any lookup needs to find the function enclosing this interior pointer.
To make it easier, this reports the address of the native method as well as the offset. A lookup table can simply key on the function start address with this now.
ie:
```
{
"native_address" : "0x1003a6340",
"native_offset" : "0x00046",
"native_module" : "mono"
}
```
```
$ nm mini/mono-sgen | grep '1003a6340'
00000001003a6340 t _mono_runtime_run_main_checked
```
```
$ nm mini/mono-sgen | grep ' t ' | sort -n
00000001000a4e90 t _alloc_ireg
00000001000a4eb0 t _decompose_long_opcode
00000001000aae90 t _mono_decompose_long_opts
00000001000aaea0 t _mono_decompose_vtype_opts
00000001000ae130 t _m_class_get_byval_arg
00000001000ae150 t _alloc_dreg
............
```
Note:
- This memory isn't accessed until we're crashing
- On any modern machine, unused static memory is lazily allocated. When
we access it, the fault will trigger the MMU to map memory for us.
- This is guaranteed to be reentrant and safe. mmap (the alternative) is
surely fairly stable on many systems, but this is not guaranteed. The
documentation pages for mmap specifically claim it as not safe in these async
contexts.
`Mono.Native` is the new name for both `System.Native` and `System.Security.Cryptography.Apple`.
It is built as a stand-alone shared library and not bundled with the runtime because we
may need to build two different versions of it.
Starting with macOS 10.12+ and iOS 10+, Apple introduced a new Unified API for some of the
crypto primitives that we're using as part of System.Security.Cryptography.Apple.
On Desktop, we can check at runtime whether the OS version is recent enough and switch
implementation accordingly. We build a single `libmono_native` shared library.
However, on Mobile we cannot have any undefined symbols as this would break Bitcode.
During the mobile build, we are called with `CC` containing an explicit minium version flag,
which is either `-mmacosx-version-min=`, `-mios-simulator-version-min=` or `-miphoneos-version-min=`
depending on platform.
We build two versions of the shared library:
- `libmono_native_compat` is built with whichever minimum version is passed to us via `CC`.
- `libmono_native_unifed` is built with the minimum version set to macOS 10.12+ / iOS 10+.
For testing purposes, there is a function called `mono_native_get_platform_type ()`
(see mono/native/mono-native-platform.c), which returns a `MonoNativePlatformType` enum value.
There is also `Mono.MonoNativePlatform.GetPlatformType ()` (see mcs/class/corlib/Mono/MonoNativePlatform.cs).
This can be called by automated tests both to ensure that the library has been correctly installed and also
to verify that it's the correct version of it.
* `configure.ac`: add new configure checks for Mono.Native.
* `mono/native/`: new directory - this replaces the `System.Native` code that was previously in `mono/metadata`.
* `mcs/class/corlib/Mono`: New internal `MonoNativePlatformType` and `MonoNativePlatform` classes.
* `-s` removes all symbols.
* `-x` removes non-global symbols.
This is needed in order to get human readable output with `MONO_VERBOSE_METHOD=method`, so instead of:
```
Disassembly of section .text:
00000000 <.text>:
0: e92d4900 .word 0xe92d4900
4: e24dd05c .word 0xe24dd05c
8: e1a0b00d .word 0xe1a0b00d
c: e58b0030 .word 0xe58b0030
10: e58b1034 .word 0xe58b1034
[...]
```
It is this now:
```
Disassembly of section .text:
00000000 <.text>:
0: e92d4900 push {r8, fp, lr}
4: e24dd05c sub sp, sp, #92 ; 0x5c
8: e1a0b00d mov fp, sp
c: e58b0030 str r0, [fp, #48] ; 0x30
10: e58b1034 str r1, [fp, #52] ; 0x34
[...]
```
This is needed due to a newer toolchain on our ARM bots. Tested on armv7 and aarch64.
* [wasm] Fix the build.
* [wasm] Add --copy parameter to packager
- copy parameter
```
--copy=always|ifnewer Set the type of copy to perform
'always' overwrites the file if it exists.
'ifnew' copies or overwrites the file if modified or size is different.
```
- Fix wasm build target in do-runtime target.
* [wasm] Add support for Module.locateFile to runtime loading
See issue https://github.com/mono/mono/issues/11099 for more information.
resolves issue: https://github.com/mono/mono/issues/11099
* Fix spelling of option `ifnew` to `ifnewer`
* Build BTLS on Windows.
* Quote more cmake paths
Should fix issue on Windows build where cmake is installed in C:\Program Files
* Fix btls cygwin x86, x64 Windows build.
NOTE, cygwin btls build depends on cygwin installed cmake, update cygwin
install to include cmake before building.
* Disable BTLS as default for Windows builds.
* [interp] Avoid unnecessary allocations when pinvoke void functions
* [amd64] Refactor interp pinvoke context computation
* [amd64] Interp trampoline for interpreter entry
* [aot] Don't include interp_in_wrapper when we use entry trampoline
These wrappers take a lot of space in the image.
* [exceptions] continue program execution when mapping of stack overflow guard page fails
Related: https://github.com/mono/mono/issues/10415
* turn comment into warning
* fix mono_gc_register_altstack call when no guard page is mapped
I don't know what the specific code is or what changed, etc.
This addresses Mac/x86:
https://jenkins.mono-project.com/job/test-mono-pull-request-i386-osx/15364/parsed_console/log.html
```Unable to compile method 'int Tests:calli_sig_check_2 ()' due to: 'Invalid IL code in Tests:calli_sig_check_2 (): IL_000b: calli 0x11000044```
which then fails an assert and fails overall.
CI goes deep into bash w/o echoing commands but a repro is:
cd mono/mini
MONO_PATH=./../../mcs/class/lib/net_4_x lldb -- ./mono --aot iltests.exe
The code is meant to be invalid, and meant to raise an exception,
which is catchable/resumable (at least in the JIT case where
executing IL the first time, can raise an exception while caller is
running, vs. AOT where the codegen all happens offline -- leaving what?
A note made at AOT time that calling the code should raise an exception?).
It isn't meant to fail an assert in either case.
This change set represents a major set of changes to the crash reporting mechanism.
1) Coordination involving mandatory timeouts and signals have been changed greatly, to instead use semaphores and to end waiting as soon as possible.
2) Dumping of unmanaged symbols outside of mono has been made possible. Embedders that want to get information on frames outside of mono-sgen can register the library with an icall. This carefully preserves both privacy (opt-in) and resiliency (can't crash/lose more info when misused).
3) The dumper has moved from a workflow that kills the runtime after a long delay into one that can dump individual threads or the entire runtime in a prompt manner. The runtime doesn't die at the end of the dump, but allows threads to resume what they were doing and returns to the caller.
4) This has allowed for the addition of a number of tests that stress both parallel and concurrent dumping of threads. These run fairly quickly, and leave the runtime in a state to continue testing.
5) With this lightweight testing setup created, a long burn-in testing period was done. Places we were using locks or trying to malloc resulted in crashes or hangs. After making the needed changes, it managed to run the dumping tests in a loop for a whole weekend on a Linux x64 configuration without any problems.
This has resulted in a dumper with dramatically improved stability and performance.
* [runtime] Fix mismatched parenthesis on exc-s390x
* [runtime] Fix mismatched static function type declaration on s390x
* [runtime] Fixup b7c18caf0c for s390x
The makefile uses $(dir $<) which has `../` and so refers to `llvm/external/llvm` rather than `external/llvm` now that we're using llvm from a submodule in external/
[interp] Optimize static field access
Do most of the work on transform side and include the field address in the instruction stream. We need to run cctor at runtime to preserve expected order. This makes static field access 4 times faster.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* [build] Unify bootstrap profiles
We can now rely on build only as we have reliable monolite and package
compilers
* Fixes genproj dependencies
* [csproj] Update project files
It is hacky to have to avoid includes in order to have conflicting/incorrect declarations.
And hacky to use extern "C" when the reason is to have incorrect prototypes.
It is arguably hacky to suppress the gcc warning -- granted, the functions are never called, and merely their addresses taken and put into void* -- arguably gcc's warning is too strict and should only trigger for calls or taking address into a non-void*.
Arguably the declarations should be moved around the tree.
Perhaps we should omit the prototypes from C++.
* [llvm] Fix the icall signature of a few llvm EH icalls.
* [wasm] Disable com/remoting in the linker.
* [wasm] Enable direct icalls.
* [wasm] Generate the configuration into a config.js file instead of rewriting the runtime.js file.
* [wasm] Enable icall symbol map in the cross compiler, compile the device runtime with -fexceptions.
* [wasm] Rename runtime-tests.g.js -> runtime-tests.js.
* [wasm] Add mono_wasm_assembly_get_entry_point () function to obtain the entry point of an assembly.
* [wasm] Add profiler support to the packager.
* [wasm] Add support for running a normal .net executable to the test runner.
Do most of the work on transform side and include the field address in the instruction stream. We need to run cctor at runtime to preserve expected order. This makes static field access 4 times faster.
* [wasm] Harden the debugger against invalid breakpoints.
This happens when you reload a page and the old BPs land in now invalid code regions.
* Add node support to library_mono.js
* [wasm] Correctly register pdb files.
* [sdks] Build Android SDKs archive in Debug configuration on master builds
* [sdks] Drop `product-` prefix from Android and iOS SDKs CI_TAGS parameters
* Mitigation for spawn FD closing taking forever with a big FD limit
On systems with a large file descriptor limit, Mono takes a very
long time to spawn a new process; with informal testing on the AIX
CI builder, (with a POWER7) it took ~30 minutes. This is obviously
very undesirable, but hand our is forced - libraries the user might
be calling could be creating non-CLOEXEC files we're unaware of. As
such, we started from the FD limit and worked our way down until we
hit stdio. Using APIs such as posix_spawn aren't desirable as we do
some fiddling with the child before we exec; and even then, closing
FDs with posix_spawn relies on non-standard file actions like
Solaris' addclosefrom not present on many systems. (All of this is
unnecessary on Windows, of course.)
This presents an alternative way (currently only implemented on AIX
but with notes how for other platforms) to try to close the child's
loose FDs before exec; by trying to get the highest number FD in
use, then work our way down. In the event we can't, we simply fall
back to the old logic.
See #6555 for a discussion and the initial problem being mitigated.
* Use an another strategy of closing only known to be open handles
...on FreeBSD and AIX.
Use the kinfo_getfiles library call on FreeBSD and only close what's
safe to close. On AIX, use the third and fourth arguments to getprocs
to check what's open. However, the array to get all the handles takes
1 MB, so allocate it on the heap; like what kinfo_getfiles does. We
don't need to free these as the child will exec or exit, which blows
it all away.
The previous strategy from previous commit is still used and on AIX,
enhanced.
* Add Linux strategy to fork FD close
Tested on WSL, shows benefits with big FD ulimit.
initialization, but rather code that is portable to C89 and C++98.
The alternative is also ok, just costs typically a pointer and a relocation per array element,
things most people wouldn't notice but was presumably the point here.
* [aot] Add clangxx option to --aot that removes the hardcoded clang++ in our aot compiler.
* [mini] Make --aot addictive.
* Update CI script for bitcode.
The makes the following classes optional to the runtime:
System.Reflection.CustomAttributeData
System.Text.StringBuilder
System.Math
System.Console
System.Diagnostics.StackTrace
Those are all types that can be clearly made optional. There are a lot of other types
we could, but there are deeper dependencies in places as threadpool or marshal.
* [runtime] Kill mono_defaults.console_class.
* [runtime] Kill mono_defaults.asyncresult_class. Doesn't help much as it's still needed by the TP.
* [runtime] Remove mono_defaults.stack_trace_class.
* [runtime] Remove dead field.
* [runtime] Remove mono_defaults.math_class
* [runtime] Cleanup handleref resolution to use the access macros.
* [runtime] Remove mono_defaults.stribuilder_class.
* [runtime] Remove System.Reflection.CustomAttributeData
* [corlib] Update linker description.
* [runtime] Fix compilation of the iOS SDK.
When passing FIXTURE or TESTNAME to "make run-test" we automatically
prepended `MonoTests.` to the value since all of our NUnit tests
start with that to save you from typing a few chars.
Now that we have xUnit tests as well this is confusing since it doesn't
happen there. Better to remove it for consistency.
Right now if anything goes wrong in the security stack you get a message like this:
```
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
```
This is confusing since SSPI is a Windows-only thing and is not used on Mono.
We inherited this error message string from referencesource.
Change the string to something more generic which also aligns us with CoreFX:
https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.Net.Security/src/Resources/Strings.resx#L210-L212
Before we only did this for PR builds but it turns out it's needed for
normal master/branch builds too.
In situations where there are two Mac builds at roughly the same time
the downstream Windows builds would otherwise both refer to the same/latest
commit since they just checkout the latest ref on the branch.
Now we reset the Windows build to the sha1 which is passed to it.
* Add support for strongly typed marshalling of C# enums.
JavaScript does not have the concept of Enums like TypeScript. Strings are used to represent enums. This PR allows a strongly type contract between C# values and the string representations used by a lot of the JavaScript API's.
Example:
DOM InputElement type -> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type#Form_<input>_types
The InputElement types are represented by strings. button, checkbox, color, date, datetime-local etc....
These string can be represented and marshalled back and forth by defining an enum as shown below with an `Export` data contract attribute.
```
public enum InputElementType
{
[Export(EnumValue = ConvertEnum.ToLower)]
Button,
[Export(EnumValue = ConvertEnum.ToLower)]
CheckBox,
[Export(EnumValue = ConvertEnum.ToLower)]
Color,
[Export(EnumValue = ConvertEnum.ToLower)]
Date,
[Export("datetime-local")]
DateTimeLocal,
}
```
The enum conversion allows controlling the marshalling:
- Default - Marshals the enum name as is
- ToLower - Marshals the enum name to lower case string
- ToUpper - Marshals the enum name to upper case string
- Numeric - Marshals the enum numeric values.
Marshalling from C# to JavaScript using the SDK Bindings should be made as easy and pain free as possible.
Marshalling the string values from JavaScript to C# will need a little help. The SDK Bindings Runtime provides a method to transport the string value to a strongly typed enum.
```
WebAssembly.Runtime.EnumFromExportContract(typeof(InputElementType), inputElementType);
```
* Add marshalling of C# Enums to method calls.
* Add tests to bindings-test harness for testing marshalling of C# enum values.
* Modify test for marshalling enum value without Export contract.
[interp] fixes for native types
please look at single commits.
------------------------
[interp] fix op_implicit/op_explicit conversions for native types
Conversion operators have been mostly broken in the interpreter, for example conversion from nint to float didn't work. While some conversions are easy to intrinsify (like nint -> I8), there are harder cases like nint -> decimal. The JIT actually falls back to the managed implementation, so let's do this in the interpreter as well.
However the managed implementation expects a pointer to the value type, i.e. the container type System.nfloat instead of float/double primitives. In such cases the value is going to be stored in a local and then the address of its storage is pushed on the stack before invoking the managed implementation of the conversion.
Added test cases for scenarios observed in Xamarin.iOS.
-----------------------
[interp] support ntype.CompareTo ()
-----------------------
[interp] support ntype.Equals ()
-----------------------
[interp] support nfloat.*Infinity
-----------------------
[interp] support ntype.ToString ()
-----------------------
The conversion issue creeped everywhere in Xamarin.iOS since it heavily relies on nint/nuint/nfloat. With this PR we are getting close to a green monotouch tests 😁
<img width="874" alt="screen shot 2018-09-21 at 23 24 36" src="https://user-images.githubusercontent.com/75403/45907566-b457eb80-bdf8-11e8-9cc7-b8cf311dd269.png">
needs backporting to 2018-06 and 2018-08
* bump external/binary-reference-assemblies
* use Mono.Android for netstandard
* use API_BIN_REFS
* move ifeq monodroid upper
* use Mono.Android in System.Drawing.Primitives instead of ns
* fix typo
* Add Mono.Android back to ns as API_BIN_REFS
* Bump API snapshot submodule
* [csproj] Update project files
We didn't include cmods when inflating var/mvar cuz we'd mono_metadata_type_dup' the inflated type
and not the (m)var MonoType.
The solution is to add a variant of mono_metadata_type_dup that takes the source of cmods to use.
Conversion operators have been mostly broken in the interpreter, for
example conversion from nint to float didn't work. While some
conversions are easy to intrinsify (like nint -> I8), there are harder
cases like nint -> decimal. The JIT actually falls back to the managed
implementation, so let's do this in the interpreter as well.
However the managed implementation expects a pointer to the value type,
i.e. the container type System.nfloat instead of float/double primitives.
In such cases the value is going to be stored in a local and then the
address of its storage is pushed on the stack before invoking the
managed implementation of the conversion.
Added test cases for scenarios observed in Xamarin.iOS.
xamarin-macios currently builds zlib-helper.o using mono's source code.
It would be preferrable to use a version built by mono, and since
zlib-helper.o is a byproduct of building libMonoPosixHelper, we need to build
libMonoPosixHelper (we already build it for simulator architectures), even
though we don't need/use libMonoPosixHelper itself.
So they are next to their NUnit counterparts.
Move xunit remote executor app to tests dir too and compile it when
compiling the test assembly instead of doing it before running the test.
We need to use an absolute path for the xunit remote executor and it
needs to be in Windows format on Windows since we pass it as an env var
to the xunit tests.
When building the SDKs on CI, the output is very scrambled. There are simultaneously outputs from making multiple runtimes, uncompressing some tar archives, cloning some repos, building various BCL profiles, etc. This makes it quite hard to easily understand what's going wrong when the build fails.
By using `--output-sync=recurse`, we make sure that even if many targets are executed in parallel, the output is still as if it was executed sequentially.
If another thread locked at least one of the other handles, and there is a
cooperative GC STW happening, this function will loop forever.
Add GC Safe transitions around the call to sleep to give this thread a chance
to suspend.
Fixes https://github.com/mono/mono/issues/10863
The `X509Certificate(byte[])` constructor should call `CertificateProvider.Import(byte[])`
to use the native apple implementation if possible.
Add temporary hack to `X509Certificate2(byte[])` to ensure that we always get an
`X509Certificate2Impl`.
* Fix problem with HttpClientHandler not returning the response status text if available when there is an http error.
resolves: https://github.com/mono/mono/issues/10842
* Extend C# sample to include:
- Calling JavaScript functions from C#
- Calling C# functions from JavaScript.
- Referencing JavaScript objects
- Getting and Setting JavaScrip object properties.
- Invoking JavaScript object functions.
- Setting up the default HttpClientHandler
- Instantiating a default WasmHttpMessageHandler.
- Setting up HttpClient calls
- Parsing and testing the correct results returned from the HtppClient.
- Obtaining a byte array and string array from response.
- Obtaining a reference to a global script function defined in the .html file and calling it.
- Working with DOM objects using the SDK's WebAssembly.Bindings.dll
resolves: https://github.com/mono/mono/issues/7548
* Update sample usage docs
* [cxx] Do not define C++ keywords: bool, inline, final, it can break things.
https://jenkins.mono-project.com/job/d/421/parsed_console/log.html
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(250): fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro. [d:\j\workspace\d\msvc\libmonoruntime.vcxproj]
* PR: Leave profiler defining C++ keywords (define bool char).
* PR: Restore libgc. (mainline removed the code in 2011).
* [sdks] Remove redundant --enable-cxx
* [sdks] Shorten `-m32`/`-m64` parameters detection for runtimes
* [sdks] Build BCL profiles without configure flags
* [sdks] Add BclTemplate to build BCL profiles
This is to avoid building all the profiles in a single `sdks/out/bcl` directory which will be shared between android, ios and wasm.
* [sdks] Create archive targets for pre-building on CI
* [sdks] Use archive-{android,ios,wasm} on CI
* [sdks] Run archive-llvm-llvm{,win}{32,64} on CI
thread-suspend-suspended and thread-suspend-selfsuspended tests has showed long
execution times on low core Windows machines running wow64. It looks like an OS
related issue where ResumeThread Win32 API takes a lot longer time to complete
when running a test scenario like thread-suspend-suspended and this additional
time adds up over many iterations pushing it over to timeout. NOTE, the same behavior
has been identified running on .NET framework, so it's not a mono specific issue and
only reproduce under wow64 on low core machines (probably when one core is busy
just leaving us with one core for most of the test).
Since the purpose of the test is to run GC when t1 is suspended, doing this more
deterministic will fix the ResumeThread issue under wow64 on low core count as
well as making the tests more deterministic, always having t1 in a suspended state
when running GC (that will test the suspend suspended scenario).
Full investigation can be found in, https://github.com/mono/mono/issues/10508.
On cooperative suspend, the wrapper frames capture the exception
in a MonoError, which then must be thrown. The problem with treating
it as a CIL THROW opcode is that every time you THROW, you completely
reset the stacktrace's collectin of saved frames.
The RETHROW opcode will force the JIT to rely on an in-flight exception,
that in our case has been taken our of the in-flight context.
By relying on the new MONO_RETHROW, we will take an explicit exception
and put it back in-flight without clearing the stored stacktrace.
Switch NUnit BCL tests to use embedded test resources instead of reading from the repo
Right now a lot of our tests expect to be able to read resources directly from the repository, e.g. `File.Open ("../../resources/some-file.txt")`
In order to run these tests in a standalone, clean environment without access to the source repo we need to change that. The most straightforward way to achieve that is to embed all the resources inside of the test assemblies and extract/read them from there during test execution time.
The new TestResourceHelper helper class extracts all embedded test resources to a temporary directory and cleans them up when the test runner process exits. This allows us to make relatively small changes to the tests as opposed to rewriting them all to read directly from the embedded resource stream (which isn't even possible in all cases).
It turns out some Debian versions identify themselves as `Debian GNU/Linux`, add
this string to the list of distributions which have mingw. This *should* fix the
PR builds (fingers crossed)
Part of #9660.
The changes:
- included corefx version of EventInfo type;
- included related xunit tests from corefx System.Reflection;
- made System.Reflection/EventInfo.cs partial and left some Mono-specific stuff only there.
Some changes will be done in corefx part.
Look like:
https://github.com/mono/mono/commit/e8029e1474b701184840f6e0abea51966d048831
caused issues in the parameters for this test since caller was not updated
accordingly.
This fixes so that the caller pass needed additional argument + simplify the
AOT use case for Windows since different tested versions will need different
toolchain versions that in turn will cause additional complexity. Since the
test doesn't validate the compile/link of AOT module (and don't handle errors)
anyways, Windows versions of this test will just generate assembler output.
Debian and its derivatives include full mingw chain (both 64 and 32-bit) and so
they don't need to build the toolchain at all. However, the current detection of
Linux flavor takes into account only Ubuntu and all other distros are configured
to *require* MXE but they do *not* build them.
This commit fixes detection of distros which provide the mingw toolchain in a
way that makes it easy to extend the set of compatible distributions as needed.
In order to mark a distribution as one with MinGW one has to add the `:Distro:`
string to the `LINUX_WITH_MINGW` make variable in `mxe.mk`. The `Distro` string
is whatever the `determine-linux-flavor.sh` script returns.
MONO_API here was dubious, as all systems have it, except Visual C++ was configured away.
In Visual C++, it is in ucrt, so present in 2015 also.
More information in nearby comments.
This PR cleanups C++SDKs support and gets them all passing for the first time, esp. Android (WebAssembly already was, iOS uncertain before, green here).
* Current Visual C++ has signbit.
* Rework C++ linkage to C99 math-- trunc, isnan, isinf, etc.
Go through mono wrappers that are compiled as C.
Remove support for Visual C++ pre-2015 and non-C99 Solaris.
(Solaris has plenty of other problems compiling.)
Cleanup Windows ssize_t support.
* Remove trunc and aintl autoconfigury.
Use trunc unconditionally. (aintl is a Solaris near equivalent to trunc).
* Replace dis_isnan with mono_isnan.
* Interpreter already assumes presence of isinf and isfinite, so everywhere else might as well too.
A fair amount of cleanup therefore -- autoconf, ifdef, etc.
If this changes back, the mono_isinf, etc. wrappers are likely, but not necessarily, where to handle it for everyone, not sprinkling ifdefs and alternate implementations around -- assuming all users want the same fallback.
As well, we might want to import some good BSD libc versions of all these if there is any remaining question of portability. *Everyone* except old VAX and Cray have always used the same 32bit float and 64bit double representations since circa 1985 so these are all probably about one line of portable C89/C++98 each, maybe with endian sensitivity.
* [wasm] Fix linker changes.
* Revert "[wasm] Enable the mini test suite under AOT. (#10670)"
This reverts commit 9cb832ff2a.
Revert this, it doesn't work yet.
* [wasm] Run AOT tests on CI.
* Fix the CI label.
* [wasm] Disable the aot test on CI, it doesn't yet run on linux.
* [wasm] Fix the computation of code_start/code_end for wasm.
* [llvm] Avoid passing a dummy extra args to wrappers which don't need it.
* [wasm] Enable gshared.
* [llvm] Fix the build.
* [llvm] Avoid passing a dummy arg to string:memcpy/bzero.
* [wasm] Enable exception catching.
* [wasm] Enable explicit division by zero checks.
* [wasm] Patch emscripten with the patch from https://github.com/kripken/emscripten/pull/7182.
* [wasm] Use '.' instead of source in the ninja build scripts since they might be ran with sh/dash instead of bash.
* [wasm] Reenable check-aot on CI.
* [wasm] Run emcc using bash -c since the emsdk_env.sh scripts contains bash-ishms.
* [wasm] Don't error out if the emscripten patch is already applied.
* [wasm] Fix do-aot-sample.
* [wasm] Disable AOT test on CI, it still doesn't work.
* [llvm] Add support for OP_RCNEQ.
* [jit] Make some tests in builtin-types.cs static.
* [wasm] Fix the return value of mono_wasm_exec_regression ().
* [wasm] Make aot-sample uses mini_tests.dll.
* [Coop] Mostly convert appdomain.c.
* Mostly don't convert mono_domain_try_unload at this time -- it was causing failures and maybe the domain swapping needs to be considered carefully with handles.
* Also a few assignments to non-local raw pointers remain, and should probably be suppressed.
See https://jenkins.mono-project.com/view/All/job/test-mono-mainline-staticanalysis-and-code-coverage/Centrinel_Report/
appdomain.c has 34 warnings. This should drop it significantly.
* [runtime] Allow strings when doing alloc-less cattr decoding.
* [runtime] Remove dead define.
* [wasm] Disable broken method under wasm.
* [wasm] Add mono_exec_regression to use mini's regression driver and make it work with WASM interp&AOT.
* [wasm] Remove dead targets. Packager is used for all test suites now.
* [wasm] Cleanup csc flags.
* [wasm] Move aot-sample to use mini_tests_basic again.
* [wasm] We no longer need to exclude FULLAOT from the test suite.
* [wasm] Expose mono_wasm_exec_regression.
* [wasm] Remove dead test driver.
* [wasm] Fix the provisioning step.
* [wasm] Bindings don't link well with the aot sample.
* [wasm] Update the test driver to include --regression support.
* [wasm] Change how regression tests are executed so we exec over aborts.
* [wasm] Appease the C++ typechecker.
* [wasm] Add more casting to make c++ happy.
There is wrong cursor placement after the \t character. Example:
textBox1.Multiline = true;
textBox1.Text = "aa\taa\r\nbb\tbb\r\n";
Point pt = textBox1.GetPositionFromCharIndex(4); //pt.X is wrong for index 4 or any other char after \t in the line.
The default behavior is still to produce an NUnit xml file but we can
now produce xunit format too with the --xunit option.
Slightly refactored the xml reporting into distinct methods for NUnit/xunit.
Roslyn submodule was updated to enable more automated tests. This bumps our submodule revision, and uses roslyn's script to run tests instead of ours.
@monojenkins skip
Part of #6991
* [ci][cxx][sdks] C++ support for SDKs.
* Remove cplusplus support, only cxx.
* [cxx][sdks] Provide isinf and isnan.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/1/parsed_console/log.html
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/jit-icalls.c:994:14: error: 'isinf' was not declared in this scope
if (isinf (v) || isnan (v))
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/jit-icalls.c:994:27: error: 'isnan' was not declared in this scope
if (isinf (v) || isnan (v))
* Change target card mask from gpointer to mgreg_t.
Consider in future target_gsize instead, though if registers are larger than pointers (x32, arm64_32), ok.
Change inst_imm from mgreg_t to target_mgreg_t.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm-cxx/1/parsed_console/log.html
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-runtime.c:3657:24: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
g_assert ((((mgreg_t)arg) & 1) == 0);
^ ^~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-runtime.c:3658:30: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
arg = (gpointer)(((mgreg_t)arg) | 1);
In file included from /mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c:75:0:
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c: In function 'void mini_emit_write_barrier(MonoCompile*, MonoInst*, MonoInst*)':
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/ir-emit.h:703:39: error: cast from 'gpointer {aka void*}' to 'mgreg_t {aka int}' loses precision [-fpermissive]
inst->inst_imm = (mgreg_t)(imm); \
^
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/method-to-ir.c:2989:4: note: in expansion of macro 'MONO_EMIT_NEW_BIALU_IMM'
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PAND_IMM, offset_reg, offset_reg, card_table_mask);
^~~~~~~~~~~~~~~~~~~~~~~
* [cxx][sdks] Move include out of extern "C" where it never belongs.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/4/parsed_console/log.html
template<typename _Tp, typename _Up, typename _Vp,
^
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/ext/type_traits.h:205:3: error: template with C linkage
template<typename _Tp, typename _Up, typename _Vp, typename _Wp,
^
In file included from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/mono-compiler.h:31:0,
from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/dlmalloc.h:33,
from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/utils/dlmalloc.c:27:
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/cmath: In function 'constexpr float std::abs(float)':
/Users/builder/android-toolchain/mxe-b9cbb53/lib/gcc/x86_64-w64-mingw32.static/5.4.0/include/c++/cmath:87:16: error: conflicting declaration of C function 'constexpr float std::abs(float)'
abs(float __x)
* Expand cmath to wasm.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm-cxx/5/parsed_console/log.html
/mnt/jenkins/workspace/test-mono-pull-request-wasm-cxx/mono/mini/mini-llvm.c:4189:6: error: 'isnan' was not declared in this scope
if (isnan (val))
^~~~~
* Provide cmath std::isnan for WebAssembly C++.
* Provide cmath std::isfinite for Android C++.
* Add cmath std::isunordered for Android
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:3282:14: error: use of undeclared identifier 'isunordered'; did you mean 'std::isunordered'?
CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
^~~~~~~~~~~
std::isunordered
* Add cmath std::isinf for Android.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/10/parsed_console/log.html
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:3751:8: error: use of undeclared identifier 'isinf'
if (isinf (sp [-1].data.f))
* "using std::isinf" sometimes breaks on Android, sometimes fixes Android,
because Android sometimes has global isinf.
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android-cxx/mono/mini/interp/interp.c:92:12: error: target of using declaration conflicts with declaration already in scope
using std::isinf;
^
/Users/builder/android-toolchain/toolchains/arm64-v8a-clang/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../include/c++/4.9.x/cmath:604:3: note: target of using declaration
isinf(double __x)
^
/Users/builder/android-toolchain/toolchains/arm64-v8a-clang/bin/../sysroot/usr/include/math.h:234:6: note: conflicting declaration
int (isinf)(double) __pure2;
There are still some errors in new lanes (WebAssembly works, Android does not, iOS not sure), to be addressed shortly, possibly by redoing some of the cmath stuff.
* mono_w32handle_wait_multiple: Duplication is ok for WaitAny, exception for WaitAll.
Fixes https://github.com/mono/mono/issues/9089
* Duplicate detection in mono_win32_wait_for_multiple_objects_ex, like mono_w32handle_wait_multiple.
* Move wait duplicate tests from mono/tests to mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs.
Run them with e.g.:
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -test:MonoTests.System.Threading.WaitHandleTest.DuplicateWaitAll`
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -test:MonoTests.System.Threading.WaitHandleTest.DuplicateWaitAny`
Find the full names with:
`PATH="/s/mono2/runtime/_tmpinst/bin:/Users/jay/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/jay/bin" MONO_REGISTRY_PATH="/Users/jay/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-macos/:./../../class/lib/net_4_x-macos//tests:./../../../external/xunit-binaries:.:$MONO_PATH" /s/mono2/runtime/mono-wrapper --debug ./../../class/lib/net_4_x-macos/nunit-lite-console.exe ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll -exclude=NotOnMac,MacNotWorking,NotWorking,CAS -format:nunit2 -result:TestResult-net_4_x.xml -explore`
and look at the resulting .xml file.
I ran them w/ and w/o the fix, verify they both failed w/o and passed w/.
(w/o the fix was a slight hack of the fix)
* Move null checks so other uses can still null dereference.
* Short circuit duplicate search, correct either way.
* Fix windows build -- missing include.
* Add MonoError to mono_win32_wait_for_multiple_objects_ex, probably did this earlier but lost it somewhere in git.
* Add missing include.
* Follow shorter convention of rest of directory.
* Make the code slightly more complicated per PR.
* PR: Split into small used-once functions.
* cleanup
* add static
* PR: sizeof (array [0]) vs. sizeof (type)
* Convert or partially convert mono_domain_try_type_resolve_typebuilder, mono_domain_try_type_resolve, mono_domain_try_type_resolve_name.
In order to use TYPED_HANDLE_DECL, this required splitting handle.h into at least two pieces,
here called handle-decl.h and handle.h.
A fair amount of early returns had to be converted.
* PR: Move mono_domain_try_type_resolve_name from domain-internals.h to reflection-internals.h.
Move mono_domain_try_type_resolve_typebuilder ditto.
Move ves_icall_TypeBuilder_create_runtime_class from object-internals.h to reflection-internals.h.
Move TYPED_HANDLE_DECL (MonoReflectionAssembly) from handle-0.h to reflection-internals.h (previously object-internals.h)
Move TYPED_HANDLE_DECL (MonoReflectionTypeBuilder) ditto.
Add MONO_HANDLE_BOOL to handle.h so we can 1. Stop inverting tests and 2. Prefer
true first in ternary.
x = MONO_HANDLE_BOOL (y) ? z : 0
instead of
x = MONO_HANDLE_IS_NULL (y) ? 0 : z
Add include "reflection-internals.h" to mono-security.c
Add include "reflection-internals.h" to security.h
object-forward.h:
Place MONO_RT_MANAGED_ATTR on MonoReflectionTypeBuilder.
Really it should just be MonoObject, and then implied
by everything that contains it.
Place MONO_RT_MANAGED_ATTR consistently.
Sort by native then managed.
mono_reflection_get_type_with_rootimage: Rename assembly to refection_assembly
and then use assembly to reduce occurences of MONO_HANDLE_GETVAL (assembly, assembly).
mono-security.c: include config.h unconditionally and just once.
* Change mono_class_get_ref_info_raw to return MonoReflectionTypeBuilder* instead of MonoObject*.
Remove casts on mono_class_get_ref_info_raw calls.
Change mono_class_get_ref_info to return MonoReflectionTypeBuilderHandle instead of MonoObjectHandle.
Move mono_class_get_ref_info from object-internals.h to reflection-internals.h.
Use mono_class_get_ref_info instead of mono_class_get_ref_info_raw.
* Cleanup -- MONO_HANDLE_BOOL and contains instead of cast.
* PR: Fix incorrect comment. Fix precise GC hole wrt invoke.
It's assuming a device or emulator is already attached or running. On our CI, a new emulator is automatically started at the beginning of the job and shutdown at the end of it.
When building 32-bit binaries on a 64-bit system and vice versa, it is necessary
to pass the `-m32` or `-m64` compiler flags, respectively. Failure to do so will
result not only in linking problems (different binary architecture) but also in
problems when using some system headers which are sensitive to the architecture.
For instance, `ucontext.h` contains register set definitions for different
architectures and building Mono runtime with a 64-bit compiler targetting 32-bit
architecture results in this error:
.../mono/mono/utils/mono-sigcontext.h:173:74: error: ‘REG_EIP’ undeclared (first use in this function); did you mean ‘REG_RIP’?
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EIP])
The issue here is that the compiler defines the `__x86_64__` macro which causes
`ucontext.h` to choose declarations for amd64 (which does not use `REG_EIP` but
has `REG_RIP` instead) while Mono runtime assumes its building for a 32-bit host
and uses 32-bit register names. Passing `-m32` to the compiler will fix the
issue as now the compiler will define the `__i386__` macro and all parties will
agree where they are and what they want.
This commit uses a rather baroque statement when constructing compiler flags to
build the Mono runtime to check whether the host triple targets 32 or 64-bit
host and adds the appropriate flag.
* [System]: Make sure `HttpWebRequest` observes exceptions on timeout. #10488.
`HttpWebRequest.RunWithTimeoutWorker()` needs to observe the worker task's exception
on timeout to prevent it from being thrown via the `TaskScheduler.UnobservedTaskException`
event. Fixes#10488.
* Add `TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.OnlyOnCanceled` as suggested by Marek.
* Use 'OnlyFaulted' only.
PAL_gssapi.c was converted to C recently in corefx but since our fork is not up to date I copied `PAL_gssapi.c` and `PAL_gssapi.h` into mono/metadata (I guess I should just cherry-pick those files to our fork).
For System.Data it will allow users to connect to sql servers using SSPI (Security Support Provider Interface).
See https://github.com/mono/mono/issues/9028 and https://github.com/mono/mono/issues/9751
on macOS (and iOS) it uses built-in GSS.framework.
on Linux it requires an additional package (`krb`) to be installed (see .NET Core prerequisites, e.g. https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x#ubuntu).
Unfortunately it's not installed on our CI yet.
* Some cleanup in appdomain.c.
- Combine exit paths.
- npaths is always incremented, so remove test against 0 (assuming no overflow).
* Change g_strdelimit first parameter from string to character.
* Fix C++ -- goto around init.
* PR: Restore legacy types gint, gchar.
* [wasm] Add beginnings of linker support in AOT mode.
* Fix the compilation of monolinker.exe.
* Link in libmono-icall-table.a as well.
* Copy monolinker.exe instead of building it.
* [jit] Fix a constant propagation problem on 32 bit with iconst+conv.i8, we would be setting inst_imm even for long opcodes.
* [llvm] Fix the special casing of OP_LCOMPARE_IMM, its not needed.
* Use TARGET_SIZEOF_VOID_P.
* [wasm/gc] It's valid to register for finalization an object without a finalizer. Don't register for fin objects added to refqueues under sgen.
The refqueue change undo part of 87fb34d18a.
This is due to how track resurrection weak refs are implemented under boehm and sgen. Sgen natively supports them so we don't
need to emulated it by registering them for finalization. This produces a lot of useless work for the GC.
* [wasm] Enable SRE.
[interp] Optimize ldtoken + GetTypeFromHandle pair
As we do with jit. Improves speed of typeof operator by 10-15 times.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
mono/mini/mini-runtime.c so it can use the correct ifdefs
which should fix WebAssembly compilation and let it work on
Mac and Win32 also. This means we no longer need HOST_LINUX in configure.ac either.
Note that for Win32 we don't have the same sort of execution
of a debugger for this to help, but you can see it works
if you run in a debugger and break on mono_sigsegv_signal_handler_debug.
* Fix outarg_vt processing. Fixes#10549
* Cleanup unused bits and pieces
* Correct the handling of structures being retuned from a call
* Restore vtcopy code etc.
[llvm] Make sure OP_LSHL_IMM is transformed to a 64 bit shift even if the input is 32 bit, which can happen because the JIT IR is not regular. Fixes bug-17590.exe on arm64+fullaot+llvm.
Fixes https://github.com/mono/mono/issues/10527
* mono_aot_get_unbox_trampoline: amd64 compute unbox trampoline size correctly via runtime disassembly.
This fixes: MonoTests.System.Linq.ParallelEnumerableTests.TestGroupBy frequently crashing on FullAOT/LLVM/Linux/amd64 CI.
https://github.com/mono/mono/issues/10441https://github.com/mono/mono/issues/9554https://github.com/mono/mono/issues/9046
Race condition because the code varies in what actually runs.
Sometimes System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT is called,
sometimes not.
FullAOT+LLVM for obvious reasons.
Very sensitive to exact code presumably because the bug depends on whether the first
unbox trampoline has the same size as the unbox trampoline for System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT?
For example, this could be the only unbox trampoline or it could be first.
For example System_Security_Cryptography_ECCurve_get_Oid gets the first unbox trampoline and compiling it with mini or LLVM makes a difference.
Guessing here:
When the first unbox trampoline is 9 bytes in size and
System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
is 6 bytes in size, then System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT's
unbox trampoline, which comes right before System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
is thought to be 9 bytes also, which overlaps System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT.
So the binary search finds that, which goes wrong somehow -- mono_aot_find_jit_info returns NULL (for reasons not debugged).
And then we fail to wrap System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
with a gsharedvt trampoline.
In the normal course when things work, calling System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT
goes through both gsharedvt_out_trampoline and gsharedvt_trampoline.
The first turns a byref into a byvalue, the second turns it back into a byref.
When the second is skipped, we end up treating the value as a pointer and SIGSEGV.
This can be seen using https://github.com/mono/mono/pull/10582.
mini amd64 unbox trampolines are always 9 bytes -- 4 byte add, 5 byte jmp
LLVM amd64 unbox trampolines vary 6 or 9 -- 4 byte add, 2 or 5 byte jmp.
There are *many* possible ways to fix this.
1. Runtime disassembly to measure the trampoline size, each trampoline, allowing just two variations. This was written, tested, works. Downside is inhibits breakpoints, at an unlikely time and place, and inhibits execute only memory protection, also unlikely. Looks a little gnarly, but really is not.
2. Get the assembler to output fixed size trampolines.
This is known for GNU assembler -- (disp32) jmp and jmp.d32.
This is not known for Apple assembler, either the older cctools or LLVM, but maybe.
The problem *seemed* to be Linux only, but the underlying causes do not.
If this were looked into more closely and a Linux-specificity actually found, then depending on GNU as is more reasonable.
3. Output object files instead of assembly text. Good and bad idea otherwise. Super non-trivial.
4. Construct the tramp_info at compile time, with compiler/assembler/linker-computed size. This should be possible and otherwise beneficial, but not trivial, and not super beneficial, only mildly.
const static data/code is generally prefer over dynamic.
5. Don't bother with the trampinfo at all. It should not be needed, even for stackwalk, as these are leaf functions (don't change nonvolatiles), so stackwalk is just *rsp++.
Good idea for another day, as it is a simple net reduction in code, pending testing a not easy to test case -- need to make a function that just jmps to self, point a thread at it, wait till it gets there, suspend it, and stackwalk it. A good exercise, for another time.
6. Pad out trampolines to at least 9 bytes by adding 3x 0xcc.
Sometimes 12 bytes.
And hardcoding size as 9 at runtime -- don't use the actual computed size, as it could be 12, apply that to a 9 byter, and back with the same problem.
That is one incorrect solution in there -- just merely adding 3 bytes of padding seemed at first like a good idea, but would not likely work.
7. Or rather, no need to pad, hardcode to 6 at runtime.
8. Or rather, hardcoding to 5 suffices. Interior bytes of last instruction need not be described, pretend it is of size 1. 2 is no more accurate than 1, when some of them are actually 5.
9. Can hardcode in compiler or runtime.
Both developed, easy.
10. Try current assemblers. Maybe the original reason to switch from 0xe9 to jmp is moot.
But continue to work with old assemblers? (in a test-only scenario?)
Not attempted.
11. Use separate source files to help achieve distance or assembler ignorance of distance.
Not attempted.
12. Move all the trampolines adjacent, with 128 bytes of padding on either end.
Not attempted.
13. Asserting the trampolines are 16-aligned would maybe work. And/or following them with a 16-aligned entity.
Here we option 9, hardcode to 5 in the compiler. It is essentially a one line change.
Removing the trampinfo and testing async stack walk is left as a future change.
This is really the best option but has more significant test burden.
* Increment MONO_AOT_FILE_VERSION to invalidate old bad images.
The badness is borderline -- limited to FullAOT+AMD64+LLVM, which is nonexistant outside test environments. This version should probably be a guid also.
It is not clear how this should be represented.
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa
"Note that an ANSI environment block is terminated by two zero bytes: one for the last string,
one more to terminate the block.
A Unicode environment block is terminated by four zero bytes: two for the last string,
two more to terminate the block."
Is unambiguous however.
* Add support for:
- Get global object - This allows developers access to variables of javascripts global space. For example the window object in the Browser.
- Add reference counting to the javascript object registry in the bindings. This can prevent a javascript object that is in the object registry from being removed unexpectedly.
- Add AddRef and ReleaseRef to manage object registry reference counting if it is needed.
* Add support for an HttpMessageHandler that works for WASM.
- Needs real world testing before we decide to make this a default.
- Depends on the delivered bindings.dll and the bindings support built.
- Due to the bindings dependency there is no need to add extra javascript library to the build.
- Works only through a browser session at this time as it works directly with window.fetch.
* Free the Task Completion Source after the promise completes.
* There are some headers that can only be attached to the Content's Headers.
- If the header returned from fetch can not be added to the response header then try to add it to the Content headers.
- Fix misspelling in binding_support.js
* Remove reference counting from bindings.
- Remove object disposal from WasmHttpMessageHandler.
* Add bindings.dll requirement to wasmhttp.dll build.
* Clear the HttpResponseMessage after setting the TaskCompletionSource so it can be garbage collected.
* [interp] move thread attach to interpreter entry
We want to attach a thread before any TLS operation is done by the
interpreter. In the JIT this happens inside the native-to-managed
wrapper via `mono_threads_attach_coop ()`. Unfortunately, this is too
late for the interpreter as it already requires a working TLS before
even calling into the wrapper.
Also, fixup naming of locals in the native-to-managed wrapper.
* [interp] do not propagate uninitialized ThreadContext to JIT TLS
* [interp] fix memory corruption around pinvoke wrapper allocation
* [interp/jit] fix memory leak in pinvoke wrapper allocation
* Make test.js use generated driver and bindings.
- bindings_tests.dll uses the generated bindings.dll.
- Modify packager to accept a template parameter that overrides the default `runtime.g.js`.
- Modify the tests to call runtime.js in the test-suite directory
- The runtime.js is automatically created in the test-suite library so no need to do extra copies.
- resolves https://github.com/mono/mono/issues/10244
* Add -template option to packager
- Part of merge conflict resolution
* Add -asset option that allows an extra asset to be copied to the output directory.
- --asset=x Add specified asset 'x' to list of assets to be copied
- An asset option needs to be specified for each asset to be copied.
Handle ref returns in runtime invoke wrappers.
Indirectly load ref return values in invoke wrappers and return by value.
Don't share wrappers with ref returns since indirect load is used.
Add soft debugger support for methods with ref returns.
* [metadata] Hack - get mono_use_interpreter from metadata
Don't use this, it's a mistake. The granularity is all wrong, for one: in the
future the interpreter may not be an all-or-nothing deal.
* [marshal] Don't emit CEE_MONO_JIT_ATTACH except for interpreter
Always use the mono_threads_coop_attach/mono_threads_coop_detach pair.
* [aot] Drop MONO_PATCH_INFO_JIT_THREAD_ATTACH
We always emit the mono_threads_attach_coop icalls now.
Bump MONO_AOT_FILE_VERSION
* [mini] mark mono_jit_thread_attach external only
It's used by Xamarin.Mac and possibly other embedders.
Interpreter still used mono_jit_thread_attach_interp until it's fixed to work
with coop.
There shouldn't be any other callers.
* [interp] Add a thread attach EE callback
Use it to set the interpreter thread context on the JIT tls value
* [marshal] Always emit mono_threads_attach_coop instead of CEE_MONO_JIT_ATTACH
Use the coop icall for the interpreter, too.
* [interp] Drop MINT_MONO_JIT_ATTACH and detach opcodes
* [metadata] Drop CEE_MONO_JIT_ATTACH and detach opcodes
* Revert "[metadata] Hack - get mono_use_interpreter from metadata"
This reverts commit c3d2f488b824dcdfa261f8292013c805740f353f.
* [mini] Drop unused mini_jit_thread_attach_interp
It was a temporary workaround for the interpreter; no longer needed.
* [coop] Switch to GC Safe in mono_jit_thread_attach.
It's an external-only function that's not called by the runtime on any
threads. So the only calls are explicit uses by Mono API clients. Leave the
thread in GC Safe mode and leave it to the n2m invoke wrappers or MONO_API
entry points to switch to GC Unsafe.
* [interp] Add MINT_MONO_THREADS_ATTACH_COOP opcode
Because this icall can be called from detached threads, don't go through
do_icall () which needs initialized tls keys
* fixup for c++ build
* fixup indentation and comments
* fixup C++ a bit more
* [mini] Bump MONO_EE_API_VERSION
* Revert "[interp] Add a thread attach EE callback"
This reverts commit 8a343d6ce15f0475a62936f28264f638ebf0344f.
* [interp] sync jittls context before entering EH machinery
Indirectly load ref return values in invoke wrappers and return by value.
Don't share wrappers with ref returns since indirect load is used.
Add soft debugger support for methods with ref returns.
* [wasm] Rename 'wasm-aot' to 'wasm-cross' for consistency with the other SDKs.
* [wasm] Use the separate libmono-ee-interp.a library for linking in the interpreter.
* [wasm] Unify interp and aot runtimes.
* [wasm] Avoid cleaning the emscripten toolchain when cleaning the runtime or cross compilers.
* [wasm] Use the sdk llvm targets to build the cross compiler, so it can use a downloaded llvm instead of building its own.
* [offset-tool] Add WASM support.
* [wasm] Generate offsets file for wasm.
* [wasm] Switch packager.exe to use Mono.Options, add a --mono-sdkdir option to specify the path to the mono sdk.
* [wasm] Emit a ninja build file from the packager when the --builddir argument is given.
* [wasm] Auto generate the aot registration code by generating a driver-gen.c file and including it into driver.c.
* [wasm] Add emcc link step to the ninja build script.
* zoltan's changes.
* [wasm] Fix merge conflicts from picking Zoltan's patches.
* [sdks] Fix the wasm build so the package target doesn't build 394839840 llvms.
* [wasm] Fix mono_arch_create_specific_trampoline to work with the AOT compiler reverse lookup of icalls
* [wasm] Don't set minimum memory size, let it dynamically grow.
* [wasm] Remove old aot targets. Now do-aot-sample does the whole magic.
* [wasm] Attept at making the offsets-tool work on linux.
* [wasm] Cleanup the hacks early in this PR.
* [wasm] Fix rebase issue.
* Fix rebase
* Fix rebase
* [llvm] Only emit the dummy arg when targeting wasm.
Part of #9660.
The changes:
- included corefx version of PropertyInfo type;
- included related xunit tests from corefx System.Reflection;
- moved `GetPropertyFromHandle `method to MonoProperty type;
- moved `internal_from_handle_type `extern method and related icall to MonoProperty type;
- fixed some edge cases where exception is expected;
- removed obsolete System.Reflection/PropertyInfo.cs.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* [System.IO] Enable CoreFX FilesystemWatcher on Android
This was the last user of the 'InotifyWatcher' Mono implementation, so this is also removed.
* [csproj] Update project files
* Ensure the finalization of SafeHandle and GCHandle in DeflateStreamNative is performed in the correct order.
* Do not access BaseStream from finalizer.
* Fix Mono Windows cross compiler using mono LLVM release_60 branch.
For scenario where llvm-config.exe can't be run (none WSL/CygWin build target)
Build will fallback to hard coded libraries not working with mono LLVM release_60
branch.
Added an exact mirror of what llvm-config.exe is returning for different components
on mono LLVM master and mono LLVM release_60 branch.
The selected codegen libraries (passed in as extra_libs) was not handled in any cases
so added them into the build script as well.
* Split parameter between lvm codegen libs and llvm extra libs.
Need to explicit pass -lz in case where configure have detected zlib availability
and llvm-config.exe can't be executed. In cases where zlib is not available, default
in mingw installs, this check make sure link step won't fail due to missing library.
* Fix inversion of aarch64codegen libs.
* Enable package-android-cross-{arm,arm64,x86,x86_64}-win builds on CI.
* Fix incorrect checks when compiling Windows cross compiler.
Windows cross compiler could have a target that is !TARGET_WIN32 but still
running on a Windows host, so check needs to look at !HOST_WIN32 to determine
if Unix source files can be included or not.
* [metadata] Fix Thread.Yield icall function signature
The signature exposed on the C# side has a boolean return but the actual C implementation used to be marked as void.
This caused an issue with the WASM backend as the interpreter would try to jump to the icall using an `MINT_ICALL_V_P` opcode. Since emscripten does function pointer jumps based on a function signature key and the signature mismatched on the C side, the jump would fail triggering the `nullFunc_i(x)` on the mono.js side.
* [wasm] Add facade resolving to packager tool
* [wasm] Use correct mono_bindings_init syntax to initialize bindings library
* [interp] Remove some duplicated code
* [interp] Don't abort in critical wrappers
Fixes premature exiting of special threads due to aborts (like threadpool threads), instead of catching exception and resuming to native code.
By default, all projects are build using "default" compiler based on source
file extension. There is a property in mono.props, MONO_COMPILE_AS_CPP
that could change this and build selected projects (eglib, libgcmonosgen,
libmini, libmono-dynamic, libmono-static, libmonodac, libmonoruntime,
libmonoutils, mono, monodis, monograph and pedump) using C++ compiler.
MONO_COMPILE_AS_CPP property could be set when calling msbuild
or through VS property manager IDE. Default value is false building using
"default" compiler (current behavior). When setting MONO_COMPILE_AS_CPP=true
the build prefix will be altered to make sure the C++ build gets its own build
folder, parallel to default build folders.
Example of building using C++ compiler from msbuild:
msbuild /p:PlatformToolset=v140 /p:Platform=x64 /p:Configuration=Release /p:MONO_TARGET_GC=sgen /p:MONO_COMPILE_AS_CPP=true msvc/mono.sln
We can't decrement the size on removal as we use tombstones.
When using tombstones, the invariant to keep is on the number of null entries as those
are used as search stop-marks.
Without this change, it's possible that a long series of add/remove operations could leave the array with no null entries,
just tombstones and filled entries. In that case, search would degenerate into a linear search that would look into all array elements.
This change fixes worst-case perf of not-found searches to be bound to the load factor.
Additionally, clear the array to null entries, otherwise we fall into the above trap even more easily.
* gmisc-win32.c(136): error C2664: 'HRESULT SHGetKnownFolderPath(const KNOWNFOLDERID&,DWORD,HANDLE,PWSTR *)': cannot convert argument 1 from 'const GUID *' to 'const KNOWNFOLDERID
REGUID is const GUID& in C++, const GUID* in C*.
It is impossible to have portable C/C++ that deals with this.
This feels like a mistake, but it is ancient and not changing.
* gpath.c(102): error C2440: '=': cannot convert from 'const char *' to 'char *'
Add const, like in the non-Windows case right before.
* sgen-gc.c(1381): error C4576: a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax
A inline function would trivially portably standardly solve this,
but wrap in compiler-specific pragma to suppress.
* [cxx] abi.c(60): error C2059: syntax error: '.'
Remove designated initializer.
[mono] Compiler warnings fixes
This fixes a bunch of warnings in threads.c. Compare-exchange cast is unfortunate because it would do without if we had platform long sized cas helper around - tid is always u32 on Windows (DWORD), and pthread_t is always long int, which could be 32 or 64 bit.
* Adapt typesafe coop handles to be valid standard C++. i.e. valid for Visual
C++, w/o gcc/clang language extension __typeof__. This is not meant to be
long term idiomatic C++, just enough to get us by for now.
The solution does not quite work for type unsafe handles, because
checking for this == NULL is not defined. A non-member function
would be needed.
C++11 decltype could be used instead at the MONO_TYPEOF_CAST level,
but this solution is trivial C++98.
Visual C++ historically was seen to have trouble giving names
to member functions of anonymous types -- an unusual construct.
So the previously anonymous structs are given a name here.
* Go back to anonymous type.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-ios/4408/parsed_console/log.html
CC libmonoruntimesgen_la-method-builder-ilgen.lo
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/marshal-ilgen.c:6403:29: error: use of undeclared identifier 'MONO_OFFSET_MonoObjectHandlePayload___raw'; did you mean 'MONO_OFFSET_MonoObjectHandle___raw'?
mono_mb_emit_ldflda (mb, MONO_HANDLE_PAYLOAD_OFFSET (MonoObject));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MONO_OFFSET_MonoObjectHandle___raw
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/handle.h:426:42: note: expanded from macro 'MONO_HANDLE_PAYLOAD_OFFSET'
^
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/handle.h:425:50: note: expanded from macro 'MONO_HANDLE_PAYLOAD_OFFSET_'
^
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-ios/mono/metadata/abi-details.h:56:42: note: expanded from macro 'MONO_STRUCT_OFFSET'
^
<scratch space>:89:1: note: expanded from here
0dbcdd5c28 added CFLAGS etc in front of the
command but that's not something the TESTCMD can execute.
We need to pass those variables to the whole process.
Part of https://github.com/mono/mono/issues/9660
The changes:
- included corert version of CustomAttributeTypedArgument type;
- included related xunit tests from corefx System.Runtime;
- updated corert/Type.cs to have some required properties from corert Type.Internal.cs;
- removed obsolete System.Reflection/CustomAttributeTypedArgument.cs;
- moved back "array case" handling in CustomAttributeTypedArgument ctor (via related PR);
- re-enabled "Arrays" test in CustomAttributeDataTest on mobile.
* [cxx][metadata] Cast from void.
* [cxx][metadata] Casts, mostly from void*.
* [cxx] [metadata] MONO_BEGIN_DECLS / MONO_END_DECLS only in public headers.
G_BEGIN_DECLS / G_END_DECLS are ok in private headers (and .c), but the vast majority of uses are not needed. In this case, every function is MONO_API anyway.
* [cxx] [metadata] Add template for mono_mb_emit_native_call under #ifdef __cplusplus.
* [cxx] [metadata] Loosen the parameter type in mono_vtype_get_field_addr from guint8* to gpointer.
* [cxx][metadata][profiler] Add G_ENUM_FUNCTIONS (MonoProfilerCallInstrumentationFlags), outside of the public header MonoProfilerCallInstrumentationFlags is defined in.
* [cxx][metadata][profiler] Cast void* to function pointer MonoProfilerCallInstrumentationFilterCallback.
* [cxx][metadata] Cast from void*.
* [cxx][metadata][sgen] Change sgen_client_root_registered(source) from int to enum MonoGCRootSource.
* [cxx][metadata][sgen] Change report_conservative_roots(root_report_address) from char* to void*.
* [cxx][metadata][sgen] In mono_gc_register_obj_with_weak_fields, cast parameter from void* to MonoObject*.
* [cxx][metadata][sgen] In sgen_client_gchandle_created and sgen_client_gchandle_destroyed, cast handle_type from int to MonoGCHandleType. This could be better.
* [cxx][metadata][sre] In mono_dynimage_encode_constant, change local box_val from char* to void*.
* [cxx][metadata][sre] Change swap_with_size(dest, val) from {,const}char* to {,const}void*. Move function starting brace to its own line.
* [cxx][metadata][sre] encode_cattr_value(argval) from char* to const void*.
* [cxx][metadata][sre] Add ICALL_EXPORT to ves_icall_TypeBuilder_create_runtime_class.
* [cxx][metadata] Templatize mono_thread_create_internal and mono_thread_create_checked. FIXME: Fix the parameter type and inputs.
* [cxx][metadata][threads] Cast from void* to MonoCoopMutex*.
* [cxx] Fix return type of start_wrapper_internal -- guint32 vs. gulong.
* [cxx][metadata] In start_wrapper_internal, cast function pointer to void*. Later we should get all the types correct.
* [cxx][metadata] Fix return type of start_wrapper from gsize to mono_thread_start_return_t.
* [cxx][metadata] create_thread: Remove cast on first parameter to mono_thread_platform_create_thread.
* [cxx][metadata] Add ICALL_EXPORT on ves_icall_System_Threading_Thread_GetPriority.
* [cxx][metadata] g_cast does not allow for ternary operator though it could with one line; add casts to workaround; remove cycle optimization from error path, favoring smaller code.
* [cxx][metadata] ves_icall_System_IO_MonoIO_Read, ves_icall_System_IO_MonoIO_Write: Change relatively untyped data from char* to void*.
* [cxx][metadata] Add parentheses around define INVALID_HANDLE_VALUE to avoid surprises.
* [cxx][metadata] In mono_w32handle_convert_wait_ret, cast between int and enum MonoW32HandleWaitRet. We could also give up on enums for this type.
* [cxx][metadata]ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal: Add cast to HWND.
* [cxx][metadata] Cast to HMODULE. Add const.
* [cxx] w32process.h: Add missing ICALL_EXPORT.
* [cxx][metadata] w32socket-win32.c: add const on string literals.
* [cxx] mono_w32socket_recvbuffers: cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.
* [cxx] mono_w32socket_send: cast from void* to char*.
* [cxx]mono_w32socket_sendbuffers cast to LPWSAOVERLAPPED and LPWSAOVERLAPPED_COMPLETION_ROUTINE.
* [cxx] mono_w32socket_getsockopt cast from void* to char*.
* [cxx] mono_w32socket_setsockopt cast from const void* to const char*.
* [cxx] mono_w32socket_ioctl fix out parameter written from glong* to DWORD* to avoid casts.
* [cxx] [w32socket] Remove casts on calls to mono_w32socket_getsockopt and mono_w32socket_setsockopt since they nicely accept void* and const void*.
* [cxx][w32socket] Change output_bytes from glong to the correct DWORD to avoid casts.
* [cxx] Add ICALL_EXPORT to ves_icall_cancel_blocking_socket_operation.
* [cxx] Remove keyword 'template'.
* PR: Revert "[cxx] Fix return type of start_wrapper_internal -- guint32 vs. gulong."
This reverts commit 8e02c9cf732a80b77af59b9a11fceaca7490a87c.
https://github.com/mono/mono/pull/10432#discussion_r215009888
This area of thread creation needs work.
1. We have function pointers with almost gratuitous casts,
2. inconsistent return types (motivating function pointer casts)
3. return values ignored
https://github.com/mono/mono/issues/10467https://github.com/mono/mono/issues/10319#issuecomment-417739621
and more.
* [cxx][mini] compile_methods: cast function pointer passed to mono_thread_create_internal to void*. This should be improved in future.
* [cxx][mini] mono_read_method_cache: C++ does not allow goto around initialization.
* [cxx][mini] mono_read_method_cache: C++ does not allow goto around initialization.
* [cxx][mini] decode_exception_debug_info: Use Enum a |= b instead of a = (Enum)(a | b); one of these might be have recent damage.
* [cxx][mini] init_method: C++ does not allow goto around initialization.
* [cxx][mini] get_new_trampoline_from_page: cast twice to guint8* instead of void*.
* [cxx][mini]Strengthen MonoAotFileInfo.runtime_version from void* to char*.
* [cxx][mini] Weaken decode_vtype(addr, buf) from guint8* to void*, but then assign right back to guint8* locals for easy to author and read diff.
* [cxx][mini] Weaken decode_value(addr, buf) from guint8* to void*, but then assign right back to guint8* locals for easy to author and read diff. (like previous but decode_vtype vs. decode_value)
* [cxx][mini] vm_commands: standard C++ has no designated initializers; actual support by compilers varies, but effectively no support and trivial to do without. (current clang++ good support, current g++ some support, g++4.4 no support, msvc presumed no support).
* [cxx][mini] Cast function pointer from void* to correct type.
* [cxx][mini] exceptions-amd64.c: mono_arch_ip_from_context: cast from integer to void*.
* [cxx][mini] exceptions-amd64.c: mono_arch_ip_from_context: cast from void* to MonoContext*.
* [cxx][mini] exceptions-amd64.c: fast_find_range_in_table_no_lock_ex: Cast from void* to DynamicFunctionTableEntry* twice. On the second one, it might be clearer to put the cast further to the left, i.e. just after =.
* [cxx][mini] exceptions-amd64.c: initialize_unwind_info_internal: Cast parameter to mono_arch_unwindinfo_create to void**.
* [cxx][mini] exceptions-arm.c: mono_arm_get_exception_trampolines: Change local variable tramp from guint8* to void*.
* [cxx][mini]exceptions-wasm.c: Cast returned function pointers to void* a few times.
* [cxx][mini] exceptions-x86: Fix win32_handle_stack_overflow(sctx) to be CONTEXT* instead of struct sigcontext *.
* [cxx][mini] exceptions-x86: win32_seh_init: Cast mono_win32_get_handle_stackoverflow() from void* to correct function type.
* [cxx][mini]mono_arch_exceptions_init: Cast GetProcAddress() to correct function pointer type and call through correctly typed function pointers.
* [cxx][mini]exceptions-x86.c: mono_arch_ip_from_context: Cast from integer to void*.
* [cxx][mini]exceptions-x86.c: mono_arch_handle_exception: Cast from void* to struct sigcontext*.
* [cxx][interp] C++ deprecates the register keyword, remove it.
* [cxx][interp] C++ deprecates the register keyword, remove it.
* [cxx][mini] liveness.c: Change MonoPtrSet to a union and then use GHashTable* instead of void* instead of casting from void*.
* [cxx][mini] main.c: probe_embedded: Change local item_size from uint64_t to uint32_t to fix error about it being truncated when initializing MonoBundledAssembly. Could cast instead.
* [cxx][mini] C++ does not allow goto around initialization.
* [cxx][mini]Do not mixup enum types between MONO_CEE_ and CEE_. This fixes an error. We might wanto have the one set of values alias the other, but this wasn't a big problem actually.
* [cxx][mini] C++ does not allow goto around initialization.
* [cxx][mini] Cast from void*.
* [cxx][mini] Cast pointer to pointer-sized integer before casting
to integer or enum. Otherwise errored.
* [cxx][mini] Cast function pointer to void* to mono_arch_instrument_prolog() and mono_arch_instrument_epilog().
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8* -- probably reduced need for additional casts.
* [mini] A field per line (MonoCompileArch.omit_fp, omit_fp_computed).
* [cxx][mini] Cast mono_aot_get_trampoline() to guint8* from void*.
* [cxx][mini] Cast parameters to __builtin___clear_cache from guint8* to char*.
* [cxx][mini] Remove casts on mono_arch_get_seq_point_info().
* [cxx][mini] Cast g_hash_table_lookup() from void* to SeqPointInfo*.
* [cxx][mini] Cast integer to enum MonoJumpInfoType. Could maybe change the incoming type to MonoJumpInfoType.
* [mini] A field per line (MonoCompileArch.omit_fp, omit_fp_computed).
* [cxx][mini] Remove cast to CallInfo*.
* [cxx][mini]mini-arm64.c: Cast pointer to pointer-sized integer before casting to other integer or enum.
* [cxx][mini] Cast from void* to guint8*, though this one is now covered by g_cast.
* [cxx][mini] Change types and add casts due to void*/non-void* mix.
* [cxx][mini] mini-exceptions.c: first_managed change local data from void*** to void**, and likewise the cast on its assignment.
* [cxx][mini][profiler] Cast integer to enum MonoExceptionEnum multiple times.
* [cxx][mini] Weaken mono_handle_exception(obj) from MonoObject* to void*, and then store it right into a local MonoObject*. This alleviates casts elsewhere.
* [cxx][mini] Cast g_hash_table_lookup() from void* a few times.
* [cxx][mini] More pointer casts.
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8* to alleviate casts.
* [cxx][mini] Cast result of mono_arch_instrument_prolog() and mono_arch_instrument_epilog().
* [cxx][mini]Change MagicTypeInfo.{big_stack_type,small_stack_type,stack_type} from short to enum MonoStackType : 16, under #ifdef __cplusplus, to allevate casts and strengthen types.
* [cxx][mini] Cast from integer to enum MonoStackType. This can probably be improved, i.e. by changing the source type to enum.
* [cxx][mini]emit_intrinsics: Change local stack_type from int to MonoStackType to alleviate casts and strengthen types.
* [cxx][mini] Cast from integer to enum MonoStackType. This can probably be improved, i.e. by changing the source type to enum.
* [cxx][mini] Cast pointers g_hash_table_lookup() and profiler input (byte* instead of void*).
* [cxx][mini] Fix the function pointer parameter type to add_signal_handler so avoid casts, but add one cast from function pointer to function pointer for systems lacking MONO_ARCH_USE_SIGACTION.
* [cxx][mini] mini-posix.c: sampling_thread_func: Remove designated initializer.
* [cxx][mini] Change get_delegate_invoke_impl() from void* to guint8*() to reduce casts at its callers.
* [cxx][mini] Undo g_cast support on mono_arch_instrument_prolog() and mono_arch_instrument_epilog(), probably a mistake from a recent other PR, harmless. i.e. remove parens from around that suppress macro expanstion
* [cxx][mini] Cast return of mono_arch_instrument_prolog and mono_arch_instrument_epilog to guint8*.
* [cxx][mini] Remove a layer from some TLS access -- macro vs. function that might not inline.
* [cxx][mini] Strengthen the parameter to mono_set_lmf_addr() from void* to MonoLMF**.
* [cxx][mini] Provide a typedef MonoAbortFunction for MonoJitTlsData.abort_func.
* [cxx][mini] Strengthen the output of setup_jit_tls_data from void* to MonoJitTlsData* and the input function pointer from void* to MonoAbortFunction, eliminating existing and future casts.
* [cxx][mini] A few pointer and enum/int casts.
* [cxx][mini] Change mini_llvmonly_initial_imt_tramp locals from gpointer* to IMTTrampFunc** to alleviate casts.
* [cxx][mini] Cast some function pointers to void*.
* [cxx][mini] Cast void* to MONO_SIG_HANDLER_INFO_TYPE* for the non-HAVE_SIG_INFO case. We could maybe change the void* local to MONO_SIG_HANDLER_INFO_TYPE*, since we are casting it to that anyway.
* [cxx][mini] Cast function pointer to void*.
* [cxx][mini] Cast void* to GSList* twice.
* [cxx][mini] Cast function pointer to mono_runtime_init_checked. In future we should get all these types and parameters to match.
* [cxx][mini] Cast result of mono_arch_instrument_prolog/mono_arch_instrument_epilog to guint8*.
* [cxx][mini]Change return type of get_delegate_invoke_impl from void* to guint8*.
* [cxx][mini] Cast result of mono_arch_instrument_prolog/mono_arch_instrument_epilog to guint32*.
* [cxx][mini] Cast function pointers to void*.
* [cxx][mini] Cast from void* to non-void*.
* [cxx][mini] Change types and add casts due to void*/non-void* mix.
* [cxx][mini] Pointer casts.
* [cxx][mini] Pointer and int/enum casts, and widen pointer before casting to smaller integer.
* [cxx][mini] Strengthen types from void* to non-void* within x86 MonoCompileArch. (void *cinfo, *ss_tramp_var, *bp_tramp_var; => CallInfo *cinfo; MonoInst *ss_tramp_var; MonoInst *bp_tramp_var;)
* [cxx][mini] int/enum casts
* [cxx][mini] create_jit_info: Use Enum a |= b instead of a = (Enum)(a | b); one of these might be have recent damage.
* [cxx][mini] Pointer/int/enum casts.
* [cxx][mini] Change mono_cfg_set_exception(int) to mono_cfg_set_exception(MonoExceptionType) to reduce casts elsewhere.
* [cxx][mini] Pointer cast.
* [cxx][mini] Change mono_cfg_set_exception(int) to mono_cfg_set_exception(MonoExceptionType) to reduce casts elsewhere.
* [cxx][mini] Pointer casts.
* [cxx][mini] recursively_make_pred_seq_points: Fix parameter to g_array_index from void* to MonoInst*.
* [cxx][mini] Change parameter to decompose_vtype_opt_load_arg from guint32* to gint32*, and assign right back to local guint32*, to avoid casts, and limit diff, and obviously preserve semantics.
* [cxx][tasklets] Add include loader-internals.h.
* [cxx][mini]Fix cast mono_win32_get_handle_stackoverflow() to function pointer restore_stack.
* [cxx][mini] Casts. See https://jenkins.mono-project.com/job/test-mono-pull-request-amd64-osx-products-sdks-android/4480/parsed_console/log.html.
* PR: Replace goto up with goto down, and split decl/init instead.
https://jenkins.mono-project.com/job/w/15083/parsed_console/log.html
assembly.obj : error LNK2001: unresolved external symbol "struct _IMAGE_DOS_HEADER __ImageBase" (?__ImageBase@@3U_IMAGE_DOS_HEADER@@A) [d:\j\workspace\w\msvc\libmono-dynamic.vcxproj]
d:\j\workspace\w\msvc/./build/boehm/Win32\bin\ReleaseCxx\mono-2.0-boehm.dll : fatal error LNK1120: 1 unresolved externals [d:\j\workspace\w\msvc\libmono-dynamic.vcxproj]
Since it is data, extern "C" w/o braces is confusing, but maybe valid, so begin/end form is used.
When creating a diff on windows, the lines are split on the `\n` so the `\r\n` results in multiple lines:
**START SNIP**
Obsoleted methods:
```diff
[Obsolete ("Use AddRoundRect instead.")]
public void AddRoundedRect (SKRect rect, float rx, float ry, SKPathDirection dir);
```
**END SNIP**
This PR makes sure to use the platform line endings everywhere. When adding line endings, use the same that `StringBuilder` uses - platform endings. This makes it easy to split - just use the platform as that is what everyone is using.
* Fix mkbundle alignment to work with Windows. See https://github.com/mono/mono/issues/8225.
Consider doing this only for Windows.
* Align only first file at 64K, the rest the previous 4K.
* Ensure strings are nul terminated, if alignment doesn't handle it.
StringPairs already are.
* Save 30K on average on Unix, for an entire bundle (not per file within, but the entire bundle).
* Probe runtime for for MZ signature to determine if target
is Windows. "Style" is about host.
* [sdks] Add CrossRuntimeTemplate
* [sdks] Add cross-{arm,arm64,x86,x86_64}{,-win} runtimes for XA
* [sdks] Use CrossRuntimeTemplate for iOS
* [sdks] Factor various variables for RuntimeTemplate
* [sdks] Use MonoRuntime template for desktop-x86_64
* [sdks] Unify provisioning of LLVM for both Android and iOS.
A global CFLAGS would be set in `run-jenkins.sh`, and that would screw up with LLVM. The global CFLAGS makes sense as long as we are only building Mono, but that's not the case with LLVM anymore.
* [sdks] Remove android-armeabi, it's been removed from XA already and the target has been deprecated in the NDK
* [jit] Add intrinsics for Math.Round/Floor/Cecil () on SSE41.
* Add LLVM support.
* Fix the build.
* Move the code to mono_arch_emit_inst_for_method ().
* Fix the build.
* [Mono.Options] Add `CommandSet.GetCompletions()`
Add a `Mono.Options.CommandSet.GetCompletions()` method, which returns
all possible commands which match a given "completion prefix".
This is intended for e.g. bash completion support.
* Bump API snapshot submodule
Part of #9660.
The changes:
- included FieldInfo type from CoreFX + related xunit tests;
- made Mono-implemented class partial; removed duplicated code;
- moved GetOptionalCustomModifiers and GetRequiredCustomModifiers methods to MonoField type;
- moved GetTypeModifiers extern method and related icall to MonoField type;
- updated ToString method in CustomAttributeTypedArgument type with CoreFX implementation;
* [cxx] Add const, and static while there.
* [cxx] Auto cast in ARM_EMIT
* [cxx] Cast from int to enum.
* [cxx] Cast from void*.
* [cxx] Cast function pointer to void*.
* [cxx] Cast int to GCHandleType.
* [cxx] Cast to GCObject*.
* [cxx] Cast unsigned char* [cxx] to char*.
* [utils] Cast void* [cxx] to function pointer (FIXME) and remove extra parens (former macro?).
* [cxx] Change int parameter to enum MonoGCRootSource.
* [cxx] Do not goto around init.
* [cxx] Fix cast -- void* [cxx] vs. void**, and volatile per error but it is optional.
* [cxx] Fix type for pointer to array element -- void** [cxx] vs. void*.
* [cxx] Remove duplicate line from Makefile.
* [cxx] Remove incorrect cast.
* [cxx] Remove unneeded cast.
* [cxx] Spell out enum values for easier to read headers.
* [cxx] Split up compound initialization with NULL because the types vary, i.e. remove implicit conversion from void* that would need a cast.
* [cxx] Static thread locals fail to link on Linux; make them extern. FIXME?
* [cxx] Strengthen void* [cxx] to SGenFinalizationProc.
* [cxx] Templatize mono_native_thread_create (FIXME).
* [cxx] Use G_BEGIN_DECLS not MONO_BEGIN_DECLS in non-public headers, for brevity and subtle extra annotation.
* [cxx] Widen integer to pointer-size before casting to pointer.
* [cxx] Wordsmith comment.
* [cxx] Wrapping a bunch of includes in extern "C" is generally in poor form and unnecessary.
* [cxx] [sgen] Remove unnecessary cast.
* [cxx] [sgen] casts
* [cxx] [utils] Add const with a string literal.
* [cxx] [utils] Casts from void* [cxx] and between int/enum.
* [cxx] [utils] Clarify empty macros.
* [cxx] [utils] Compile more as C++ if enabled.
* [cxx] [utils] extern "C" mono_file_map_error. (FIXME?)
* [cxx] [utils] Remove autocast from mono_lock_free_alloc.
* [cxx] [utils] ifdef wasm the type in unused mono_pages_not_faulted so it compiles, remove incorrect comment, add FIXME.
* Use typedefs of structs in the usual fashion.
* [cxx] externC to the 'operating system'
* [cxx] Add externC for debugger interop.
* Fix indentation.
* [cxx] externC on chkstk.
* [cxx] externC on sys_icache_invalidate.
* [cxx] externC on __aeabi_read_tp.
* [cxx] externC on sys_icache_invalidate.
* Remove exactly duplicated license.
* __EGLIB_X11 is defined but never used.
* Let compiler decide inline.
* Get ves_icall_System_Environment_GetOSVersionString declaration from environment-internal.h.
* Put ves_icall_System_Reflection_Assembly_GetCallingAssembly at start of line for grep ^foo.
* Remove accidental space.
* Remove casts and error_init.
* Fix warning: sgen-mono.c:959:36: warning: incompatible pointer to integer conversion passing
'void *' to parameter of type 'MonoGCDescriptor'
(aka 'unsigned long long') [-Wint-conversion]
return mono_gc_alloc_fixed (size, NULL, source, key, msg);
* Add a comment and associate comment more closely with code.
* Remove gratuitous pragma -- header is only included once, fix the include.
* [cxx] Just enough extern "C" for profilers, libtest, MonoSupportW, MonoPosixHelper, THREAD_INFO_TYPE, WebAssembly interop.
Some of this is redundant, i.e. in glib.h and mono-threads-coop.h.
But if someone removes otherwise unnecessary header wrappers, these become meaningful.
This is an alternative to:
https://github.com/mono/mono/pull/10160 Remove most G_BEGIN_DECLS but add back to make things work.
https://github.com/mono/mono/pull/10284 Port libtest to C++
https://github.com/mono/mono/pull/10294 Rework mono-threads.h THREAD_INFO_TYPE parameterization to not violate C++ typesafe linkage.
https://github.com/mono/mono/pull/10297 Fix typesafe linkage problem in gc-internals.h THREAD_INFO_TYPE parameterization.
https://github.com/mono/mono/pull/10341 Port all of MonoPosixHelper MonoSupportW to C++, including K&R zlib.
https://github.com/mono/mono/pull/10342 Port profilers to C++
https://github.com/mono/mono/pull/10378 Port all of MonoPosixHelper MonoSupportW to C++, except K&R zlib.
https://github.com/mono/mono/pull/10375 Eliminate THREAD_INFO_TYPE by suggestion, to fix typesafe linkage.
https://github.com/mono/mono/pull/10379 Mark the 14 functions used by MonoPosixHelper as extern "C" (basically this PR)
Most of the alternatives are very reasonable and remain viable, except porting K&R zlib.
Hopefully in future, SgenThreadInfo will derive from MonoThreadInfo, improving the THREAD_INFO_TYPE fixes.
* [cxx] Replace invalid two extern "C" with just one.
* Strengthen MonoImage.aot_module and _MonoJitInfo.aot_info to be MonoAotModule* instead of void*.
* Strengthen thread locals away from void*.
* Strengthen _MonoThreadInfo from void* to HandleStack*.
* Elminate "struct".
Introduce mono-forward.h and mono-forward-internal.h.
Add cast for profiler.
* Strengthen tramp_info; remove struct on JitInfo; remove a cast.
* Tweak and add #includes accordingly.
Any header that was providing a typedef, or forward declaring a struct and now
using typedef instead must include a header to get it.
Internal types must come from internal header.
Internal header may include internal header.
Public header must not include internal header.
foo.c does not have to include what foo.h must include to declare foo.c's functions (mono-tls.c
does not need to include mono-forward-internal.h)
I misssed mono/metadata/metadata-internals.h: void *image_info; do it later.
* Remove use of sln dependencies and use csproj project references instead
* Rewrite jay.vcxproj so it builds correctly even without help from the sln file
* Force pre-build event to run after references are resolved. Change how culevel.exe path is computed to be more resilient.
* [csproj] Update project files
See my comments in https://github.com/mono/mono/pull/10134 for details.
The problem was that
1. It is wrong to assume that `chain != null`. In fact, it likely won't be if `wantsChain == false`.
2. Similarly, the `storeCtx` should only be used if `storeCtx != NULL && wantsChain == true`.
3. It was missing `MonoBtlsX509Error.HOSTNAME_MISMATCH`.
4. I reformatted and re-indented the method to match Mono's style.
Since `mono_raise_exception_deprecated` never returns, the transition won't be
balanced. This fixes a cookie-counting problem (assert on mono shutdown) in
coop and hybrid checked builds using the new test case:
MONO_THREADS_SUSPEND=coop MONO_CHECK_MODE=thread,gc mono mono/tests/install_eh_callback.exe
* [cxx] Port mono main to be in C++.
This allows to remove more extern "C" from glib.
* [cxx] DllMain should be extern "C".
* [cxx] Make OutOfProcessFunctionTableCallback and OutOfProcessFunctionTableCallbackEx externC.
* Remove do-nothing line and change .o to $(OBJEXT).
[sgen] Fix string size inconsistency between alloc/scan
This could lead to crashes when having strings with size at the LOS boundary.
https://github.com/mono/mono/issues/10309
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
Pass arguments to LLVM's LLC via --aot=llvmllc
Currently we can override arguments passed to llvm's `opt` via `--aot=llvm,llvmopts="some args"`, this PR introduces a similar capability for `llc` - `llvmllc` parameter.
E.g. for my environment Mono uses the following arguments for llc:
```
-march=x86-64 -mattr=sse4.1 -asm-verbose=false -disable-gnu-eh-frame
-enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_fffff_eh_frame
-disable-tail-calls -no-x86-call-frame-opt -relocation-model=pic
-filetype=obj -o "mono_aot_IWvNWm/temp-llvm.o" "mono_aot_IWvNWm/temp.opt.bc"
```
what if I want to test some avx stuff, e.g. `-march=core-avx2 -O2` and test other parameters.
Extracted custom marshaler logic into managed code.
Fixed crash when using mono_verbose_method
Fixed free of zero desc ptr in mini_method_compile when verbose method variable doesn't resolve to a method
If the cfg is in verbose mode emit a brief message on abnormal termination of IR generation
Use CEE_MONO_CLASSCONST to store the type of the custom marshaler since it appears to work with AOT
Handle various error conditions in Marshaler.GetInstance and produce exceptions that roughly match .net framework
Use ValueTuple instead of a custom tuple type. Use LazyInitializer to init dictionary for marshalers on demand.
Add test case for custom marshalers in linker tests (disabled because the linker does not understand custom marshalers yet)
* [cxx] Make some code valid C++, esp. adding casts and esp. not touching allocators.
* [cxx] PR: Update comment on MonoThreadPriority.
* [cxx] PR: Provide templates for register_icall mono_mb_emit_icall
mono_register_jit_icall mono_register_jit_icall_full mono_aot_register_jit_icall
to cast from arbitrary type to gpointer or gconstpointer.
Ideally this would be limited to function pointers but anything is progress here.
* [cxx] Move C++ template mono_add_internal_call from loader.h to new loader-internals.h.
[cxx] Add C++ template register_opcode_emulation.
[cxx] Add C++ template register_icall.
[cxx] Add C++ template register_icall_no_wrapper.
[cxx] Add C++ template register_icall_with_wrapper.
[cxx] Add C++ template mono_emit_jit_icall.
[cxx] Add C++ template mini_register_opcode_emulation.
[cxx] Add #include loader-internals.h.
[cxx] Remove preemptive extern "C++" until/unless needed.
* [cxx] Change preexisting #define register_icall to C++ templates.
- #define HAVE_SGEN_GC in order to get missing prototype of sgen_sort.
- Move main to static libraries, in order to compile as C++ but not link as C++.
Linking pedump as C++ in particular broke running it in Windows x64 CI.
- Some const fix.
- "class" => "klass"
There are advantages and disadvantages here.
adv: No file rename.
dis: Not linking to libc++ -- which broke Windows x64 CI running pedump.
adv: Linking with -xc++ incorrectly treats .o/.a files as C++ text and fails to link; avoids that.
Moving these to C++ enables the runtime to not need extern "C" sprinkled around
on internals -- which was done but not accepted (https://github.com/mono/mono/pull/10160#pullrequestreview-148551783).
Free the thread_info_key and thread_exited_key during unload
Fixes a crash where pthread_key_clean_all will call destructors that should have been freed before unload.
[mini] fix memory dumping on devices
also, guard for `IP == NULL`: I haven't seen it in the wild, but when messing with EH I have seen it happen and then we have a segfault in the signal handler, which is... bad 😄
we should backport this to `2018-06` and `2018-08`.
- Add a private static variable to HttpClient called `Func<HttpMessageHandler> GetHttpMessageHandler` that will be used to obtain the default message handler and can be set for example as follows:
```
var httpMessageHandler = typeof(HttpClient).GetField("GetHttpMessageHandler",
BindingFlags.Static |
BindingFlags.NonPublic);
httpMessageHandler.SetValue(null, (Func<HttpClientHandler>) (() => {
return new MyHttpClientHandler ();
}));
```
- If a handler is not set or returns null the default implementation HttpClientHandler will be returned.
- Add HttpClient.wasm.cs implementation to handle the default HttpClient
- Add simple test to the wasm test harness bindings-test.
- Reference https://github.com/mono/mono/issues/9941
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* [cxx] int vs. enum.
There are at least three or so approaches to this.
1. Sprinkle around casts.
2. Overload operators.
2a. Bit-only (| & ^ |= &= ^=) This PR.
2b. Also math (+ - ++ -- == !=)
3. typedef to int instead (https://github.com/mono/mono/pull/10231)
They all have tradeoffs.
1. Casts: The most line damage. Not huge, but the most.
2. Overloads: New idiom to some but an old idiom. Supported in this way by windows.h even.
This is the most "C++y solution".
3. int: Highest level of source compat and semantic compat. Least line damage (just
change the declarations). Least debuggable and least typesafe.
In terms of semantic compat, even in C the guarantees aren't particularly strong.
Some enums will be int, some unsigned, depending on the values and the compiler.
Perhaps even other types, but I doubt it.
I observe C++ compilers don't tend toward unsigned the same way, so switching
to C++ will on some platforms lose unsignedness. Given we didn't have it portably
anyway, should be ok.
A typesafe enum has the properties that enum A cannot be silently assigned to enum B (ok,
there might be a warning), or from an integer.
A typesafe enum, bitfield or otherwise, can/will be shown symbolically by a debugger.
(lldb does not handle bitfields, only strict enums)
A C enum might be debuggable, w/o typesafety.
A C enum can be freely mixed with other enums and integers.
A C++ enum is more restricted.
Using typedef int, is a maybe surprising option, but does provide the closest meaning to C enum.
Per guidance, this PR also changes one enum to #defines + int.
* PR: "mono" => "g"
"T" => "type"
static_cast where it works (not to reference)
Use templatized typedef instead of macro, if it works on g++4.4.
Add test.
Provide to build eglib tests.
Borrow CXXFLAGS_COMMON from https://github.com/mono/mono/pull/10271.
Add some const to test harness.
* g++4.4 compat (not quite C++11) -- use macro, not template typedef.
* Fix real problem with aliasing seen with g++4.4.
Use attribute(may_alias) when casting pointers/references.
* Add mono/eglib/test/enum.cpp.
gcc/clang do have __restrict and/or __restrict__.
On MacOSX, __restrict is preprocessed out of the headers for C++.
On Linux, __restrict is used and preserved for C++.
I didn't check others.
__restrict does not appear to be part of the function signature.
You cannot overload on it.
It is not in the mangled name.
If you declare one way and implement the other, there is no warning or error.
Therefore, remove restrict.
There are alternatives.
One could preserve it for C only.
One could preserve it for C and for Linux/C++.
One could preserve it based on autoconf, and autoconf results on Mac and Linux.
Perhaps as well we will autoconf or ifdef wasm away use of these functions?
If we merely if them away, we still need them.
Needed for TimeZoneInfo.
Imports CoreFX's Registry API for Windows. Other platforms use old mono file-based Registry API implementation because CoreFX doesn't support it yet, see: https://github.com/dotnet/corefx/issues/14896
(however, some basic types such as enums are imported for all platforms)
Part of #8131
When the TLS Handshake fails in `MonoTlsStream.CreateStream()`, then we must dispose
the `SslStream` to avoid a memory leak.
In addition to this, `MonoTlsStream` now implements `IDisposable` and is disposes
in `WebConnection.CloseSocket()`.
Fixes#8689
Part of #9660.
The imported CoreFX types:
- MemberInfo;
The changes:
- used MemberInfo type from CoreFX;
- moved MetadataToken property from MemberInfo to leaf classes; added unit tests.
- updated icall-def.h for related types;
- updated corlib version;
- added overridings for new HasSameMetadataDefinitionAs property to leaf classes;
- included more MemberInfo xunit tests to verify HasSameMetadataDefinitionAs property;
- renamed MemberInfoExtensions class to DbLinqMemberInfoExtensions in System.Data.Linq assembly to avoid a conflict with the class imported to System.Reflection namespace.
- [acceptance-tests] removed AssemblyExtensions class which duplicates the same functionality introduced in System.Reflection.
* Fix layout of scrollbars in combobox.
* Fix TextBox height fixup to work properly inside TableLayout.
* Fix changing TextBox font before the Control handle has been created.
* Add test case.
* Reintroduce fix for TextBoxTest.Bug82749. We need to save the user requested control bounds outside of ExplicitBounds since ExplicitBounds are used by table layout engine.
The issue was that packager.exe was using Mono.Cecil from net_4_x, which is only built/installed if the desktop sdk is built. We replace
Finally, we change the CI script to disable desktop as well to ensure we don't regress in that scenario.
The llvm/llvm_config.mk makefile fragment just includes make (not automake)
variable definitions. So there is no need to regenerate the mini/Makefile.am
file if the fragment updates - the include will pick it up.
* [w32socket] Refactor ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal and ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal into common mono_w32socket_getname.
* [w32socket] Zero consistently. Note that a statically sized struct sockaddr_storage would be appropriate here.
* [cxx] Remove goto around init.
* PR: [w32socket] Use gboolean local instead of function-pointer/string to mono_w32socket_getname.
Restore lost comment.
* [cxx] [w32socket] Remove ternary operator on allocators so that rvalue constructor
can be removed here: https://github.com/mono/mono/pull/10027#issuecomment-414848498
Provide for void* to non-void* conversion on common allocators (g_malloc, etc.) to "just work", via perhaps a bit of a surprising twist ("hack" or "technique"?).
This greatly reduces the churn of C to C++ conversion.
This helps handle.h in 3 places, at least 2 of which could use C++11 `auto` instead.
Ternary operator has reduced functionality as a result.
Either:
1. Put in rvalue constructor, omitted here.
2. Cast both sides of the ternary.
3. Don't ternary.
This impacted only here:
https://github.com/mono/mono/pull/10206/commits/b543f3f0fd71e5801af059663b4d7b01a6390707
Add some explicit casts.
Remove `register`, as it is deprecated (warning or error) and means little (it does prevent taking-address, which helps optimizers).
Add parens missing in macros.
Favor `gssize` over `long` for consistency on Win64.
Implement a two-phase hybrid suspend scheme:
1. In the _entente phase_ put all threads in the suspend request state (either `ASYNC_SUSPEND_REQUESTED` or `BLOCKING_SUSPEND_REQUESTED`). Wait for pending operations (but only wait for the async ones) and let all threads try to self-suspend.
2. In the _aggressive mop-up phase_ - preemptively suspend any threads that are still in `BLOCKING_SUSPEND_REQUESTED`.
* [coop] Check async suspend status in ReqSuspendInitSuspendBlocking case
So the issue is that calling begin_suspend_for_blocking_thread under hybrid
suspend will perform a preemptive suspension of the victim thread.
The preemptive suspend doesn't always succeed.
In particular, thread_state_init_from_sigctx or thread_state_init_from_handle
could return FALSE and into->suspend_can_continue will be set to FALSE.
When the thread_state_init_* functions return FALSE, they also set the
MonoThreadUnwindState:valid to FALSE.
So it is important to check the value of MonoThreadInfo:suspend_can_continue
before proceeding with a suspension.
As a result in suspend_sync in the ReqSuspendInitSuspendRunning case we call
check_async_suspend which checks (for preemptively suspended threads) whethere
suspend_can_continue is true. If it isn't, we resume the victim thread and
loop once more in suspend_sync_nolock and try again.
We didn't have a check_async_suspend call in the ReqSuspendInitSuspendBlocking
case, so a thread could be considered suspended even if we couldn't capture a
valid MonoThreadUnwindState for it.
That breaks the assertion the call to mono_thread_info_get_last_managed in
async_suspend_critical which needs a valid MonoThreadUnwindState.
Fixes https://github.com/mono/mono/issues/10031
* fixup - remove coop assertion in check_async_suspend
result for coop could be iether BeginSuspendOkCooperative or
BeginSuspendOkNoWait depending on whether the thread was running (Ok) or
blocking (OkNoWait)
* [coop] suspend_can_continue if async raced with self-suspend (osx + win32)
Companion to 006d6ce097 from earlier this year
which applied this fix for POSIX signal based suspend. This is the
corresponding OSX and Win32 fix.
In hybrid suspend, in the case where a suspend initiator needs to preemptively
suspend a thread, but the thread self-suspended while after the suspend
initiator put it into the blocking_suspend_requested state, we want to allow
the suspend to continue. We do have to call the syscall to undo the native
async suspend, but after that, we can leave the victim to continue waiting for
a resume.
This should not have any effect on full cooperative or full preemptive suspend
- in the full coop case we never call async suspend, in the full preemptive
case the thread never self-suspends in blocking.
When we execute the certificate verification callback we just don't test for success and set status11. Now we get the error (if any) and map the error code to those defined by ChainStatusFlags and add it to a list of X509ChainStatus objects for that chain. Now when get_ChainStatus is called we convert that list to an array of X509ChainStatus and return it.
Use argv for cli_launcher on OSes that don't return full path for process names; fix mono_w32process_get_path on Free/NetBSD
Should fix process-leak test on AIX, maybe more. Also tested that it fixes the
same behaviour on FreeBSD. Other OSes may be affected; consult and test with the
files `w32process-unix-*.c`.
From comments:
```c
/*
* XXX: verify if other OSes need it; many platforms seem to have it so that
* mono_w32process_get_path -> mono_w32process_get_name, and the name is not
* necessarily a path instead of just the program name
*/
/*
* mono_w32process_get_path on these can only return a name, not a path;
* which may not be good for us if the mono command name isn't on $PATH,
* like in CI scenarios. chances are argv based is fine if we inherited
* the environment variables.
*/
```
There is a small race condition during the completion of a native thread join
call. During that period of time the tid is no longer included on the
internal list tracking joinable threads so a thread that will join on the
tid while another thread (like the finalizer thread) is waiting on native
join to complete for the same tid, will cause the managed Thread.Join call
to complete before the native join call has completed. This race could cause
issues on some OS:es that clear's up some thread resources, like abandoned
mutexes when the thread has exited. This race is hit by WaitAnyWithSecondMutexAbandoned
since the call to Thread.Join will return before the thread owning the mutex
has terminated meaning that it doesn't get ownership of the abandoned mutex
as assumed by the test.
Fix makes sure Thread.Join won't complete until native thread join is complete.
Increasing the join timeouts in the test also eliminates a timeout error making it
harder to hit the problematic code path, primarily during reproduction
in the debugger.
Fix also switch to coop mutex for joinable threads.
And they are not checked in a consistent order, leading to bugs, or at least
somewhat surprises. This incorrect/unintended code fails to compiles as C++.
We should check them in a consistent order.
This favors Win32 over unistd.h but the opposite is probably ok too.
Also fix infinite loop in error path.
See https://jenkins.mono-project.com/job/x/12739/parsed_console/log.html
```
sgen-protocol.c: In function 'void binary_protocol_open_file(gboolean)':
sgen-protocol.c:101:31: error: invalid conversion from 'int' to 'HANDLE {aka void*}' [-fpermissive]
binary_protocol_file = open (filename, O_CREAT | O_WRONLY, 0644);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sgen-protocol.c:102:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (binary_protocol_file == -1) {
^
sgen-protocol.c:114:38: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
ftruncate (binary_protocol_file, 0);
^
In file included from ../../mono/utils/mono-compiler.h:14:0,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:65:18: note: initializing argument 1 of 'int ftruncate(int, off32_t)'
__CRT_INLINE int ftruncate(int __fd, off32_t __length)
^~~~~~~~~
sgen-protocol.c:116:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
} while (binary_protocol_file == -1);
^
sgen-protocol.c: In function 'void close_binary_protocol_file()':
sgen-protocol.c:164:36: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
while (close (binary_protocol_file) == -1 && errno == EINTR)
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:10:0,
from ../../mono/utils/mono-compiler.h:14,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:328:15: note: initializing argument 1 of 'int close(int)'
int __cdecl close(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~
sgen-protocol.c: In function 'void binary_protocol_flush_buffer(BinaryProtocolBuffer*)':
sgen-protocol.c:229:82: error: invalid conversion from 'HANDLE {aka void*}' to 'int' [-fpermissive]
ret = write (binary_protocol_file, buffer->buffer + written, to_write - written);
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:10:0,
from ../../mono/utils/mono-compiler.h:14,
from sgen-gc.h:30,
from sgen-protocol.c:16:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:344:15: note: initializing argument 1 of 'int write(int, const void*, unsigned int)'
int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
^~~~~
```
That is, >=0x80000000 does not fit in a signed 32bit long.
Linux manpage acknowledges the mess and says "unsigned int" will work "for most systems".
So let's do that and hope, "most systems" and other C runtimes besides glibc.
http://man7.org/linux/man-pages/man2/statfs.2.html
The __fsword_t type used for various fields in the statfs structure
definition is a glibc internal type, not intended for public use.
This leaves the programmer in a bit of a conundrum when trying to
copy or compare these fields to local variables in a program. Using
unsigned int for such variables suffices on most systems.
Remove excess const and add more meaningful const.
* Truncate MachineName (and UserDomainName) at first period
Unix machines often put their FQDN as the host name, and domain
name is used for things such as yp. As such, truncate the FQDN to
just the hostname, as other Unix utilities seem to do.
Matches the .NET Core and .NET Framework behaviour, and MS seems to
require this for a future project. Fixes#9839.
* Add a unit test for bug
* Formatting tweaks
* For ProcessArchitecture, use the DllMap arch of the runtime.
* For OSArchitecture, make an educated guess combining ProcessArchitecture and Environment.Is64BitOperatingSystem.
* For non-Intel/ARM architectures, (supported by Mono and not on the chopping block are PPC32/64, z, and WebAssembly) please dogpile onto dotnet/corefx#30706.
macOS 10.14 introduces a Network framework, which means Xamarin.Mac now has a Network namespace.
This conflicts with 'using Network = System.Net':
> mono/mcs/class/System.Xml.Linq/Test/System.Xml.Schema/ExtensionsTest.cs(97,27): error CS0576: Namespace '<global namespace>' contains a definition conflicting with alias 'Network'
so just remove the using and use the full 'System.Net' namespace instead.
* [wasm] add wasm-aot and wasm-aot-runtime
* [runtime] Add MONO_STRUCT_SIZE that works similarly to MONO_STRUCT_OFFSET and handles mini types.
* [wasm] Add enough scafold for the AOT compiler.
* [wasm] Make some functions available for the interp to satisfy the linker.
* [wasm] Add aot-sample and link-sample helper targets for AOT development.
* [wasm/sdks] Update documentation.
* Update README.md
broken:
```c
#include <math.h>
void * pmod = fmod;
fmod-broken.cpp:3:15: error: address of overloaded function 'fmod' does not match required type 'void'
void * pmod = fmod;
^~~~
```
fixed:
```c
#include <math.h>
typedef double (*fmod_t)(double, double);
fmod_t pfmod = fmod;
```
A wrapper function would also work:
```c
double mono_fmod (double a, double b)
{
return fmod (a, b);
}
fmod_t pfmod = mono_fmod;
```
This may be advantagous, if the standard allows fmod to be a macro ("cannot take address of macros") or its signature to not match this.
However this would veer even further from apparent C compatibility (if our previous code was portable), so probably not.
* [reflection] Assembly.LoadFile should throw ArgumentException for relative paths
Fixes https://github.com/mono/mono/issues/9943
* [mcs/tests] Use full path in the compiler-tester
Otherwise the call to LoadFile will fail
* [mono/tests] Use full path in LoadFile in test-multi-netmodule-4-exe
* [mono/tests] Use the test runner for a couple of tests
* [fullaot] Disable test-multi-netmodule-4-exe and custom-attr-errors.exe
* [tests] Use Path.GetFullPath and Path.Combine in AssemblyTest
Fix windows test failures
EH still uses the original ip for determining whether there are any abort protected blocks to be exited, once the frame is unwinded.
Fixes delegate2.exe
https://jenkins.mono-project.com/job/x/12802/parsed_console/log.html
ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken(gpointer, MonoError*)':
mono-security-windows.c:214:62: error: invalid conversion from 'int (*)(int)' to 'gpointer {aka void*}' [-fpermissive]
return DuplicateToken (token, SecurityImpersonation, &dupe) ? dup : NULL;
^
The code is confusing the local variable dupe with an 'e' at the end
with the function dup.
* [System.Reflection] CoreFX import for ManifestResourceInfo and ResourceLocation types.
Part of #9660.
* Bump API snapshot submodule
* [csproj] Update project files
Longer term some functions accepting function pointers can/should take
a stronger type, and the parameters match w/o casting.
Also cast int to enum one same line.
One of these is under if 0.
Should fix the following:
attach.c:494:13: error: no matching function for call to 'mono_thread_create_internal'
internal = mono_thread_create_internal (mono_get_root_domain (), receiver_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (void *)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
threadpool-io.c:585:7: error: no matching function for call to 'mono_thread_create_internal'
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, error))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
gc.c:957:14: error: no matching function for call to 'mono_thread_create_internal'
gc_thread = mono_thread_create_internal (mono_domain_get (), finalizer_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
attach.c:494:13: error: no matching function for call to 'mono_thread_create_internal'
internal = mono_thread_create_internal (mono_get_root_domain (), receiver_thread, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (void *)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
threadpool-io.c:585:7: error: no matching function for call to 'mono_thread_create_internal'
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, error))
^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:82:1: note: candidate function not viable: no known conversion from 'gsize (gpointer)' (aka 'unsigned long (void *)') to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, MonoThreadCreateFlags flags, MonoError *error);
^
:411:24: error: no matching function for call to 'mono_create_ftnptr'
func = (TestMethod)mono_create_ftnptr (mono_get_root_domain (), func);
^~~~~~~~~~~~~~~~~~
../../mono/mini/mini-runtime.h:432:11: note: candidate function not viable: no known conversion from 'TestMethod' (aka 'int (*)()') to 'gpointer' (aka 'void *') for 2nd argument; take the address of the argument with &
gpointer mono_create_ftnptr (MonoDomain *domain, gpointer addr);
driver.c:1170:2: error: no matching function for call to 'mono_thread_create_checked'
mono_thread_create_checked (mono_domain_get (), compile_all_methods_thread_main, &args, error);
^~~~~~~~~~~~~~~~~~~~~~~~~~
../../mono/metadata/threads-types.h:441:1: note: candidate function not viable: no known conversion from 'void (CompileAllThreadArgs *)' to 'gpointer' (aka 'void *') for 2nd argument
mono_thread_create_checked (MonoDomain *domain, gpointer func, gpointer arg, MonoError *error);
^
LLVM was using the helper for the abandoned prototype linkonce work that
much predated when I picked up the project.
This is a problem because it can lead to aot-compiler thinking a method
is dedupable, while llvm thinking it's not. When this happens, the
symbol does not have the Assembly baked into it's name to ensure
uniqueness.
We now adopt CoreFX's behavior in `X509Certificate` regarding serialization and immutability.
* All serialization APIs now throws `PlatformNotSupportedException`.
(this was initially part of #9650, but had to be taken out due to problems with Xunit 2.4).
* All `Import()` overloads now throw `PlatformNotSupportedException`.
* The property setter of `X509Certificate2.PrivateKey` now also throws `PlatformNotSupportedException`.
If an AOT library is loaded that was compiled with safepoints, but currently
we're running with preemptive suspend (e.g. MONO_THREADS_SUSPEND=preemptive is
set), don't assert. `mono_polling_required` will always be false, so the
safepoint will be ignored.
Fixes https://github.com/mono/mono/issues/9947
- Remove two unused types from corlib (DecoupledTask is not used since migrating to StreamReader/StreamWriter from referencesources).
- Fix indentation in System.Security.Policy/Site.cs which mixed tabs and spaces.
- Fix comment in Test/System.Diagnostics/DebuggerTypeProxyAttribute.cs (to avoid false results when using grep on the source code).
* Add support for marshalling ArrayBuffer and TypeArrays from JavaScript to C#.
- The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. More Info ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays#ArrayBuffer
- JavaScript typed arrays are array-like objects and provide a mechanism for accessing raw binary data. (...). More Info ---> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
- Some examples of API's that use these are Fetch, WebGL, Canvas, Web Audio API, XMLHttpRequests, WebSockets, Web Workers, Media Source API and File APIs.
| ArrayBuffer | uint8_t | byte[] | byte or Byte (unsigned byte)
| Int8Array | int8_t | sbyte[] | byte or SByte (signed byte)
| Uint8Array | uint8_t | byte[] | byte or Byte (unsigned byte)
| Uint8ClampedArray| uint8_t | byte[] | byte or Byte (unsigned byte)
| Int16Array | int16_t | short[] | short (signed short)
| Uint16Array | uint16_t | ushort[] | ushort (unsigned short)
| Int32Array | int32_t | int[] | int (signed integer)
| Uint32Array | uint32_t | uint[] | uint (unsigned integer)
| Float32Array | floa t | float[] | float
| Float64Array | double | double[] | double
- Added tests to the bindings-test test harness.
* Add support for marshalling TypeArrays from C# to JavaScript.
- Add tests to test harness.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
iconv in eglib was broken due to a broken define. Also fix linking
of iconv when iconv isn't in libc.
Also remove the usage of a GNU libcharset specific function and rely
on a standard POSIX function that outputs the same value on every
modern Unixoid I've tried it on. (Ubuntu/macOS/i/FreeBSD)
This comment explains a lot of things for the latter:
```c
/*
* This function used used to use the "locale_charset" call in
* libiconv's libcharset library. However, this isn't always
* available on some systems, including ones with GNU libc. So,
* instead use a function that's a standard part of POSIX2008.
*
* nl_langinfo is in POSIX2008 and should be on any sane modern
* Unix. With a UTF-8 locale, it should return "UTF-8" - this
* has been verified with Ubuntu 18.04, FreeBSD 11, and i 7.3.
*
* The motivation for using locale_charset was likely due to
* the cruftiness of Unices back in ~2001; where you had to
* manually query environment variables, and the values were
* inconsistent between each other. Nowadays, if Linux, macOS,
* AIX/PASE, and FreeBSD can all return the same values for a
* UTF-8 locale, we can just use the value directly.
*
* It should be noted that by default, this function will give
* values for the "C" locale, unless `setlocale (LC_ALL, "")`
* is ran to init locales - driver.c in mini does this for us.
*/
```
Fix s390x build broken by incorrect specification of the msgfi instruction used in MUL_IMM type operations. The instruction had been encoded as its 32-bit counterpart (msfi).
In addition, the s390x microcode makes the mono_strength_reduction_division unnecessary so this can be bypassed.
The change to basic.make is just to avoid error messages when basic-profile-check.exe hasn't been built yet.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* Fix build on AIX
* crash reporting requires dladdr, a function AIX (at least
the version on CI) lacks
* fix build with a powerpc64-*-(aix|os400)* triplet as IBM
wishes to do
* Fix some stuff for Haiku
Some stuff requires CoreFX PAL changes that haven't been merged and
thus one or two more items for configure to detect.
* sigaltstack is broken for haiku
* getifaddrs is available and PAL would like it, so fix it
* Fix detection of flock64
This erroneously detected flock64 on platforms that lacked it.
Fixes the build of CoreFX PAL on FreeBSD and Haiku.
* Fix flock64 define
* Fix define for flock64 in PAL block
* Remove nonsense comment that only applied to an older unreleased version of the patch
Noticed this today when the corlib test which checks for unknown filesystems failed. Turned out it was because of a .dmg I had mounted:
```
$ mount | grep nullfs
/Volumes/Skype Meetings App/Skype Meetings App.app on /private/var/folders/cs/kt8x25p14g9dlk_p192rd7th0000gn/T/AppTranslocation/957CCB05-C113-4897-9C80-700C2CE4809E (nullfs, local, nodev, nosuid, read-only, noowners, quarantine, nobrowse, mounted by alexander)
```
By default ```msbuild bcl.sln``` will fail because of our non-standard platform names and the need to restore nuget packages. Add a default response file so it just works. (Response files can be suppressed)
This imports github.com/kumpera/ws-proxy into mono.
It facilitates distribution and coordination of upstream as there's a clean version connect between the two bits.
The proxy is currently version locked with the runtime.
* [wasm] Call the correct single step trampoline. Fixes some step-into scenarios.
* [wasm] Make the debugging sample a bit more complicated.
* [wasm] Add debugger support for removing breakpoints.
* [cxx] mono-logger.c int vs. enum and casts void* to non-void*
mono-logger.c:18:16: error: cannot initialize a variable of type 'GLogLevelFlags' with an rvalue of type 'int'
GLogLevelFlags mono_internal_current_level = INT_MAX;
^ ~~~~~~~
mono-logger.c:19:16: error: cannot initialize a variable of type 'MonoTraceMask' with an rvalue of type 'int'
MonoTraceMask mono_internal_current_mask = ~((MonoTraceMask)0);
^ ~~~~~~~~~~~~~~~~~~~
mono-logger.c:305:17: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ "io-layer", MONO_TRACE_IO_LAYER_PROCESS
^~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:315:12: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ "all", ~((MonoTraceMask)0) },
^~~~~~~~~~~~~~~~~~~
mono-logger.c:316:11: error: cannot initialize a member subobject of type 'const MonoTraceMask' with an rvalue of type 'int'
{ NULL, 0 },
^
mono-logger.c:392:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an lvalue of type 'void *'
UserSuppliedLoggerUserData *ll =logCallback.user_data;
^ ~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:400:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an lvalue of type 'void *'
UserSuppliedLoggerUserData *ll = logCallback.user_data;
^ ~~~~~~~~~~~~~~~~~~~~~
mono-logger.c:451:30: error: cannot initialize a variable of type 'UserSuppliedLoggerUserData *' with an rvalue of type 'gpointer' (aka 'void *')
UserSuppliedLoggerUserData *ll = g_malloc (sizeof (UserSuppliedLoggerUserData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated.
* [cxx] Add missing cast from void* to non-void* in g_renew.
* [cxx] mono-flight-recorder.c:97:22: error: cannot initialize a variable of type 'MonoFlightRecorder *' with an rvalue of type 'gpointer' (aka 'void *')
MonoFlightRecorder *recorder = g_malloc0 (size_of_recorder_prefix + size_of_item_ptrs + size_of_items);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
add cast
* [cxx] mono-error.c:769:18: error: cannot initialize a variable of type 'MonoErrorBoxed *' (aka '_MonoErrorBoxed *') with an rvalue of type 'gpointer' (aka 'void *')
MonoErrorBoxed* box = mono_image_alloc (image, sizeof (MonoErrorBoxed));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cast from void* to non-void*
* [cxx] lock-free-alloc.c:358:27: error: no viable overloaded '='
new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lock-free-alloc.c:90:9: note: candidate function (the implicit copy assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
typedef union {
^
lock-free-alloc.c:90:9: note: candidate function (the implicit move assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
typedef union {
^
lock-free-alloc.c:465:27: error: no viable overloaded '='
new_anchor = old_anchor = *(volatile Anchor*)&desc->anchor.value;
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lock-free-alloc.c:90:9: note: candidate function (the implicit copy assignment operator) not viable: 1st argument ('volatile Anchor') would lose volatile qualifier
C++ does not by default allow copying volatile aggregates (struct, union, class).
This is mostly reasonable because, imagine the struct does not fit in a register. How would it work?
Here, and it is probably common, the struct does fit in a register and the intent and implementation
is pretty obvious.
Anyway, you can provide operator= or copy the constituents (i.e. one integer that unions over the rest).
* [cxx] mono-threads.c strengthen type from gpointer to actual type,
add casts from void* to non-void*, add casts between int and enum,
remove excess GSList type that caused some errors.
mono-threads.c:568:2: error: no matching function for call to 'mono_threads_signal_thread_handle'
mono_threads_signal_thread_handle (handle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:491:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoThreadHandle *' for 1st argument
mono_threads_signal_thread_handle (MonoThreadHandle* thread_handle);
^
mono-threads.c:570:2: error: no matching function for call to 'mono_threads_close_thread_handle'
mono_threads_close_thread_handle (handle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./mono-threads.h:516:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoThreadHandle *' for 1st argument
mono_threads_close_thread_handle (MonoThreadHandle *handle);
^
mono-threads.c:776:12: error: cannot initialize return object of type 'MonoThreadInfoFlags' with an rvalue of type 'gint32' (aka 'int')
return mono_atomic_load_i32 (&info->flags);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:783:22: error: cannot initialize a variable of type 'MonoThreadInfoFlags' with an rvalue of type 'gint32' (aka 'int')
MonoThreadInfoFlags old = mono_atomic_load_i32 (&info->flags);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-threads.c:794:8: error: definition of type 'GSList' conflicts with typedef of the same name
struct GSList {
^
../../mono/eglib/glib.h:330:24: note: 'GSList' declared here
typedef struct _GSList GSList;
^
mono-threads.c:811:22: error: assigning to 'GSList *' (aka '_GSList *') from incompatible type 'gpointer' (aka 'void *')
wait_request.next = old;
^~~
mono-threads.c:852:10: error: assigning to 'GSList *' (aka '_GSList *') from incompatible type 'gpointer' (aka 'void *')
old = old_read;
^~~~~~~~
mono-threads.c:866:3: error: no matching function for call to 'mono_os_sem_post'
mono_os_sem_post (curr->data);
^~~~~~~~~~~~~~~~
./mono-os-semaphore.h:166:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'MonoSemType *' (aka 'unsigned int *') for 1st argument
mono_os_sem_post (MonoSemType *sem)
^
mono-threads.c:1865:10: error: cannot initialize return object of type 'MonoThreadInfoWaitRet' with an rvalue of type 'int'
return MONO_THREAD_INFO_WAIT_RET_SUCCESS_0 + (res - MONO_OS_EVENT_WAIT_RET_SUCCESS_0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 errors generated.
* [cxx] mono-threads-coop.c In C++, enums are not quite ints.
Their default underlying type (you can change it, per type, nice!), is int,
but they are unique types not automatically interchangable with int.
mono-threads-coop.c:530:9: error: cannot initialize return object of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
return 0; /* unset */
^
mono-threads-coop.c:558:27: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
MonoThreadsSuspendPolicy policy = 0;
^ ~
mono-threads-coop.c:571:27: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
MonoThreadsSuspendPolicy policy = 0;
^ ~
mono-threads-coop.c:590:34: error: cannot initialize a variable of type 'MonoThreadsSuspendPolicy' with an rvalue of type 'int'
static MonoThreadsSuspendPolicy policy = -1;
^ ~~
4 errors generated.
* [cxx] mono-utility-thread.c; cast from void* to non-void*.
mono-utility-thread.c:85:21: error: cannot initialize a variable of type 'MonoUtilityThread *' with an rvalue of type 'gpointer' (aka 'void *')
MonoUtilityThread *thread = g_malloc0 (sizeof (MonoUtilityThread));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-utility-thread.c:128:27: error: cannot initialize a variable of type 'UtilityThreadQueueEntry *' with an rvalue of type 'gpointer' (aka 'void *')
UtilityThreadQueueEntry *entry = mono_lock_free_alloc (&thread->message_allocator);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mono-utility-thread.c:154:27: error: cannot initialize a variable of type 'UtilityThreadQueueEntry *' with an rvalue of type 'gpointer' (aka 'void *')
UtilityThreadQueueEntry *entry = mono_lock_free_alloc (&thread->message_allocator);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
* [cxx] Fix assignment of volatile aggregate without raising specter of ifdef __cplusplus.
Does this violate the abstraction? i.e. wouldn't it be better to assign entire aggregate
at the caller than to dig into its constituent member data?
All the casts of (x) can be replace with G_CAST (x) that I developed this morning and am working through.
mono_metadata_read_constant_value was extracted from mono_get_constant_value_from_blob
but removing the bits that require GC interaction. This function will be used to read corlib version without allocating strings.
mono_string_from_blob decodes a string from a blob pointer, returns g_malloc'd memory.
* [cxx] Port complex math to small portable C and C++ with the only dependency being hypot and non-complex math, and small preexisting code we already had for msvc.
I.e. we already had two versions, with varying portability.
Use one of them, adding about three lines to it.
There was some debate back and forth about macros/renames here.
This version significantly reduces line damage and is much easier to read.
Doing the rename as a separate step may still be advisable, to erase any doubt as to portable semantics, i.e. namespace isolation.
Mono style divergence is also left unfixed to avoid further line damage.
i.e. consider `double_complex` => `MonoComplex`.
`mono_double_complex_` => `mono_complex_`.
A recent commit revealed that in cases where we select based on a mix of host platform and profile, genproj csproj files can end up with duplicate sources because the existing <ItemGroup Condition= approach could make multiple groups match for a given compile when we really just want one.
This PR changes to generating a cascade of msbuild <Choose> elements, which give if-else selection to ensure that we only ever build a single set of files.
* [cxx] C++ does not allow goto around initialization.
The result would be undefined/uninitialized -- presumably that is what we get in C,
not as safe as it seems. Though, since variable not typically/ever used after goto target, it is ok. A little bit of language requirement for the compiler to do such analysis would have gone a long way, not sophisticated analysis, just used/not-used.
Not a problem in C89 because variables only at top.
Not a problem in idiomatic C++ because, often, early return + destructors.
But definitely a problem with C99, and goto for error handling.
Not a problem with msvc in default permissive mode.
Not likely a problem with gcc due to permissive option.
But a problem with clang.
* [cxx] Split declaration from initialization, instead of go up to within if (0).
* [cxx] mono-merp.c:83:9: error: implicit default constructor for 'MERPStruct' must explicitly initialize the const member 'systemModel'
There are possible other solutions involving initializing up front, and later casting away const for additional initialization. Having public-const private-mutable is a good-seeming interface, but is pretty rare. Maybe in [cxx]future can restore const, add a constructor, etc.
* Remove toplevel const in struct for extremely obscure reasons, again pretty rare pattern.
The obscure reason:
given:
```
typedef struct foo
{
const int i; // remove const to fix
} foo;
foo global = { 1 };
```
compiled as C++, with some recent versions of Visual C++, there is a regression
where it thinks this is a dynamic initialization. Which is usually ok, but can be a problem in unusual cases (true story..delayload implementation..).
The icall was converted to use HANDLES(), so the icall wrapper will set the
pending exception from the MonoError. If the icall does it, too, the second
use (in the wrapper) will assert that the MonoError is being reused after
cleanup without being reinitialized.
Also add an assertion in mono_error_get_message that we're not trying to get a
message from a cleaned up MonoError.
Fixes https://github.com/mono/mono/issues/9935
* console-unix.c:221:21: error: cannot initialize a variable of type 'MonoMethod *' (aka '_MonoMethod *') with an rvalue of type 'gpointer' (aka 'void *')
static MonoMethod *System_Console_DoConsoleCancelEventBackground_method = ((gpointer)-1);
^ ~~~~~~~~~~~~~~
* ../../mono/metadata/opcodes.h:27:14: error: ISO C++ forbids forward references to 'enum' types
typedef enum _MonoOpcodeEnum MonoOpcodeEnum;
* w32socket-unix.c:601:9: error: no matching function for call to 'mono_w32socket_send'
ret = mono_w32socket_send (((MonoFDHandle*) sockethandle)->fd, buffers->Head, buffers->HeadLength, 0, FALSE);
Change parameter from char* to void*.
* In file included from console-unix.c:479:2: error: no matching function for call to 'set_control_chars'
set_control_chars (MONO_ARRAY_HANDLE_PIN (control_chars_arr, gchar, 0, &h), mono_attr.c_cc);
^~~~~~~~~~~~~~~~~
^
console-unix.c:362:1: note: candidate function not viable: cannot convert argument of incomplete type 'gpointer' (aka 'void *') to 'gchar *' (aka 'char *') for 1st argument
set_control_chars (gchar *control_chars, const guchar *cc)
add cast in MONO_ARRAY_HANDLE_PIN
* w32socket-unix.c:635:11: error: assigning to 'gchar *' (aka 'char *') from incompatible type 'gpointer' (aka 'void *')
buffer = g_malloc (SF_BUFFER_SIZE);
^~~~~~~~~~~~~~~~~~~~~~~~~
Change buffer to gpointer, and another similar.
* w32socket-unix.c:1136:99: error: cannot initialize a member subobject of type 'gpointer' (aka 'void *') with an lvalue of type 'gboolean (SOCKET, OVERLAPPED *, guint32, guint32)' (aka 'int (int, OVERLAPPED *, unsigned int, unsigned int)')
{ {0x7fda2e11,0x8630,0x436f,{0xa0,0x31,0xf5,0x36,0xa6,0xee,0xc1,0x57}} /* WSAID_DISCONNECTEX */, extension_disconect },
^~~~~~~~~~~~~~~~~~~
w32socket-unix.c:1137:99: error: cannot initialize a member subobject of type 'gpointer' (aka 'void *') with an lvalue of type 'gboolean (SOCKET, gpointer, guint32, guint32, OVERLAPPED *, TRANSMIT_FILE_BUFFERS *, guint32)' (aka 'int (int, void *, unsigned int, unsigned int, OVERLAPPED *, TRANSMIT_FILE_BUFFERS *, unsigned int)')
{ {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} /* WSAID_TRANSMITFILE */, extension_transmit_file },
Add cast to gpointer.
Also add const while there.
* w32process-unix.c:2189:14: error: no matching function for call to 'process_wait'
waitret = process_wait (process_info->process_handle, MONO_INFINITE_WAIT, NULL);
Add cast from void* to non-void*.
* w32process-unix.c:2099:3: error: cannot jump from this goto statement to its label
goto done;
^
w32process-unix.c:2111:13: note: jump bypasses variable initialization
gunichar2 *args = utf16_concat (utf16_quote, lpFile, utf16_quote, lpParameters ? utf16_space : NULL, lpParameters, (const gunichar2 *)NULL);
^
w32process-unix.c:2104:19: note: jump bypasses variable initialization
const gunichar2 *lpDirectory = coop.length.working_directory ? coop.working_directory : NULL;
^
w32process-unix.c:2103:19: note: jump bypasses variable initialization
const gunichar2 *lpParameters = coop.arguments;
^
w32process-unix.c:2102:19: note: jump bypasses variable initialization
const gunichar2 *lpFile = coop.filename;
^
w32process-unix.c:2285:3: error: cannot jump from this goto statement to its label
goto exit;
^
w32process-unix.c:2291:13: note: jump bypasses variable initialization
gunichar2 *dir = coop.length.working_directory ? coop.working_directory : NULL;
^
w32process-unix.c1 error generated.
:2288:13: note: jump bypasses variable initialization
gunichar2 *args = coop.length.arguments ? coop.arguments : NULL;
etc.
Separate declaration from initialization.
* appdomain.c:554:22: note: jump bypasses variable initialization
MonoAppDomainHandle ad = mono_domain_create_appdomain_internal (friendly_name, setup, error);
^
appdomain.c:590:2: error: cannot jump from this goto statement to its label
goto_if_nok (error, leave);
^
etc.
Split local declaration from initialization.
* w32process-unix.c:1914:27: error: no matching function for call to 'mono_handle_new'
and error on every typesafe MONO_HANDLE_NEW call
Have MONO_HANDLE_TYPECHECK_FOR return MonoObject* instead of gpointer, by casting.
Could probably also change mono_handle_new to accept gpointer.
* class-accessors.c:247:9: error: cannot initialize return object of type 'MonoMarshalType *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_MARSHAL_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:265:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:273:19: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_REF_INFO_HANDLE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:279:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'gpointer' (aka 'void *')
Uint32Property *prop = mono_class_alloc (klass, sizeof (Uint32Property));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:294:19: error: cannot initialize a variable of type 'PointerProperty *' with an rvalue of type 'gpointer' (aka 'void *')
PointerProperty *prop = mono_class_alloc (klass, sizeof (PointerProperty));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:334:9: error: cannot initialize return object of type 'MonoClassPropertyInfo *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_PROPERTY_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:347:9: error: cannot initialize return object of type 'MonoClassEventInfo *' with an rvalue of type 'void *'
return mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_EVENT_INFO);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:372:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'void *'
Uint32Property *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_DECLSEC_FLAGS);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:379:18: error: cannot initialize a variable of type 'Uint32Property *' with an rvalue of type 'gpointer' (aka 'void *')
Uint32Property *prop = mono_class_alloc (klass, sizeof (Uint32Property));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:412:18: error: cannot initialize a variable of type 'WeakBitmapData *' with an rvalue of type 'gpointer' (aka 'void *')
WeakBitmapData *info = mono_class_alloc (klass, sizeof (WeakBitmapData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:423:18: error: cannot initialize a variable of type 'WeakBitmapData *' with an rvalue of type 'void *'
WeakBitmapData *prop = mono_property_bag_get (m_class_get_infrequent_data (klass), PROP_WEAK_BITMAP);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:454:19: error: cannot initialize a variable of type 'DimConflictData *' with an rvalue of type 'gpointer' (aka 'void *')
DimConflictData *info = mono_class_alloc (klass, sizeof (DimConflictData));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-accessors.c:469:19: error: cannot initialize a variable of type 'DimConflictData *' with an rvalue of type 'void *'
DimConflictData *info = mono_property_bag_get (&klass->infrequent_data, PROP_DIM_CONFLICTS);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cast from void* to non-void*.
* class.c:3005:16: error: assigning to 'char *' from incompatible type 'const char *'
if ((nested = strchr (name, '/'))) {
^~~~~~~~~~~~~~~~~~
class-init.c:437:11: error: assigning to 'MonoClass *' (aka '_MonoClass *') from incompatible type 'gpointer' (aka 'void *')
klass = mono_image_alloc0 (image, sizeof (MonoClassGtd));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-init.c:442:11: error: assigning to 'MonoClass *' (aka '_MonoClass *') from incompatible type 'gpointer' (aka 'void *')
klass = mono_image_alloc0 (image, sizeof (MonoClassDef));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class-init.c:500:5: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:496:5: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:490:4: error: cannot jump from this goto statement to its label
goto parent_failure;
^
class-init.c:599:6: note: jump bypasses variable initialization
int first_method_idx = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
^
class-init.c:597:6: note: jump bypasses variable initialization
int first_field_idx = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
^
class-init.c:838:14: error: no matching function for call to 'class_kind_may_contain_generic_instances'
image_set = class_kind_may_contain_generic_instances (eclass->class_kind) ? mono_metadata_get_image_set_for_class (eclass) : NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* class.c:3005:16: error: assigning to 'char *' from incompatible type 'const char *'
if ((nested = strchr (name, '/'))) {
^~~~~~~~~~~~~~~~~~
class.c:427:10: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
char *s = strchr (klass_name, '`');
^ ~~~~~~~~~~~~~~~~~~~~~~~~
add const, add cast, and also fix adjacent integer truncation
* assembly.c:2964:8: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
char *eqsign = strchr (pair, '=');
add cast
* cominterop.c:664:2: error: no matching function for call to 'register_icall'
register_icall (cominterop_get_method_interface, "cominterop_get_method_interface", "ptr ptr", FALSE);
^~~~~~~~~~~~~~
repeatedly
Add cast in macro.
Also another need for a cast on a string (error not recorded).
* [cxx] icall.c:
casts
change char* to void*
split local declaration from initialization
add extern "C" around external code (environ -- probably merged to master already)
* image.c:726:8: error: no matching function for call to 'strcmp'
if (strcmp (list_iter->data, name) == 0) {
^~~~~~
image.c:1184:20: error: constant expression evaluates to 2218203019 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
IGNORED_ASSEMBLY (0x8437178B, SYS_NET_HTTP, "C0E04D9C-70CF-48A6-A179-FBFD8CE69FD0", "4.3.0 net46"),
^~~~~~~~~~
repeatedly
add casts
* [cxx] marshal.c
marshal.c:224:3: error: no matching function for call to 'register_icall'
register_icall (mono_marshal_string_to_utf16, "mono_marshal_string_to_utf16", "ptr obj", FALSE);
repeatedly; add cast in macro
Also possible int/enum mixup -- add cast.
* [cxx] property-bag.c
property-bag.c:44:37: error: cannot initialize a variable of type 'MonoPropertyBagItem *' (aka '_MonoPropertyBagItem *') with an lvalue of type 'void *'
MonoPropertyBagItem *cur, **prev, *item = value;
Add cast here, and another.
* [cxx] metadata.c
add casts from void* to non-void*
indicate future enum instead of int
remove designated intitializers
* [cxx] more appdomain.c
* PR: Repatriate orphaned comment.
* PR: include opcodes.h instead of duplicating MonoOpcodeEnum
Otherwise I get consistent access failures for CALLVIRT from mono_method_to_ir().
Stacktrace looks like this:
```
System.InvalidOperationException: WinForms_SeeInnerException ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MethodAccessException: Method `System.__ComObject..ctor()' is inaccessible from method `System.__ComObject..ctor()'
445286 at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_throw_method_access(intptr,intptr)
445287 at System.__ComObject..ctor () [0x00000] in <430892d2beef407ea6b21748b72c1144>:0
445288 at (wrapper cominterop-invoke) System.__ComObject..ctor()
445289 at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
445290 at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445291 --- End of inner exception stack trace ---
445292 at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445293 at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445294 at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <b683bf5ced8643af8ec 2e589dfb23c2b>:0
445295 at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <b683bf5ced86 43af8ec2e589dfb23c2b>:0
445296 at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
445297 at System.Activator.CreateInstance (System.Type type) [0x00000] in <b683bf5ced8643af8ec2e589dfb23c2b>:0
```
My understanding is that misleading exception message is due to exact same name used for dynamic type, in fact it means that some type in dummy assembly can't access internal method from corlib.
* [threads] switch to GC Safe around pthread calls in mono_thread_internal_set_priority
Observed pthread_getschedparam taking a lock on OSX
* [win32] Capture GetLastError before MONO_EXIT_GC_SAFE
* Fix Tasks and Promises in bindings.
- Tasks were not being marshalled correctly in some circumstances. The only place that I could reproduce this was in the bindings tests. Running from outside the test harness would not reproduce this error.
- Promises would intermittently throw Exceptions: NullReferenceException, ArrayIndex out of bounds.
- When using Promises from JS to CS there were random Memory access exceptions. Looks like memory was being trampled on. Adding an integer variable to the create_task_completion_source call fixed these problems as the CreateTaskSource is defined as receiving an int variable. This also fixed the NullReferenceExceptions and ArrayIndex out of bounds exceptions.
* Make JSObject disposable
- Add the ability to dispose of a JSObject.
- The dispose will remove the object from the tracked object list and will allow the reference counter to be recycled later.
- By keeping a recycled list of references and reusing those will keep the tracked objects array from growing out of hand.
- Add test to the Test Harness.
- Modifiy the way the bindings init works by passing in of the Assembly and Class `[asm]namespace.class`. Modfiy test.js to use the new format.
* Add support for Get and Set of javascript properties on a JSObject.
* The namespace problem was fixed in https://github.com/mono/mono/pull/9836
* Cleanup unused and duplicate definitions
* [runtime] Add mono_runtime_get_caller_no_system_or_reflection
Exposes an already existing stackwalk that we use to find out who called a corlib API.
* [loader] Consult asmctx of executing assembly for Assembly.Load
if an assembly in LoadFrom context calls Assembly.Load, the given assembly name
should be tried in the basedir of the executing assembly, and the resulting
loaded assembly should be in LoadFrom context.
* [loader] Assemblies in individual asmctx can reference assemblies in application base
If an assembly was loaded with LoadFile, it can reference assemblies from the
application base, the GAC or MONO_PATH.
Fixes https://github.com/mono/mono/issues/8575
* [loader] Pass requesting assembly to mono_assembly_open_predicate
In LoadFrom and LoadFile icalls, pass the currently executing assembly as the
requesting assembly.
* [utils] Add mono_path_filename_in_basedir
* [loader] Add mono_install_asmctx_from_path_hook
Add a hook that can be used to check whether a given path belongs to some
assembly load context.
For example if a given path is in the application base of the current
appdomain, an appdomain hook would set out_asmctx to MONO_ASMCTX_DEFAULT and
return TRUE.
* [loader] Use appdomain base dir and loadfrom asmctx hooks
1. If an assembly filename is in the GAC, always open the assembly in default
context.
2. If an assembly filename is in the appdomain search path (base directory or
private bin path) always open the assembly in default context.
3. If an assembly filename is in the base dir of the requesting assembly and
the requesting assembly was in LoadFrom context, always open the assembly in
LoadFrom context.
Fixes https://github.com/mono/mono/issues/9753
and Fixes https://github.com/mono/mono/issues/9542
* [tests] Test loading references from LoadFrom and LoadFile contexts
The LoadFrom assembly loading context and the individual assembly loading
context (aka LoadFile aka "no context") behave differently when requesting a
referenced assembly - for LoadFile we expect the runtime to probe the appdomain
base, the GAC + MONO_PATH but not the basedir of the requesting assembly. For
LoadFrom the basedir of the requesting assembly _is_ included. So the tests
here try all the possible variations.
* [tests] AOT assembly-load-reference tests
* [metadata] Cache method signature in correct image hash
When freeing dynamic methods in mono_free_method, we remove entries in the method image's hashtables, hashed by the soon to be freed method signature.
* [metadata] Avoid unnecessary alloc
Fixes https://github.com/mono/mono/issues/9869.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* [coop] Turn hybrid suspend on by default on desktop platforms
Use hybrid suspend by default on x86 and amd64 OSX, Windows and Linux
Pass `--disable-hybrid-suspend` to configure to disable at build time, or set the environment variable `MONO_THREADS_SUSPEND=preemptive` when running Mono to use preemptive suspend (the previous default).
Pass `--disable-hybrid-suspend --enable-cooperative-suspend` to configure cooperative suspend at build time.
* [sdks] Disable coop and hybrid suspend for iOS and Android
Only the devices and simulator builds, not the host ones.
* [coop] Add mono_threads_suspend_override_policy ()
Do not use it. It provides a last resort method to ignore configure and environment settings and use a hardcoded threads suspend policy.
* [interp] Override suspend policy - warn and use preemptive
Until the interpreter supports safepoints and performs threads suspend states switches in its trampolines, always use preemptive suspend if the interpreter is used.
* [coop] Enter GC Safe around mono_threads_join_lock ()
Like other uses of mono_threads_join_lock, enter GC Safe before trying to take the lock.
* [interp] Use preemptive suspend with --full-aot-interp
Move safepoint suspend check to mono_runtime_set_execution_mode
* [test] fullaotmixed - force preemptive suspend[test] fullaotmixed - force preemptive suspend
Force preemptive suspend in fullaotmixedcheck. We must compile the AOT images without safepoints.
* [sdks] Run the offset-tool in 64 bit mode.
* [sgen] SgenDescriptor should use the target wordsize.
* [sdks] Fix 'Run the offset-tool in 64 bit mode.'
* Manually add a csproj file for cil-stringreplacer
Adjust trace level for genproj
* Manually add cil-stringreplacer to bcl.sln and set it as a dependency of corlib
* Fix typo
* Add post-build event to corlib that runs cil-stringreplacer on it in mscorlib mode
* [csproj] Update project files
Right now, the set of mono-api-tools only works as console apps. This PR will make them work as normal dlls so they can be consumed by other apps and libraries. They will still work as .exes, so nothing visibly changes for existing users.
The motivation for this is for some build process or third party tool to take an assembly and generate an .xml doc from it. Since the writer is in-memory, the tool can then parse the .xml and do whatever it needs to. The same goes for the diff tools - if the diff happens in-memory, then the tool can process it without having to save and then load from the file system.
## Libraries
- [x] mono-api-info -> `Mono.ApiTools.ApiInfo`
- [x] mono-api-diff -> `Mono.ApiTools.ApiDiff`
- [x] mono-api-html -> `Mono.ApiTools.ApiDiffFormatted`
## Major changes
- the existing `Driver` classes are now just thin wrappers to parse the args and pass it on to the generators
- the "options" are now abstracted into config classes to avoid methods with numerous parameters
- the APIs have new support for reading assembly and info `Stream`s instead of just file paths
- added compiler flags to control the namespace and type visibility to make the library APIs nicer
- added compiler flag to remove the `Driver` class and `Mono.Options` dependencies
- the mono-api-info tool has some more options to allow it to run on libraries, and ignore dependencies that it cannot find - this makes it easier to use so that the entire dependency chain does not have to be loaded just to output the current assembly API
## Compiler defines
- `EXCLUDE_DRIVER` will remove the console entry point and remove the dependency of Mono.Options
- `USE_MONO_API_TOOLS_NAMESPACE` will switch the namespace to `Mono.ApiTools` so that libraries can have a nice API
- `USE_INTERNAL_VISIBILITY` will make any non-essential, `public` APIs turn `internal`
## Review points
- are there any variables/fields that are still static?
- are there any exposed types/members that need to be hidden?
- are the new names for the APIs and config classes OK?
- are my whitespaces according to the guidelines?
- did I go horribly wrong?
- Public headers should be wrapped in it (all but one are).
- MONO_API should include it.
But it is not needed "everywhere".
Placement of "extern" therefore tweaked.
- Remove from functions where it is meaningless and gets in the way.
- Mark data with MONO_API_DATA instead of MONO_API.
[not yet]Sprinkle in a few G_BEGIN_DECLS for monodis and where THREAD_INFO_TYPE makes prototypes incorrect.
include/add prototypes for all icalls. [undone per PR, possibly a misunderstanding]
A problem would be, if embedders manage to use functions that are neither MONO_API nor
in public headers.
Some parts of the larger solution are omited here in the hopes of finding better options.
In particular, compiling all of monodis as C++ so we don't need some extern "C" for it,
and THREAD_INFO_TYPE at least incoming being gpointer so declaration and definition match.
This is based on https://github.com/mono/mono/pull/9812/commits/40315ee475bdf89c40189707a8cca86b3f6d91c8 and is an alternative to https://github.com/mono/mono/pull/9782.
We also can/should prune the preexisting G_BEGIN_DECLS / G_END_DECLS uses.
* [runtime] Add a MONO_ABI_SIZEOF(MonoObject) define, use it instead of sizeof(MonoObject). Add a few helper functions to avoid sizeof(MonoObject) in many places.
* [aot] Add a 'deterministic' testing argument to have the compiler produce deterministic output by turning off the generation of the AOT id.
* [jit] Use target sizes in many places.
* [runtime] Avoid corlib checks in cross compile mode, its not possible to read the field value from corlib.
* [runtime] Fix the arm build.
Every different locale getter in unmanaged attempts to
cache the result from this icall. Some of them fail to do so in a manner
that is correct.
CFLocaleCopyCurrent (); in get_darwin_locale ends up being called
thousands of times. In an app with a few dozen printfs, it's easy to see
18mb of leaked memory through this.
Rather than trying to fix them all in unmanaged in a perfect manner, I
thought it better to also avoid the icall overhead and to cache it in
C#.
Without this fix, a memory traffic stress test (debian shootout's pidigits) leads to 66% of
memory pressure being due to this icall. With this fix, it is 4.3%.
If this caching is wrong for correctness reasons (we expect it to change?),
I would like to point out that we have similar caching done in unmanaged
and that we should then bring both into a correct design.
Right now we have a race condition where parallel make on CI will barge ahead and start building things before monolite+basic-profile-check have completed, which results in some weird behavior - gensources silently fails to run, etc. Testing some possible fixes for this.
* [offsets-tool] Add i386-apple-darwin11.2.0 as an abi target, used only for development.
* [offset-tool] Emit sizes for structures.
* [runtime] Cleanup the cross targets in configure.ac and add more target defines.
Redefine SIZEOF_REGISTER to refer to the target size.
Add TARGET_SIZEOF_VOID_P define and target_mgreg_t type.
* [runtime] Add missing object offsets for x86.
* [runtime] Avoid trying to execute assembly load hooks in aot mode.
* [runtime] Fix the windows build.
* [offset-tool] Fix indentation.
* [runtime] Add a mono_gc_get_target_card_table () function which is the same as mono_gc_get_card_table () but returns information for the target. Use it in the JIT and in places where we generate IL code.
* [aot] Save the card table parameters in the AOT image and check them at load time.
* Fix llvm support.
Using solution dependencies in ```bcl.sln``` seems flaky and seems like it might not establish the full ordering we need to ensure that ```Consts.cs``` exists before we build things that require it. Let's try using project references (where ```corlib.dll``` 'depends' on ```genconsts.exe```) instead. This should also insert the dependency for any project that includes Consts.cs instead of just corlib.
This PR also makes update-solution-files actually fail if ```genconsts.exe``` fails to build because it was driving me mad.
Part of #6886
* Add check for a generic method when invoking in debugger
VSTU will try to invoke a generic (uninflated) method in certain
situations, which was causing the Mono debugger to assert and crash
Unity. Added a check for this situation before the invoke so the
debugger can return an error to the client. Previously, this case
wasn't caught until the method was in JIT compilation, which will
assert when this situation is detected.
* Fixing typo
The version imported and attempted to patch didn't work fully. This
preserves the .NET representation while converting if directives to
runtime checks, which CoreCLR inlines.
Testing was done poking some values in the REPL and running some
test suites (System.Json, System.Decimal) that broke as a result.
mcs should also properly handle constants; again, the "bits" inside
are consistent with amd64, and just converted as needed.
Unless I fucked up, should fix#9772.
Carbon implementation now throws exception instead of crashing in the mismatched p/invoke calls.
Cocoa implementation now support 64-bit mode and uses the handle of `NSView` that is passed in instead of relying on `NSGraphicsContext.CurrentContext`. It also fixes handling of flipped views.
Requires up to date libgdiplus.
* [appdomain] MONO_API mono_domain_set needs GC Unsafe
* [runtime] MONO_API mono_domain_set_config needs GC Unsafe
* [runtime] MONO_API mono_dllmap_insert sometimes needs GC Unsafe
When adding a global mapping, don't do the state transition because the thread may not be attached yet. When adding a per-image mapping, do the transition.
* [runtime] MONO_API mono_g_hash_table_insert needs GC Unsafe
* [runtime] MONO_API mono_g_hash_table_new_type needs GC Unsafe
* [runtime] MONO_API mono_gc_reference_queue_new needs GC Unsafe
* [runtime] mono_thread_detach_if_exiting thread state change
1. Mark it external only, it's unused in the runtime.
2. If detaching, switch to GC Unsafe before detaching
* [metadata] Make mono_class_get_fields external only
- Runtime should use mono_class_get_fields_internal
- MONO_API mono_class_get_fields needs GC Unsafe
* [runtime] MONO_API mono_gc_reference_queue_add needs GC Unsafe
* [metadata] Make mono_class_get_name and namespace external only
- Runtime should use m_class_get_name and m_class_get_name_space
- MONO_API mono_class_get_name and mono_class_get_namespace need GC Unsafe
* [metadata] MONO_API mono_class_get_parent needs GC Unsafe
- mark it external only; runtime should use m_class_get_parent
* [metadata] Make mono_class_is_delegate external only
- runtime should use m_class_is_delegate
- MONO_API mono_class_is_delegate needs GC Unsafe
* [metadata] Make mono_class_is_valuetype external only
- runtime should use m_class_is_valuetype
- MONO_API mono_class_is_valuetype needs GC Unsafe
* [metadata] Make mono_class_is_enum external only
- runtime should use m_class_is_enum_type
- MONO_API mono_class_is_enum needs GC Unsafe
* [metadata] Mark mono_class_get_element_class external only
- runtime should use m_class_get_element_class
- MONO_API mono_class_get_element_class needs GC Unsafe
* Add support for Blazor custom interop support.
This adds additional ability to perform unmarshalled calls for advanced but high-performance shared-memory interop.
* Note: * This is only safe in Blazor's case because of its exact usage patterns.
* Add dotnet_support.js backing file.
Instead of accessing them using the inst_ls_word/inst_ms_word macros which use the union in MonoInst.data, access them normally using
MonoInst.Data.i8const.
It wasn't possible to debug any F# app that contained PInvokes.
The F# compiler omitted MethodDebuginformation for PInvokes which in
turn caused Mono to fail on an assertion.
```
* Assertion at metadata.c:1117, condition `idx < t->rows' not met
```
https://github.com/mono/mono/commit/0f0e31842f1f394c4e95d3726c20af547e706278 added a new pipes_pns.sources file
but we forgot to add it to EXTRA_DISTFILES so it gets included in the tarball.
Given that this happens almost all the time when we add a new .sources file
we should just always include all *.sources
* [cxx] Build/CI support for C++.
configure -enable-cplusplus and CI_TAGS=cplusplus
https://jenkins.mono-project.com//job/test-mono-mainline-linux-cplusplus/
* [cxx] Rename CPLUSPLUS/cplusplus to CXX/cxx.
* [cxx] Add C++ build support to mini.
* [cxx] Jenkins/CI support for cxx not just cplusplus.
* [interp] Fix some conv ovf opcodes
* [interp] Correctly hande a few conv ovf cases
For conversion from unsigned value to i1 and i2.
* [interp] Fix multiplication overflow case
* [interp] Remove some constants from code
* Use System.Security.Policy.Publisher from corefx (they essentially stubbed it out).
Fixes the XUnit 2.4 problem.
* Use `PublisherMembershipCondition` from CoreFX as well (stubbed out in there) and remove the tests.
* Bump API snapshot submodule
* [Coop] System.IO mark all remaining NOHANDLES().
* Functions take no parameters, not any parameters -- () vs. (void).
* [Coop] Mark System.Threading.Interlocked as mostly NOHANDLES().
* [Coop] ves_icall_System_Threading_Thread_MemoryBarrier is NOHANDLES().
* [Coop] System.Threading volatile reads/writes are NOHANDLES().
* Make YieldInternal NOHANDLES and remove two potential layers.
* [Coop] Make ves_icall_System_Threading_Thread_current_lcid NOHANDLES().
* [Coop] mono_100ns_ticks nohandles.
* [Coop] More nohandles volatile reads/writes.
* [Coop] NOHANDLES() System.Security.SecurityManager.
Return objects from load_cattr_value () using an additional out parameter. Add a variant of
mono_reflection_create_custom_attr_data_args () which can only decode a subset of cattr types, but
it doesn't allocate any objects. Use this in marshal.c/marshal-ilgen.c to avoid allocating objects
while decoding FixedBufferAttribute and UnmanagedFunctionPointerAttribute.
* [interp] Refactor MINT_ICALL opcodes
Remove integer versions, since they add unnecessary complexity, and with some signatures we were already implicitly casting int to gpointer.
* [interp] Use fast versions for icalls
* [interp] Include more fast pinvoke/icall signatures
These cover almost all icalls
* [interp] Fix fast icall return value
The returned value needs to be converted to the stackval representation
* [corlib]: Cleanup `X509Certificate` implementation and sync it with CoreFX.
Completely refactored the `X509Certificate` implementation to make it based very closely on CoreFX.
We cannot fully switch to their implementation yet because we are missing things and they also have
a few issues in their implementation. However, this will make it a lot easier to do this at a later time.
The internal `X509CertificateImpl` has been cleaned up as well, using properties instead of methods in
most places and the `ToString()` implementation is now shared between all platforms.
* `X509Certificate.CreateFromSignedFile()`: in CoreFX, this is the same as `CreateFromCertFile()`.
Our old implementation was incomplete and did not verify the signature - we even had a test where
loading a certificate with an invalid signature was supposed to work; this test has been disabled
because we're now throwing an exception.
* `X509CertificateImpl.KeyAlgorithmParameters`: this is supposed to throw `CryptographicException`
on error, see `Certificate13` in `X509CertificateTest.cs`.
* We now match CoreFX's behavior regarding serialization - while the `X509Certificate` type is still
marked as `[Serializable]`, we now throw `PlatformNotSupportedException` when attempting to serialize
or deserialize it.
* Bump API snapshot submodule
* [csproj] Update project files
* Make `corlib` internals visible to `System.Security` on all profiles, not just monotouch watch.
* Moves all generated `SR` files and their generation logic from `System` and `System.Security` into `corlib`. Since `corlib` internals are visible to these assemblies, we don't need to duplicate the resource strings.
* Cleanup the `RESX_RESOURCE_STRING` is `corlib` and sort them alphabetically.
* Add the internal `Internal.Cryptography.Helpers` helper class from CoreFX to `corlib` (currently unused, but "Blue" will need it).
* Fix up behaviour of verbose method with arguments
Given a method spec which looks like:
`MainClass:Do(int,int,int)`
Via f024e820a025aacc1cf80eb82a8aee4552c3ac11 the code would match 3 methods:
`MainClass:Do(int`, `int`, `int)`, crashing the runtime.
Accept the multiple method matches via `;`, rather than `,`.
Now, the behaviour is changed so:
`MainClass:Do(int,int,int);MainClass:Do(int,int)`
Get parsed as:
`MainClass:Do(int,int,int)`
`MainClass:Do(int,int)`
* Add tests
* add test file and make tests actually output something
* Smarter unit test around disassembling methods
* Try single quoting environment variable value
* Try using non-throwing setter
Temporarily switch back to ref-source impl for `CharUnicodeInfo` which contains a few special BE patches while I am trying to upstream them.
Fixes#9684
Both `Certificate_11_Properties` and `Certificate_14_Properties` use an invalid
certificate that violates X.690 11.8.2 (UTCTime under a DER encoding).
This will no longer be supported once we switch to CoreFX's PAL code.
See also https://github.com/dotnet/corefx/pull/31293.
Instead of digging around in the environment for the coop and hybrid suspend
settings, define in terms of mono_threads_suspend_policy (or the
MONO_ENABLE_BLOCKING_TRANSITION env var as before).
Set to one of "preemptive", "coop" or "hybrid".
Unlike the old MONO_ENABLE_COOP, MONO_ENABLE_COOP_SUSPEND,
MONO_ENABLE_HYBRID_SUSPEND, the value of MONO_THREADS_SUSPEND will take
priority over the configure flags default.
For compatability the old environment variables will be respected if neither
MONO_THREADS_SUSPEND nor a configure flag was set. A warning will be emitted
if MONO_THREADS_SUSPEND isn't set. (Rationale: maybe the environment set both
because they're not sure which version of Mono they will be running - so don't
nag them).
Rework of #5448, contributes to #7143.
The anonymous pipes were tested on macOS, build was tested only on few configurations (hoping to solve some issue through Jenkins builds). Named pipe tests get stuck on macOS, but it may be unrelated Xunit issue and needs some proper debugging.
@Therzok, do you know of anything else that is missing for parallel MSBuild? Do you have some test environment for it by chance?
[MacOS] On Mac, use the copyfile API to copy files
Rebase of #9038 with added fix for the failing unit tests. Note that there's a race condition in the check between `source file == destination file` and the `copyfile` call, but a similar race condition already exists there in the current code except the outcome is different.
* `X509Helper`, `X509CertificateImpl`, `X509Certificate2Impl` and `ISystemCertificateProvider` now use `SafePasswordHandle` instead of strings.
* `X509Certificate`: actually implement `SecurePassword` based APIs using `SafePasswordHandle`.
* `mono_btls_pkcs12_import()`: when passed an empty password, try both the empty string and null.
After the dependency injector changes, the `X509Certificate` code in corlib now uses the implementation from `System.dll`, including the platform-specific switch via `MONO_TLS_PROVIDER` / `MonoTlsProviderFactory`.
This adds a new `X509Certificates2` category to the corlib tests and runs them with `MONO_TLS_PROVIDER=btls` on OS X (where the default is applets).
* [interp] fix stack type warning around ldlen instruction
removes this warning in e.g. mcs-tests:
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
> Object.CallSite.Target: Store local stack type mismatch 0 1
* [interp] fix compiler warning around MINT_INTRINS_BYREFERENCE_CTOR
fixes those warnings:
> interp/interp.c:3924:13: warning: unused variable 'valuetype_this' [-Wunused-variable]
> stackval valuetype_this;
> ^
> interp/interp.c:3926:13: warning: unused variable 'retval' [-Wunused-variable]
> stackval retval;
> ^
> 2 warnings generated.
Adds 1192 xunit tests for System.XML from CoreFX
Also, moves common lines from `mobile_System.Xml.sources` and `System.Xml.sources` to `common.sources`
Part of #8132
* Use __declspec(thread) with Visual C++, and __thread with Win32/gcc,
instead of much slower TlsGetValue / TlsSetValue
* Avoid affecting Boehm.
* Replace HAVE_KW_THREAD and USE_KW_THREAD with MONO_KEYWORD_THREAD.
* Refactor the AppleTls Certificate code into a PAL-based approach.
* Added the internal `SafeHandle` based classes from CoreFX's PAL:
`SafeSecCertificateHandle`, `SafeSecIdentityHandle`, `SafeKeychainItemHandle`
and `SafeSecKeyRefHandle`.
* Added a new static internal class `MonoCertificatePal`:
- `Mono.AppleTls/MonoCertificatePal.cs` is shared between OS X and Mobile.
- `Mono.AppleTls/MonoCertificatePal.OSX.cs` contains the OS X specific parts.
- `Mono.AppleTls/MonoCertificatePal.Mobile.cs` contains the Mobile specific parts.
This split allows us to avoid all the `MONOTOUCH` conditionals in the code.
* In the `Mono.AppleTls` directory, all code from `Certificate.cs`, `Items.cs` and
`ImportExport.cs` have all been merged into the new `MonoCertificatePal` class.
* The entire AppleTls code is now using these safe handles instead of the old
Mono-specific types. This allows us to swap out the implementation of the certificate
code with CoreFX's PAL code.
* Cleaned up and removed some ancient dead code.
* `build/profiles/build.make`: Don't set `MONO_FEATURE_APPLETLS` here.
* Add `appletls.sources` and cleanup `MONO_FEATURE_APPLETLS` conditionals.
* [csproj] Update project files
These programs work if you just compile them with g++ and most of the automake/autoconf/libtool
flags, but not if you use all of them. Something to do with search paths perhaps.
* [linker] Add BCL size regression testing
We're now tracking the size of the BCL after it was processed by the linker
across various profiles we care about (currently net_4_x, monotouch and monodroid).
The way it works is that we keep a file with size measurements in the repo
and during CI we run the linker against the current state and compare.
Right now we're simply running the linker tests as they are a good approximation
of various usages (this PR additionally adds more comprehensive linker tests we had in XI).
If changes are found there's a report to check where the increase/decrease came from.
The changes can be applied via `@monojenkins commit sizediff` similar to
existing csproj and apidiff usages.
Fixes https://github.com/mono/mono/issues/6992
* Don't run new linker tests yet, just use for size checking
The mono_load_runtime_and_bcl allows upstream to remap requests and report download progress.
This cb semantics might change in the future when we implement more agressive loading.
The `mono_threads_attach_coop` / `mono_threads_detach_coop` icalls are called
from the wrapper around managed methods that will be called from native code
`emit_managed_wrapper_ilgen`.
If the managed method throws an exception, the mono_threads_detach_coop will
not be called, and the checked build
`mono_threads_enter_gc_unsafe_region_internal`/`mono_threads_exit_gc_unsafe_region_internal`
accounting will be mis-matched which will break later checked mode checks.
(The unbalanced thread state transition is not a problem - the next outermost
exit_gc_unsafe will operate just fine - it's just the checked mode check that's
wrong)
Once we lost the try/finally in b20d5ce1e5 these
should have become unbalanced.
* [Coop] Convert 3 more functions and strengthen some types to be not just gpointer.
i.e. to see in debugger and for static type checking
* ves_* probably shall not call ves_*.
non-ves_* (mono_*) really shall not call ves_*.
Only C#/icall-def.h shall call ves_*, and only ves_*.
Where there is a contradiction, rename ves_* to mono_*,
have ves_* and mono_* call mono_*, and possibly cleanup.
For example, removing MonoError* parameter, and moving asserts
around to preserve or improve semantics.
* Remove incorrect comment.
This adds a simple script for generating Consts.cs that can run on Windows, and makes it a dependency of corlib.csproj in the BCL solution file. From my initial testing this will autogenerate Consts.cs if it's missing and then corlib will successfully build.
This (mostly?) addresses issue https://github.com/mono/mono/issues/6886.
This currently has an awkward dependency on ```winsetup.bat``` and I modified it slightly to make it clearer whether the batch file succeeded.
Rather than always writing to the std out, provide an option to write to a file. This makes things easier for tooling by not requiring `RedirectStandardOutput = true`
* [interp] Check delegates for null this
* [interp] Resolve target method for delegates created with abstract methods
* [interp] Fix delegate invocation
Previously, when first calling the Invoke method on a delegate we would silently transform the delegate invoke wrapper of the delegate on which Invoke is called, after which all calls would go through this method. This is problematic because the same Invoke method can be called on a different delegate afterwards (the delegate_invoke wrapper needs to be tied to the delegate and it's not global for all invokes of same type),
We solve this by storing the invoke method in the delegate, similarly to the JIT.
* [interp] Remove unused argument
[llvm] Avoid using the preserveall calling convention in another plac…
…e on watchos.
Fixes https://github.com/mono/mono/issues/9318.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
Generate similar array-coop*.cs files from pieces.
System.Array icall logging/testing tweaks.
Add const, but only in comment.
[Coop] Convert ves_icall_System_Array_CreateInstanceImpl.
PR feedback: Don't have icall call icall, refactor into common helper instead.
Add more disabled printing.
test_get_generic_value fails even CI JIT due to AOT runtime,
but does work with full JIT configuration.
Generic ref/out parameters are not supported by HANDLES(), so
NOHANDLES(SetGenericValueImpl)
NOHANDLES(GetGenericValueImpl)
Also add MONO_REQ_GC_UNSAFE_MODE because of unsafe gpointer value (which reinforces NOHANDLES?)
Remove extra evaluation of arg.
Enable 3 more tailcall tests on x86.
Enable more tailcall AOT tests.
Program to split fsharp-deeptail.il into separate tests.
Split up F# test into individual tests.
Simplify test IL and make it stack overflow upon failure.
Cleanup test code before splitting.
Program to split tailcall-interface-conservestack into separate tests.
Enable split up versions of tailcall-interface-conservestack and F#.
There is a problem in that we use gsharedvt unexpectedly, and gsharedvt
has almost-fundament contradiction with tailcall.
Need to figure out why it used, if that is correct.
Disable some FullAOT tests that are broken by gsharedvt.
Lower apparent memory use.
Move tests into directories and reset disabled lists.
Centralize tailcall debug helpers.
Add comments why test_virt.exe fails on 32bit x86.
Remove tail. prefixes that are besides the point, and add noise to the logging.
Print more in failure.
Better align the stack for x86, so tests pass.
There were already tailcalling and conserving stack, but still using a little stack.
Real world code will use zero or a little. The test self-check is very strict
and wants zero, and prints how much.
Rename duplicate tests, and sort them.
Otherwise we were missing split tests.
Add 96 ARM failures and 30 FullAOT failures, mostly all understood.
ARM cannot pass extra parameter in a tailcall (except bitcode that we do not fix).
FullAOT uses gsharedvt a lot even for statically discovered types created, due to
interface and virtual.
Convert to C++98 and fix warnings about /* in //
Split the tests up in the build instead of ad hoc by developer.
Disable tests on wasm and win32 (and cross) due to build problem.
* [Coop] Convert ves_icall_System_Runtime_InteropServices_Marshal_IsComObject.
* [Coop] cominterop and marshalling partial conversion and cleanup.
* Some refinement/correction/commenting to mono_string_to_utf8str_handle.
* Fix index out of bounds.
* Fix error handling.
* Remove some mono_error_set_pending_exception.
* Fix icall interface -- string vs. ptr/len.
* tweaks
* Restore the corlib interface, and maybe address the apidiff gate.
* cleanup
* Fix PtrToStructure GC assertion failure tests/marshal2 interpreter.
* Fix merge.
* Revert "Restore the corlib interface, and maybe address the apidiff gate."
This reverts commit ca8456a05f75f0fc05f6559e2f075e18a455a362.
* Try harder to support fixed in array copying.
* Allow for overlap.
* Put mono_ in front of type and fix Windows.
* Fix small problems on Windows build.
* Fix Windows and support larger data.
* [arm64] Make OP_CHECK_THIS read only a byte, to prevent unaligned access errors.
* Bump corlib higher.
* Merge with https://github.com/mono/mono/pull/9430/files.
* Bump API snapshot submodule
* cominterop_get_interface(gboolean throw_exception) throw_exception is always true.
* Remove unused cominterop_get_hresult_for_exception.
* Guids are constant.
* Replace g_assert (mono_error_ok (error)) with mono_error_assert_ok (error).
* Move function name to start of line for grep ^foo.
* PR feedback: g_assert(ex)
* Cleanup cominterop_get_interface -- single point of exit, more canonical non-coop form,
assert error indicator equivalence.
* Cleanup cominterop_get_interface_checked: early return and assert equivalent error indicators.
* Combine two versions of mono_cominterop_init.
* g_new0 instead of g_new+memset
* Remove obviously redundantly error_init.
* Inline cominterop_get_idispatch_for_object into its only caller ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal,
and make it a more coop-friendly.
* add const
* Combine forks of some functions and ifdef out more on Win32.
* Initialize with declaration.
* Use integers for sizes, not pointers.
* More asserts though redundant.
* Combine two forks of mono_marshal_safearray_set_value.
Dependency Injector
===================
* `corlib/Mono/DependencyInjector.cs`: this is corlib's entry point.
* `corlib/Mono/ISystemDependencyProvider.cs`: this interface is implemented in `System.dll`.
* `System/Mono/SystemDependencyProvider.cs`: the `System.dll` side of it.
To use this, we need to call `SystemDependencyProvider.Initialize()` during system startup on Mobile
(this is already done for Android, but still needs to be done for XI/XM).
For Desktop, this will be triggered by a few `System.dll` based APIs such as for instance `SslStream`
or `X509Certificate2` - and the corlib side can use reflection if needed.
The corlib side should use `DependencyInjector.GetSystemDependency()`.
X509Certificate - corlib side
=============================
We previously had a mechanic called `INativeCertificateHelper` (which unfortunately was not really
working as intended) to use the BTLS code (which lives in System) in corlib. This has now been
replaced to use the new dependency injector.
The actual implementation as well as all the platform conditionals have now been moved into `System.dll`
where they can take advantage of existing PAL code.
This also removes all `Mono.Security.X509` usage from the `System.Security.Cryptography.X509Certificates`
namespace (it is still used by some of the other crypto classes, so we can't remove it yet).
* `Mono/ISystemCertificateProvider.cs`: this interface is now hooked up via the new
dependency injector and replaces `INativeCertificateHelper`.
* `System.Security.Cryptography.X509Certificates/X509Helper.cs`: this file has been completely
reworked and is now just a tiny stub around `ISystemCertificateProvider` and will eventually go
away completely. The entire implementation has been moved into `System.dll`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplMono.cs`: removed, we now use
`X509Certificate2ImplMono` from System via `ISystemCertificateProvider`.
* `System.Security.Cryptography.X509Certificates/X509CertificateImplApple.cs`: moved into `System.dll`
and slightly reworked there.
* `System.Security.Cryptography.X509Certificates/X509Helper.Apple.cs`: removed, we do not have any
platform-specific code here anymore; the new `ISystemCertificateProvider` provides this for us.
X509Certificate - System side
=============================
The actual implementation as well as all the platform-specific code now lives in `System.dll`.
* `Mono/SystemCertificateProvider.cs`: the `System.dll` implementation of `ISystemCertificateProvider`.
We do the platform / TLS Provider checks in here, then construct a custom PAL class.
* `Mono/X509Pal.cs`: New internal static class.
* `Mono/X509PalImpl.cs`: New abstract internal class. It contains some common code, including the
fallback implementation.
* `Mono/X509PalImpl.Mono.cs`: Fallback PAL, used by platforms without SslStream / MonoTlsProvider.
* `Mono.Btls/X509PalImpl.Btls.cs`: BTLS implementation.
* `Mono.AppleTls/X509PalImpl.Apple.cs`: We are using the `MONO_FEATURE_APPLE_X509` conditional in
here, so it can be used without the actual Apple TLS code.
* `Mono.AppleTls/X509CertificateImplApple.cs`: moved here from corlib.
* `Mono.AppleTls/*.cs`: Use the `X509CertificateImplApple(IntPtr)` constructor everywhere instead of
`X509Certificate(IntPtr)` to make sure we are using the "correct" PAL.
* [System]: Fix `mono_btls_x509_get_public_key()` implementation.
* Copy corlib's `X509CertificateTest.Certificate8` into System, call it
`Corlib_Test_Certificate8` and use `X509Certificate2`.
The test in corlib does not expose the problem because it would use the
fallback implementation.
* Use `[SetCulture ("")]` as suggested by Marek.
[coop] Fix MONO_HANDLE_TRACK_OWNER build
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
Originated from PR #1283, they now pass because we're using referencesource
code for the hash algorithm classes now.
In RSAPKCS1SignatureDeformatterTest.cs we weren't testing against the
actual `badSignature` (it doesn't make a difference since the referencesource
code or .NET Framework throws NullReferenceException anyway, but is more correct).
Closes#1283
* `HashCode` is now enabled in all profiles.
* Added `RNGCryptoServiceProvider` based fallback implementation.
* Added internal `RNGCryptoServiceProvider.GetRandom(byte*,IntPtr)` overload.
* The fallback implementation is enabled by default in `corlib.dll.sources`,
platforms which provide a native implementation need to add it to their
`.exclude.sources`.
[sdb] Avoid calling vm.GetThread () in the event callback, it could c…
…all into the debuggee leading to a deadlock if the thread mirror object has not been created yet.
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
[interp] fullaotmixedcheck fixes
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
It is too easily trashed, e.g. by mono_thread_info_uninstall_interrupt.
See https://github.com/mono/mono/pull/9104.
See https://github.com/Unity-Technologies/mono/commit/b6f1ba89f7ab285a0990e696e78798f7cf18dafb
Which this should be an alterate fix for, as discussed in 9104.
This is a small change, but ultimately we should be able to thread
gint32 *win32error around enough, such as to eliminate the thread local on Unix.
It doesn't appear to take much. Thread locals, it turns out, are not a good mechanism.
They are sensitive to loss as addressed here. They are slower to access than regular globals
or locals. They do have the advantage of "automatic threading through a callgraph", as long
as you are very careful with their use (this PR demonstrates that problem).
As well we could/should move the GetLastError calls down one layer on Win32,
from w32file.c to w32file-win32.c.
But this change addresses only ReadFile/WriteFile.
Also remove unnecessary void** vs. void* cast.
Also combine Unix mono_w32file_read and mono_w32file_write.
[mini] make interp work with AOT image generated with aot=interp
[aot-compiler] use mono_aot_mode_is_interp instead of directly using the flag
---------
[interp] add FULL_AOT flags to AOT image when `--aot=interp` is used
fixes regression from 67e995c6e2
---------
partial forward port of https://github.com/mono/mono/pull/9266
needs backporting to `2018-06`
* Fix unit tests to use SERIALNUMBER instead of OID.2.5.4.5 in X.500 names. Modify the code to pass the tests.
* Add SERIALNUMBER for BTLS implementation.
* Fix one more place where SERIALNUMBER was not handled.
[interp] Optimise allocation path
Speeds up allocation by 30-40%
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
As part of #7589
- CoreFX import only for Windows platform (no support for non-Windows platforms, see https://github.com/dotnet/corefx/issues/22510)
- left Mono managed implementation for non-Windows platforms
- removed DataProtectionScope parameter value check (no such a check in CoreFX and NET Framework, see https://github.com/dotnet/corefx/pull/30726) and couple of related unit tests
- added CoreFX xunit tests
When implementing Windows x64 valuetype ABI mono’s SIMD optimization didn’t
handle the case when passed arguments uses ArgValuetypeAddrInIReg/
ArgValuetypeAddrOnStack so optimization was disabled on Windows x64.
This commit fixes mono SIMD support for ABI’s passing value types using
ArgValuetypeAddrInIReg/ArgValuetypeAddrOnStack on Windows x64. It does this
as part of regular value type decomposition, including a pass decomposing SIMD
intrinsic ending up as arguments of type OP_ARG into correct load/store of the
value type reference before argument can be used by SIMD instructions.
All JIT and full AOT regression tests pass with enabled SIMD optimization
on Windows x64. Running this optimization on some vector intensive applications
showed some great performance increase. Just running this on basic-simd.exe
regression shows:
Elapsed time: 0.040471 secs (no optimizations at all)
Elapsed time: 0.015756 secs (only simd and intrins optimization)
So in this small, isolated test, the optimization indicates a 2.5x performance increase.
* [runtime] Map memory used by code managers with MAP_JIT on osx.
* [runtime] Use MAP_JIT only on osx mojave and later, it seems to cause crashes on earlier versions.
* [runtime] Add a constant for darwin 18.
* [runtime] Fix the race in get_darwin_version ().
* Fix indentation.
When doing full AOT of System.dll on Windows and other platforms building
runtime without HOST_DARWIN or HOST_BSD we will get an ugly error,
but compilation will still succeed leaving the user confused around the result.
The following error is printed:
--------------------------------------
cant resolve internal call to
"System.Net.NetworkInformation.MacOsIPInterfaceProperties::ParseRouteInfo_internal"
(tested without signature also)
Your mono runtime and class libraries are out of sync.
The out of sync library is: C:\github\mono\msvc\build\fullaot\winaot\system.dll
When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first.
cant resolve internal call to
"System.Net.NetworkInformation.MacOsIPInterfaceProperties::ParseRouteInfo_internal"
(tested without signature also)
Your mono runtime and class libraries are out of sync.
The out of sync library is: C:\github\mono\msvc\build\fullaot\winaot\system.dll
When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first.
--------------------------------------
The problem is that MacOs/BSD specific NetworkInformation classes are build into
System.dll on all platforms. One way to solve this is to start splitting the different
platforms specific implementations into different source files so we could start to
include/exclude sources per platform and profile in a nicer way instead of just
ifdef:ing inside current source files. This strategy also matches how corefx have
structured their NetworkInformation sources making it easier in the future to bring
mono’s NetworkInformation implementation closer to corefx. This PR implements this strategy.
Due to the fact that we don’t have platform specific configs for all profiles
(like basic and build) we can’t exclude all platform specific sources from
common.sources in System and move them to platform specific profiles. Ones we
have that full capability we could drop the #if WIN_PLATFORM in all the Win32*
files and exclude them from common.sources and only include them in the corresponding
win32 specific profiles. The same strategy could then be applied for other platform
specific profiles as well.
For Windows specific profiles, like win32_net_4_x_System.dll and winaot_System.dll we
use the .exclude.sources to remove the unix/linux/macos NetworkInformation sources,
so with this commit we will get a System.dll that only includes the Win32 specific
NetworkInformation classes and none of the unix/linux/macos, this will make sure the
compile error during full AOT won’t happen since there is no classes left including
the icall not available on a Windows mono runtime.
Other platforms will have the same classes in System.dll as before for now
but the source code is now structured making it possible to include/exclude platform
specific source files for other platforms as well, when needed.
The previous system was a nice prototype, but it ran into the problem of
taking a global lock on every thread doing logging. A fully lockless
implementation of a data structure with so much state would have been
madness to debug, and I really didn't want to spend much time in the future
debugging this.
What I did is to make a thread that reads from a lockless queue and logs the
message from the queue.
Most of the rest of this code is to address the fact that hazard
pointers depend on state that is initialized after logging is expected
to come up.
[checked-build] don't collect state transition backtraces on abort_blocking
for the same reason as the other cases in this function - if we're in `RUNNING`
or `ASYNC_SUSPEND_REQUESTED` under hybrid suspend we're supposed to cooperatively
suspend. If we call `backtrace()`, we might block waiting for the low-level
dynamic linker mutex on Linux which may be held by a thread that was
preemptively-suspended already.
Returns a text description of the suspend policy currently in effect.
Also combine logic that probes for suspend policy defines and environment
variables into a single function that returns an enum value; use that to drive
the individual boolean predicate functions.
The policy is subject to configure flags from when mono was built, and the
assorted environment variables at runtime:
MONO_ENABLE_COOPERATIVE_SUSPEND
MONO_ENABLE_COOP
MONO_ENABLE_HYBRID_SUSPEND
(the second one is a backward-compatible alias for the first)
The logic is:
If coop xor hybrid is enabled by configure flags, always return that policy.
Otherwise if coop and hybrid env vars are set simultaneously, it's an error.
Otherwise if MONO_ENABLE_COOP or MONO_ENABLE_COOPERATIVE_SUSPEND is set use full coop.
Otherwise if MONO_ENABLE_HYBRID_SUSPEND is set use hybrid.
Otherwise use full preemptive suspend.
[mini] respect additional flags when caching runtime invoke wrappers
depending on `virtual_` and `need_direct_wrapper` we generate slightly
different IL. The interpreter always set `need_direct_wrapper`, but the
JIT doesn't, so this gets problemantic with mixed mode. We need to be
careful when we cache those results.
This bug has been lurking for four years, being introduced in commit
5b2bb8c901. BYTE_ORDER != G_BYTE_ORDER.
Not throughly tested, but System.Decimal from csharp seems to return
sane results again. (related: is z or AIX CI available for PR checks?
if not, what test suite is System.Decimal under?)
Also remove my shoddy workaround from a few months ago, it got the
BCL building, but was incorrect.
* [sdb] Add a AssemblyMirror.GetMetadata () method to read the metadata from the debuggee, make AssemblyMirror.Metadata return it, or null if its not set/read yet.
Fixes a regression introduced by b26a41cc3e. Parts of Mono.Debugger.Soft would check
AssemblyMirror.Metadata against null, and that would throw an exception when the debuggee was using an older protocol version.
* Bump API snapshot submodule
This PR prepares the upcoming removal of the Legacy TLS Provider.
- The internal (and soon-to-be-removed) class `MD5SHA1` has been moved and changed namespace.
- `Novell.Directory.Ldap.Connection` now uses `SslStream` instead of Legacy TLS, this ports the Novell Ldap library to use TLS 1.2, see #9363.
- Removed obsolete Ssl/Spnego authentication from `System.ServiceModel`.
- Removed duplicate copy of the Legacy TLS Provider from `System.ServiceModel`.
- Ported `System.Web.Mail.SmtpClient` to use `SslStream`.
- Removed the `Mono.Security.Protocol.Tls` documentation.
* Functions at start of lines for grep ^foo.
* [Coop] Convert System.Security.Cryptography.RNGCryptoServiceProvider.
* Remove 'count' in more places in favor of inc/dec buffer/size.
Guard all loops with while (size > 0).
Don't pretend that sizeof int32/16/8 is other than 4/2/1.
assert instead of loop forever of degenerate systems with small RAND_MAX and
without better random.
* [Coop] Some conversion of custom-attrs.c. (#9309)
* Add comment explaining mono_array_addr_with_size_fast vs. mono_array_addr_with_size.
* Have mono_array_addr_with_size reuse mono_array_addr_with_size_fast.
* split create_custom_attr_data into self and create_custom_attr_data_into_array, to avoid handle creation in loop (like alloca in loop)
Note there is a subtle semantic change here, in that previously
when invoke failed, we'd still store into the array.
The caller checks the error and throws out the data so it should be ok,
the same in the end.
* Combine mono_cominterop_get_com_interface and ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal which are nearly identical.
* Fix disabled COM.
* Replace unformative and possibly dangerous g_assert_not_reached with safer more informative g_assertf.
Fix many warnings like: icall.c:666:2: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
Most uses of mono_error_set_argument do not take a format string.
So rename mono_error_set_argument to mono_error_set_argument_format
and provide mono_error_set_argument that just takes one string, not to be formated.
Visit every call to mono_error_set_argument and change just a few to be mono_error_set_argument_format.
While there, notice that method_encode_code forms up extra data and does not use it.
* [debug] mono_pmip shouldn't assume it's called from an attached thread
`mono_pmip` calls `get_method_from_ip` which needs to make a string with the
name of a method. It used to call `mono_method_full_name` which is a `MONO_API`
function and so tries to switch to GC Unsafe mode (which requires the thread to
be attached).
However `mono_pmip` is often used from GDB/LLDB and it might be invoked by the
developer from a stopped thread that isn't currently attached which would assert.
Instead call `mono_method_get_name_full` in `get_method_from_ip` which doesn't
switch the thread state.
* [coop] mono_coop_cond_signal and mono_coop_cond_broadcast should switch to GC Safe
Under Linux/glibc `pthread_cond_signal` and `pthread_cond_broadcast` can block
on a futex in `__cond_quiesce_and_switch_g1`, so switch the thread to GC Safe
mode around the blocking operation.
* [coop] ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal shouldn't swith to GC Safe
On Win32, still do the thread state change here; on other platforms
its handled in the implementation of mono_w32handle_signal_and_wait
Add support for platform customization of native crash info output.
Add support to replace implementation of a post native crash handler behavior
if needed (used on none desktop Windows platforms).
NOTE, currently alternative implementations are in separate source file only
for Windows (since there was a need to implement in sources keept in external
closed repository). All other platforms (none Windows) still uses the exact same
logic still located in the same source file as before.
[interp] fix scope issue regarding `klass` var
`klass` exists in the main loop, but we defined `klass` again inside the
block, so the outer `klass` never had the right value.
Fixes https://github.com/mono/mono/issues/9023
* Update genproj makefile to include gensources
Update genproj argument parser to be more generous about displaying help
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint
* Fix rebase issue
* Checkpoint
* Checkpoint
* Fix built sources only being added to one profile
* Fix typo
* Checkpoint
* Fix indentation
* Use csc instead of mcs
* Checkpoint
* Fix BUILT_SOURCES only being handled for the first profile processed
* Checkpoint
* Checkpoint
* Strip double slashes from paths to fix spurious csproj change
* Checkpoint
* Checkpoint
* Checkpoint
* Checkpoint: Fix genproj compilation
* Checkpoint
* Checkpoint
* Checkpoint
* Fix crash when no targets were loaded (due to an error)
* Checkpoint
* Checkpoint
* Checkpoint
* Fix TryParseTargetInto bug
* Checkpoint
* Shuffle exclude logic around so that it works correctly during genproj diffing
* Remove gensources tracing
* Checkpoint
* Fix handling of oddball sources paths from executable.make
* Fix jay not being set to build
* Fix wrong slashes being used for embedded resource paths
* [csproj] Update project files
We had a problem with order of operations before. Makefile.am.in is
interpolated twice in the standard build. The first time happens when
autoconf runs. The second time happens when we enter the mono/mini directory
and execute our build. In the refresh, we lose our AM_CONDITIONAL conditionals
defined that aren't also AC_DEFINE variables on linux.
That's what it's vital to define all variables in all namespaces to have maintainable
automake code.
Furthermore, some of the CFLAGS logic we defined is designed for older LLVM copies, as
it includes some flags like O3 and Wall that we don't want.
In order to not get hacky with this, I moved the logic for using llvm-config into
a bash file in /llvm that creates a makefile fragment. The logic says that this fragment
should be null on calling autoconf, and then will be instantiated after we build llvm.
This fixes the build on Linux. We can expect bash behavior to be more consistent between
OSX and Linux than we can with automake too. I think this is a reorg with good long-time
maintainability.
* Use System.Security.Cryptography.Oid* from CoreFX.
* [csproj] Update project files
* Add CoreFX unit tests.
* Add obsolete S/MIME OID to make the Oid CoreFX tests pass on non-Mac systems.
* Enable Windows specific implementation of OidLookup.
* [sdks] Only rebuild MXE when it doesn't exist, not when we just cloned the sources
* [sdks] Default to ~/android-toolchain and ~/android-archives to better share with XA
Current DYNCALL on AMD64 didn’t handle scenario when spilling parameters from
registers to stack and that parameter was of type float/double. It then incorrectly
updated the floating-point register slot, but should have written it into the general
stack slot, making sure it will be correctly placed on callers stack in correct slot.
Current DYNCALL implementation didn’t handle the Windows x64 ABI when hitting a scenario
when spilling a valuetype into stack, it currently only supported the regular ArgOnStack
storage type, but Windows x64 will use ArgValuetypeAddrOnStack storage type.
There was also an additional issue with the number of stack slots allocated since it used
the stack argument offset instead of number of slots represented by the offset
(as used in later calculations). This caused to much stack space to be allocated and copied
(but things still worked as expected).
Commit also include a number of new test in aot-tests.exe mini regression test hitting above
issues.
* Modernize Windows random number generation.
- Less code.
- Less chance for failure.
- Not seedable.
- Requires Windows 7 or newer -- er, require Vista or newer until/unless Unity drops it, under ifdef.
This might get much further pruned with CoreFX import, which is on hold here, and doesn't really change much, except to indeed drop Vista support. (https://github.com/mono/mono/pull/9249)
After fixes issues in DYNCALL Windows x64 ABI all aot-tests.exe previously
excluded using !FULLAOT-AMD64 can now be reenabled since outstanding issues
have been fixed. There is one new test still failing on Windows x64,
test_42_arm64_dyncall_vtypebyval, that is now excluded until investigated
and fixed.
Correctly handle use cases when parameter storage is ArgValuetypeAddInIReg
or ArgValuetypeAddrOnStack. This is used for value types not fitting into
registers on Windows x64.
The Winx64 calling convention handles parameters in a way that was not
correctly implemented in some DYNCALL use cases. When using a method signature
like this (double, int, double), the Winx64 ABI dictates that the first parameter
goes into first floating point parameter register (XMM0), second parameter goes into
second general register (RDX) and third floating point goes into third floating point
parameter register (XMM2). So above call should use registers XMM0, RDX and XMM2,
but current DYNCALL implementation will just use next floating-point register,
like XMM0, RDX and XMM1 and this will load wrong parameter registers as expected by callee.
For an example https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx#Anchor_2
Fix makes sure mono_arch_start_dyn_call uses the already evaluated registry information
for floating point parameters. Currently it assumes floating point registers are assigned
in a linear fashion and that works for System V ABI, but not for Winx64’s ABI.
Commit also adds a couple of tests into ao-test.cs that works with mixed signatures
together with DYNCALL.
* [wasm] Add helper target to update the runtimes.
* [wasm] Reenable tests that previously crashed due to JS engine issues.
* [wasm] Update jsvu 1.3.1 so we get jsc on linux. Fix uname magic on OSX.
Omitting positional parameters works for gdb linked to python 2.7 / 3.1+. On older systems (e.g. redhat 6, centos 6) gdb might be linked to python 2.4-2.6 or 3.0, adding parameter ordinals enables proper backtraces on those systems.
Fixes#9292.
* [System]: `HttpWebRequest` now throws `WebExceptionStatus.RequestCanceled` on abort. #9031.
Cleanup the internal `HttpWebRequest.RunWithTimeout()` function and use
`GetWebException()` everywhere to throw `WebException` with
`WebExceptionStatus.RequestCanceled` on abort.
New tests for this will be added to the web-tests by extending the existing
`Xamarin.WebTests.HttpInstrumentationTests.AbortDuringHandshake` to check the
synchronous and begin/end async APIs as well, using both `GET` and `POST`.
See https://github.com/xamarin/web-tests/blob/master/Xamarin.WebTests.Tests/Xamarin.WebTests.HttpInstrumentationTests/AbortDuringHandshake.cs.
Fixes#9031.
* Fix exception checks, setting `TransferEncoding` without `SendChunked` is supposed to throw `InvalidOperationException`.
* [System]: Renegotiation in AppleTls requires OS X 10.12+.
* Make renegotiation version check conditional to `!MONOTOUCH`.
The rest of the renegotiation code is currently conditional to `!MONOTOUCH`
as well, we might want to eventually revisit this at some point.
Fixes#9234
Had additional restructure not been ok, at least typedefing the function pointer
would have helped.
Add const for efficiency -- make the copy-on-write faults count for more and
not take extra readonly data with them.
Remove unused and actually confusing parameter -- it is just zeroed memory
and almost cannot be used for anything (granted, could hash it).
* [sgen] Use longs with nursery array fill
Objects are 8 byte aligned. This enables us to support nurseries of up to 32GB.
* [sgen] Add explicit limit to nursery size
* g_string_insert does not update string->len, and copies the wrong number of characters around,
and does not allow for overlapping parameters,
and is not used -- remove it.
g_string_erase does not always update string->len,
and is not used -- remove it.
g_string_prepend does not update string->len.
Switch the only use to append in the reverse order, and fix a leak.
[runtime] Fix debugger dumping when unused
Somewhere in the daily rebasing to edit the PR, I lost the correct version of the early-exit. This fixes our native crash when we did not use the debugger. It's important to merge, or we'll crash before MERP/gdb dumping happens.
Using dynamic symbol resolve (LoadLibrary/GetProcAddress) for all unwind info related registration functions enables
building the same code on all Windows platforms where JIT is build and included.
There are Windows platforms (like UWP) that doesn't support getenv. The implementation
of g_getenv makes it possible to replace the implementation at build time on
none desktop platforms.
The throwing of the pending exception after the finally blocks are executed was in unreachable code.
Refactor the code a bit and exit the abort protected block directly in endfinally. We throw the abort after all guarding finally blocks were invoked, to avoid throwing from inside a finally block. Guard also fault handler, which are called from EH.
* [runtime] Implement tombstone scrubbing for our concurrent hashtables.
Tombstones must be scrubbed as they can end up taking up all space of a hashtable and make lookup fail.
* [runtime] Added regression stress test for #9176
This test triggers insertion and removal from runtime_invoke_hash to the point
that if there's no scrubbing it will cause a deadlock.
* [runtime] Disable new test under full-aot as it uses SRE.
The callback consists in `mono_thread_info_abort_socket_syscall_for_close` which itself calls `mono_threads_suspend_abort_syscall`. The problem with the previously existing interrupt callback is that, even if `mono_threads_suspend_abort_syscall` is called by the thread suspend mechanism, it would still call `mono_thread_info_abort_socket_syscall_for_close` which would duplicate the call to `mono_threads_suspend_abort_syscall`
* Helper scripts running mini regression tests in JIT/Full AOT on Windows.
A set of helper scripts running all mini regression tests, supporting both
JIT and full AOT (including building full AOT assemblies) using local build
Visual Studio mono runtime (can be switched in setp.env.bat). Includes logic
to pick correct Visual Studio toolchain and support to setup command prompt
targeting x64 full AOT build and running tests. NOTE, the scripts are not limited
to the mini regression tests, only includes a set of predefined assemblies making
it easier to execute regression tests.
Full AOT scripts includes capabilities to build dynamic library, static linked objects
or assembler output, it also supports switches to use LLVM when building full AOT
assemblies if supported by local build mono runtime.
By default, scripts follow default build configurations used by mono BCL builds and
Visual Studio x64 Release build mono runtime.
Examples to run all JIT regression tests:
run-jit-regression.bat all
To run individual programs using JIT (doesn’t need to be a regression test):
run-jit.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
run-jit.bat basic.exe
Examples to build all regression tests using full AOT:
build-full-aot-regression-tests.bat all
Builds all regression tests in full AOT including all needed support and
BCL assemblies. All build assemblies will end up in msvc\build\fullaot\winaot
folder by default. It is possible to build individual assemblies as well using:
build-full-aot-regression-tests.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
build-full-aot-regression-tests.bat basic.exe
Examples to run all regression tests using full AOT:
run-full-aot-regression-tests.bat all
Runs all regression tests in full AOT. It is possible to run individual assemblies
as well using:
run-full-aot-regression-tests.bat [full path to assembly]
NOTE, for regression tests there is a shortcut making them easier to locate,
so then just the assembly name can be used, not the full path is needed.
run-full-aot-regression-tests.bat basic.exe
There are some more features included in the scripts as well, but above shows
basic usage. It could also be possible to reuse the scripts in Visual Studio
build targets going forward to at least run the JIT regression tests
as part of Visual Studio build.
* Fixed some review feedback.
* Switching to 1 instead of -1 in case of errors.
* Used case insensetiv compare for some if's.
* Dropped use of ECHO OFF/ON in nested scripts.
* Removed clear of PATH (was not intended).
* [mini] Implement delegate tramp info using gsharing context.
* [mini] Remove duplicate patch type.
* expand a FIXME to include what needs fixing.
* [mini] Copy MonoDelegate::method from the delegate tramp info instead of emiting a rgctx fetch. This is 6% faster on a delegate microbenchmark.
* Fix Process.ProcessName on AIX
AIX has a procfs with raw structures congruent with Solaris. For i,
which lacks procfs, fall back to a libc call.
This doesn't solve the Process weirdness that bungs up the test
suite, but I hope it's a start.
* Bye bye, annoying AIX setschedparam warning
AIX (but weirdly, not i) complains every time you do this. Squelch
the warning on AIX and avoid line noise.
* Remove more assumptions of /proc on AIX
* should probably always use getprocs64 for w32process,
but looks like we could just use proclib on the fallback?
* there's some more cases relating to resource usage stat,
will have to investigate those cases further
* Basic process modules support on AIX (but not i)
Not aware of a PASE compatible API, but this will work on AIX. Not
sure about .ModuleName versus .FileName, but it seems to fill it in...
The gensources.cs currently checked in to master doesn't fail on missing files by default because it didn't work at the time. This turns that behavior on. It is currently only in my other in-progress branch so I'm moving it here.
Fixes#9232
* Enable failing on missing files in gensources
* Copy over the missing file checks from genproj2
* Trim whitespace off file names from sources files
* Strip double slashes from paths to fix spurious csproj change
Previously we called it only if gdb was enabled, and we called it after
we invoked handlers asynchronously, in ways that could eat our session
state. By moving it higher up, we can increase the numbder environments in which
debugger crashes are logged, and log them even in the case when
telemetry dumping kills the runtime quickly.
* [runtime] MONO_API mono_assembly_get_object needs GC Unsafe
* [runtime] MONO_API mono_array_length needs GC Unsafe
* [runtime] Make MONO_API mono_reflection_load_from_full external only
Also mono_reflection_load_from ()
Also make them both transition to GC Unsafe
* [runtime] Make MONO_API mono_assembly_load_full external only
And make it transition to GC Unsafe
* [runtime] Make MONO_API mono_assembly_loaded external only
Runtime should use mono_assembly_loaded_full.
Make mono_assembly_load transition to GC Unsafe
* [runtime] MONO_API mono_assembly_open needs GC Unsafe
Also mono_assembly_open_full
* [runtime] MONO_API mono_check_corlib_version needs GC Unsafe
* [runtime] MONO_API mono_class_enum_basetype needs GC Unsafe
* [runtime] MONO_API mono_value_box needs GC Unsafe
* [runtime] Make mono_type_get_object external only
Runtime should use mono_type_get_object_checked or mono_type_get_object_handle
* [runtime] MONO_API mono_string_to_utf8 needs GC Unsafe
* [runtime] MONO_API mono_raise_exception needs GC Unsafe
* [runtime] Make mono_reflection_type_get_type external only
Also make it use GC Unsafe.
Runtime should use mono_reflection_type_get_handle
* [runtime] MONO_API mono_object_new needs GC Unsafe
* [runtime] MONO_API mono_domain_assembly_open needs GC Unsafe
* [runtime] MONO_API mono_method_get_object needs GC Unsafe
* [runtime] MONO_API mono_method_full_name needs GC Unsafe
* [runtime] MONO_API mono_method_signature needs GC Unsafe
* [runtime] MONO_API mono_thread_create needs GC Unsafe
* [runtime] MONO_API mono_field_get_type needs GC Unsafe
* [runtime] MONO_API mono_field_get_value needs GC Unsafe
* [runtime] MONO_API mono_field_set_value needs GC Unsafe
* [runtime] Mark mono_image_open_from_data_with_name external only
Runtime should use mono_image_open_from_data_internal
* [runtime] MONO_API mono_image_open_from_data_with_name needs GC Unsafe
* [runtime] MONO_API mono_field_static_set_value needs GC Unsafe
* [runtime] MONO_API mono_property_set_value needs GC Unsafe
* [runtime] Make MONO_API mono_assembly_load_with_partial_name external only
Runtime should use mono_assembly_load_with_partial_name_internal.
Make mono_assembly_load_with_partial_name transition to GC Unsafe
* [profiler] Log whenever the profiler library fails to load
* [test] Fixup return type of mono_gc_toggleref_add
* [sgen] Don't pin obj in test_toggleref_callback under coop
Don't call mono_field_get_value which under coop will perform a thread state transition to GC Unsafe and that may include copying the stack data which will pin the toggle object and subsequently make the toggleref test fail. Call mono_field_get_value_internal which assumes we're already in GC Unsafe mode.
Uses mono LLVM master branch, build using cmake and VisualStudio 2015/2017.
Commit adds support for AOT/Full AOT LLVM codegen for Windows x64 Visual Studio
build mono runtime. Normal configure/make using cygwin won’t support LLVM and will
trigger an error if configured.
In order to build using LLVM first mono LLVM master branch must be build using
static linked LLVM configuration (dynamic loading can be added later),
NOTE mono LLVM build needs to include the following commit,
https://github.com/mono/llvm/commit/9b92b4b87607e137266f84dc307181b8842fe54a
in order to successfully build on Windows x64.
Build mono LLVM branch using the following cmake configuration:
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ZLIB=OFF
-DLLVM_TARGETS_TO_BUILD="X86"
-DCMAKE_CROSSCOMPILING=False
-DCMAKE_SYSTEM_NAME=Windows
Use cmake with -G "Visual Studio 14 2015 Win64" to generate VS 2015 x64
targets. NOTE, if mono runtime is build using VS 2017, then LLVM should
be build using the same VS version using -G "Visual Studio 15 2017 Win64"
To enable LLVM build in mono.sln, set MONO_ENABLE_LLVM to “true” and make
sure MONO_LLVM_INSTALL_DIR_PREFIX points to the install directory used in
LLVM build above, default msvc/dist/llvm. Above LLVM properties can also
be set if build using msbuild.
A sample LLVM configure script has been included in msvc/llvm-cmake-config.bat.
* [typesafe coop] Go through generated token-pasted helpers
instead of casting function pointers. This should be safer and
not trigger quashed gcc warning and I had hoped it would
work with WebAssembly, but seemingly not.
Add MONO_TYPEOF_CAST to avoid repitition.
Here we have a structured log and a richer "model" of states.
This serves to be a 10-foot view of the debugger. The debugger
has a lot of layers of abstractions, and lots of intermingled
bookkeeping.
This debugger log serves to be a summary of the state of the debugger
as a whole, and our ringbuffer of recent events helps put the debugger
state into context.
It also allows us to easily identify, for instance when we resume
a new thread versus a suspended thread. We can see single-stepping
through the breakpoints added, removed, and hit. Lastly, we have a view
of how commands and events are totally ordered over the TCP socket,
helping the server to understand what the client has seen and in which
order.
Previously one had to include the proper types for this header in
the file including this header, before this header is included. Rather
than put irrelevant includes in other files, I'm adding includes here so
this file brings in its own dependencies.
* Make coop handles typesafe.
Type-safe handles are a struct with a pointer to pointer.
The only operations allowed on them are the functions/macros in handle.h, and assignment
from same handle type to same handle type (which cannot be prohibited in C, but is ok here anyway.)
Type-unsafe handles are a pointer to a struct with a pointer.
This is a leakier abstraction and besides the type-safe operations, also allows:
1. compared to NULL, instead of only MONO_HANDLE_IS_NULL
2. assigned from NULL, instead of only a handle
3. MONO_HANDLE_NEW (T) from anything, instead of only a T*
4. MONO_HANDLE_CAST from anything, instead of only another handle type
5. assigned from any void*, at least in C
6. Cast from any handle type to any handle type, without using MONO_HANDLE_CAST.
7. Cast from any handle type to any pointer type and vice versa, such as incorrect unboxing.
8. mono_object_class (handle), instead of mono_handle_class.
None of those operations were likely intended and some are crashing sort of bugs, esp.
the last two. See https://github.com/mono/mono/pull/9188 for the last two. The rest all occur also but are not necessarily harmful. Raw(NULL_HANDLE) and IsNull(NULL_HANDLE) were both access violations, so NULL just as well. MONO_HANDLE_CAST is still pretty liberal in what it allows.
NULL_HANDLE has been brought into question and this will allow grepping for it instead of the plainer NULL (i.e. returning them as handles).
The interaction of these handles with JITed code depends on the ABI to pass/return a struct
with a pointer the same as a pointer. Marshalling assumes this.
There might be some OS/CPU ABIs that do not support this.
CI suggests it is broadly but not 100% viable (disabled for non-Mac non-Windows x86, but enabled for arm, arm64, amd64, Mac/x86, Windows/x86).
* Typesafe handles enforcement brings with it a little more pointer enforcement, mostly around const and volatile. Repair a bit, and disable temporary for Windows.
* Fix MONO_HANDLE_IS_NULL (NULL_HANDLE) to not null dereference.
* Fix MONO_HANDLE_RAW(NULL_HANDLE) to not null dereference.
This depends on a gcc/clang extension, and a Visual C++ (C) quirk.
Otherwise we have to chose double evaluation, or C++, or assignment or cast from void* to temporary (possibly passing more types to more macros).
Another choice is a runtime assert, and double evaluation or not.
Asserts seen can be covered up by first checking MONO_HANDLE_IS_NULL, which will not null dereference nor assert.
Prior to making RAW(NULL) not null derefence, fixing code of the form:
```gboolean is_null_handle = handle && MONO_HANDLE_IS_NULL(handle)```
to be
```gboolean is_null_handle = MONO_HANDLE_IS_NULL(handle)```
while working on this change led to failures.
* Add gcc -Werror=incompatible-pointer-types to catch some handle type mismatches.
This has slight collateral damage on other code, mostly around const and volatile, mostly in Android-specific code. Disabled for Windows/gcc at first.
* Change mono_icall_handle_new_interior to return gpointer instead of MonoObjectHandle. It isn't returning a handle and making the non-handle typesafe is unnecessary/incorrect.
Likewise change mono_handle_new_interior to return gpointer instead of MonoRawHandle (same thing).
gpointer* is more correct, gpointer is more opaque; unclear which is preferred here.
gpointer makes this a smaller semantic change, as MonoRawHandle was already equivalent, just a rename.
* Move NULL_HANDLE, NULL_HANDLE_STRING, NULL_HANDLE_ARRAY so they are near the comment that refers to all of them.
* Remove mono_handle_new_full prototype, the function does not exist.
* Remove unnecessary casts.
* Remove unused MONO_HANDLE_INIT.
* Add an assert to handle_assign.
* A refinement of this change should enable WebAssembly and skirt underlying safety less. WebAssembly does not allow the function pointer casts used here.
Try to catch situations leading to a segv in mono_domain_assembly_search by
checking that we never put NULL into domain_assemblies and that callers of
mono_assembly_names_equal_flags never pass NULL args to it.
* [coop] Use coop mutex
ldstr_section can be taken during jit compilation.
* [runtime] Switch to non recursive mutex
ldstr_section only guards hashtable accesses.
* Import System.Security.Cryptography.Pkcs from CoreFX.
* Change 'as' operator to a cast.
* Add missing EnvelopedCms overloads.
* Include CMS signing classes in all builds.
* [csproj] Update project files
* Add missing DSACertificateExtensions class.
* Update references.
* Rename EnvelopedCms.Overloads.cs to EnvelopedCms.cs.
* Enable some of the System.Security.Cryptography.Pkcs xunit tests.
* Update references.
* Bump API snapshot submodule
* Disable xunit tests that may depend on Windows PAL.
Contributes to https://github.com/mono/mono/issues/7589
One unit test is removed as part of the commit because it is not consistent with documentation and CoreFX behaviour on non-Windows platforms (https://github.com/dotnet/corefx/issues/30416).
The main goal of this patch is to actually get meaningful error messages when constructing X509Certificate2 from a byte array. Previously PKCS#12/PFX certificate import could fail due to unimplemented features (such as ECDsa support) or bugs. The certificate import would then be retried as PKCS#7 and the original error message was lost.
* Fix some handle type violations.
* MONO_HANDLE_CAST (MonoArray, NULL_HANDLE)
is fragile and deprecated except in optimized hot paths,
prefer NEW instead. NULL_HANDLE is const and cannot be assigned to,
NEW is not const and can be assigned to. It takes extra validation
to insure NULL_HANDLE is correct, and it is usually not worthwhile.
Brings in https://github.com/mono/bockbuild/pull/67.
This fixes the msbuild build problem where it'd crash with `error MSB4242: The SDK resolver "NuGetSdkResolver" failed to run. Unexpected failure reading NuGet.Config. Path: '@/external/bockbuild/builds/msbuild-15/artifacts/toolset/restore.proj/$HOME/.config/NuGet/NuGet.Config'.`.
The reason is that bockbuild exported the `XDG_CONFIG_HOME` environment variable with the value `$HOME/.config`. The problem is that the `$HOME` in there is never expanded so it just stays as the literal value.
`XDG_CONFIG_HOME` is later used by e.g. `Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)` which is what nuget uses to construct the path to NuGet.config - hence why we end up with the weird path.
We now just expand the variables in bockbuild before we pass them on.
Fixes https://github.com/mono/mono/issues/9179
(cherry-picked from cb54c26f6c)
Threads which do things with signals and locks may end up unresponsive
to our signals. I cannot get threads that crash in a lock to respond to
SIGTERM on Darwin even if I explicitly unmask SIGTERM on those threads.
In order to defensively program against platform bugs around signals and
stubborn threads, we need to be able to abandon these threads and
continue, dumping other threads.
[tests] reduce IO load in process-stress-3
The spawned process by the test iterates through the whole mono repo,
including submodules. On a loaded machine with a already slow I/O
device, 10 seconds could be a tight time budget. Instead of increasing
the timeout, let's try to reduce the generated output.
Fixes https://github.com/mono/mono/issues/6947 hopefully.
Ubuntu Linux (possibly others too, but only Ubuntu is tested thus the
limitation) don't need to build or use `mxe`, they instead use mingw packaged
for the distribution, thus making the build faster.
This commit detects the Linux flavor in use and, if it's Ubuntu, configures the
build so that system mingw is used instead of mxe.
Followup for 9ad5255338
Note that on win32 we already did the right thing because of nested
conditionals in mono_image_open_a_lot, but on non-win32 we need the extra
check.
[mono/mini/helpers.c:195]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[mono/mini/helpers.c:197]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
* [mcs] Rename darwin paltform to macos
Darwin is common to both macOS and iOS/tvOS/watchOS, while we use the darwin platform only for macOS.
* [mcs] Add Unix platform for other Unixes than Linux
* [mcs] Remove PLATFORMS from xammac_net_4_5 since it only make sense on macos
* [bcl] Bump corlib version
* [csproj] Update project files
Android NDK supports cmake in addition to the older make-based ndk-build as the
build system and Xamarin.Android is in the process of switching the build of its
native bits to cmake. The reason for this switch is that certain parts of
Xamarin.Android (libmonodroid) are built for both the host system and
the Android target. The host system build currently uses hand-crafted code
directly in .csproj to build the native bits while the Android build uses
ndk-build. This results in duplication of code, compiler parameters are
specified in two locations - it is easy to introduce incompatibilities, bug
fixes may be applied only in one scenario etc.
Using cmake allows us to use a single build "script" for all the targets, thus
making the build more reliable. Android SDK has a cmake package which contains
full support for NDK builds and allows us to easily use cmake across all the
supported platforms without having to install cmake on the host system.
This commit adds the cmake package to the Android SDK provisiong process and,
alas, at the same time adds a workaround to properly unpack the package. Unlike
other Android SDK packages, cmake doesn't unpack to a single subdirectory of the
zip root, instead all its files and directories are placed directly in the zip
root. This requires yet another workaround to install the package properly.
[segfault] hard crash if it is not a NRE
that is, if a `ji` is available, but the offset is too large to be a
plausible implicit null pointer.
The "upper bound" must be higher, but I don't know a good value. Any good suggestions other than "increase the value until all tests are passing"?
* [mini] Change region formation pivot from BB to EH clause.
The original BB region computation would loop all BBs and search which EH clause each of them.
EH search is implemented as a linear search, meaning performance was count(BB) * count(clauses).
Since each clause generates at least one BB, it's quadratic on the number of clauses.
Degenerate methods, with tens of thousands of EH clauses, would lead to minutes of JIT time.
New code loops over the clauses and mark all BBs covered by each of them. Given EH ranges are a much
smaller subset of all BBs, this performs significantly better. It remains possible to construct methods
that leads to degenerate compilation times, but it's less likely now.
* [mini] Bound the size of a linked list during liveness.
The `visited` linked list can grown to tens of thousands of entries with some degenerate methods.
This change uses a stack allocated array and switches to a hashtable on overflow.
* [mini] Change printf to g_print
* [mini][amd64] Limit more precise branch target optimization based on number of basic blocks.
On amd64 we update branch target data before each BB is emitted. This has quadratic behavior on number of basic blocks
and can lead to excessive compilation times in degenerate cases.
Limit the increased precision to methods with less than 800 basic blocks.
Reduces compilation time of #7809 by 88% (from 44s to 5s).
When creating dynamic methods, we put those in a queue so they can be collected later via `mono_jit_free_method ()`. the interpreter part was assuming, as soon as we allocate a dynamic method, it will be executed eventually and therefore an InterpMethod must exist in `info.interp_code_hash`, but this isn't necessarily the case.
Fixes https://github.com/mono/mono/issues/9109
We can't raise event before that as the profiler depends on too much runtime
infrastructure at this point for it to reliably work.
For example, we need the threading infrastructure to be init'd so we can access the
thread-local profiler state to store events there.
issue detected by cppcheck
[mono/metadata/threads.c:3993] -> [mono/metadata/threads.c:3991]:
(warning) Either the condition 'if(location&&location->source_file)'
is redundant or there is possible null pointer dereference: location.
condition is redundant indeed, it is nested in "if (location) {"
* [jit] Add some rules to the local propagation pass to transform iconst+sext+mul into mul_imm.
* [jit] Make OP_LDLEN more general by storing the offset of the array length field in it.
* [jit] Add span intrinsics.
* [jit] Avoid converting Span.get_Length () to OP_LDLEN, it doesn't help abcrem. Avoid asserts when running on portable spans.
* [jit] Convert Span.get_Length () to OP_LDLEN, only mark the loading of array lengths invariant.
* [uwp] UWP supports: ReplaceFile CopyFile LockFile UnlockFile GetDriveType GetComputerNameW
Some of these were already supported and identical code copied.
* Remove pre-Windows 2000 support -- use GetFileSizeEx instead of GetFileSize.
UWP does not support GetFileSize.
* Introduce fine-grained ifdefs.
This should make maintenance of Win32 subsets easier (see w32subset.h).
* Generally the code should be/stay in "classic.c" and the "uwp.c" files can/should go away. The uwp.c files were a medium-sized granularlity of reuse/replace, but the fine-grained ifdefs are better/smaller -- more code reuse.
Which involves:
`serialize_object`
`deserialize_object`
`mono_object_xdomain_representation`
and then the other users of `mono_object_xdomain_representation`:
`create_unhandled_exception_eventargs`
`call_unhandled_exception_delegate`
* [runtime] Add an 'interp_method' field to MonoDelegate.
* [runtime] Add a MONO_LD_DELEGATE_PTR jit opcode which is used to load the method ptr from a delegate, so the JIT and interpreter could have a different implementation.
* [runtime] Store the interpreter method invoked by the delegate in MonoDelegate.interp_method, make MonoDelegate.method_ptr always point to a JIT callable entry point.
* [interp] Avoid sharing pinvoke and non-pinvoke signatures in mini_get_interp_in_wrapper ().
* [interp] Fix interp_get_remoting_invoke (), it receives a interp entry trampoline as well.
* [interp] Store remoting invokes into interp_method in delegates.
* [interp] Handle compilation failures in do_jit_icall (). Handle calls to delegates created in JITted code.
* [jit] Add a 'aot-skip=' MONO_DEBUG option to skip loading the Nth aot loadable method, useful for forcing mixed mode transitions during testing.
* [jit] Add tests for fullaot+interp mode
The tests work by injecting interp-jit transitions in varying locations controlled by the MONO_DEBUG=aot-skip= option.
* [interp] Avoid races when caching method pointers. Fix wasm support.
* Revert "[interp] Avoid races when caching method pointers. Fix wasm support."
This reverts commit 0f78c230b5102d625c300a4e1c6eaf97ad055dd5.
* [interp] stub native-to-managed on platforms where it is not working
* [ci] add fullaotmixed-regression step
Currently if we change for example `corlib.dll.sources` and then execute `make` - the `make` won't rebuild the lib, because it depends only on `net_4_x_corlib.dll.sources` and doesn't depend on all `#include` inside it.
As a temporarily solution we can depend on all *.sources files in the directory so a change in any of them will trigger rebuild. Unfortunately changes in un-related profiles will also trigger the rebuild but it's better than nothing for now I guess. For better experience we should fetch all #includes recursively for the current profile
The only reason for the restriction was that handle_alloc previously would not handle generic instances.
This speeded up the following microbenchmark by 19x (3.38s x 0.17s):
```
class Driver {
static T Identity<T> (T t) {
return t;
}
[MethodImpl(MethodImplOptions.NoInlining)]
static Func<T,T> MakeDelegate<T> () {
return new Func<T, T> (Identity);
}
static void Main () {
object o = new object ();
for (int i = 0; i < 400 * 1000; ++i) {
MakeDelegate<object>()(o);
}
}
}
```
* [Coop] Cleanup ahead of converting ves_icall_System_Threading_Thread_GetAbortExceptionState.
- serialize_object and deserialize_object are almost identical and
can be implemented on top of the same function.
- Error propagation was a little wierd and had FIXME comments.
It involved MonoError, MonoException, and gboolean *failed, and
some conversions. Converge on mostly MonoError, with fewer conversions,
albeit still sometimes holding a MonoException.
* Move error parameter to last.
Move static locals to global -- more easily seen in debugger.
Remove errant exclamation point.
* [jit] Make the interp_in wrappers work better with byref arguments.
* [runtime] Move some EH tests to exceptions.cs.
* [interp] Fix some problems in the interp entry/exit code in mixed mode.
* [jit] Avoid code patching from gshared code when the callee is an interp entry trampoline.
* [aot] Map byref return values to int&.
* [interp] Handle r4 return values in do_jit_call ().
This lets the linker catch any missing symbols, and fixes a problem
I had building AIX with CoreFX PAL. Fixes#8979, though there may
be more cases like this.
dotnet/corefx#30012 is blocking on this.
Since GitHub pages rolled out HTTPS support, links to `www.mono-project.com` can now be `https://` :) This also removes a `www.` 301 users currently hits.
In the case of the FSEvent FileSystemWatcher, the CFRunLoop event loop thread has already an interrupt handler installed in the icall, and mono_monitor_try_enter may try to install one as well which is not supported. So we create separate event tasks before we use the Operation() method.
We'd get the following warning during the build:
```
'/Users/alexander/dev/mono/mcs/class/System.Data.Services.Client/ONO_PATH' in MONO_PATH doesn't exist or has wrong permissions.
```
The reason is that we didn't escape the $ symbol in the resgen template
so the embedded $$MONO_PATH in the RESGEN variable ended up being mangled.
I'm kinda surprised this worked at all for so many years ¯\_(ツ)_/¯
* [loader] Make mono_assembly_names_equal_flags visible
Previously was static assembly_names_equal_flags in assembly.c
Add "mono" prefix to all the names
* [loader] Ignore version if assembly name isn't a strong name
When checking if a loaded assembly satisfies a request for a given assembly
name, don't compare versions if requested name doesn't include a public key
token.
Fixes https://github.com/mono/mono/issues/8820
* [loader] Add MONO_ANAME_EQ_IGNORE_CASE flag
In some circumstances we may need to compare one MonoAssemblyName to another
ignore case differences in simple names (ie "Asm1" vs "asm1" should be
considered equal)
* [tests] Regression test for simple name assembly preloading
Regression test for https://github.com/mono/mono/issues/8820
If one assembly references another that has a simple name (no public key), then
the requested version and the actual version don't need to match.
Also - the simple names are compared case-insensitively.
* [loader] When looking for already loaded assemblies, ignore case differences
When we're looking for a loaded assembly by simple name, ignore case differences.
* [debugger tests] use runtime flags for debugee
* [debugger] handle managed-to-native frames
fixes DebuggerTests.InspectThreadSuspenedOnWaitOne on the interpreter
* [interp] set SP in monoctx that is passed to exception handling
fixes DebuggerTests.ExceptionFilter on the interpreter
* [debugger] fix debugger_invoke frame in interp case
fixes DebuggerTests.BreakpointDuringInvoke on the interpreter
Currently the list elements are allocated in the root domain, while the data can be allocated in other domains. We need to clear the reference when removing the list element so we are not left with hidden cross domain refs.
Ideally we should have per domain lists, so we also would just let the list and elements die, without having to iterate through them at domain unload time.
* [mono-threads] Introduce mono_thread_info_get/set_tools_data so they can store data sanely.
The tools_data is a helper to bind tls data lifecycle to MonoThreadInfo.
This is needed to make it sane to deal with posix TLS destructors.
* [profiler] Switch tls storage to use mono_thread_info_get/set_tools_data. Fixes#7683
External threads are detached using TLS destructors and this leads to non-determinism around to cleanup ordering of keys.
This causes the profiler to see the profiler tls key null'd even though it was not detached yet.
* [profiler] Since we depend on thread_info to be attached before tls works, do so for the helper threads.
We can't just move the mono_thread_attach call earlier as it leads to all sorts of weird crashes (as it generates events and we won't be attached).
This is the second and final part to bring Client Certificate support.
It needs to be landed on top of #8753 and #8756.
* `Mono.Security.Interface.IMonoSslStream`: Add `CanRenegotiate` and `RenegotiateAsync()`.
* `Mono.Security.Interface.MonoTlsSettings`: Add `DisallowUnauthenticatedCertificateRequest`.
* `AppleTlsContext`: fully support renegotiation.
- we may now receive `SslStatus.PeerAuthCompleted` and `SslStatus.PeerClientCertRequested`
during `Read()`. It should in theory not happen during `Write()`, but I added it there
as well just to be on the safe side.
- `SetSessionOption()` may only be called before the initial handshake.
* `MobileAuthenticatedStream`: this is the major part of the work and the most complex one.
- added a new `Operation` enum to keep track of what is going on and detect invalid state.
- a renegotion may only be triggered while we're idle - that is no handshake, read or write
operation is currently active.
- `InternalWrite()` may now be called from `SSLRead()`, the new `Operation` tells us what
is currently happening.
- `ProcessHandshake()` now takes a `bool renegotiate` argument.
- added sanity checks to `ProcessRead()` and `ProcessWrite()`.
* `MobileTlsContext.SelectClientCertificate()`: check for
`MonoTlsSettings.DisallowUnauthenticatedCertificateRequest`
* `MonoTlsProviderFactory.InternalVersion`: bump the internal version number.
Tests have already been added to `web-tests/master`, they will auto-enable themselves when
using a Mono runtime that contains this code.
* Remove two methods with incorrect arguments
These two methods on `IPersonalizable` don't match the .NET 4.7.1 API.
In both cases the methods should take one `PersonalizableDictionary`
argument, but _that_ type does not exist.
Since nothing in the current class library code is using these methods,
just remove them.
* Bump API snapshot submodule
This is the first of two Pull Requests to implement Client Certificates :-)
Part One binds the new native APIs that will be used internally, finishes
the certificate selection callbacks, but without the more riskly changes
to the underlying handshake and I/O layer.
Part Two will bring support for TLS Renegotiation - and due to the required
changes in the underlying handshake, it is the more risky one.
* `Mono.Security.Interface.MonoTlsSettings`: Add `ClientCertificateIssuers`.
* `MobileTlsContext`:
- fully implement `SelectClientCertificate()`; the `acceptableIssuers` parameter
is now actually set and we also have a reasonable default selection.
- add `CanRenegotiate` and `RenegotiateAsync()` - these are not hooked up yet.
* `AppleTlsContext`:
- we will only ever call `RequirePeerTrust()` once per session, so we can
also remove it alltogether and just use `EvaluatePeerTrust()` instead.
- use proper exceptions for `SslStatus.PeerNoRenegotiation` and `PeerUnexpectedMsg`.
- don't call `SetClientSideAuthenticate()` on the client side.
- bind and hook up `SSLAddDistinguishedName()` and `SSLCopyDistinguishedNames()`.
- bind `SSLReHandshake()`.
* `MobileAuthenticatedStream`: minor cleanups; there will be more uses of the new
`GetInvalidNestedCallException()` helper class once Part Two lands.
* Enable some more constants in `SecureTransport.cs`.
* Add new `MonoBtlsError.GetErrorReason()` and `mono_btls_error_get_reason()`
implementation, only supporting `SSL_R_NO_RENEGOTIATION` at the moment.
* Add new native `mono_btls_ssl_ctx_set_client_ca_list()` function and managed
`MonoBtlsSslCtx.SetClientCertificateIssuers()`; hooked up via
`MonoTlsSettings.ClientCertificateIssuers`.
* According to a comment in the header file, `SSL_get_client_CA_list()` may only
be called during the selection callback or while the handshake is paused.
To respect this restriction, we now call it during the client certificate
selection callback and pass the list from native to managed.
- changed signature of `MonoBtlsSelectFunc` from
`int (* MonoBtlsSelectFunc) (void *instance)` to
`int (* MonoBtlsSelectFunc) (void *instance, int countIssuers, const int *sizes, void **issuerData)`.
- the managed counter-part is in `MonoBtlsSslCtx.NativeSelectFunc` / `NativeSelectCallback`.
* MonoBtlsContext:
- use the new `MonoBtlsError.GetErrorReason()` to throw a `TlsException` with
`AlertDescription.NoRenegotiation` that can be checked for by user code.
- `SelectCallback()` now has a `string[] acceptableIssuers` argument; pass it
to `SelectClientCertificate()`.
- the native backend does not support TLS Renegotiation, so `CanRenegotiate`
always returns false.
Implements #7075
Rather than reaching into the library internals and potentially
violating its invariants, assemble a cipher string and call the
supported public API. (There's no need to touch the version-specific
cipher lists because mono/btls never configures them.) The existing code
also had a bug; it incorrectly assumed OPENSSL_malloc returned a
zero-initialized buffer for in_group_flags. (Though Mono doesn't set
SSL_OP_CIPHER_SERVER_PREFERENCE, so I suspect this was a no-op.)
Additionally, this should hopefully ease updating to a less outdated
version of BoringSSL in the future.
Note I've changed the return value of this function from returning the
number of ciphers to merely returning 0/1 for whether the operation
succeeded. The only caller of this function, MonoBtlsSslCtx.SetCiphers,
only cares about success vs. failure.
* [jit] Move the handling of special methods like pinvoke etc. into mini-runtime.c, since they are not handled by the JIT.
* [jit] Add a --full-aot-interp command line argument which is the same as --full-aot with a fallback to the interpreter.
* [jit] Implement fallback to the interpreter in full-aot+interp mode.
* [jit] Add a 'methods using the interpreter' stat.
The old thunk machinery was sort of working on 64bit (before
f4bd084438 ), but it relies on having on
the memory layout of allocated chunks for code. Either the property got
lost due to some refactoring, or it was never true on ppc64. Anyway,
this patch switches the implementation to something we do on arm32 too:
If we potentially need some thunks for the emitted code, we reserve some
space for it at the end of the code buffer. That wastes a bit more
memory, because we often don't need it, but at least it works reliable.
Untested on 32bit systems.
The "problematic images" are Windows-specific assemblies that are often
included with applications that do not work on Mono, but for which Mono has its
own implementation.
Previously (9ec8ec5389) we changed mono to deny
loading problematic images using Assembly.Load or when one assembly references
another and we find a problematic image using the usual assembly search.
For Assembly.LoadFrom, we used to emit a warning and then load the assembly anyway.
In this commit, we change the behavior: If Assembly.LoadFrom tries to open a
problematic image, we will instead probe for an assembly of that name in the
default context. That should eventually end up opening Mono's version of that
assembly.
Example:
Suppose a problematic System.Runtime.InteropServices.RuntimeInformation.dll
is in the application bin path: /home/user/myapp/bin
1. User code does (for whatever reason)
Assembly.LoadFrom ("/home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll")
2. We find the image and try to open it; add it to the images absfpath to
image hash; note that there are no binding redirects; but that it is a
problematic image. We extract the assembly
name ("System.Runtime.InteropServices.RuntimeInformation", version x.y.z.w
and public key token 123456789a) from the problematic image.
3. We probe for "System.Runtime.InteropServices.RuntimeInformation version
x.y.z.w public key token 123456789a" in the default context.
4. We find
/home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll in
the application bin path; we try to open it, we see it's already in the
images hash, but it's a problematic image, and we're not in a loadfrom
context (we re-probed with default!) so we keep probing
5. We find
<prefix>/lib/mono/4.5/Facaded/System.Runtime.InteropServices.RuntimeInformation.dll,
it's not a problematic image, so we open that and return it to (3)
6. We return to (2) and close the problematic image and return the good one
instead.
7. Assembly.LoadFrom returns with the good image.
Fixes https://github.com/mono/mono/issues/8726
When we switched to the new version of Monitor.Enter, we didn't expand the try block to include the call. This led to unreleased locks when we acquired the lock but were aborted shortly afterwards.
This brings the internal `MailAddressParser` class and switches `MailAddress` and `MailAddressCollection` to the CoreFX version.
The tests have been updated to reflect the CoreFX behavior, which is more strict about rejecting invalid addresses.
When PropertyGrid contains more than one propertyTab it crashes whith NullReferenceException. And when clicking on propertyTab toolstripbutton it didn't switch to this tab.
* [jit] Unify the way the results of inlined calls are pushed on the stack.
* [jit] Allow class inits during inlining if the class has no cctor.
* [bcl] Mark EqualityComparer<T>.get_Default () with MethodImplOptions.AggressiveInlining, its used in inner loops in the corefx code.
* [jit] Implement devirtualization of some EqualityComparer<T>.Equals calls, the corefx code assumes this.
* [jit] Rename has_array_access to needs_decompose to better reflect its meaning.
To make sure that System.Reflection.Emit types in the class libraries
are properly removed by the linker, mark them with the "sre" feature in
the embedded linker descriptor file for mscorlib.
It contains this fragment:
```
<TargetFrameworkFallbackSearchPaths Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworkFallbackSearchPaths);/Library/Frameworks/Mono.framework/External/xbuild-frameworks</TargetFrameworkFallbackSearchPaths>
```
This PR introduces a new tool, gensources.cs, which replaces gensources.sh. It is able to parse the whole set of .sources files for a library in one go so that genproj can use that information to encode all our platform and profile specific files into one csproj file.
For now this PR just introduces it and switches libraries to using it instead of gensources.sh.
* Fix assert to print the error, and not sometimes itself crash. It was evaluating varargs twice.
* Fix all the warnings in the eglib tests. Leave them not building for now.
* [jit] Decompose some CEE_BOX opcodes later to allow more optimizations.
Optimize a code sequence emitted for Enum.HasFlag () by newer csc versions.
Also mark the temporary bblocks used by decompose_vtypes () as out-of-line if
the bblock under processing is out-of-line. Mark the domainvar as volatile to avoid
optimizing it away since references to it can now be generated later from the
decomposition of OP_BOX.
* [jit] Check that the enum types are the same.
* [jit] Fix support for generic enums.
* [jit] Disable the optimization with 64 bit enums on 32 bit platforms.
* Use size_t for gsize if it matches, else C99 uintptr_t.
Using size_t provides for an exact match with functions like malloc and pthread_attr_getstack, no warnings.
* GINT_TO_POINTER and co. need no autoconf, beyond chosing gsize, gssize.
* Use autoconf to find size_t among unsigned int, long, long long, __int64 for printf purposes.
Avoid 18+ year old C99 print("zu") dependency but still less likely to warn than the previous approach which only looked for matching size, not matching type.
* mini-ppc-os.h doesn't exist. If the OS lacks a define,
give an error instead of a broken include.
* Remove redundant Mac OS case.
* Move AIX define for sigaction above cross-compile case,
so it won't get lost in the noise there.
* [aot] Fix encoding/decoding of types with custom modifiers.
Fixes https://github.com/mono/mono/issues/8701.
* [aot] Add a test, disabling for now because it depends on c# 7.2.
* [aot] Bump AOT file format version.
* [aot] Only disable the test with mcs.
* [aot] Fix compilation of test.
* [sre] ParameterBuilder.SetConstant should work with Nullable<T>
Rewrite ParameterBuilder.SetConstant like CoreCLR
Same logic as TypeBuidler.SetConstantValue from coreclr at
src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
The details are different because we don't have CorElementType in corlib (so
use TypeCode), and we want to write to a var instead of directly invoking an icall.
Among other things, this enables ParameterBuilder to work with Nullable<T>.
If a parameter is of type Nullable<T> then pb.SetConstant (null) should work.
Also pb.SetConstant (value) should work when T is one of the supported
types (primitives, enum, datetime, etc).
Fixes https://github.com/mono/mono/issues/8597 and fixes https://github.com/mono/mono/issues/8504
* [test] ParameterBuilder.SetConstant with a nullable type
mkbundle works by generating a small C source file which, in addition to
embedded assemblies/configs/etc, contains a certain amount of code to initialize
the bundle, uncompress the assemblies and set runtime options (e.g. AOT mode).
This source code is generated based on a number of templates shipped as
resources inside `mkbundle.exe` and is not part of any public, maintained API.
The generated code contains calls to Mono runtime which work just fine when
mkbundle is used to generate a desktop application bundle with the default
template code. However, it breaks when a third party (like Xamarin.Android)
embeds Mono runtime and loads it dynamically **after** the application is
initialized. Such third parties must ensure that the bundle's startup code is
able to access the Mono runtime functions it needs by providing pointers to
them, loaded using e.g. the `dlsym` function.
However, as the Mono calls are hard-coded into the generated source code, the
third party needs to resort to search-and-replace methods (e.g. Xamarin.Android
https://github.com/xamarin/xamarin-android/blob/62e7792ca52949f2fa213330d292865ad78d2bfa/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs#L159-L166)
which are very fragile and prone to undetected breakage.
One example of such breakage which slipped under the radar is
https://github.com/xamarin/xamarin-android/issues/1651 which was caused by
addition of the `mono_jit_set_aot_mode` call to the generated code. The change
slipped under the radar and was discovered only after release.
This commit attempts to make the situation better by establishing a sort of a
code contract between "upstream" mkbundle and the third party. Since the
template code is not "public" (nor should it be), the third party cannot simply
include a header file with the API definitions. Instead, the idea here is to
ensure that all and any Mono runtime calls needed by the template code are
placed in a dispatch structure as pointers to functions and that the structure
needs to be initialized by the embedding party before calling the
`mono_mkbundle_init()` function. The third party is responsible for maintenance
of its own version of the dispatch structure as well as for its initialization
via the `initialize_mono_api` function in the template code. The generated code
must include the third party's version of the structure, in place of the default
one as shipped with `mkbundle`, and to make it possible this commit adds the
`--mono-api-struct-path` mkbundle parameter which points to a file that's
injected into the generated code, replacing the default structure definition.
Following that, the `mono_mkbundle_init()` code calls the `validate_api_struct`
function which checks each and every pointer in the structure for `null`,
exiting the application with error if any `null` pointer is encountered.
This (along with the `initialize_mono_api` function in the template) has the
additional effect that if the third party's structure is incompatible with the
default one a build error will happen, thus allowing early detection of obvious
incompatibilities/omissions.
As long as all the new Mono runtime calls are added to the structure, the above
should make it possible for issues like the one linked to above to not happen in
the future.
* `SslStream`: Reject attempts of setting conflicting callbacks using both the
Mono-specific `MonoTlsSettings` and the new `SslClientAuthenticationOptions` /
`SslServerAuthenticationOptions`.
This makes it consistent with CoreFx behavior where those callbacks may only be
specified in one of the possible places.
* `ChainValidationHelper` - this internal class has received a major overhaul and
lots of old and unused code removed.
All callbacks are not invoked with the correct `sender` parameter to make it
match the .NET / CoreFx behavior.
* `Mono.Security.Interface.CertificateValidationHelper`: remove unused internal code.
* Volatile static field accesses lack barriers.
This is a contributing factor to https://github.com/mono/mono/issues/8321.
finally_block_ending_in_dead_bb.exe does not poll the volatile field.
This is not the entire problem.
* [llvm] Notice the MONO_INST_VOLATILE flag on load/store, not just MONO_INST_FAULT.
This is related to https://github.com/mono/mono/issues/8321 finally_block_ending_in_dead_bb.exe
however emitting a barrier suffices to get LLVM to do the read.
* method_to_ir: Factor out operand decoding, including of constants.
* Cleanup unused file.
* Use MonoOpcodeEnum_Invalid instead of (MonoOpcodeEnum)-1.
* Move CHECK_STACK and CHECK_STACK_OVF mostly to central place, except variable
ones like call/ret/newobj.
* No _Static_assert on msvc.
* Remove some FIXMEs.
* Remove an inline.
* Less use of `tailcall_calli`, more use of `tailcall`, by assigning first to second.
And then eliminate `tailcall_testvalue`, as it just becomes `tailcall`.
* Merge the end, almost just the end, of CALLI with CALL/CALLVIRT.
Also merge the start, and with JMP, i.e. initializing shared variables.
This eliminates a bunch of shared code, without being too complicated (subjective)
and gives CALLI its missing sequence point.
goto here is disliked, maybe later a function.
* Change virtual_ from int to gboolean, assign it TRUE and FALSE instead of 0 and 1.
* Change guint32 call_opcode to MonoOpcodeEnum il_op.
* Replace *ip with il_op.
il_op is chosen over op, to disambiguate IL from IR.
And this is why C++ enums are not just ints:
enum Animal {dog, cat};
enum Color {red, blue};
Color color = dog; // valid C, invalid C++ (sometimes a warning in C)
Animal animal;
if (color == animal) ... // valid C, invalid C++ (sometimes a warning in C)
* add a FIXME
* Bring `SslClientAuthenticationOptions`, `SslServerAuthenticationOptions`
and `SslApplicationProtocol` from CoreFX.
* SslStream: Added new public overloads from CoreFX:
- All authentication methods have a new overload without the `SslProtocols` argument.
- New `AuthenticateAsClientAsync(SslClientAuthenticationOptions,CancellationToken)`.
- New `AuthenticateAsServerAsync(SslServerAuthenticationOptions,CancellationToken)`.
- We now use `SecurityProtocol.SystemDefaultSecurityProtocols` (which is zero) as
default value everywhere.
Everything below is internal:
* `Mono.Security.Interface`: Add internal `MonoServerCertificateSelectionCallback`,
`IMonoAuthenticationOptions`, `IMonoSslClientAuthenticationOptions` and
`IMonoSslServerAuthenticationOptions`.
* `Mono.Security.Interface.IMonoSslStream`: Add new overloads without the
`SslProtocols` argument.
* `Mono.Security.Interface.IMonoSslStream2`: New internal interface, extending
`IMonoSslStream` with the new internal APIs.
* `Mono.Net.Security`: New internal `MonoSslAuthenticationOptions`,
`MonoSslClientAuthenticationOptions` and `MonoSslServerAuthenticationOptions`
classes; these are just proxies for `SslClientAuthenticationOptions` and
`SslServerAuthenticationOptions` (which unfortunately don't share a common
base class).
* `Mono.Net.Security.MobileAuthenticatedStream`:
- Implement `IMonoSslStream2`.
- `ProcessAuthentication()` now takes `MonoSslAuthenticationOptions` instead
of the old argument list, added `CancellationToken`.
- All `IMonoSslStream` facing APIs now construct `MonoSslAuthenticationOptions`
to pass it to `ProcessAuthentication()`.
* `Mono.Net.Security`: `MobileTlsContext` and `MobileTlsStream` now use
`MonoSslAuthenticationOptions` to store all options.
Tests for the new APIs are in https://github.com/xamarin/web-tests/commit/fe347589326206f36d3cd42b59d305ff3c291857.
* Use MonoOpcodeEnum instead of int. Provide MonoOpcodeEnum_Invalid = -1.
* Fix and cleanup bounds checks.
Some were off by one, some could be clearer.
This pattern will go away anyway and is partly gone below.
* Prepare to fix incorrect read behind.
* Add test to hit assert in incorrect readbehind in ldvirtftn.
* Confuse the JIT (or runtime) into crashing.
* Fix parens.
* Move some macros from verify.c to verify-internals.h.
* Attempt to make IL readahead easier to understand, by having
less spread out instruction sizing and decoding.
This converts several readaheads but not all.
It is possible we should just convert to a large array of pointers,
and then do these optimizations.
This also fixes the incorrect readbehind.
* Disable new test. Fixing the readbehind fixes the assertion failure but still sigsegvs later in trampoline.
* More use of common code. More to do here.
Old gcc does not allow pragma diagnostic within function.
Fixes#8572
#if is a deliberate shorter form than #ifdef
- shorter
- allows for #define foo 0
- standardly undefined silently evaluates to 0
- potential for if instead of #if, though that does require #define foo 0, no
silent undefined => 0
* [jit] Fix a warning about disabling an unknown warning: trace.c:147:32: warning: unknown warning group '-Wframe-address', ignored [-Wunknown-warning-option]
* [jit] Fix a warning.
* [jit] Fix a warning.
Fix OSX x86 warnings.
In particular:
1) Be sure to pass a function all of its parameters, no more, no less.
You can't have a stack imbalance because parameters usually fit in registers,
and because calling conventions except for __stdcall are explicitly designed
to accomodate common programming mistakes, e.g. printf ("%d") and printf ("%d", 1, 2),
are well defined on all modern ABIs to never crash (except for the extreme
case of printf ("%d") where stack is near the top and it accesses invalid next page,
most unlikely).
2) size_t and gsize are not always the same type.
For example, one can be unsigned int and the other unsigned long (32bit).
Or unsigned long and unsigned long long (64bit).
3) gsize is not necessarily unsigned long, nor even the same size as it.
It could be any of:
unsigned int -- viable on all 32bit (Win32 and Unix32)
unsigned long -- viable on Win32 and all Unix (Unix32 and Unix64)
unsigned long long -- viable on Win64 and Unix64
unsigned __int64 -- viable on Win64, possibly same as unsigned long long
To printf a gsize in the "u" style (not the "x" nor "d" styled), G_GSIZE_FORMAT is provided.
(Fix for Win32 and Win64 forthcoming.)
We should strongly consider typedef size_t gsize but this a larger change.
4) Pop without push.
```
mono-publib.c:27:30: warning: incompatible function pointer types initializing 'gpointer (*)(gsize)' (aka 'void *(*)(unsigned int)') with an expression of type
'void *(*)(size_t)' (aka 'void *(*)(unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~
mono-publib.c:27:46: warning: incompatible function pointer types initializing 'gpointer (*)(gpointer, gsize)' (aka 'void *(*)(void *, unsigned int)') with an
expression of type 'void *(*)(void *, size_t)' (aka 'void *(*)(void *, unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~~
mono-publib.c:27:77: warning: incompsatible function pointer types initializing 'gpointer (*)(gsize, gsize)' (aka 'void *(*)(unsigned int, unsigned int)') with an
expression of type 'void *(*)(size_t, size_t)' (aka 'void *(*)(unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
^~~~~~~~~~~~~~
mono-time.c:204:1: warning: unused label 'exit' [-Wunused-label]
exit:
^~~~~
mono-threads-posix.c:92:43: warning: incompatible pointer types passing 'gsize *const' (aka 'unsigned int *const') to parameter of type 'size_t *'
(aka 'unsigned long *') [-Wincompatible-pointer-types]
res = pthread_attr_getstacksize (&attr, stack_size);
^~~~~~~~~~
/usr/include/pthread.h:250:85: note: passing argument to parameter here
int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict);
^
profiler.c:1062:57: warning: incompatible pointer types passing 'void (MonoProfiler *, MonoProfilerGCEvent, uint32_t)' (aka 'void (struct _MonoProfiler *,
MonoProfilerGCEvent, unsigned int)') to parameter of type 'MonoProfilerGCEvent2Callback' (aka 'void (*)(struct _MonoProfiler *, MonoProfilerGCEvent,
unsigned int, int)') [-Wincompatible-pointer-types]
mono_profiler_set_gc_event_callback (current->handle, gc_event_cb);
^~~~~~~~~~~
../../mono/metadata/profiler-events.h:85:1: note: passing argument to parameter 'cb' here
MONO_PROFILER_EVENT_3(gc_event, GCEvent2, MonoProfilerGCEvent, event, uint32_t, generation, mono_bool, is_serial)
^
profiler.c:908:2: note: expanded from macro 'MONO_PROFILER_EVENT_3'
_MONO_PROFILER_EVENT(name, type)
^
profiler.c:897:103: note: expanded from macro '_MONO_PROFILER_EVENT'
mono_profiler_set_ ## name ## _callback (MonoProfilerHandle handle, MonoProfiler ## type ## Callback cb) \
^
marshal.c:4770:72: warning: format specifies type 'unsigned long' but the argument has type 'gsize' (aka 'unsigned int') [-Wformat]
mono_error_set_out_of_memory (error, "Could not allocate %lu bytes", size);
~~~ ^~~~
%u
trace.c:146:32: warning: unknown warning group '-Wframe-address', ignored [-Wunknown-warning-option]
^
trace.c:148:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
^
```
* Cleanup IL operation size checks -- data driven.
* Removed duplicate declaration.
* Prepare to cleanup IL IP advancement. Do a self-checking run first, which found incorrect sizing of switch, dyncall, icall.
* Cleanup -- looks like macro debris.
* Cleanup IL IP advancement -- mostly data driven.
Occasionally due to https://github.com/Microsoft/visualfsharp/issues/4637
Mono will assert if it tries to load a PPDB file that has an incorrect number
of MethodDebugInformation rows:
* Assertion at metadata.c:1117, condition `idx < t->rows' not met
Instead of asserting, check that the method index is in bounds, and print a more informative error.
* Fix mono_icall and mono_dyn_call operands in opcode.def.
This might require cpan install XML::Parser, or disable
the generation of opcode.def in Makefile.am.
* Fix sizing of switch instructions: 5 + 4 * n, not 4 + 4 * n.
* Hi Mono Team,
This commit fixes an interesting bug that relates to the System.Net.Http nuget packages.
So the short story is that System.Net.Http can view the internals of this assembly because of InternalsVisibleTo and the HttpClient references System.Net.Logging's "On" _property_. The problem is that mono has implemented "On" as a _field_ . When the latest version of System.Net.Http.HttpClient tries to invoke a SyncAsync using Mono, you get a MissingMethodException because:
bool System.Net.Logging.get_On()
does not exist.
This commit is simple and only changes the signature of On to match that of the reference source (property instead of field). This will cause the Missing Method Exception not to be thrown.
* Fix indentation
* [System]: The big WebConnectionStream cleanup.
`WebResponseStream` has been broken down into smaller pieces and now
fully supports GZip / Deflate decompression.
The entire `contentLength`, `readBuffer` and `totalRead` logic has been
replaced by a nested layer of `WebReadStream` classes.
* `WebReadStream` is a new abstract base class.
* `BufferedReadStream` handles the situation where we have some buffered
data and an (optional) inner stream to read from.
* `ContentDecodeStream` takes care of GZip / Deflate decompression.
* `FixedSizeReadStream` handles the `contentLength` logic - ie. making sure
we are only reading up to `contentLength` bytes from the stream.
* The old `MonoChunkStream` has been renamed into `MonoChunkParser` (as it was
really just a parser and not a stream) and a new `MonoChunkStream` has been
added that's based on `WebReadStream`.
* Remove HttpWebRequestTest.TestLargeDataReading().
This test was using Reflection to poke around implementation internals.
* [csproj] Update project files
* Cosmetic cleanups.
* [btls] Do not give gcc flags to msvc.
* [btls] #include "btls-foo.h" instead of #include <btls-foo.h> to work
with existing build system, on Windows, with out-of-tree build.
Not sure which factor does not like <> but "" should be ok.
* [blts] MONO_API is not used consistently and therefore errors on Windows.
1. Make it be nothing.
1b. Use a .def file if there are actual exports.
Really, .def files are a good idea.
or
2. Use it consistently.
This does #1.
* Fix, classify, enable some CoreCLR tests.
* [Tailcall] Add partial calli support, so a test passes.
* Disable r4/r8 mismatch for all architectures, and one due to interface on ARM.
* [runtime] Transition to GC Unsafe in MONO_API functions
The idea is that on any external->runtime transition we want to ensure that we
switch to GC Unsafe mode (and back on return). This allows Mono embedders to
be oblivous about hybrid suspend - the runtime will run native embedder code in
GC Safe mode (and use preemptive suspend when necessary) and when they switch
back to the runtime we will switch to GC Unsafe mode (and use cooperative suspend).
Since this needs to be backported, we're going to make this osx-specific
for now, and then I'll backport this. This is fully working on linux,
including the android SDK at the time of this commit
The debug log fnptr is used with MonoStringHandle arguments since
cc7406b226
The corresponding functions and prototypes in mini/ have already been updated.
The renderer would stop at the first XML comment `-->` which means
the diff was cut off.
We can fix this by switching from storing the diff in an HTML div to
a script tag instead.
Fixes https://github.com/mono/mono/issues/8469
* [Tailcall] Implement x86 OP_TAILCALL_REG (https://github.com/mono/mono/issues/8582)
This should enable calli, which isn't just for cee_calli but also internal purposes.
* [Tailcall] Split x86_align_for_patch out of emit_call.
* [Tailcall] Align x86 tailcall patches, using x86_align_for_patch.
* [Tailcall] Allow x86 tailcall to be AOTed.
* [Tailcall] Make all the 'missed tailcall' cases more similar looking.
* [Tailcall] Fill in a little more tailcall support.
* [arm] emit_big_add: Handle degenerate imm == 0 and dreg == sreg.
* [arm] Split emit_call_reg into emit_call_reg and emit_jmp_reg (for reuse by tailcall).
* [arm] handle hardfloat in tailcall
* [arm] Fill in TAILCALL_MEMBASE and TAILCALL_REG (reuse emit_jmp_reg)
virtual calls should work now (but not interface)
* [Tailcall] Comment about tail.calli -- no this-type in signature, to check for byref valuetype.
(data is available on compile-time staci, and a proposal to check for ldloca/ldarg pending)
* Add some asserts.
* More detangling of vtable_arg/imt_arg (extra_arg) from tailcall_supported -- they must be set, or nullness predicted, earlier.
* [Tailcall] Capture inputs to is_supported_tailcall and assert they don't change.
* [Tailcall] ARM32 tailcall not supported if mono_class_is_interface (cmethod->klass).
* [System]: Free ServicePoints when they're no longer used.
* Cleanup.
* Don't crash when ServicePoint.CloseConnectionGroup() is called after the ServicePoint has been freed.
* Remove the CloseConnectionGroupConcurrency() test.
This test was for a regression in a piece of code that no longer exist
and the test is poorly designed as it depends on precise timings.
It also attempts to make a web request to a non-exisiting server and
just ignores the error - it is unclear whether that is intentional or not.
In CoreFX, `ServicePointManager.SecurityProtocol` defaults to
`SecurityProtocolType.SystemDefault` (which is zero).
We now allow this value to mean "whatever the system default is"
in both AppleTls and BTLS.
The default value of `ServicePointManager.SecurityProtocol` has also
been changed to be consistent with CoreFX.
* [jit x86] Move microoptimization down a level: x86_mov_reg_reg do nothing
if source == desta and size == 4 (size is always 4, except in amd64 reuse,
which was only used once, unnecessarily, remove it).
[jit x86] x86_mov_reg_reg size is always 4,
split into unused. x86_mov_reg_reg_size and specialized x86_mov_reg_reg
* Remove last parameter from x86_mov_reg_reg that is always 4.
It is not guaranteed to work if the valuetype was allocated in the same stackframe.
This was initially leading to crashes because when storing in **this**, we were storing as a valuetype instead of the pointer (**this** valuetype is passed as pointer). Even if we fixed this issue, the other problem still exists.
* [interp] Fix stobj
When writing to a stackval, we write at least 4 bytes. Because we were wrongly casting destination to stackval*, we could be clearing other fields for 1/2 byte stores.
* [interp] Use memmove also with stackval_to_data
As we do with stackval_from_data to prevent unaligned faults.
* [sdks] Use cmake to build llvm.
* [sdks] Build all targets for llvm32 as well, since android might not build llvm64.
* [sdks] Build the llvm windows builds using cmake as well.
* Address review comments.
* Switch to the release60 branch of LLVM as an experiment.
* [sdks] Bump LLVM.
* Bump LLVM.
* [sdks] Fix the build.
* [llvm] Emit default debugging info for all llvm builders otherwise methods without debug info like iterators will fail to compile.
* Fix a crash if ctx->minfo is not set.
* [sdks] Add an LLVM_BRANCH variable.
* [llvm] Emit default debugging info for all llvm builders otherwise methods without debug info like iterators will fail to compile.
* Fix a crash if ctx->minfo is not set.
* [Tailcall] Add tailcall-return-valuetype.il test.
This can be fixed easily -- when F1 calls F2 tailcalls F3.
F2 can pass F3 the temporary it got from F1 instead of having another temporary.
* [Tailcall] Add a test for passing large valuetypes by value.
This has problems on some ABIs but not others -- arm64 and Windows/amd64 fail.
Presumably the temporary is either within the paramete area
or is a local. The first works, the second does not.
* [Tailcall ppc/s390x] Update ppc/s390x to be more like x86/amd64/arm/arm64
i.e. matching return storage, and s390x matching struct-ness/size.
* [Tailcall] Let valuetypes be returned through tailcalls.
Specifically there was already this handling them:
mono_emit_call_args:
{
if (tailcall) {
if (mini_type_is_vtype (sig_ret)) {
call->vret_var = cfg->vret_addr;
//g_assert_not_reached ();
}
so when F1 calls F2 and F2 tailcalls F3, F3 will return the value
where F1 was expecting it. There is no extra code needed after F3
returns to copy it from F2's temporary.
* CallInst.tailcall field is read before written in amd64, and is also wrong for llvmonly.
Replace CallInst.tailcall with MONO_IS_TAILCALL_OPCODE when accuracy is desirable and works.
Add FIXME when inaccurate CallInst.tailcall is presently required.
Tailcall field should probably be replaced by FALSE, except CEE_JMP needs attention first.
(see https://github.com/mono/mono/pull/8571)
* [Tailcall arm64 amd64 s390x] Do not allow tailcall when passing large valuetypes.
For s390x this is being conservative and might not be needed.
For ppc it is already done. Needed?
arm32/x86 seem to pass struct inline so it works, nice.
Small structs are sometimes passed in registers as well.
* Disable tailcall/coreclr/JIT/opt/ETW/TailCallCases.exe.
It passes a struct by value and fails.
Typo: is_adressable_valuetype_load => is_addressable_valuetype_load
Don't mark large multi-called function inline.
Remove lines that are all whitespace (leave whitespace at ends of lines, there is a lot).
One case of spaces to tabs.
* [System] When doing process redirect, use Console.OutputEncoding instead of Console.Out.Encoding. Fixes#8417.
This change makes mono behave in the same way as dotnet, which uses Console.OutputEncoding instead of whatever Console.Out is.
* [System] Add regression test for #8417.
https://jenkins.mono-project.com/job/test-mono-pull-request-coop/3429/testReport/junit/(root)/BuildSubmissionTest/EndBuildWaitsForSubmissionCompletion/
```
BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion
Failing for the past 1 build (Since Unstable#3429 )
Took 36 sec.
add description
Stacktrace
MESSAGE:
#5
Expected: less than or equal to 00:00:02.5000000
But was: 00:00:09.1408213
+++++++++++++++++++
STACK TRACE:
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in /mnt/jenkins/workspace/test-mono-pull-request-coop/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
```
* [x86] Add support for tracing native-to-managed thiscall wrappers.
* [x86] Add support for native-to-managed thiscall wrappers.
* Add test for managed thiscall methods.
interp: If one of the operands is NaN, we have a default result: It is false (0)
when doing a compare (`ceq_r8`), but must be true (1) on `cne_r8`.
JIT: match behaviour what C# compiler would generate for float/double.
If you load Foo.dll and it happens to be version 2.0.0.0 and an app.config says
to redirect all versions of Foo.dll to version 2.0.0.0, we're there already -
don't close the image and probe again, that's silly.
When running with cookieless sessions, the file_path does not necessarily contain a leading '/' character which can lead to a Uri being constructed from something that looks like, "http://hostmyPage.aspx" which immediately fails and throw an exception stating that the hostname could not be parsed.
This is not trivial to fix -- either a range check
in the backend as to if the parameter is in the frame, or
value tracking in the frontend to see if it came from the frame.
mcs/tools/xbuild/data/deniedAssembliesList.txt:
- sorted by name and assembly version
- This file had one duplicate line
System.Text.Encoding.CodePages.dll,FD178CD4-EF4F-44D5-9C3F-812B1E25126B,4,0,2,0
mono/metadata/image.c:
- sorted by hashcode
- This had one duplicate line
IGNORED_ASSEMBLY (0xFA686A38, SYS_TEXT_ENC_CODEPAGES, "FD178CD4-EF4F-44D5-9C3F-812B1E25126B", "4.3.0 net46"),
commit 0b3cb8ac12cd839f8110775d4085e822e8af4d7b (HEAD -> master, origin/master, origin/HEAD)
Author: Zoltan Varga <[email protected]>
Date: Tue May 1 14:52:22 2018 -0400
Emit an LSDA for methods without landing pads too since we need the information about the 'this' register.
to fix generic-stack-traces2.2 -- so it gets a generic type definition
instead of a generid type instance, consistent with other execution modes.
See https://github.com/mono/mono/issues/8356
Backtrace can deadlock with threads that have been suspended while holding a
dynamic linker lock on Linux.
In checked build mode we collect backtraces on state machine transitions.
When we transition from BLOCKING->RUNNING under hybrid suspend the thread must
not block without polling. So we must not collect a backtrace on this
transition.
* Make autogen.sh output accurate -- print actual commands run.
* Have automake copy instead of symlink.
- This sounds analogous to libtool --copy that we do.
- It enables sharing a source tree more broadly.
For real example, Cygwin symlinks are not portable to Windows Subsystem For Linux, and probably vice versa.
For real example, Homebrew symlinks are not portable to Linux in Docker.
Downside I notice is that ls -l is less informative as to what is from git vs. a symlink to outside.
git clean -xxddff works just as well either way.
Hypothetical downside is that updating automake/autoconf doesn't upgrade the copies.
This has never mattered to me, but it might matter. It might be viewed as an advantage.
* [interp] Don't throw exceptions if we are in the middle of EH
Fixes delegate2.exe failures
* [interp] Don't set parent for invoke frame
This leads to unwinding same frame twice (once when going through the parent frame and, after we have no more parent frames, again through the pushed LMF). We should unwind past invoke only through LMF structures.
Fixes https://github.com/mono/mono/issues/8372
* [Coop] Introduce mono_gchandle_new_weakref_from_handle.
* Convert some old code to `mono_gchandle_new_weakref_from_handle`.
* [Coop] Convert ves_icall_Mono_Interop_ComInteropProxy_AddProxy to coop.
* [Coop] Convert ves_icall_Mono_Interop_ComInteropProxy_FindProxy to coop.
* Remove whitespace from whitespace-only line.
* [Coop] Remove 140+ uncooperative pointers due to calls to mono_set_pending_exception ().
Instead typically use:
ERROR_DECL (error); // sometimes already present
mono_error_set_xxx (error, ...);
mono_error_set_exception_pending ();
* Improve error in not supported.
* Allow null in set_error_messagev.
* () and (void) are not the same in C, use (void)
When/if these functions are revisited for further coop conversion, the first and last line might be deleted but the second is likely to survive asis.
Context: https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
When making the bumps to use the `mono-sdks` upstream in Xamarin.Android,
we were getting build errors such as:
usage: mktemp [-d] [-q] [-t prefix] [-u] template ... (TaskId:404)
The build bot is running Mavericks (10.9), so it must be an issue with older
versions of macOS.
When reading the Unix StackExchange post, it appears that the `-t` option
without a template should work more reliably on older macOS versions.
Then I tested it locally via `make -C sdks/builds provision-android`.
The command:
mktemp -d unzip_android_archive_XXXXXXXX
Resulted in paths such as:
creating: unzip_android_archive_Nt1XzgS5/android-P/
And sure enough, looking into `sdks/builds` it had created a directory in
the working directory, so it isn't using a path inside of `$TMPDIR`.
Changing the command to:
mktemp -d -t unzip_android_archive_XXXXXXXX
Resulted in paths such as:
creating: /var/folders/nx/rzr6lcqj6j3_vp7vtp28v2cw0000gn/T/unzip_android_archive_W247QkyW/android-P/
The StackExchange post mentions `-t` is a "prefix" that gets expanded to
`$TMPDIR/{prefix}.XXXXXXXX`, so I think it is better to use this option as
long as it works on all platforms.
[Coop] Convert Microsoft.Win32.NativeMethod to coop.
These are all pretty trivial. There are no pointers or handles.
The only small wrinkle is internal calls -- split the function into w/ and w/o MonoError*.
CEE_LDFLD replaces at the top of the stack the object/valuetype one of its fields. MINT_LDFLD_VT loads a valuetype field from the object/valuetype at the top of the stack. When loading a field from a valuetype, at the end we also did a MINT_VTRESULT to pop the vtspace. If previously we were loading also a valuetype, then, when popping the original valuetype, we discard memory from the loaded field. With this change, we use 2 MINT_VTRESULT, one to pop the loaded field and second to copy it in place of the original valuetype.
* [threads] (windows,mach) If a thread self-suspended, initiator shouldn't wait
Under hybrid suspend if the suspend initiator raced with
done_blocking/abort_blocking, then the thread self-suspended and is already
waiting for the resume semaphor - there's nothing else for the suspend initiator
to do, so don't add victim to the pending operation set.
* [profiler] Do GC state transitions in profiler helper threads
After the calls to `profiler_thread_check_detach`, the GC doesn't skip
the profiler helper threads anymore (because of the call to
`mono_thread_info_set_flags (MONO_THREAD_INFO_FLAGS_NONE)`.
Under hybrid or full cooperative GC, the helper threads in GC Unsafe
mode should not block without periodically polling. Otherwise we get
into a deadlock on shutdown when finalizing the root domain: The profiler
threads have been told to detach and we run a GC in preparation for
running the finalizers. The GC STW ends up waiting for the dumper and
writer threads which never self-suspend.
* style - (void) vs. (), favor (void) in C; function names at start of line for grep ^foo
* [Coop] Convert ves_icall_System_Threading_Thread_Resume to coop.
Cleanup three instances of "Thread has not been started, or is dead.".
Move raising exception (on current thread) outside of locking of resuming thread.
Keep lock hold times shorter.
* [Coop] Convert ves_icall_System_Threading_Thread_Interrupt_internal.
Cleanup uses of ThreadStateException.
I added an option to allow storing a "thread dump" of the running program into a file in the specified directory. It is useful when you need to understand what is going on in your application and you cannot capture stdout or attach a debugger.
Replace bounds check assertions of mono_assembly_get_assemblyref (and
everything that it calls) by Bad Image MonoErrors.
Call from System.Reflection.Assembly.InternalGetReferencedAssemblies to cope
with malformed images
* [runtime] If a MonoError was set, display its message.
* [verifier] Cleanup the metadata verifier interface to use MonoError instead of the old GSList hack.
Runs of bumping `code` should be followed by calling set_code_cursor, every so often, or least when done.
Checks for enough room and realloc should be instead realloc_code.
Reads and esp. write of code_len, code_size, native_code should be relatively rare.
* [mini] Don't verify types if you store to a pointer byref. Workarounds #8403.
* [mini] Add regression test for punting a type system check.
* Fix variable names in test to match comments
The only place where the handler thread should block is in the
kqueue_notimeout() call; interrupting the thread should cause
that call to exit with EINTR, and allow the thread to exit.
* [Tailcall] Fix the patching of GOT sites under FullAOT.
This fixes bug https://github.com/mono/mono/issues/8273 where FullAOT generic-shared (valuetype?) runs hundreds of times slower than regular AOT due to hitting the trampoline for every call.
[Coop] Fork test 8273.il from 3.il and increase iteration count
so it takes a long time previously.
Also possibly fix a JIT path where gshared but not gsharedvt handled.
Tailcall:
Remove arm32 limit of 64 bytes of stack usage. Limit it to 4K instead (12bit immediate displacement).
Remove arm64 limit of 0 bytes of stack usage. Limit it to 1G instead (32bit limit).
i.e. copy arm64 stacked parameters
Limit x86 and amd64 stack usage to 1G (32bit limit).
Even as small as 100 is reasonable.
Add OP_TAILCALL_PARAMETER for more accurate earlier tailcall sizing,
including of unbounded parameter lists.
i.e. a certain number of bytes per parameter (including enregistered,
which makes it an overestimate)
Allow arm64 to return r4 -- caller and callee must agree, which means
caller's caller gets what it expects.
Add test coverage for large parameter list (256+).
Cleanup:
Introduce ins_get_size in place of ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
Use it in a few places. Replace PowerPC's ins_native_length with it.
Cleanup usage of EXTRA_CODE_SPACE vs. 16 -- EXTRA_CODE_SPACE everywhere.
This will get further cleaned up shortly.
Replace if (need to realloc code) with while (need to realloc code.
It is almost the same, but protects against degenerate very small code
where doubling is not enough (except for zero).
Use fsig we already have instead of another call to sig = mono_method_signature.
(for OP_TAILCALL and nearby existing code)
There are 4 different ways that an assembly can be loaded in .NET:
1. default context - `Assembly.Load(string)` does this.
2. reflection only context - `Assembly.ReflectionOnlyLoad` and `Assembly.ReflectionOnlyLoadFrom` do this.
2. load from context - `Assembly.LoadFrom(string)` does this. The interesting bit is that the assembly at the specified path is probed for its assembly name, and then binding redirects are applied to figure out if we need to load a different version of the assembly (from elsewhere in the search path, presumably).
3. "no context" (.NET Core's [AssemblyLoadContext](https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/assemblyloadcontext.md) design doc calls it "custom context", and internally they implement it as `IndividualAssemblyLoadContext`) - in Mono I'm going to call it the "individual context". This is what `Assembly.LoadFile(string)` and `Assembly.Load(byte[])` do: you get exactly the thing you asked for even if something with the same assembly name is already loaded and you get to have problems with type resolution.
So this PR adds:
1. `MonoAssemblyLoadContextKind` enum - default, refonly, loadfrom and individual.
2. Store the `MonoAssemblyLoadContext` in every `MonoAssembly` instead of a boolean `refonly` flag.
3. When loading references from assemblies, consider the load context of the requesting assembly.
4. Do the wacky `LoadFrom` probe and rebind dance.
5. Don't check for duplicated for the individual assembly context.
Not in this PR:
The managed assembly load context stuff in .NET Core. If we eventually want to add it, it will likely build on this work, but it's not here now.
Details:
* [loader] Replace 'refonly' by an assembly load context (NFC)
Replace MonoAssembly:ref_only field by a new context field of type MonoAssemblyContext (which right now just contains a single 'ref_only' boolean).
The .NET Framework documentation describes for contexts for assembly loading:
1. default context - Load(string) and referened assembly loading use this context.
2. LoadFrom context - LoadFrom(string) and references from LoadFrom assemblies.
3. reflection only context - ReflectionOnlyLoad and ReflectionOnlyLoadFrom use this.
4. individual assembly context[footnote:1] - Used by Load(byte[]) and LoadFile(string)
This commit only implements default context and reflection only context. As such, there should be no functional change.
[footnote:1]: Individual assembly context is called "no context" in the .NET
Framework docs, but "individual" is what the .NET Core assembly load context
implementation calls it.
https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/assemblyloadcontext.md
* [loader] propagate MonoAssemblyContextKind instead of refonly, loader_from_context flags
Instead of passing a pair of booleans around, pass a MonoAssemblyContextKind value.
In System.Reflection.Assembly.LoadFrom, pass MONO_ASMCTX_LOADFROM, instead of default.
In System.Reflection.Assembly.Load(byte[]), pass MONO_ASMCTX_INDIVIDUAL instead of default.
In SRE, create new assemblies with MONO_ASMCTX_INDIVIDUAL or refonly
Finally in mono_assembly_load_reference:
For a LOADFROM context always include the requesting assembly's basedir when probing for references.
For INDIVIDUAL context, don't probe for their references - they must be already loaded or else resolved by an AssemblyResolve event.
In a REFONLY context, only look at loaded assemblies or fire the
ReferenceOnlyAssemblyResolve event.
In a DEFAULT context, follow Mono's existing strategy: first probe without
including the basedir (and let the managed AssemblyResolve event fire), then
probe again with the basedir set (potentially firing the event again).
* [reflection] Implement System.Reflection.Assembly.LoadFile as a separate icall
The difference between LoadFrom and LoadFile is that LoadFile should not look in the loaded assembly's basedir when resolving references. (It is also not be subject to remapping).
Also, for LoadFile never return a previously loaded assembly even if one with the same name is already cached by a domain.
Fixes https://github.com/mono/mono/issues/8149
The changes to mono_assembly_load_from_predicate (in conjunction with using MONO_ASMCTX_INDIVIDUAL) for the LoadAssemblyRaw icall also fix https://bugzilla.xamarin.com/show_bug.cgi?id=11199 and https://bugzilla.xamarin.com/show_bug.cgi?id=33728
* [loader] Apply binding redirects to LoadFrom assemblies
Fixes https://github.com/mono/mono/issues/8152
* [loader] Include class failure cause in find_method_in_class TypeLoadException
* [loader] apply binding redirects to LoadFile() and Load(byte[])
Same as LoadFrom: If the identity of the assembly matches a binding redirection, drop the currently opened image and go probing by name instead.
* [loader] Print assembly load context in debug traces
* [loader] Split up mono_assembly_load_full_nosearch
There are two phases: first try the preload hook, second look in the gac, the given base directory, and in the default_path.
Split out the second phase into its own function.
* [loader] Apply remapping and binding when looking for INDIVIDUAL asmctx references
* [loader] Probe the GAC and assemblies path for INDIVIDUAL asmctx
Checked on .NET Framework 4.7.1
Despite the documentation insisting that `LoadFile` does not do any probing for referenced assemblies, it seems that actually, assemblies from the GAC (or at least the framework Facade assemblies such as `System.Runtime`) are nonetheless loaded if no context assembly depends on it.
This commit does the same thing for Mono (except we will additionally look in MONO_PATH).
This makes the xunit console runner work:
At startup they call LoadFile() on all the assemblies in the main executable's dir without doing anything to resolve the references. Those LoadFile assemblies then have broken references to things like System.Runtime that should be in the GAC but that haven't been loaded yet.
* [tests] Add tests for Assembly.Load(byte[]), LoadFile and LoadFrom
Test that loading two assemblies from two different paths (or byte arrays) with the same AssemblyName will produce different results if using Load(byte[]) or LoadFile() but will reuse the first assembly if using LoadFrom().
Regression tests for:
- https://bugzilla.xamarin.com/show_bug.cgi?id=11199
- https://bugzilla.xamarin.com/show_bug.cgi?id=33728
- https://github.com/mono/mono/issues/8149
* [tests] Check that binding redirects work for Assembly.Load(byte[]), LoadFile and LoadFrom
In old version of .NET it was only supposed to work for LoadFrom, but now it should work for all three.
Regression test for https://github.com/mono/mono/issues/8152
* [tests] Don't run Assembly.Load(byte[]) tests with AOT
* [aot] Make load_image return the aot module assembly for LoadFile
LoadFile allows loading more than one assembly with the same name. That means that just calling mono_assembly_load is unlikely to find the correct assembly (it'll just return the first one loaded). But we shouldn't hardcode the full assembly filepath into the AOT image, so it's not obvious that we can call mono_assembly_open_predicate.
Fortunately, an assembly opened with LoadFile is supposed to only refer to already-loaded assemblies (or to GAC & MONO_PATH) assemblies - so nothing new should be loading. And for the LoadFile'd assembly itself, we can check if the name and guid of the current AOT module matches the wanted name and guid and just return the AOT module's assembly.
* [mini] Fixup one MonoClass member access to use getter
* If check_call_signature fails and we break on it, run it again, i.e. so you can
step in a debugger.
* Change check_call_signature to returning a boolean, albeit in the same perhaps backwards way.
* [arm] Create trampoline for passing fixed arguments
It is the same as static rgctx trampoline, but it clobbers ARMREG_IP
* [arm] Create trampoline for native to interp transition
* [arm] Add interp entry from trampoline
Tweak CallContext methods to work in opposite direction
* [interp] Create wrapper that saves lmf for m2i transitions
If we want to unwind from interpreter directly into managed code we need to have a wrapper whose purpose is to save the lmf, so we can start unwinding frame by frame.
* [arm] Add unwind info for interp entry trampoline
We need to unwind through this trampoline since it sits between jitted code and the interp lmf wrapper.
* [interp] Let the unwinder unwind through trampolines
These frames are still ignored (by EH and stack walking), they are only used for unwiding further to the caller.
[Coop] Abort_internal and ResetAbortNative to coop/handle.
* [Coop] Add some comments.
* [Coop] Convert thread abort and interruption to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_ResetAbort to coop/handle.
* Make mono_set_pending_exception_handle static.
* [Coop] mono_join_uninterrupted: Avoid creating handles in loops.
If we have
`catch (Exception e) when (SomeMethod (e))`
.. then the exception object received in `SomeMethod` has an empty
trace. This is because in `handle_exception_first_pass` we populate the
trace in `MonoException` object only at the "end":
- filter returns TRUE
- exception caught
- unhandled exception
But if we have a filter then the trace at that point needs to be
accessible. And if the filter fails then as we unwind more frames, the
earlier frames (`trace_ips`) need to be retained to get the correct full
trace.
`dynamic_methods` needs to be handled similarly and in
`setup_stack_trace` we need to add to the existing `dynamic_methods` in
the MonoException object.
Fixes https://github.com/mono/mono/issues/7649 .
* [Tailcall] Print more. Clarify printing. Dial back a fix by one line
until a test demonstrates it is required.
Move debug_tail up for easier editing.
* [Tailcall arm64] Add tailcall_reg support.
* Fix new warning about maybe-used-uninitialized -- moving variables down is incompatible slightly with goto around them.
* [runtime] Handle failed classes in mono_type_get_checked (). Fixes https://github.com/mono/mono/issues/8311.
* [runtime] Use m_class_has_failure ().
* [runtime] Set the error if the class has a failure.
* [runtime] Add a signal handler for sigterm
* [runtime] Register sigtramp when merp handler enabled
* [runtime] Limit sigterm handler symbol definition to OSX
* [Tailcall] Use tailcall_reg to tailcall internal `calli` to improve F# FullAOT tests.
Rework printing a bit and add more.
Split mini_emit_calli into mini_emit_calli and mini_emit_calli_full.
mini_emit_calli_full takes an extra tailcall parameter.
This enables fixing some F# tests.
`check_sp` inhibits tailcall -- share logic and assert -- in order
to only call `is_supported_tailcall` once.
mono_emit_call_args is big and probably shouldn't be inlined; let compiler decide
anyway, which it always does.
Significant reworking of is_supported_tailcall.
Have it compute "regular" and "calli".
Replace is_interface with imt_arg which should be a more accurate
representation of the important part.
Capture complex conditionals `virtual_generic` and `virtual_generic_imt`
into local variables, so they can be evaluated a second time,
so that `is_supported_tailcall()` can be called just once with its
final inputs.
Move `tailcall` and `tailcall_calli` `tailcall` down
to initialization and make them const (with a temporary/internal non-const).
Note that tailcall still gets changed/reevaluated in multiple places,
and the new value is not returned. One such duplication is the form
of shared logic and an assert (check_sp), the other (calli + llvmonly) is not.
The correct value is needed, sometimes, for e.g. remove_ret.
There also remains a path that appears to change it to false but true in `ins`.
* [interp] fix warning
```
interp/interp.c: In function ‘ves_real_abort’:
interp/interp.c:251:17: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
printf ("\t[%ld] 0x%08x %0.5f\n", sp-stack, sp[-1].data.i, sp[-1].data.f);
~~^ ~~~~~~~~
%d
```
* [mini] ignore GCC warning in trace.c
```
trace.c: In function ‘mono_trace_enter_method’:
trace.c:145:3: warning: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Wframe-address]
printf (") ip: %p\n", MONO_RETURN_ADDRESS_N (1));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
* [tramp-x86] remove unused function
```
tramp-x86.c:171:1: warning: ‘get_vcall_slot_addr’ defined but not used [-Wunused-function]
get_vcall_slot_addr (guint8* code, mgreg_t *regs)
^~~~~~~~~~~~~~~~~~~
```
* [mini-x86] remove unused function
```
mini-x86.c:6327:1: warning: ‘emit_load_aotconst’ defined but not used [-Wunused-function]
emit_load_aotconst (guint8 *start, guint8 *code, MonoCompile *cfg, MonoJumpInfo **ji, int dreg, int tramp_type, gconstpointer target)
^~~~~~~~~~~~~~~~~~
```
* [tramp-x86] remove unused function
```
tramp-x86.c:146:1: warning: ‘get_vcall_slot’ defined but not used [-Wunused-function]
get_vcall_slot (guint8 *code, mgreg_t *regs, int *displacement)
^~~~~~~~~~~~~~
```
* [mini-x86] change previous_lmf to pointer type (same as amd64)
```
mini-runtime.c: In function ‘mono_push_lmf’:
mini-runtime.c:806:24: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ext->lmf.previous_lmf = *lmf_addr;
^
mini-runtime.c:808:24: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
ext->lmf.previous_lmf = (gpointer)(((gssize)ext->lmf.previous_lmf) | 2);
^
mini-exceptions.c: In function ‘arch_unwind_frame’:
mini-exceptions.c:420:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
*lmf = (MonoLMF *)(((guint64)(*lmf)->previous_lmf) & ~3);
^
mini-exceptions.c: In function ‘unwinder_unwind_frame’:
mini-exceptions.c:715:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
*lmf = (MonoLMF *)(((guint64)(*lmf)->previous_lmf) & ~7);
^
```
* [monolmf/x86] make int cast dependend one machine word size
```
In file included from debugger-agent.c:36:0:
debugger-agent.c: In function ‘get_top_method_ji’:
debugger-agent.c:2501:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
g_assert (((guint64)lmf->previous_lmf) & 2);
^
../../mono/eglib/glib.h:710:46: note: in definition of macro ‘G_UNLIKELY’
#define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
^~~~
debugger-agent.c:2501:3: note: in expansion of macro ‘g_assert’
g_assert (((guint64)lmf->previous_lmf) & 2);
^~~~~~~~
```
* [interp] remove unnecessary code
* [mini] fix ptr with int cmp
this was wrongly changed.
```
mini-exceptions.c: In function ‘unwinder_unwind_frame’:
mini-exceptions.c:702:33: warning: comparison between pointer and integer
if (unwinder->last_frame_addr > (gsize)(*lmf)) {
^
```
This include breaks compiling the interpreter on platforms which don't have a
signal.h. The code in interp.c doesn't seem to need it to be included anyway.
* [wasm] Fix CI target.
* [wasm] Switch to do a local install of npm packages.
* [wasm] Switch to fine-grained execution steps to avoid VM bugs.
* [wasm] Disable System.Core under Chakra as the JS engine crashes.
* [Tailcall] Remove OP_JMP support. Require OP_TAILCALL.
This only hurts mips and sparc -- it breaks them.
Remove front end support for OP_JMP and conditionalality of OP_TAILCALL.
* And remove MONO_ARCH_HAVE_OP_TAILCALL and require mono_arch_tailcall_supported.
* And tailcall_remove_ret becomes temporarily irrelevant.
* [Tailcall] Keep mips and sparc working, albeit never tailcalling.
* Remove jmp opcode too.
for F# FullAOT.
Add some FIXMEs about alignbment and possible
improvements (fixed size rep mov to move tailcall parameters).
Grow static unknown sizes to 255.
* [sdks] Wrap configure to provide better output.
Wrap configure in a script that:
* Captures stdout/stderr and only shows it in case of errors.
* If configure fails, and a cache file was used, deletes the cache file and
tries again.
* If configure really fails, then print config.log in addition to
stdout/stderr, since a lot of valuable diagnostic output is in that file
(and it's annoying to track down configure failures on bots when the file
with the important output has already been deleted).
* Only show config.log when running on bots.
* [System.ServiceMode] Create unit test for #46917
* [System.ServiceModel.Discovery] Fix messages validation
The current validations are not correct and throws an exception calling
GetVideoSources API in an ONVIF media client. This API
is a combination of a first message with an input parameter and
a second message with the reply that is not void.
Removing this checks makes the client work correctly.
Fixes#46917
* [threads] Check that thread is in a valid suspend state before notifying the initiator.
* [threads] Suspend running threads cooperatively in coop or hybrid suspend
Reverts an inadvertant change from 282ee4bfd7
* [checked-build] Add a mutex in collect_backtrace
GNU libc backtrace() calls _Unwind_Backtrace in libgcc which internally may
take a lock.
That allows for a deadlock situation where two threads try to call collect_backtrace and
one of them takes the lock and is async suspended with the lock held, while the
other is supposed to cooperatively suspend but it is blocked waiting for the
backtrace mutex.
The suspend initiator ends up waiting indefinitely for the threads to suspend,
and the runtime hangs.
As a workaround we add a mutex around the call to backtrace() and only collect
a backtrace if we can immediately grab the lock without contention.
* [threads] Drop DoneBlockingNotifyAndWait & AbortBlockingNotifyAndWait
These two actions were causing a race in hybrid suspend.
Suppose thread T is in blocking and thread S (suspend initiator) wants it to
suspend:
S sets T to BLOCKING_SUSPEND_REQUESTED and sends a suspend signal and waits for
pending operations.
T continues running and comes to exit the GC Safe region.
T executes done_blocking and transitions to BLOCKING_SELF_SUSPENDED and returns
DoneBlockingNotifyAndWait.
T notifies S; T waits for a resume.
S wakes up, does whatever it needs to do and resumes T - T goes from
BLOCKING_SELF_SUSPENDED to RUNNING.
T wakes up and finishes the done blocking transition.
Suspend signal finally arrives in T. T attempts finish_async_transition from
RUNNING. Assertion. Crash.
What we do in this commit is change done blocking not to notify the initiator.
Instead done blocking immediately waits for a resume.
In that case T is waiting for a resume in BLOCKING_SELF_SUSPENDED, and S is
waiting for pending operations. So when T's suspend signal handler runs, it
will return FALSE (raced with self suspend), send a notification to the
suspend initator, and then immediately return. T then will continue waiting for
the resume. S will wake up, do what it needs to do and switch T to RUNNING and
post the resume to wake it.
class-inlines.h:13:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
mono_get_void_type ()
In C: () means accept any parameters -- K&R unprototyped
(void) is new-standardized-in-1989 form meaning accept no parameters
In C++ this is fixed and they mean the same thing -- accept no parameters.
To accept any parameters in C++, use (...), which is not valid in C, C requires
at least one fixed-type parameter when you use "...".
() is very rarely what you want in C, or in C++ headers consumable from C.
If you do need () for highly unusual code, for a function that accepts anything,
and has no fixed parameters, then use ifdef __cplusplus and ... for C++.
printf for example does not fit in this bucket because it always has the const char *format.
In fact, it is so rare because a variable-argument ("varargs") function would need *some* way to decide what is in "...".
* Teach sn.exe about PE32+, and while there ROM images and MS-DOS-less.
See https://github.com/mono/mono/issues/8218.
* Make Error static.
* Remove .Close () redundant with using.
* Use helper function ReadMore and System.Array.Resize.
* Fix typos in comment.
* Move hash.Hash to fix 'Hash must be finalized before the hash value is retrieved.'.
* Cleanup.
* Fix Automatic Proxy Configuration protocol for OSX 10.13
Reference comparison of kCFProxyTypeAutoConfigurationURL doesn't work in 10.13. Added fallback to do value/string comparison to get proxy type
* Change string comparison from C# string to CFString for possible memory safety and efficiency
* Code style changes
The previous code would produce
```diff
-public const string Version = "11.11.0";
+public const string Version = "11.9.1";
```
instead of
```diff
-public const string Version = "11.9.1";
+public const string Version = "11.11.0";
```
when diff are inlined. The addition and removal sections are fine.
* [wasm] Fix build scripts to work on linux.
* [wasm] Force emscripten version to 1.37.36 to fix OSX breakage.
* [wasm] Fix failure in new FloatF test.
* [wasm] Fix detection of test failure.
commit message said
> [w32file-unix] convert nano seconds to microseconds properly, by using
> TICKS_PER_MILLISECOND (which has L suffix in its definition)
first it talks about microseconds, but then uses constant for _milli_
seconds
* [runtime] Add public API to set the pending exception.
Xamarin.iOS and Xamarin.Mac need a public API to set the pending exception
when converting Objective-C exceptions to managed exceptions.
This adds a public API to support this scenario.
Partially fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60065.
* [runtime] Document that pending exceptions should not be overwritten when the runtime is handling a thread abort request.
* [threads] Have Hybrid Suspend not depend on Coop Suspend
* [threads] Enable CI
* [hybrid suspend] Wait for pending operations when suspending a blocking thread
In hybrid suspend we should wait for the pending suspend to finish when we're
suspending a blocking thread.
In full cooperative suspend, we treat blocking threads as already suspended, so
in that case there is nothing to wait for.
* [checked-build] don't use malloc for thread state history
Use a ring buffer, so we're signal safe.
* [checked-build] checked_build_thread_transition - async signal safe variant
Can't call backtrace on Linux from a signal handler.
Change mono_threads_transition_finish_async_suspend not to collect a
backtrace.
* [class] Rename MonoClass byval_arg field to _byval_arg
Update all use sites to use the getter method m_class_get_byval_arg instead
when possible.
* [runtime] add mono_get_*_type accessors for common MonoTypes
Just do void, object, int32 and int (aka IntPtr) for now
Refactor g_print on top of new g_printv. g_log / g_logv provided precedent.
The intent is like:
void foo_print (const char *format, ...)
{
if (debug_foo || MONO_IS_TRACED (foo, log)) {
va_list args;
va_args (format, args);
g_printv (format args)
}
}
so I can either set the environment variable, or edit the global,
besides removing the two parameters from every mono_trace call.
* [jit] Enable float32 by default.
* [arm64] Fix some 32 bit float compares so they handle unordered operands correctly.
* [runtime] Disable a coreclr test which fails with float32.
* [FileTest] regression for https://github.com/xamarin/xamarin-macios/issues/3929
* [w32file-unix] fix File.Copy timestamps
4a8d840d6f introduced that the destination
file of a copy operation has the same modification and access timestamps
as the source file.
With e0e185d70a this behaviour regresses,
since getting timestamps provides more precise information. Fixing this
by being more accurate when applying timestamps to destination file.
* [w32file-unix] convert nano seconds to microseconds properly, by using TICKS_PER_MILLISECOND (which has L suffix in its definition)
* [w32file-unix] introduce constant for ns->qs conversion with proper suffix
fixes problem on 32bit.
* [jit] Add a r8->r4 conversion in stind.r4 when the item on the stack is a r8 because of stack merging.
* [jit] Disable a SIMD test which can fail with -O=float32 due to precision problems.
* [jit] Use m_class_get_byval_arg ().
* [jit] Fix OP_RCONV_TO_I on amd64.
* [jit] Revert '[jit] Use r8 for r4 stack vars to avoid problems with stack merges when one side is an r4 and the other an r8. Add conversions for compares. (#8196)'. It causes r4-r4 merges to produce an r8 stack value, leading to invalid il errors.
* [Mono.Options] Allow CommandSet nesting, spaces in command names.
`git` (largely) only provides a single level of sub-commands, and
this is the use case that `Mono.Options.CommandSet` originally
supported.
However, this isn't the case for all command-line applications.
Take for example the Azure [`azure`][azure] command, which allows near
arbitrary command name depths:
[azure]: https://docs.microsoft.com/en-us/azure/virtual-machines/azure-cli-arm-commands
$ azure config mode arm
$ azure vm create
$ azure vm list
$ azure vm disk attach
Try to integrate "arbitrary" command nesting through two new
mechanisms:
1. `Command` names may now contain spaces, and
2. `CommandSet`s may be nested within `CommandSet`s.
`Command` names containing spaces allows for the same *style* of
"nested" sub-commands, but means that C# nesting isn't as deep:
var azure = new CommandSet ("azure") {
new Command ("config mode") {...},
new Command ("vm create") {...},
new Command ("vm list") {...},
new Command ("vm disk attach") {...},
};
When `CommandSet.Run()` is invoked, separate string indexes will be
"merged" while attempting to find a matching command-name, allowing
the "natural" command-line invocation to be used:
mono example.exe vm disk attach
# Invokes `vm disk attach` command
Alternatively, a `CommandSet` may be added to a `CommandSet`:
// C#
var azure = new CommandSet ("azure") {
new CommandSet ("vm") {
new Command ("create") {...},
new Command ("list") {...},
},
};
When this is done, `CommandSet.Suite` is required on the command-line:
mono example.exe vm list
If a "`Command` with spaces" has the same command-name as a nested
`CommandSet`, the `Command` "wins" and is invoked.
* [Mono.Options] Fix unsupported MCS compiler feature
* Bump API snapshot submodule
This brings the patch: https://github.com/dotnet/coreclr/pull/6898
Fail faster for `Wait(0)` when no counts available.
Don't allocate in the `Wait(0)` and `WaitAsync(0)` fail paths.
1M iters Server GC
method | pre (ms) | post (ms) | improvement
-------- |------- |------- |------ |
Wait(0) | 33,788.25 | 12.28 | x 2751.5
WaitAsync(0) | 360.79 | 24.38 | x 14.8
Memory allocations, saves 360MB over the 1M ops
* [jit] Use r8 for r4 stack vars to avoid problems with stack merges when one side is an r4 and the other an r8. Add conversions for compares.
* [jit] Use m_class_get_byval_arg in one place.
* Add a FIXME.
* [runtime] Get rid of the GLIB_LIBS autoconf define, it prevents automake from detecting the dependency on libeglib.la. Fixes#8175.
* [runtime] Link eglib against -lm to avoid duplication.
* [runtime] Remove a few extra -lm options.
* [runtime] More GLIB_LIBS fixes.
In interp we implement the leave statement by enqueuing finally ips (and the destination ip that we are leaving to) that we call as we exit finally blocks. When throwing an exception from a finally block we need to flush these ips, so we don't jump back into clauses that were already skipped by EH.
* [runtime] Make GetFrames consider nested exceptions
Fixes#7260
* [runtime] Add test from repro for #7260
* [runtime] FIx test using absolute line numbers
* [ci] Add {,hybrid,full}aot_llvm presets to make sure we compile with LLVM
* [configure] Rename runtime_preset to runtime-preset
* [bcl] Make sure we build the testing_aot_{hybrid,full} profiles when building all profiles
* [test-runner] Factor test-runner parameters for picking up and passing arguments to the runtime
* [hybridaot] Fix testing_aot_hybrid build
* [mini-llvm-aot] Fix common race condition in parallel builds due to common defaults.
When a connection fails, the socket error was being incorrectly reported
as an address family not supported error, instead of connection refused.
Why did this happen? The order of addresses returned from
`Dns.GetHostAddresses` changed. The newer code returns the IPv6 address
first, and the IPv4 address second. While `GetCheckedIPs` mentioned in a
comment that it skips addresses that don't match the address family, it
did not. The code using the addresses returned by `GetCheckedIPs` will
use the first address in the array. If this address happens to match the
address family of the socket, things will work "properly" (the correct
socket error will occur).
If, however the first entry has the wrong address family, then the
socket error will be an address family not supported error, since the
socket was created with different address family.
This change modifies `GetCheckedIPs` to filter the addresses, removing
those which do not match the address family.
[coop] Hybrid suspend
## Summary
This is a new suspend mode where threads that are running managed or native runtime code (what we call "GC Unsafe") are suspended cooperatively using safepoints, but threads running either embedder code or P/Invoke code or blocking syscalls (what we call "GC Safe") are suspended preemptively using signals.
The motivation is to make an embedder-friendly coop suspend mechanism where the runtime will do GC Safe -> GC Unsafe transitions on calls to `MONO_API` functions, but the embedders themselves don't have to have any special knowledge of coop safepoints or state transitions.
To try this out, set **both** `MONO_ENABLE_COOP` and `MONO_ENABLE_HYBRID_COOP` environment variables.
## Implementation
Here's a picture of the new state machine. There's two new states `Blocking_Suspend_Requested` and `Blocking_Async_Suspended` and one updated transition `req_s` (request suspension).

### State machine states and transitions
The hybrid cooperative suspend mechanism works like this:
- when a thread is executing in GC Unsafe mode, we use cooperative suspend and expect
the thread to periodically checkpoint its execution (as in the ordinary full
coop mode).
- when a thread is executing in GC Safe mode, we use a preemptive signal-based
suspend. This is new - previously in full coop we would allow `BLOCKING`
threads to continue executing and only suspend them when they wanted to go
from GC Safe to GC Unsafe (via the `BLOCKING_SELF_SUSPENDED` state).
There are two new states and one updated transition - the transition will
service both running and blocking threads: The idea is that suspend mechanism
is determined by the suspend initiator, and is not embodied in the the state
machine. The state machine just has to return distinctive enough values from
the transitions for the initiator to select a policy.
Resume mechanism is determined by the state that a thread finds itself in when
it is resumed, and the original suspend policy.
The primary differences between suspend mechanisms are: the preemptive
suspend is two phase - the `finish_async_suspension` does not
apply for cooperative suspend; the cooperative policy uses the `poll` transition when the thread is running.
We renamed `mono_threads_transition_request_async_suspension` to `mono_threads_transition_request_suspension`.
- It must be called by a suspend initiator on a victim thread that is not
itself.
- There can only be one suspend initiator for a victim at a time - if the
suspend initiator initiates a suspension it must follow through with the
whole protocol.
- If a victim is `RUNNING` we transition it to `ASYNC_SUSPEND_REQUSTED` and return
`ReqSuspendInitSuspendRunning` which signals that the caller must initiate
suspension for a running thread. (Same as the old `AsyncSuspendInitSuspend`).
- If a victim is `BLOCKING` we transition it to `BLOCKING_SUSPEND_REQUESTED`.
Note that this is different from the old `request_async_suspension` which just
incremented the suspend count and returned `AsyncSuspendBlocking`. Now we
return `ReqSuspendInitSuspendBlocking`. The return of
`ReqSuspendInitSuspendBlocking` means the initiator may signal the victim and
must wait to be notified of the suspension (in preemptive suspend it will be
notified by the signal handler, in cooperative when the blocking thread
attempts to exit from blocking mode).
- In `BLOCKING_SUSPEND_REQUESTED` we
may increment the suspend count. This is slightly too lax if we're going to
be using preemptive suspend on blocking threads: in that case we're in the
middle of a two-phase suspend and since there is only one suspend initiator,
we wouldn't expect another suspend to be initiated until we have a chance to
finish suspending. We leave it to the suspend initiator to rule out by returning
`ReqSuspendAlreadySuspendedBlocking` from this state.
- In all the not executing states (`SELF_SUSPENDED`, `ASYNC_SUSPENDED`,
`BLOCKING_SELF_SUSPENDED`, `BLOCKING_ASYNC_SUSPENDED`) we just
increment the suspend count.
- All other transitions are illegal.
- Note that `BLOCKING` must always have a suspend count of 0 and
`BLOCKING_SUSPEND_REQUESTED` must have suspend_count > 0.
We add two new states:
- `STATE_BLOCKING_SUSPEND_REQUESTED` - this is a new state that indicates that a
suspend initiator wants to suspend this victim thread.
- The thread is still executing in this state.
- We only transition into this state with
`mono_threads_transition_request_suspension`.
- The only legal transitions out from this state are:
- `resume` - decrements the `suspend_count`. If the `suspend_count` becomes 0 we
go back to `BLOCKING`, otherwise we stay in `BLOCKING_SUSPEND_REQUESTED`.
- `finish_async_suspension` (executed by the suspend signal handler to
finish the two phase preemptive suspend request and notify the suspend initiator),
- `done_blocking` and `abort_blocking`. It means that the a
suspend initiator requested a suspend but we got to done (or abort)
blocking before the signal was delivered. We return `NotifyAndWait` and the
caller is supposed to send a notification to the suspend initiator and
wait for a resume(with suspend count == 0) which will return to
`RUNNING` (the victim thread goes to `STATE_BLOCKING_SELF_SUSPENDED`).
- `STATE_BLOCKING_ASYNC_SUSPENDED`
- The thread is not executing in this state (it is waiting for a `resume`).
- a thread transitions into this state from `STATE_BLOCKING_SUSPEND_REQUESTED`
on a `finish_async_suspension` transition (see above).
- on a `resume` transition we decrement the suspend count. if it's still
positive we stay in this state. if it's 0 the thread transitions out of
this state. Unlike other resume transitions, in this case the thread goes
back to `BLOCKING` and resumes executing in GC Safe mode. The resume caller
must notify the resume initiator (ie this is a `ResumeInitAsyncResume`).
- on a `request_suspension` we stay in this state and just increment the
suspend count.
- all other transitions from this state are illegal.
We add two new return values for `abort_blocking` and `done_blocking`:
- `DoneBlockingNotifyAndWait` and `AbortBlockingNotifyAndWait`. Similar to
`SelfSuspendNotifyAndWait` - there was a race between the second phase of a
preemptive suspend and another operation (in that case a poll, in this case a
done or abort blocking) and the other operation won, so its caller should
notify the suspend initiator. Since the thread is now suspended, the caller
should wait for the resume signal.
We add new results for `request_initiate_suspension` `MonoRequestSuspendResult`
(formerly `MonoRequestAsyncSuspendResult`):
- `ReqSuspendAlreadySuspended` means the thread is not executing and we just
incremented its suspend count and there's nothing else for the suspend
initiator to do. (The old `AsyncSuspendAlreadySuspended`)
- `ReqSuspendAlreadySuspendedBlocking` means the thread is in
`BLOCKING_SUSPEND_REQUESTED` and we initiated another suspend request. This
should only happen with full cooperative suspend - with hybrid suspend we
will use a two phase preemptive suspend on a blocking thread and since only
a single suspend initiator is active, this state should not be visible to
another suspend initiator.
- `ReqSuspendInitSuspendRunning` - Thread is executing in GC Unsafe mode and the
caller should suspend it. This is the old `AsyncSuspendInitSuspend`. In
full preemptive suspend this is the only suspend initiation action and the caller
should begin the preemptive suspend procedure. In full coop we expect the
victim thread to reach a safepoint and poll to finish suspending.
- `ReqSuspendInitSuspendBlocking` - Thread is executing in GC Safe mode and
the caller should initiate a suspend. In full coop the caller has nothing
to do - a thread executing in blocking mode is assumed to be suspended. In
hybrid suspend, the caller has to initiate a preemptive suspend.
### Suspend initiator, signal handler, self suspender
Basically we call `mono_threads_transition_request_suspension` instead of `mono_threads_transition_request_async_suspension`.
Then if it says to suspend a running thread we call `begin_suspend_for_running_thread`, if it says initiate a suspension of a blocking thread, we call `begin_suspend_for_blocking_thread`, and if it says do nothing we do nothing.
**Questions**
1. We have an assumption in `safe_interrupt_thread` that we can return from a self interrupt if we're using coop suspend. I'm not sure if that makes sense for hybrid suspend, and not clear what to do about it.
2. In `mono_thread_info_safe_suspend_and_run` we expect that the callback won't return `KeepSuspended` if coop is enabled. I'm not sure what this means for hybrid.
3. A bunch of tests like `monitor-abort` and `appdomain-threadpool-unload` are failing if I enable hybrid suspend. Don't know why yet.
* fix ThreadPool.SetMinThreads fails if ThreadPool.GetMaxThreads was not called before #7988
* check mono_lazy_initialize in ves_icall_System_Threading_ThreadPool_SetMaxThreadsNative first
[console-unix] retry `tcsetattr` if it was interrupted by signal
if configuring the terminal failed, we still try to continue (see
a3ce2f008b ) and therefore succedings
`read`s can fail.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=26983
Change begin_cooperative_suspend and begin_preemptive_suspend to return one of
three results: suspend fail, suspend succeeded using cooperative suspend,
suspend succeeded using preemptive suspend.
This is used by check_async_suspend to decide whether to check the
MonoThreadInfo for the result of a suspend. (If a thread is suspended
cooperatively, it doesn't make sense to check).
Fixes sporadic failures in mono/tests/monitor-abort.exe
When the environment variable is set, Mono will use cooperative safepoint
suspend for threads running in GC Unsafe mode (running managed code or native
runtime code), and preemptive suspend for threads running in GC Safe
mode (running native embedder or P/Invoke code, or blocking system calls)
The environment variable is visible through
mono_threads_is_hybrid_suspension_enabled ().
This commit just adds the env var, it doesn't turn on hybrid coop suspend.
The hybrid cooperative suspend mechanism works like this:
- when a thread is executing in GC Unsafe mode, we use cooperative suspend and expect
the thread to periodically checkpoint its execution (as in the ordinary full
coop mode).
- when a thread is executing in GC Safe mode, we use a preemptive signal-based
suspend. This is new - previously in full coop we would allow BLOCKING
threads to continue executing and only suspend them when they wanted to go
from GC Safe to GC Unsafe (via the BLOCKING_SELF_SUSPENDED state).
There are two new states and one updated transition - the transition will
service both running and blocking threads: The idea is that suspend mechanism
is determined by the suspend initiator, and is not embodied in the the state
machine. The state machine just has to return distinctive enough values from
the transitions for the initiator to select a policy.
Resume mechanism is determined by the state that a thread finds itself in when
it is resumed, and the original suspend policy.
The primary differences between suspend mechanisms are: the preemptive
suspend is two phase - the finish_async_suspension transition only does not
apply for cooperative suspend; the cooperative policy uses the poll transition
when the thread is running.
We renamed mono_threads_transition_request_async_suspension to mono_threads_transition_request_suspension.
- It must be called by a suspend initiator on a victim thread that is not
itself.
- There can only be one suspend initiator for a victim at a time - if the
suspend initiator initiates a suspension it must follow through with the
whole protocol.
- If a victim is RUNNING we transition it to ASYNC_SUSPEND_REQUSTED and return
ReqSuspendInitSuspendRunning which signals that the caller must initiate
suspension for a running thread. (Same as the old AsyncSuspendInitSuspend).
- If a victim is BLOCKING we transition it to BLOCKING_SUSPEND_REQUESTED.
Note that this is different from the old request_async_suspension which just
incremented the suspend count and returned AsyncSuspendBlocking. Now we
return ReqSuspendInitSuspendBlocking. The return of
ReqSuspendInitSuspendBlocking means the initiator may signal the victim and
must wait to be notified of the suspension (in preemptive suspend it will be
notified by the signal handler, in cooperative when the blocking thread
attempts to exit from blocking mode).
- In BLOCKING_SUSPEND_REQUESTED we may increment the suspend count. This is
slightly too lax if we're going to be using preemptive suspend on blocking
threads: in that case we're in the middle of a two-phase suspend and since
there is only one suspend initiator, we wouldn't expect another suspend to
be initiated until we have a chance to finish suspending. We leave it to
the suspend initiator to rule out by returning
ReqSuspendAlreadySuspendedBlocking from this state.
- In all the not executing states (SELF_SUSPENDED, ASYNC_SUSPENDED,
BLOCKING_SELF_SUSPENDED, BLOCKING_ASYNC_SUSPENDED) we just increment the
suspend count.
- All other transitions are illegal.
- Note that BLOCKING must always have a suspend count of 0 and
BLOCKING_SUSPEND_REQUESTED must have suspend_count > 0.
We add two new states:
- STATE_BLOCKING_SUSPEND_REQUESTED - this is a new state that indicates that a
suspend initiator wants to suspend this victim thread.
- The thread is still executing in this state.
- We only transition into this state with
mono_threads_transition_request_suspension.
- The only legal transitions out from this state are:
- resume - decrements the suspend_count. If the suspend_count becomes 0 we
go back to BLOCKING, otherwise we stay in BLOCKING_SUSPEND_REQUESTED.
- finish_async_suspension (executed by the suspend signal handler to
finish the two phase preemptive suspend request and notify the suspend initiator),
- done_blocking and abort_blocking. It means that the a
suspend initiator requested a suspend but we got to done (or abort)
blocking before the signal was delivered. We return NotifyAndWait and the
caller is supposed to send a notification to the suspend initiator and
wait for a resume(with suspend count == 0) which will return to
RUNNING (the victim thread goes to STATE_BLOCKING_SELF_SUSPENDED).
- STATE_BLOCKING_ASYNC_SUSPENDED
- The thread is not executing in this state (it is waiting for a resume).
- a thread transitions into this state from STATE_BLOCKING_SUSPEND_REQUESTED
on a finish_async_suspension transition (see above).
- on a resume transition we decrement the suspend count. if it's still
positive we stay in this state. if it's 0 the thread transitions out of
this state. Unlike other resume transitions, in this case the thread goes
back to BLOCKING and resumes executing in GC Safe mode. The resume caller
must notify the resume initiator (ie this is a ResumeInitAsyncResume).
- on a request_suspension we stay in this state and just increment the
suspend count.
- all other transitions from this state are illegal.
We add two new return values for abort_blocking and done_blocking:
- DoneBlockingNotifyAndWait and AbortBlockingNotifyAndWait. Similar to
SelfSuspendNotifyAndWait - there was a race between the second phase of a
preemptive suspend and another operation (in that case a poll, in this case a
done or abort blocking) and the other operation won, so its caller should
notify the suspend initiator. Since the thread is now suspended, the caller
should wait for the resume signal.
We add new results for request_suspension MonoRequestSuspendResult
(formerly MonoRequestAsyncSuspendResult):
- ReqSuspendAlreadySuspended means the thread is not executing and we just
incremented its suspend count and there's nothing else for the suspend
initiator to do. (The old AsyncSuspendAlreadySuspended)
- ReqSuspendAlreadySuspendedBlocking means the thread is in
BLOCKING_SUSPEND_REQUESTED and we initiated another suspend request. This
should only happen with full cooperative suspend - with hybrid suspend we
will use a two phase preemptive suspend on a blocking thread and since only
a single suspend initiator is active, this state should not be visible to
another suspend initiator.
- ReqSuspendInitSuspendRunning - Thread is executing in GC Unsafe mode and the
caller should suspend it. This is the old AsyncSuspendInitSuspend. In
full preemptive suspend this is the only suspend initiation action and the caller
should begin the preemptive suspend procedure. In full coop we expect the
victim thread to reach a safepoint and poll to finish suspending.
- ReqSuspendInitSuspendBlocking - Thread is executing in GC Safe mode and
the caller should initiate a suspend. In full coop the caller has nothing
to do - a thread executing in blocking mode is assumed to be suspended. In
hybrid suspend, the caller has to initiate a preemptive suspend.
* [sdks] New SDK target: soft debugger + non-nunit exe
This adds support for building an arbitrary .exe (dtest-app is hardcoded
now, but changing that and setting the arguments is another line or two,
to bu customized to the app being bound)
When an environment variable is set, the runtime will wait for the
managed debugger. This enables the desktop to debug the deployed .exe.
This will be used for the Mono.Debugger.Soft tests, but is useful for
isolated reproductions with android bugs.
An unmanaged debugger versions of the managed debugger is coming in
another PR.
* [runtime] Provide argument to dtest-app when running remotely
* [runtime] Fix case of VMDisconnectionException when getting Process of remote host that has disconnected
* [runtime] Script monodroid desktop debugger agent
* [runtime] Use g_warning in debugger agent
* [sdks] Ship PDBs on android
* [sdks] Add Android target to run debugger tests
* [sdks] Add desktop profile target for debugger tests
* [sdks] Disable debugger tests on mobile that use unsupported apis
* [sdks] Add monodroid test profile to android sdks
* [runtime] Allow dtest-app to be built on non-debugger-client profiles
* [runtime] Allow dtest-app building on mobile profiles
* [bcl] Mark some some code with DISABLE_COM which depends on icalls which are disabled in the runtime when --enable-minimal=com is used.
* [bcl] Fix compilation of System.Runtime.InteropServices.WindowsRuntime.dll.
* .
When we tried switching mono-project.com to enforce HTTPS these tests
started failing on systems without working SSL configuration.
Use a different domain which is guaranteed to be available over HTTP instead.
Note that eventually, the length will depend on stack_usage
difference between caller and callee, though for arm64 it does not currently.
This should fix https://github.com/mono/mono/issues/8112.
* [jit] Add a MONO_ARCH_FLOAT32_SUPPORTED arch-specific define, use it to disable float32 on platforms which don't support it.
* [amd64] Fix r4fp support for the ATOMIC_LOAD/STORE_R4 opcodes.
* [jit] Disable a unused test method with invalid IL.
* [jit] Handle r4->u conversion correctly in float32 mode.
* [amd64] Fix some OP_R<cmp> opcodes.
If the runtime is configured using --enable-minimal=soft_debug, the debugger code will be compiled into a separate
libmono-dbg.a library which needs to be linked into the app. The debugger needs to be registered with the runtime by
calling mono_debugger_agent_init () before runtime initialization.
* [llvm] Add intrinsics support for some of the new MathF icalls when using llvm+float32.
* [jit] Use m_class_get_name ().
* [llvm] Fix the signature of the llvm instrinsic used by OP_ABSF.
* [llvm] Use llvm.fabs only on amd64, it doesn't seem to be supported on some platforms.
* [ci] Update csproj files during PRs
Similar to how API diff is done.
Replace EXTERNAL_DRAWING_FACADE in csproj in genproj
It'd embed the absolute path in the csproj, but we want the variable instead.
* [csproj] Update project files
Custom modifiers are an odd feature of .net which allow types to
be tagged. These tags are semantically relevant. A method with a
modifier should not override a method without a modifier, for
instance (github bug #6936).
We don't put enough information into the modifier to uniquely find the
Image associated with the token we have in the type. Modifiers from
different referring assemblies will have different tokens to refer to
the same modifier class, making it important to resolve the tokens to
MonoClass pointers at runtime. Pointer equality of these classes is the
way to determine two custom modifiers the same, or unique.
We cannot resolve the image just from the MonoType because it is
possible to put modifiers on primitive, builtin types. These builtin
types lack any filled-out pointers in the data block, meaning we have
zero metadata associated with our floating token.
Other places in the codebase fixed this by passing around MonoImages,
but adding a MonoImage argument to our type comparison function for
this single bug would be a very poor decision with much code churn all
throughout the runtime.
The bug above resolves to two I4 types, one of which has a modifier, one
of which does not.
In order to pass this MonoImage around, we need to put a reference to it
into something reachable from the MonoType. We can't put it in the
custom module type because that is exported. It is part of the public
API.
MonoTypes do not adhere to pointer equality, and custom modules are structs
baked directly into the MonoType. We need therefore to make MonoType
point to a MonoCustomModInternal, a new type. This type embeds the
public type as a struct and carries around the image as another element
in the struct.
All public interfaces still see the same metadata endpoints for parsing the
modules, including the icalls. It is only our type comparison code that
accesses our new field.
This fixes https://github.com/mono/mono/issues/8074.
I see this 100%. Why others do not? I usually skip aot so usually I don't see it. Linux Ubuntu 1604 and
1710 tested. mono-devel package is installed, which is probably not relevant.
git clean -xddf (or new git clone)
./configure --with-runtime_preset=fullaot likely also with others (hybridaot)
make
Many errors like:
MONO_PATH="./../../class/lib/build:$MONO_PATH" /s/mono/runtime/mono-wrapper ./../../class/lib/build/sn.exe
-q -R ../../class/lib/testing_aot_full/mscorlib.dll ./../../class/mono.snk Couldn't sign the assembly
../../class/lib/testing_aot_full/mscorlib.dll with this key pair. Public key of assembly did not match
signing public key. ../../build/library.make:342: recipe for target
'../../class/lib/testing_aot_full/mscorlib.dll' failed
If you run make V=1 you see the sn command.
You can see the installed sn works ok. Remove the -Q for quiet and you see a warning about missing
machine.config. Run with ptrace and you see it looking for 4.5/machine.config. Look in the tree and you
see 1.1 and 2.0. Copy the 2.0 to 4.5 and problem goes away. And can be edited down a bunch. Actual fix is
to move symlink of the file to outside a conditional.
Maybe people aren't using fullaot or git clean? Repro is 100% for me.
I was going to bisect, but it was occuring as far back as September 2017 so I did not.
.
* [sdks] Add support for building llvm unless the USE_PREBUILT_LLVM Make.config var is set.
* [sdks] Use prebuilt llvm binaries on ios CI.
* [sdks] Use the IGNORE_PACKAGE_LLVM variable to enable the building of llvm.
* [runtime] Handle interpreter-related frames in async stack walks.
* [profiler] Fix exception clause reporting.
This fixes three separate issues:
* Finally clauses in the non-exceptional case were not reported because we
implement these by simply calling them from managed code, as opposed to the
exceptional case where we call them from runtime C code.
* The catch portion of a try-filter-catch clause was being incorrectly reported
as a filter.
* Actual exception filters were not being reported at all.
Because we have to instrument JIT'd code to report non-exceptional finally
clauses, a new mono_profiler_enable_clauses () function has been introduced
which profiler API users must call in order to get exception clause events, in
a similar fashion to mono_profiler_enable_allocations (). Since this is a
breaking change, the profiler API version has been bumped.
Fixes#7525.
* [profiler] Remove the iomap_report event and associated code.
The IOMap profiler no longer exists, so we no longer need to expose this
somewhat hacky event.
* [profiler] Replace the old gc_event with gc_event2.
* [coop] Squash the thread state machine state numbering
In
https://github.com/mono/mono/commit/9767b8a55ec8be3fc46055d7a1e21b6894fd0fc5
we removed STATE_SELF_SUSPEND_REQUESTED
but left a hole in the state numbering, as a result, `state_name()` was off by
one (and falling off the end of the array).
* [coop] Renamed STATE_BLOCKING_AND_SUSPENDED -> STATE_BLOCKING_SELF_SUSPENDED
Noticed this while looking at Jenkins logs today:
```
15:00:56 /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/lib/net_4_x/mscorlib.dll
15:00:56 cant resolve internal call to "System.MathF::ModF(single,single*)" (tested without signature also)
```
We need to use `single` in the icall def instead of `float`.
It was introduced by https://github.com/mono/mono/pull/7941
Using `Task.Delay (timeout)` has the potential of possibly allocating and holding large
chunks of memory throughout the timeout period. While this is not strictly speaking a
memory leak because those objects will eventually be disposed and garbage collected, it
can cause memory usage of apps to grow quite significantly in the short run.
The default timeout values are as follows:
* `HttpWebRequest.ReadWriteTimeout`: 5 minutes.
* `HttpWebRequest.Timeout`: 100 seconds.
* `ServicePointManager.MaxServicePointIdleTime`: 100 seconds.
And these values can be increased by the user. This means that we're potentially holding
hundreds, maybe even thousands of timeout objects in memory for 5+ minutes.
This has now been fixed by using the `Task.Delay(int,CancellationToken)` constructor.
Note that disposing a `CancellationTokenSource` will not cancel it, so the following code
will still leak:
using (var cts = new CancellationTokenSource ()) {
Task.Delay (TimeSpan.FromDays (3), cts.Token);
// Work
}
To actually make the `Task.Delay` instance go away when we're done with it, we need to
use this pattern:
var cts = new CancellationTokenSource ();
try {
Task.Delay (TimeSpan.FromDays (3), cts.Token);
// Work
} finally {
cts.Cancel ();
cts.Dispose ();
}
We also cannot use `CancellationToken.CancelAfter()` for timeouts because unfortunately
some of the underlying framework code that we're using does not honor cancellation
requests - like for instance `NetworkStream`.
This is a partial fix for #7356. While this commit significantly improves the problem,
there may be other unrelated issues left that needs to be investigated.
Output formatting is now delegate to a `Formatter` subclass. The default
one remains HTML with `HtmlFormatter` so any script should not see any
difference.
The output file is largely identical, except a few whitespace changes
that could not easily be avoided and how modified base types were
reported, since that was different from the rest.
The big change is the `--md` option which can output markdown, which
is the format to use from docs.microsoft.com. There are less options
available, e.g. colors, so additions are rendered using the `csharp`
blocks, while modification are rendered as a `diff` block.
Each assembly output is made to be easy to re-assemble into a single
document if needed, e.g. https://github.com/xamarin/xamarin-macios/pull/3814
* [coop] Include function names in coop state change assertions
i.e. better reporting here:
https://jenkins.mono-project.com/job/test-mono-pull-request-coop/2298/parsed_console/log.html
***** MonoTests.System.Runtime.Remoting.RemotingServicesTest
***** MonoTests.System.Runtime.Remoting.RemotingServicesTest.Bug46473
Assertion failure in thread 0x7f21a504b740 due to: Cannot transition thread 0x7f21a504b740 from STATE_BLOCKING with DO_BLOCKING
Last 3 state transitions: (most recent first)
[DO_BLOCKING] RUNNING -> STATE_BLOCKING (0) 0 at:
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ef31a) [0x560336a6f31a]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2eb477) [0x560336a6b477]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ec7a2) [0x560336a6c7a2]
at /mnt/jenkins/workspace/test-mono-pull-request-coop/mono/mini/mono(+0x2ec7e6) [0x560336a6c7e6]
This will provide one function instead of 0 or n, and could be expanded to include more.
This bloats shipping binary some (under condfigure only) which can be addressed with
an #if that conditionally turns the strings to null or empty. And slight code bloat.
Note that JIT and products and test use all this stuff and are left compatible and unchanged.
Previously:
foo(gpointer *stackdata)
{ ...
}
stackdata pointing to uninitialized, and not even size-specified
is now:
foo_internal(MonoStackData *stackdata)
{
...
}
foo(gpointer* stackpointer)
{
MonoStackData stackData = { &stackdata, __func__ }; // define MONO_STACKDATA
stackdata.stackpointer = stackpointer; // replacing &stackdata
foo_internal(&stackdata);
}
with __func__ being a known-inaccurate standin for the caller.
If products/JIT/test evolve, flags to indicate which fields are present are likely in order.
Currently only the top function is printed, but we can likely store them longer.
As well running the debugger will help.
backtrace library could also be expanded. Currently it finds symbols on Mac but not Linux.
* [Tailcall] Disable tailcall-virt.exe tailcall/fsharp.exe per-arch instead of !AMD64
so we can whittle away at it.
* [Tailcall, arm64, jit] Make mono_arm_emit_destroy_frame flexible
as to if ip0 or ip1 (or both) is temporary. This isn't strictly necessary as caller
can carefully chose the correct one, i.e. ip0.
* [Tailcall jit arm64] Add virtual tailcall support to ARM64 (OP_TAILCALL_MEMBASE).
It could be either "interleaved" with regular tailcall support as done here,
or split up into a separate case. The level of code sharing with interleaving
is not huge.
* [Tailcall] Spell out 'membase' as 'tailcall_membase' for clarity.
Remove extra "shadowed local" MonoCallInst *call and use
the other one. It achieves the same thing in this case
and helps debugging experience. Alternative would be
to rename the second one to "tailcall".
* [Tailcall] x86 tailcall_membase support (i.e. for virtual now, interface later)
* [Tailcall] Be sure not to tailcall interface calls on ARM.
* [Tailcall] More debugprinting.
* [Tailcall] arm64: allow floating point through (but only full registers)
arm, x86, amd64: require caller and callee return storage to match (arm64 already did)
Cleanup and debugprint.
* [Tailcall test] Always get hugeint (recursion depth) via function call,
so we can edit it one place.)
* [Tailcall] Add a FIXME for returning structs that can be made to work.
* [Tailcall test] Turn the F# test into three variations:
deeptail same as original -- failure mode is stack overflow
shallowtail which tailcalls but not to great depth -- it won't stack overflow
and so it should have no other failure, but make sure -- for example
this might still struggle on arm and we might split it up further
shallownotail which is really should be nothing special
In this commit, all three are the same -- copy w/o edit.
* [Tailcall test] Make shallow in two tests and remove tail in one.
* [Tailcall test] Disable deeptail TailCallLoopGenericClass<DateTime> for all architectures.
It fails on x86 and arm64. It passes on amd64. arm tbd.
* [Tailcall test] Enable F# tests for x86 and arm64 (three internally are disabled for all architectures, one of which passes for amd64).
* [Tailcall test] Every configuration should be able to run the shallow/notail F#/tailcall tests.
They don't depend on tailcall, but either correctness w/ or w/o tailcall,
and if they do fail, it is not due to stack overflow.
* [Tailcall test] Fix .assembly directive to make some tailcall tests AOT compatible.
* [Tailcall] Dial back debugprint bloat after merge.
it won't be scanned by the GC, defer string allocation to execution-time instead.
this fixes a GC crash when running mini regression suite on iOS/arm64.
OS: Ubuntu 18.03
CMake: 3.10
For some reason cmake fails to detect any make program (be it ninja or make)
when cross-compiling for Android in XA. It happens despite the programs being in
$PATH and working correctly. The effect is that CMAKE_MAKE_PROGRAM is set to
"not found" in CMakeCache.txt and configuration fails as follows:
Call Stack (most recent call first):
external/mono/external/boringssl/util/android-cmake/android.toolchain.cmake:1140 (CMAKE_FORCE_CXX_COMPILER)
external/mono/sdks/builds/android-armeabi-v7a-debug/mono/btls/build-shared/CMakeFiles/3.10.2/CMakeSystem.cmake:6 (include)
CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
This commit does not fix the issue, per se, but it works around it by finding
the first ninja/make (as configured) executable in $PATH and setting the
CMAKE_MAKE_PROGRAM to full path of the executable. I haven't spent too much time
investigating *why* cmake fails to find the executable (I merely ran it with
--trace-expand --debug-output which revealed nothing of consequence) but this
workaround should be safe for any version of CMake and any OS we use makefiles
on.
* [gc] Silently ignore mono_gchandle_free(0) so callers do not have to check.
* [threads] Take advantage of mono_gchandle_free(0) being nop (a few extra instructions
in dynamic path for when it is 0, same path length if it is not 0).
* [threads] Restore one if, it isn't clearly correct otherwise.
This pull request brings support to Mono's class libraries for the new `System.MathF` type which includes operations for single-floating point.
This is needed to run some new applications like:
https://github.com/aras-p/ToyPathTracer
With this change, it is possible to run this unmodified. With this support, and the `-O=float32` option, it is possible to improve the performance from 6.3Mrays/sec to 7.8Mrays/sec on a Mac.
Oddly, this seems to be faster than .NET Core 2.1.4, which is at 4.2Mrays/sec.
* Bump API snapshot submodule
* [wasm][corlib] Disable some tests that don't work with WASM.
* [wasm][corlib] Disable IO test that requires threading.
* [wasm] Disable parallelism when building the wasm runtimes. Fixes CI build.
* [wasm] The incremental test runner can now skip tests in bulk.
* [wasm] Address reviewer feedback.
Current build uses `tar` to extract ZIP archives. This works with BSD
tar but not with GNU tar, alas. Tar was used in order to strip the root
directory of Android archive while moving files into place. This commit
replaces `tar` with a call to a shell script (because doing what it does
using Make defines is an exercise in pain) which works both on macOS/BSD
and on Linux.
* [Tailcall] Dial back single -v output, and enable under MONO_DEBUG=tailcall, and -v -v.
* [Tailcall] MONO_LOG_LEVEL=debug MONO_LOG_MASK=tailcall and mono_trace instead of mono -v -v and g_print
This fixes `test_0_simple_double_casts` on iOS/arm64.
According to the C standard (section [conv.fpint]), the behaviour of
such a cast is undefined if the truncated value doesn't fit into the
destination type.
```c
unsigned char __attribute__ ((noinline)) convr8u1 (double i)
{
return (unsigned char) i;
}
```
for arm64, `clang -O0` produces:
```
_convr8u1:
100006848: ff 43 00 d1 sub sp, sp, #16
10000684c: e0 07 00 fd str d0, [sp, #8]
100006850: e0 07 40 fd ldr d0, [sp, #8]
100006854: 08 00 78 1e fcvtzs w8, d0
100006858: 00 1d 00 53 uxtb w0, w8
10000685c: ff 43 00 91 add sp, sp, #16
100006860: c0 03 5f d6 ret
```
while `clang -O2` produces:
```
_convr8u1:
100006ae8: 00 00 78 1e fcvtzs w0, d0
100006aec: c0 03 5f d6 ret
```
which is fine according the standard: Any value < 256 gets casted just
fine, but for example `convr8u1 ((double) 0xffff)` would end up with
`0xffff` in `w0`.
We workaround this behaviour by casting to a 32bit int first, the
resulting code looks like this then:
```
_convr8u1:
100006ae4: 08 00 78 1e fcvtzs w8, d0
100006ae8: 00 1d 00 12 and w0, w8, #0xff
100006aec: c0 03 5f d6 ret
```
* [Tailcall] Require an exact match on return type. Sometimes this makes sense (float<=>double), sometimes
it is a little overly restrictive (integer truncation, I <=> I[48])
* [Tailcall] Disable CoreCLR tests that have mismatched return types.
[mini] Introduce MonoEEFeatures with a single feature use_aot_trampolines.
MonoEEFeatures is meant to replace the mode flag soup with have.
Each feature is supposed to be checked alone and descriptive enough of the underlying behavior.
use_aot_trampolines is a good example because the inter_aot_llvmonly mode could set it to false and
skip all the trampoline engine nonsense as trampolines are C functions.
Contributes to #7885
* [wasm] Switch wasm interp to not set use_aot_trampolines.
This allows the regular "JIT" tramp path be used instead of hacking our way around the AOT runtime.
* [mini] Introduce MonoEEMode to let us enumerate non-aot execution modes.
This lets us have all code setting up mono_ee_features in a single place.
* [Coop] Opportunistically remove some raw pointers.
Replace some uses of mono_thread_interruption_checkpoint with
mono_thread_interruption_checkpoint_void or mono_thread_interruption_checkpoint_bool.
* [Coop] Remove some more raw pointers opportunistically -- mono_thread_execute_interruption to mono_thread_execute_interruption_void.
* Fix warnings from old bad merge.
* Add another static.
* [coop] Remove more raw pointers.
* [sdks] Add provisioning for Android SDK and NDK
This will also be used by XA
* Add missing backslash to mxe.mk
* Only grab bin/autopoint
* [sdks] Use provisioning for MXE
We want to treat MXE the same way we do Android SDK and NDK because it only rarely changes, and it's very long to build it.
* WCF: ChannelDispatcher/ListenerLoopManager.Setup validate InstanceProvider, not InstanceContextProvider
- the creation of endpoints requires an instance provider or a default constructor
- InstanceProvider vs InstanceContextProvider was obviously a typo
* include InstanceContextProvider for validation as before
- two unittests failed due InstanceProvider is null and ed.DispatchRuntime has not type set
- comment for the validation is not useful anyway (It is tested at Open(), but strangely it is not instantiated at this point.)
* [Facades] Add System.Memory facade to mobile profiles
Contains only the types we have right now.
Fixes https://github.com/mono/mono/issues/7610
* Bump API snapshot submodule
In 38a348c991 we got rid of
mono_threads_transition_reqest_self_suspension. So there is now no way to
enter into STATE_SELF_SUSPEND_REQUESTED, so we no longer need to have cases for
transitioning out of it.
It's done by ifdef'ing WASM because I don't see a way to change Environment.Platform / Environment.OSVersion without touching the public API.
Right now OSDescription is being used to return the execution environment. Once we properly support node and other non-web embeddings, it will be adjusted to do so.
* [runtime] Fix class visibility check for protected nested classes. Fixes#7657.
A nested class that has protected access must be checked using the same inheritance based rules as members.
The existing code ignores that and does a plain visibility check that is only amendable for public/internal nested types.
* [runtime] Add regression test for nested famility visibility.
* [runtime] Add a --disable-btl-lib configure option to disable the building of the btls lib, but compile the managed code with btls support.
* Disable building btls/ and support/ on the bcl build, they are not needed.
* [Tailcall] Copy some tests from CoreCLR.
* [Tailcall] Copy and build some tests from CoreCLR.
* [Tailcall] Add mono --test-tailcall-require switch
that asserts that every tail. is honored.
Add some tailcall output under -v.
* [Tailcall] Switch tests/coreclr/tailcall to tests/tailcall/coreclr
on the theory that this is where additioanl tailcall tests will go,
not that is the coreclr test area.
Also remove leading "./" which did afford easier search/replace
but will likely be seen as noise, and might break out of tree builds.
* [Tailcall] update readme
* [Tailcall] Tweak logging and first working Makefile, w/o disabled tests.
Next step is try to restore parallelism.
* [Tailcall] Add indent and fix check-tailcall to be parallel and incremental.
* [Tailcall] Out of tree builds just need mkdir.
* [Tailcall] Remove accidental content.
* [Tailcall] Undo fix for out of tree builds.
* [Tailcall] Use environment variable MONO_DEBUG in place of command line parameter despite
environment variables having problems and being banned in other contexts.
Accept and ignore empty MONO_DEBUG option so that ",foo" can be appended without
first checking for empty -- without having to learn how in another language.
Use g_print instead of printf in new code, i.e. for Android debugger.
Remove newlines to restore unreadability/unmergability.
Make running tailcall tests not incremental by default but leave I= to make it incremental.
Add comments indicating "tailcalllog" is a public interface, not to be changed
without changing its users.
* [Tailcall] Resolve a recent "FIXME".
* [Tailcall] Compile but do not run the C# tests.
* [Tailcall] Split disabled compile from disabled run, and compile the last of the tests.
Disable compile remains, because one of the tests contains 3 files, and putting
the three sources in the sources variable (for distribution) implies building them each separately.
Disable compile is used to remove two of them from compiling independently
and then another dependency rule makes them compile together.
* [Tailcall] Follow convention without incrementality and less verification.
* [Tailcall] Disable new failing tests on x86/arm/arm64 and Linux/amd64.
* [Tailcall] Disable more tests for x86 and sort the lists.
* [Tailcall] Move from .NET Standard to mscorlib see if that works better.
* [Tailcall] Add missing build dependency.
* [Tailcall] Do not compile tailcall/coreclr/JIT/opt/Tailcall/TailcallVerifyWithPrefix.exe for
FullAOT. Compiling it fails an assert where it is supposed to raise an exception. Fix later.
* [Tailcall] For now, do not run any CoreCLR tailcall tests with FullAOT.
--compile-all fails an assert there. Instead we have to find what can run, and don't use --compile-all.
* [Tailcall] Disable all CoreCLR tests under FullAOT. Some fail to tailcall.
Many work, w/o assertion failure and printing success, but none exit with 0 exit code.
* [Tailcall] Add clarifying comment.
* [Tailcall] Add two opportunistic tail. prefixes.
add some OpenBSD patches
Hi,
A few trivial additions of OpenBSD to ifdefs, plus the change of the abort signal to SIGUSR1 which fixes the SIGABRT problem (other compilation problems remain). SIGTTIN is broadcast to the process group which leads to the SIGABRT (at least on OpenBSD).
The original design review is here: dotnet/corefx#22866 . To summarize, this adds a new flag to `BindingFlags` called `DoNotWrapExceptions`. When this flag is used to invoke a method using reflection, any exceptions thrown are not wrapped with a `TargetInvocationException`.
It has already been implemented in some other version of .NET:
- dotnet/corert#4437
- dotnet/coreclr#13767
I would be delighted if this handy feature was also available in Mono.
I have in part based my changes on the CoreCLR implementation. There all already tests for this feature in corefx, so I have added those to the corlib_xtest.dll.sources file.
I have a couple of concerns about my implementation:
- I notice that `DynamicMethod.Invoke` was ignoring the BindingFlags and other arguments. I changed this method to pass along all the arguments. For what it's worth, it appears that [CoreCLR respects](https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs#L488) these arguments.
* [sdks] Pass LLVM_SRC from XA to use `xamarin-android/external/llvm`
We do not clone to `$(LLVM_SRC)` because this is up to XA.
* [sdks] Pass IGNORE_PACKAGE_MXE from XA
This is to avoid rebuilding MXE while XA already took care of it.
* [sdks] Only checkout specific MXE and LLVM commit when cloning
It is enough to check for iconv
dependencies once in the eglib/configure
- just use the generated libtool
library file to automatically
add additional dependencies (if any).
While here, make sue libeglib.a
has libraries returned by LTLIBTOOL
as a libtool dependency.
* [genproj] Move obj to common folder and remove unnecessary properties
We now default to mcs/class/obj instead of writing to the assembly folder.
* [genproj] Fix jay path on Unix
* [genproj] Fix IntermediateOutputPath for Facades
* Add some PerformanceCounter test code from reference source and MSDN,
combined and lightly edited per local conventions.
* Restructure PerformanceCounter code for type safety and fix incorrect typing.
* [monograph] Don't link duplicate copies of metadata and utils
Monograph builds against mono/mini/($LIBMONO_LA) (aka libmonosgen-2.0.la), so
the only pieces it would pick up from staticlly linking the extra libs are
non-API functions (such as the MonoClass getters), but at the cost of linking
errors due to duplicate symbols.
Also replace calls to MonoClass getters by mono API functions.
* [ilgen] Fixup MonoClass getter usage
Followup for e610e443cd
* [boehm] Fix a few direct MonoClass accesses
* [monograph] Statically link against the mono runtime
Dynamically linking but using some symbols (such as mono_read32) on some
platforms that are hidden in the library means that we had to statically link
against the runtime anyway, which then caused build issues.
* [monograph] Fix runtime crash on startup
```
mono_os_mutex_lock: pthread_mutex_lock failed with "Invalid argument" (22)
```
* [msvc] Fix monograph build
* [runtime] Rework how the native-to-managed eh callback is called.
Instead of catching all exceptions in the native-to-managed wrapper and calling the callback from the catch clause, call it directly from the EH code. The
previous approach caught all exceptions, which messed up debugging, since the debugger wouldn't break on uncaught exceptions raised from native-to-managed
callbacks.
* [coop] Enable tests bug-58782-plain-throw and bug-58782-capture-and-throw for PRs
* [mini] Installed native-to-managed exception handling callback from second pass.
The constraints are:
1. We must allow managed exceptions to be caught and finally blocks must run
2. We must not call the unmanaged exception handler if the first unwinding pass
detects that there is a native-to-managed wrapper and a callback is
installed that will handle managed exceptions (by unwinding the native code
and either re-raising the managed exception or otherwise dealing with it).
So we change the return value of handle_exception_first_pass to be:
- MONO_FIRST_PASS_HANDLED - caught by a managed frame (with a matching filter if one was present).
- MONO_FIRST_PASS_CALLBACK_TO_NATIVE - there's a native-to-managed wrapper and a ftnptr_eh_callback is installed.
- MONO_FIRST_PASS_UNHANDLED - first pass unwound all the way and there was no wrapper or there was no callback installed.
In mono_handle_exception_internal, we treat MONO_FIRST_PASS_CALLBACK_TO_NATIVE
as handled and unwind the managed stack, invoking finally clauses as we go,
until we reach the managed-to-native frame, at which point we invoke the callback.
* [test] Test for mono_install_ftnptr_eh_callback
* [test] AOT-friendly test for mono_install_ftnptr_eh_callback
* [sre-save] Remove type_token assignment in mono_image_fill_export_table
In 9725d50c87 we added the `g_error`, that should
fire if the MonoClass:type_token and the TypeBuilder token ever disagree. As a
result, this assignment is strictly redundant.
* [pedump] Use MonoClass getters
* [monograph] Use MonoClass getters
* [mini] Use MonoClass getters in a few more places
Catch up with recent commits.
In 9725d50c87 we added the `g_error`, that should
fire if the MonoClass:type_token and the TypeBuilder token ever disagree. As a
result, this assignment is strictly redundant.
Adopts a linked list of MonoW32HandleSlot (based on feedback from Rolf Kvinge). This allows for an unlimited amount of handles to be allocated, as well as for a lower cost to allocate only 1 handle across the process.
Fixes https://github.com/mono/mono/issues/7460
This implements a simple deduplication of source files in the .csproj's.
A postprocessing step opens the files and grabs all ItemGroups with sources
and then does an intersection. It then moves files that are common
across all platforms into a separate ItemGroup.
* Fix warning: Add static.
* Fix warning: Remove unused function from a recent incorrect merge/rebase.
* Fix warning(s): Cast away const.
* Add static to avoid global link-namespace pollution.
* Add const on input strings.
* (void) and () are not the same in C, overwhelmingly you want (void)
{0} does not portably zero unions, so favor memset
braces at start of function go on their own line
space before parens on function calls
spaces around binary operators
favor memset (x, 0, sizeof(x)) instead of memset (x, 0, sizeof(type))
favor TRUE/FALSE over true/false unless/until we switch to C++
This batch of commits makes further updates to our support for building the BCL using msbuild (Visual Studio, to be specific).
* Generates a single sln and set of csproj files with support for all of our build profiles (orbis, monodroid, net_4_x, etc)
* Project configuration selector (in VS or as parameter to msbuild) can be used to select which profile to build
* Includes partial dependency information so that culevel and jay are compiled before the rest of the sln (this keeps pre/post events from from failing on first build)
As of this rev things are working pretty good, but a lot of the measures I took here are temporary so I'd appreciate thoughts on how to go about them. The hard-coded System.Web -> Culevel dependency feels gross, for example - I kind of want to go through and build an automatic solution for it but I'm not sure it's necessary.
Implements #6858
---
* Checkpoint: Generate single .csproj file with conditional item/property groups
* Checkpoint: Updates to csproj and sln generation to support building specific profiles
* Move targets file in csproj template so that it isn't evaluated before all properties are set
* Checkpoint profile fallback (use net_4_x if project does not have appropriate profile)
* Use in-process cache for project guids to fix bug where many guids were being generated. Fix profile fallback.
* Clean up unnecessary debug writelines
* genproj error fixes
* Remove duplicate gacutil entry from makefile to fix order.xml corruption. Cleaner project names in msbuild sln. Compile genproj before generating inputs.
* Delete genproj.exe at beginning of update-solution-files because otherwise syntax errors will cause an old version to be used silently
Cleaner messages from genproj
* Hard-code the guid for culevel and add it as a dependency for system.web
* Bug fixes
* sln files are sensitive to whitespace format
* Don't generate pointless solution configurations if we have no information for them
* Updates based on PR feedback
Contributes to #7682
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=12850
FtpWebRequest used to work incorrectly with sub directories.
Let's say we have a following FTP structure
```
myserver
├── file1
└── subdir
└── file2
└── file3
```
Old behavior:
### 1) For `ftp://myserver/subdir/` printed:
```
file2
file3
```
Expected:
```
file2
file3
```
### 2) For `ftp://myserver/subdir` printed:
```
file1
subdir
```
Expected:
```
subdir/file2
subdir/file3
```
### 3) For `ftp://myserver/subdir/file2` printed:
```
file2
file3
```
Expected:
```
file2
```
With the fix in this PR it works as expected (matches netfx and netcore behaviors).
* [mini] Don't wait for other threads to finish JITing if the current thread is running a cctor.
This eliminates a possible source of deadlocks found during AOT runs of Roslyn.
* [mini] Introduce a 1s timeout to JIT job control to ensure we don't simply deadlock in case of execution dependency bugs.
* [mini] fix spelling5DD
* [metadata] Use getters in a few ilgen files
* [mini] Use MonoClass getters in several files
* [mini] Use MonoClass getters in mini-generic-sharing.c
* [debugger-agent] Use MonoClass getters
* [monodis] Use MonoClass getters in get.c
* [Tailcall] Add but do not use the F# tailcall test suite.
* [Tailcall] Compute inst_tailcall much earlier, it is cheap, and it will be used more and earlier.
* [Tailcall] Compute supported_tail_call and tail_call earlier.
* [Tailcall] Fix virtual generic methods that F# test TailCallLoopGenericClassAndMethodAbstractClass<byte>.Method3<byte> uses.
There is a general problem of customized code paths missing pieces.
This fixes just part of it.
* [Tailcall] Use common code for removing ret after tailcall, and not handling return value.
* [Tailcall] Cleanup.
* [Tailcall] Short circuit looking at parameters for has_vtargs.
* [Tailcall] Tailcalls presumably do not need sequence points, or anything, after them.
* [Tailcall] Fewer labels, more booleans, move existing label up, with additional booleans
controlling its behavior -- intent is to tease one altered behavior (tailcall of
virtual generic) and one existing and one new sharing of common code (remove_ret).
Longer term might have more tailcall handling.
* [Tailcall] F# tests closer to original.
* [Tailcall] Add the F# tests in blob form.
comment out the two failing tests
fsharpc --standalone --optimize- fsharp.fs
monolinker fsharp.exe to trim a little
change resource-using code to use constant strings
* [Tailcall] CI fails roughly where local passes.
* [Tailcall] Merge fsharp.fs into fshar.il as a comment.
* [Tailcall] Cleanup, remove unused labels, etc.
* [Tailcall] Cleanup test code some.
* [Tailcall] Cleanup.
* [Tailcall] Try harder to disable fsharp for AOT due to CI failures.
The only user was Xamarin.iOS in a weird way: The define is only set for
device builds where the icall table is excluded anyway. For the cross
compiler however, the define isn't set, and therefore those icalls can
be resolved by the AOT compiler.
With the interpreter now, this define actually had an effect: The
guarded icalls weren't inclueded in `libmono-icall-table.a`.
* [mkbundle] Automatically bundle config files and machine.config files for the simple/cross compiler scenario, fixes one of the missing issues for #6230
* Remove debug writeline
* Remove outdated information
* Bump API snapshot submodule
* [interp] Handle mono_handle_exception () returning a ctx which refers to JITted code by restoring the context.
* [aot] Clear the pinvoke flag from the interp_in wrapper signatures, so they get an lmf in mini_get_interp_in_wrapper (), this is needed for mixed-mode exception handling.
* [aot] Change the semantics of the 'interp' option, use it only to emit additional interp wrappers etc. instead of disabling code generation as well.
* [aot] Emit more interp-in/interp-out wrappers when using --aot=full,interp.
* Add a --interp=interp-only= command line option, used for testing.
In full-aot+interp mode, prefer full-aot code instead of interp code, except for methods in the classes listed
in the interp-only option.
Use normal runtime invokes in full-aot+interp mode.
* [interp] Prefer AOTed code when making calls out of interpreted code in full-aot mode.
* [aot] When running with --aot=interp, preserve the previous behavior of only emitting interp wrappers and trampolines.
* Revert "[Tailcall] Quick fix for building F#. Do not tailcall any method with a vtable_arg. (#7609)"
This reverts commit 8ceead93e3.
* [Tailcall] Correct fix for regression from change b4ee86154f.
Regression test not yet available.
* extra brace
* [Tailcall] Add FIXME for tail. not followed by ret. Correct behavior is to raise an exception, not fail an assert.
* [Tailcall] Add disabled debug code to break when compile a tailcall and/or execute a tailcall.
* [Tailcall] Add disabled debug code to try to tailcall any call followed by a ret.
This might be reasonable in the future, as well as a little data flow
analysis skipping nops and branches, as csc w/o -optimize outputs.
* [Tailcall] Add more tailcall tests, i.e. that would
have caught recent regression.
* [Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,
tailcall_all. Consider MONO_TAILCALL_DEBUG instead.
* Revert "[Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,"
This reverts commit 796d9490f672625189dfac47ff24b05f3fb65cbe.
* [Tailcall] Replace #if 0 with ifdefs:
define DEBUG_TAILCALL_BREAK_COMPILE breakpoint in method-to-ir
define DEBUG_TAILCALL_BREAK_RUN 1 codegen outputs breakpoint
define DEBUG_TAILCALL_TRY_ALL 1 consider any call followed by ret, can expand later
define DEBUG_TAILCALL 1 low volume logging under -v instead of -v -v
* [Tailcall] Dial back tailcalls on ARM32, where there is no
volatile non-parameter register in the ABI, in which to pass
an extra parameter. (Why not just pass as a regular first/last parameter?)
* [Tailcall] Dial back untested architectures MIPS S390x PowerPC SPARC.
* [Tailcall] Copy tailcall-generic-cast-il.il to tailcall-generic-cast-nocrash-il.il and tailcall-generic-cast-conservestack-il.il
All platforms should be able to run it without crash,
but only some can run it and conserve stack.
* [Tailcall] Finish splitting tailcall-generic-cast into nocrash and conservestack variations.
All platforms can run nocrash, only some conservestack.
* [Tailcall] Nested if and ifdef in certain order do not render well in some editors, so just use if.
* [Tailcall] Fix typo.
* [Tailcall] Disable tailcall-mrgctx.exe and tailcall-rgctxa.exe on ARM32 MIPS PowerPC due to MONO_ARCH_HAVE_VOLATILE_NON_PARAM_REGISTER=0 SPARC has no disabling.
ARM32 is very difficult to fix, maybe not possible.
The other architectures are not tested, so the progress is not enabled.
process_breakpoint() will process breakpoint, stepping, and method
exit/entry events all at the same time when checking a sequence point.
So, if there is is a breakpoint and a stepping event at the same time,
the debugger agent will suspend the current thread twice, which means
you have to click the step button in the debugger client twice on that
line. Considering only one of these events at a time seems to fix
the issue without breaking any current unit tests or showing any other
noticeable issues in testing.
* Fix bug #60843 and add test:
If an enum was nested inside a generic class, using it as an argument to a custom attribute would cause a runtime error in the custom attribute decoder. Update the decoder to forward this special case through the normal primitive loading path.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60843
* Update based on PR feedback
* Don't use caller info attributes since FullAOT does not have them
* Revert "Don't use caller info attributes since FullAOT does not have them"
This reverts commit 316afb686363ef0e46c15d5858bbc1b85ffd5264.
* Fix embarassing bug in test case
* Update outdated test category name
* Disable bug 60843 test in interpreter
In commit 8ba48b5a41
mono_string_new was adjusted to only assert for
out of memory rather than all errors to preserve
previous behavior for invalid strings. This
change preserves behavior for mono_string_new_wrapper.
This commit allows customization of WCF service creation via the Factory attribute in an .svc file:
`<%@ ServiceHost Language="C#" Service="CustomService" Factory="CustomServiceHostFactory" %>`
All the patch does is uncomment a few lines that were already there and fix a small error. I am not sure why these lines were commented. Possibly the code is not sufficiently robust or it was just never given another look. But this works for me and it seems better than no support at all. For example, a custom ServiceHostFactory appears to be the only way to create a WCF service in a managed host which customizes EndpointDispatcher.AddressFilter and EndpointDispatcher.ContractFilter. This in turn is useful for proxied WCF services.
See also http://mono.1490590.n4.nabble.com/Mono-WCF-ServiceHost-Factory-option-td4251992.html (from 2012; never posted on the mailing list for some reason).
The previous code was handling only objects residing in 2 32bit card protected address spaces. This means card table scanning for objects larger than 4GB was potentially broken, while card scanning of objects larger than 8GB was completely broken.
Fixes https://github.com/mono/mono/issues/7537
[threads] Delay abort via handler block guard when in abort protected block.
`mono_install_handler_block_guard` is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
Fixes#7588
The latest `WebCompletionSource<T>` changes (PR #7358) exposed and
intensified the side-effects of a race condition between `WebOperation`
and `ServicePointScheduler`.
* WebCompletionSource<T> now contains new `CurrentResult` and `CurrentStatus`
properties, which allow completion status to be checked in a non-blocking way.
* WebOperation.CompleteResponseRead() has been renamed into Finish() and
contains the continuation that was previouly known as FinishReading().
Calling this new Finish() method will now complete the `finishedTask`
completion, which has a new accessor called `Finished`.
* The ServicePointScheduler's main-loop is still woken up by completion of
`WebOperation.Finished.Task`, but we use the new `CurrentResult` property
to check state in a non-blocking way. This ensures the the clean-up and
bookkeeping work that's necessary after `WebCompletion.Finish()` always
happens prior to starting new connections.
* [w32file] remove unused mono_w32file_get_times ()
* [w32file-unix] replace SECMULT with TICKS_PER_SECOND
* [w32file-unix] use CONVERT_BASE in more places
* [w32file-unix] factor setfiletime
* [w32file-unix] use utimes if available in order to set subsecond information on access and write time
* [FileTest] add regression test for github issue 7646
* [w32file-unix] reduce compiler warnings
* [w32file-unix] 1000ns = 1us and 1us = 10ticks
* [w32file-unix] add LL suffix to constant in order to prevent overflowing on 32bit systems
* [loader] Don't load framework Facade assemblies that are older than expected.
If there is an older framework Facade assembly in the search order before the
one that we want, don't load it.
"older" here means just compare the major components of the version.
Fixes https://github.com/mono/mono/issues/7624
Even though it's found during configure when targetting 10.7, it's not "really" available before versions 10.12 and it would crash with "lazy symbol binding failed".
When mono is used as a submodule then .git will be a file instead of a
directory. Adjusted the version.h generation code to support that.
Also newer git version started to use `(HEAD detached at <git sha>)`
in `git branch` output instead of `(detached from <git sha>)`,
fixed the regex to support that pattern too.
* [Tailcall] Cleanup is_supported_tail_call to only check virtual_, not opcode == CALLVIRT.
* [Tailcall] Generate tailcall address earlier to honor NT ABI.
Let R11 through tailcall.
Assert alignment when patching.
* [Tailcall] Factor out two copies of SysV varargs handling to a helper function and remove for NT.
Tailcall needs a third instance, and it likely gets in the way of NT tailcall, where it is not needed.
* [Tailcall] Teach amd64_patch how to patch jmp rip+32 and jmp [rip + 32]
very similar to call rip+32 and call [rip + 32]. This might be useful.
* [Tailcall] Fix varargs handling of tailcalls.
* Remove new asserts and just leave comments.
* [Tailcall] No need to free RAX on non-reg calls.
send an internal VM_DISPOSE command to shut down the debugger thread
properly. This prevents runtime hangs that occur during profile
events after the debugger shuts down.
* Fix bounds manipulation in Control.DrawToBitmap and dispose objects properly.
* Add test for DrawToBitmap and fix one more bug in the implementation.
Fixes#7620
On macOS the stopwatch's elapsed time was regularly getting skewed by 200-800ms. On average, yielding decreases the number of GCs by only 25%, while the elapsed time error is always less than 15ms.
Fixes#6999
When a thread has a handler block guard installed (a `finally` block
that checks the exvar to see if it should issue abort the thread because
another thread called Abort on it), ves_icall_thread_finish_async_abort
is called. It must clear the handler block guard for the current thread
in case the abort landed while we're in an abort protected block (a
cctor, most commonly). In that case we must resume the interruption
when we leave all the abort protected blocks, not just at the end of an
intermitent catch clause.
mono_install_handler_block_guard is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
* Revert "[Tailcall] Quick fix for building F#. Do not tailcall any method with a vtable_arg. (#7609)"
This reverts commit 8ceead93e3.
* [Tailcall] Correct fix for regression from change b4ee86154f.
Regression test not yet available.
* extra brace
* [jit] Incorrect code under mono --trace.
* [Tailcall] call_opcode == CEE_CALLVIRT does not matter for tailcall_membase, only virtual_ does.
* [Tailcall] Add FIXME for tail. not followed by ret. Correct behavior is to raise an exception, not fail an assert.
* [Tailcall] Add disabled debug code to break when compile a tailcall and/or execute a tailcall.
* [Tailcall] Add disabled debug code to try to tailcall any call followed by a ret.
This might be reasonable in the future, as well as a little data flow
analysis skipping nops and branches, as csc w/o -optimize outputs.
* [Tailcall] Add more tailcall tests, i.e. that would
have caught recent regression.
* [Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,
tailcall_all. Consider MONO_TAILCALL_DEBUG instead.
* Revert "[Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,"
This reverts commit 796d9490f672625189dfac47ff24b05f3fb65cbe.
* [Tailcall] Replace #if 0 with ifdefs:
define DEBUG_TAILCALL_BREAK_COMPILE breakpoint in method-to-ir
define DEBUG_TAILCALL_BREAK_RUN 1 codegen outputs breakpoint
define DEBUG_TAILCALL_TRY_ALL 1 consider any call followed by ret, can expand later
define DEBUG_TAILCALL 1 low volume logging under -v instead of -v -v
* [Tailcall] Dial back tailcalls on ARM32, where there is no
volatile non-parameter register in the ABI, in which to pass
an extra parameter. (Why not just pass as a regular first/last parameter?)
* [Tailcall] Dial back untested architectures MIPS S390x PowerPC SPARC.
* [Tailcall] Copy tailcall-generic-cast-il.il to tailcall-generic-cast-nocrash-il.il and tailcall-generic-cast-conservestack-il.il
All platforms should be able to run it without crash,
but only some can run it and conserve stack.
* [Tailcall] Finish splitting tailcall-generic-cast into nocrash and conservestack variations.
All platforms can run nocrash, only some conservestack.
* Change the logic for closing ToolStrip drop-downs to work for more complex nesting.
* Implement SetOwner/GetParent(with_owner=true) behavior for X11 and Carbon backends.
Fixes the logic for closing ToolStripDropDowns for the following cases:
* ComboBox embedded in ToolStripDropDown as seen in KeePass when the window is resized to be small enough for the toolbar to overflow.
* ToolStripDropDown containing controls that open other ToolStripDropDowns and the user clicks on the top-level ToolStripDropDown. The child ToolStripDropDown, and only that child, should be closed in that case.
* Update AnchorLayoutEvents to match Windows behavior, make Bug82762 test platform independent.
* Cache affected layout control and property across SuspendLayout/ResumeLayout.
* Extend AnchorLayoutEvents test.
* Update for little nuances in the layout code.
* Unify flow layout for ToolStrips and FlowLayoutPanel by using the IArrangedContainer and IArrangedElement abstractions.
* Implement basic table layout support for ToolStrips.
* Clean up handling of FlowLayoutSettings.
* Fixes for default values of LayoutSettings in tool strips.
* Remove more of the duct tape holding the ToolStrip layouts together and replace it with calls into the LayoutEngine. Fix other small bugs that prevented ToolStrip overflows from being displayed correctly. Tested with KeePass.
* Fix indentation.
* Address code style issues.
* Remove unnecessary override.
* Fix indentation.
* Bump API snapshot submodule
* Fix error in vcxproj filter causing load error in Visual Studio.
* Fixes issue #7596 on Windows x64.
Passing value types in Windows x64 not fitting into register will be passed
by reference (ArgValuetypeAddrInIReg or ArgValuetypeAddrOnStack )
using a local variable allocated in caller’s frame.
Current implementation sized and marshaled the native struct correctly when
using pinvoke, but it sized the final local passed as reference to the native method
using the managed stack size instead of the native. This caused the final copy
into the local to overwrite other locals on stack if managed and native struct stack
sizes differed.
The fix is to flag the local variable used as stack parameter with its pinvoke state.
This makes sure the stack allocation size will be correct when using value types
passed on the stacks in pinvokes.
When running other unit tests with sequence points I hit a similar issue with
empty structs as return parameters (using [StructLayout (LayoutKind.Sequential, Size = 0)].
This commit includes a fix to ignore the return value if it’s an empty struct on Windows x64.
* [sgen] Use current nursery size when computing allowance
The allowance is the minimum heap growth that we allow between two majors (which is 4 * nursery_size). We need to use the current nursery size instead of the 4MB default, in order to facilitate low memory uses.
* [sgen] Account for soft heap limit in allowance calculation
This is relevant in cases where the nursery size and soft heap limit are comparable in size.
* [profiler] Fix wrong docs for mono_profiler_set_call_instrumentation_filter_callback ().
* [mini] Don't inline methods if they're going to be instrumented for coverage.
This handles coverage instrumentation in a similar fashion to call
instrumentation.
Fixes#6186.
* [mini] Add MonoError to mini_get_shared_method_full and replace bucket of booleans with a flags enum.
* [mini] Eliminate mini_get_shared_method in favor of the variant that takes a MonoError.
* [mini] Rename GetSharedMethodFlags members to follow our coding conventions.
* [mini] Remove reduntant arguments in get_shared_inst.
* [mini] Inline partial in mini_get_shared_method_full.
* [mini] In mini_get_shared_method_full, rename gsharedvt to use_gsharedvt_inst and move it's value to depend on all_vt.
* [mini] Eliminate SHARE_MODE_ALL_VALUETYPES as its semantically equivalent to SHARE_MODE_GSHAREDVT.
* Fix platform-specific build issues
These changes allow some of the Mono code used by the debugger to build
on a few additional platforms. Specifically, this includes platforms:
* That don't have access to the full Win32 API
* That don't have access to the full Posix API
* That don't support IPv6
* Wrap `access` and `_access` in `g_access`
* Convert indentation to tabs
* Wrap `mktemp` and `_mktemp` in `g_mktemp`
* Wrap `open` and `_open` in `g_open`
* Wrap `write` and `_write` in `g_write`
* Fix indentation
* Use proper asserts
* Add a configure check for `access`
* Remove the use of HAVE_XBOXONE_WINAPI_SUPPORT
* Replace the previous definition of `g_open`
I missed that it was here in my earlier commit, and ended up redefining
it.
* Use `g_error` instead of `g_assert(0)`
* [Tailcall] Quick fix for building F#.
Do not tailcall any thing with a vtable_arg.
This does often work, but not in F#, along with unbox in the call target.
The problem is being further reduced and debugged, but this will serve for now.
Regression is from change b4ee86154f.
* [Tailcall] Temporarily disable tests that depend on tailcall.
* [Coop] ves_icall_System_Threading_Thread_GetDomainID convert to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_ConstructInternalThread to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Thread_internal to coop/handle.
* [Coop] Convert mono_threads_get_max_stack_size ves_icall_System_Threading_Thread_SystemMaxStackSize/typo SystemMaxStackStize to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Suspend to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_SpinWait_nop to coop/handle.
* [Coop] Convert threadpool.c to handles -- no pointers, just MonoError.
* [Coop] Convert ves_icall_System_Threading_InternalThread_Thread_free_internal to coop/handle.
* [Coop] Convert mmap to coop/handle -- where there aren't pointers, just unused errors.
* [Coop] Rename some error to ioerror or win32error.
* [Coop] Convert ves_icall_System_Threading_Thread_current_lcid to coop/handle -- no pointers.
* [Coop] Convert mono_mmap_open_file, mono_mmap_open_handle to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Yield to coop/handle (no pointers).
* [Coop] Layer ves_icall_System_Threading_Thread_ConstructInternalThread over new mono_thread_construct_internal.
* Ignore out of memory.
* Favor mono_error_set_generic_error over small factories (loss of breakpoint?).
* Restore accidentally lost barrier.
* [Coop] Mostly undo commit d7bdbcc9a2e76913861b69ff106f0bf9573e7ea6
Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
for now.
It duplicates mono_thread_execute_interruption to mono_thread_execute_interruption_handle
which we want to ensure does not last long.
This should be achieved better by pull
https://github.com/mono/mono/pull/6639
which removes all but one pointer user and leaves
that pointer user layered over handle instead of duplicating.
* [Coop] Fix Windows build.
* [Tailcall][Windows] Add missing error parameter.
* [Tailcall] Cleanup is_supported_tail_call to use language-base short circuit.
* [Tailcall] Move more of the logic into is_supported_tail_call.
* [Tailcall] Be sure not to use TAILCALL_MEM_BASE if not supported.
i.e. not if virtual_, besides CALLVIRT -- they are not quite the same.
* [Facades] Make System.Net.Http.Rtc.dll a net_4_x only facade
It doesn't make sense on mobile (see https://github.com/mono/mono/pull/7541#issuecomment-372434424) but we'd like to keep it in net_4_x to match Desktop .NET
* Bump API snapshot submodule
We implemented them in the facades until now but in .NET 4.7.1
they were promoted into the regular class libraries.
Use PLATFORM_DEBUG_FLAGS for IL-less assemblies
Also replace some files with corefx that were identical.
* Fix the test for OnCreateControl.
* Do not create child controls until the parent is created.
* Fix showing menus after CreateControl behavior change.
* Make all top-level controls call SetTopLevel.
* Fix TopLevelControl property to actually return top-level controls, not just Forms.
* [threads] Fix race between abort socket syscall and thread shutdown
The race happens when we call mono_thread_info_abort_socket_sycall_for_close on
a thread that's about to shut down.
We lookup the MonoThreadInfo for that thread outside the
mono_thread_info_suspend_lock, and then use it to send the signal once we've
taken the lock.
In between those two actions, the other thread already finished
unregister_thread and pthreads may already have destroyed its TLS keys and
otherwise started to dismantle the thread.
The fix is to do a second mono_thread_info_lookup once we have the lock and
only signal the other thread if it still around.
Fixes https://github.com/mono/mono/issues/6998
* [threads] Simplify mono_thread_info_abort_socket_syscall_for_close
Call mono_thread_info_lookup while holding the thread info suspend lock.
We no longer need to check for STATE_DETACHED because removing MonoThreadInfo on
detach is done while holding the suspend lock.
* [metadata] split IL generation code into seperate compilation units.
* [metadata] move ENABLE_ILGEN definition to configure
* [metadata] split IL generation code into seperate compilation units.
By adding callbacks for IL generating runtime code, we can link in code
later into the runtime that does such for configurations which do not
need IL generation initially. This is the case if you configure the
runtime with `--enable-minimal=jit,interpreter`.
In such configuration, the build will produce an additional library,
called `libmono-ilgen`.
An embedded can choose to link this library to the final binary and
initialize IL generation with the following three, newly added, API
calls:
* `void mono_marshal_ilgen_init (void)`
* `void mono_method_builder_ilgen_init (void)`
* `void mono_sgen_mono_ilgen_init (void)`
This change is mostly moving code around, but there are minor changes
like introducing the enum `MarshalTypeCheckPositions`, so we avoid
copy/paste constants accross compilation units.
* [windows] add IL gen files to windows build and set ENABLE_ILGEN
* [fixup!] fix windows build
* [fixup!] resolve merge conflicts with class getter commits
* marshal.c: b8da973620
* sgen-mono.c: 8ba4947f7a
at some point I gave up to resolve merge conflicts and worked through
errors/warnings by compiling with
> `CFLAGS=-DENABLE_CHECKED_BUILD_PRIVATE_TYPES=1`
so the result is likely a bit different
* redo lost changes from 57f3f34e60
* redo lost changes from 52514effbf
* [fixup!] fix array marshal
* [method-builder] use eglib types
review comment by Ludovic,
https://github.com/mono/mono/pull/7375#discussion_r171876337
* [marshal] remove stelem strings from header
review comment by Rodrigo,
https://github.com/mono/mono/pull/7375#discussion_r171921029
* gboolean g_is_usermode_native_debugger_present (void).
i.e. Win32 IsDebuggerPresent which is just call mov mov ret.
Other slower methods on other systems if possible and unintrusive (OSX).
This is very useful as in:
if (g_is_usermode_native_debugger_present ()) G_BREAKPOINT
"native" meaning "not managed"
"usermode" meaning "not kernel"
Both other kinds exist and are detected differently.
* Move new debugging utility from glib to mono/utils.
* Redo it with CoreCLR as basis. https://github.com/dotnet/coreclr/blob/master/src/pal/src/init/pal.cpp
* Link to a specific stable revision, not master.
https://raw.githubusercontent.com/dotnet/coreclr/f1c9dac3e2db2397e01cd2da3e8aaa4f81a80013/src/pal/src/init/pal.cpp
* Use a clearer form of boolean normalization.
* Update Visual Studio project files.
* Fix include path, remove unnecessary boolean canonicalization, spell out words, swap int/boolean.
* Header got missed in the move from glib.
It'd fail with the following errors since e6de24c2d1:
```
MCS [net_4_x-darwin] net_4_x_System.Data.OracleClient_test.dll
Test/System.Data.OracleClient.jvm/MonoTests.System.Data.Utils/ADONetTesterClass.cs(337,71): error CS0012: The type `System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] net_4_x_System.Json.Microsoft_test.dll
Test/System.Json/JsonValueTest.cs(23,12): error CS0012: The type `System.Dynamic.IDynamicMetaObjectProvider' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] DummyAssembly.dll
error CS0518: The predefined type `System.Object' is not defined or imported
error CS0518: The predefined type `System.ValueType' is not defined or imported
```
* [ci] Add compiling class lib tests to mcs job
* Avoid recalculating Document on TextBox controls without handles. Properly dispose graphic contexts.
* Make sure all CreateGraphics calls are wrapped in using block.
* Avoid a couple more no-op calls in RichTextBox.
* Fix default values and the StartPage property in PrintPreviewControl.
* Do not cache resized bitmaps in PrintPreviewControl if the source data are scalable metafiles.
* [interp] Use jit's dead basic block detection
Using generating_code doesn't cover all cases since it doesn't do basic block liveness calculation.
* [interp] Throw instructions clear the stack
* [interp] Add stack check at return
There would be a compilation error in the XA build as follow:
```
obj/Release/bundles/armeabi-v7a/temp.c: In function 'install_aot_modules':
obj/Release/bundles/armeabi-v7a/temp.c:49:25: error: 'MONO_AOT_MODE_NORMAL' undeclared (first use in this function)
mono_jit_set_aot_mode (MONO_AOT_MODE_NORMAL);
^
obj/Release/bundles/armeabi-v7a/temp.c:49:25: note: each undeclared identifier is reported only once for each function it appears in
```
* [Tailcall] Fix the F# code; let rec functiona ()= printfn "%d" 1; functionb ()
and functionb ()= functiona ()
let ()= functiona ()
The test case and the fix are from https://bugzilla.xamarin.com/show_bug.cgi?id=25224.
Just bringing in change ca0dd5c0bb:
commit ca0dd5c0bb
Author: Zoltan Varga <[email protected]>
Date: Thu Dec 11 15:37:29 2014 -0500
[jit] Enable tail calls from gshared code. Fixes#25224.
Previously it was reverted due to performance regression, which has been fixed.
The problem was that use vs. patch of jmps was using inflated vs. non-inflated code.
Fixed here: https://github.com/mono/mono/commit/fe95e4b34b00caa8073dfa3b4473a43182abcbbb
The IL is:
.method public static !!a functiona<a>() cil managed
{
.
.
.
IL_001d: tail.
IL_001f: call !!0 '1'::functionb<!!0>()
IL_0024: ret
}
.method public static !!a functionb<a>() cil managed
{
IL_0000: tail.
IL_0002: call !!0 '1'::functiona<!!0>()
IL_0007: ret
}
* [Tailcall] Add tail.callvirt support to AMD64 JIT. Not yet
any other architecture (arm, x86, etc.) or scenario (AOT, LLVM,
interpreter, etc.)
This is based on F# that stack overflows to report failure:
type A() =
member this.f2 (a) = if a > 0 then this.f1(a - 1)
else 1
member this.f1 (a) = if a > 0 then this.f2(a - 1)
else 2
let a = A()
printfn "%d" (a.f1(1000 * 1000 * 10))
and in turn C#, self checking instead of stack overflowing:
using System;
using System.Runtime.CompilerServices;
using static System.Runtime.CompilerServices.MethodImplOptions;
unsafe class A
{
static int check (long stack1, long stack2)
{
return (stack1 == stack2) ? 0 : 1;
}
[MethodImpl (NoInlining)]
public virtual int f1 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f2 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public virtual int f2 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f1 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public static void Main ()
{
int stack;
Environment.Exit (new A().f1 (100, (long)&stack, 0));
}
}
And then IL, inserting tail prefixes and cleaning up a little:
.assembly extern mscorlib { }
.assembly b { }
.class A
{
.method static int32 check(int64 stack1, int64 stack2)
{
ldarg.0
ldarg.1
beq.s IL_0006
ldc.i4.1
ret
IL_0006:
ldc.i4.0
ret
}
.method newslot virtual instance int32 f1 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f2 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method newslot virtual instance int32 f2 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method static int32 Main () noinlining
{
.entrypoint
.locals init (int32 V_0)
newobj instance void A::.ctor()
ldc.i4 0x100
ldloca.s V_0
conv.u
conv.u8
ldc.i4.0
conv.i8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
}
.method instance void .ctor ()
{
ldarg.0
tail. call instance void [mscorlib]System.Object::.ctor ()
ret
}
}
* Allow comments anywhere in .md line, not just the start.
* [Tailcall] Avoid changing ins->sreg1 in OP_TAILCALL_MEMBASE.
This was likely based on OP_CALL_REG which has more reason to do
it but still not a good example.
* [Tailcall] Rollback x86/arm/ppc/llvm until changes are actually
complete/working.
* [Tailcall] Fix code formating: default at end, open brace at right on
previous line.
* [Tailcall] Consolidate comments out of tailcall-virt.cs and tailcall-virt.fs and into tailcall-virt.il.
Make IL less unreadable with whitespace.
Disable instead of enable tailcall-virt test.
* [Tailcall] Combine assert and default that it made unreachable and make assert more informative.
* [Tailcall] Remove a newline.
* [Tailcall] Add additional verbose output.
Add 3 tests that would seem focused on this change and would
seem to be fixed -- all three pass on desktop, all three fail
on previous mono, two are fixed now -- one needs more debugging --
generic value types.
Problem is probably:
is_supported_tail_call:
if (fsig->hasthis && cmethod->klass->valuetype)
/* this might point to the current method's stack */
supported_tail_call = FALSE;
* [Tailcall] Allow tail.callvirt on AMD64 AOT now, having tested it.
* [Tailcall] LLVM support for tail.callvirt/OP_TAILCALL_MEMBASE, now having tested it.
* [Tailcall] Disable new tests for interpreter as I had intended.
* [Tailcall] Consolide interpreter disabling of tailcall tests.
Address https://github.com/mono/mono/issues/7093 in kind of an adhoc way.
The correct fix is to make
```
((IEnumerable<U>) (new T[] {...})).GetEnumerator()
```
return an `IEnumerator<U>` (like .NET does) instead of `IEnumerator<T>`
and to stop marking IEnumerator as an array special interface.
fetching Microsoft.NET.Build.Extensions nuget from `cli-deps` to
`dotnet-core`. Both of these should have the same nugets but sometimes
seem to be off by one.
To pick up:
commit 345755cb49ee1979df280399f03178aae0b4029a
Author: Alex Rønne Petersen <[email protected]>
Date: Tue Mar 6 13:40:16 2018 +0100
Add build support for RISC-V. (#6)
Use `MonoClass` getters in the rest of the code in `mono/metadata/`
1. Add `mono_class_contextbound_bit_offset()` which returns the bit offset of `MonoClass:contextbound` which is needed by `remoting.c`
2. Add `mono_class_create_array_fill_type` which is used by sgen to write over unused nursery fragments.
3. Alllow `metadata-cross-helpers.c` to access `MonoClass` fields directly. Rationale: it needs to compute field offsets.
4. Everything else shouldn't have any functional changes.
https://github.com/mono/mono/issues/6925
---
* [metadata] Fix warnings in class-accessors.c
Fix warnings about missing prototypes for class-abi-details.h functions.
* [cominterop] Use MonoClass getters in cominterop.c
* [loader] Use MonoClass getters in loader.c
* [runtime] Use MonoClass getters in icall.c
* [metadata] Add mono_class_contextbound_bit_offset() accessor
Compute the bit offset of MonoClass:countextbound
* [remoting] Use MonoClass getters for remoting.c
* [boehm] Use MonoClass getters in boehm-gc.c
* [callspec] Use MonoClass getters in callspec.c
* [sre] Use MonoClass getters in dynamic-image.c
* [w32] Use MonoClass getters in w32process.c
* [debug] Use MonoClass getters in mono-debug.c
* [runtime] Use MonoClass getters in method-builder.c
* [runtime] Use MonoClass getters in security-manager.c
* [coop] Use MonoClass getters in handle.c
* [reflection] Use MonoClass getters in reflection.c
* [sgen] Add mono_class_create_array_fill_type
Used by sgen to fill nursery fragments before a collection
* [sgen] Use MonoClass getters in sgen-mono.c and the GC bridges
* [verify] Use MonoClass getters in the verifier
* [sre] Use MonoClass getters in SRE
* [custom_attr] Use MonoClass getters in custom-attrs.c
* [metadata] Use MonoClass getters in gc.c
* [security-core-clr] Use MonoClass getters in security-core-clr.c
* [metadata] Use MonoClass getters in metadata.c
* [metadata] Allow metadata-cross-helpers to access MonoClass fields
* [coop handle] Use MonoClass getter in mono_handle_unbox_unsafe
attribute(deprecated(message)) was introduced in gcc 4.5.
attribute(deprecated) was introduced in gcc 4.0?
pragma GCC diagnostic 4.2?
https://github.com/mono/mono/issues/7408
* Update many of the unit tests to pass on Windows.
* Update the TextBox default colors.
* Update ToolStripManager.RevertMerge error handling.
* Update menu item cloning to pass unit tests.
* Update PreviewKeyDownEventArgs.KeyValue behavior.
* Update return value of AccessibleObject.State.
* Update TextBoxBase.IsInputKey to treat backspace as input key.
* Update constructors of BindingCompleteEventArgs to properly set the Cancel property.
* Fix and cache ToolStrip[Item] default font.
* Run fixed layout unit tests.
* Silence the warnings and debug prints in unit tests.
* Update the default colors for ComboBox to match the TextBox.
* Remove superfluous debug prints that are already checked by Assert anyway.
* Make sure HandleCreated event is called for MDI children.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions and lot of noise in the unit test output.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions.
[System.Windows.Forms] Layout fixes
This is accumulation of layout related fixes from https://github.com/filipnavara/mac-playground. Some of the patches were rewritten, small bugs were fixed and it passes the unit tests now.
All the changes are listed in the commits, but the main ones are listed here:
- Rewritten TableLayout, which handles many quirks and unifies the code for GetPreferredSize and the actual layout.
- Fixed FlowLayoutPanel.GetPreferredSize to respect flow breaks.
- Many of the GetPreferredSize implementations fixed to return sensible values. For container controls with default layout the implementation is moved to DefaultLayout and shared.
- Implemented cache for GetPreferredSize that greatly improves the performance for complex layouts.
- Cleaned up implementations of SetBounds, SetBoundsCore and UpdateBounds that improve the performance by reducing the number of re-computations of the same values.
- Moved the calculation of dist_right and dist_bottom for anchor layouts to DefaultLayout.InitLayout.
The Linux build currently just displays "tarball" since we don't
have the .git directory when building the Linux packages.
This allows us to pass environment variables that contain the
branch+commit to the build for generating version.h so we can
show the more detailed info like on OSX.
Same as in https://github.com/mono/mono/pull/6033 to fix the following error on the FullAOT armel/armhf builds:
```
Ran out of trampolines of type 0 in '/home/builder/jenkins/workspace/test-mono-mainline-fullaot/label/debian-9-armhf/mcs/class/lib/testing_aot_full/mscorlib.dll' (limit 9000)
```
Now explicit bounds are only updated in SetBoundsCore, no more all the updating and restoring with UpdateBounds calls.
Rely on the WM_WINDOWSPOSCHANGED message to be sent from XplatUI.SetWindowPos to call UpdateBounds. This avoids an explicit call to XplatUI.GetWindowPos and UpdateBounds in SetBoundsCore.
Fix events triggered in incorrect order when Control.Controls.Remove is called.
Update Dispose behavior with events and exceptions to match the reference implementation more closely.
Rework the layout engines to use AutoSizeInternal property since TextBoxBase has its own AutoSize that should not be respected by layout engines.
Rework automatic sizing behavior of TextBoxBase to return correct values.
Rework TableLayout completely to use same code for layout and calculation of preferred size.
Co-authored-by: Jiri Volejnik <[email protected]>
The Label control has special sizing behaviour that predates the introduction of layout engines in .NET Framework 2.0. In earlier versions of the framework it used to auto-size itself. Now it does it only if it's contained in the default layout engine, otherwise it lets the layout engine do its magic.
* [mcs tests] fix runtime arguments passing to test harness
This fixes a regression introduced by
https://github.com/mono/mono/pull/5484/files#diff-d4a99dd2b7df29f027dae0b3eec6c8e6R193
The change it subtle: Variables are moved into another one, but one
variable got changed from `TEST_RUNTIME_FLAGS` to `RUNTIME_FLAGS`, which
causes the harness not picking up `--interpreter` if set.
* [interp] disable System.Threading.ThreadTest.Test_Interrupt
* [sre-save] Emit a warning if overwriting a MonoClass token with unequal value
It's not clear to me how we could ever have a class without a type_token set
even with a TypeBuilder.
* [sre-save] Use MonoClass getters in sre-save.c
* [sre-save] Change g_warning to g_error in mono_image_fill_export_table
We think this case should not happen.
* [sdks] Move common targets
* [sdks] Have RELEASE be empty when CONFIGURATION != 'release'
* [sdks] Create common runtime compilation template
* [sdks] Use runtime template for Android
* [sdks] Use runtime template for iOS
* Use VSCMD_ARG_TGT_ARCH env in mkbundle on Windows when trying to autodetect target architecture.
Using mkbundle on Windows with VS toolchain, mkbundle will detect target
architecture (x86/x64) by looking at the architecture of executing .NET runtime.
This could lead to some surprises when run from a VS development command propmt setup
to target x86 or x64 but running a mono binary using opposite architecture.
To mitigate this issue mkbundle will look now at the VSCMD_ARG_TGT_ARCH
set in VS development command prompts and use target architecture based
on this env variable. If not defined, current behavior will be used, picking the target
architecture based on executed .NET runtime architecture.
* Updated mkbundle documentation.
* [corlib] Remove IVT for S.R.I.RuntimeInformation facade
The types live in corlib now so we don't need the IVT anymore.
Also removed leftover SR.cs file.
* Bump API snapshot submodule
The original version of this code overwrote the same string over and over
again. Because of the order of operations, when looking for siblings of
Test.dll, we would probe for Test.dll.mdb, then Test.pdb, then Test.pdb.config
(note the last one - should be Test.dll.config).
New version of the code uses fresh strings for each sibling.
Fixes https://github.com/mono/mono/issues/7262
* [sdks] Add armv7s device build.
* [sdks] Disable dtrace on the cross compiler builds.
* [sdks] Avoid building mono-dtrace.h for the cross compilers, its not needed anymore.
* [sdks] Add a configure-mono target.
* [sdks] Put back the call to CheckXcodeDir.
* [sdks] Enable ccache if possible.
* [sdks] Generalize iosDeviceTemplate so it can build the tvos runtime as well. Add tvos device build.
- This is independent of optimization, which is seemingly what we want.
- This does not have bug under optimization that `error` has, that
currently breaks FullAOT builds.
This is an alternative to https://github.com/mono/mono/pull/7353.
Use ifdef GNUC || clang to indicate we know clang is compatible,
and not just depend on clang defining GNUC and being very compatible.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628.
* [runtime] Export mono_runtime_get_aotid () for use in the profiler.
* [profiler] Add nanoseconds startup time to file header.
Fixes#6178.
* [profiler] Add a TYPE_AOT_ID event containing the current runtime's AOT ID, if available.
Fixes#6181.
* [profiler] Add Mvid to image load events.
Fixes#6180.
* [profiler] Add generation field to heap object events.
Fixes#6174.
* [profiler] Remove TYPE_SAMPLE_UBIN and some more dead ELF code.
We had a few stubs that threw not implemented exceptions in Dispose()
which causes the finalizer thread to abort.
Since those classes throw in the constructor already there's no way
to create a valid object and we can remove the throw in Dispose().
Fixes https://github.com/mono/mono/issues/7338
This new helper class uses `TaskCompletionSource<>` internally, but instead
of using TrySetException(), it sets a result containing an `ExceptionDispatchInfo`.
The problem with using TrySetException() is that it wraps the exception
object in an `AggregateException`, that would be unobserved if the caller
throws the original exception.
* [System]: Enable some System.Net.Requests tests from CoreFX.
* tests.make: add `$(XTEST_HARNESS_PATH)` to `TEST_MONO_PATH`,
so we can find xunit.assert.
* corefx/SR.cs: add `System.Net.Requests` resources from corefx.
* HttpWebRequest: See below for detailed summary.
* Match parameter names of overridden base class members.
* Fixed order of some argument / state checks to match the
tested behavior.
* Most async methods now throw exceptions instead of returning
faulted tasks when called with incorrect arguments.
* HttpWebResponse.ContentType: use `string.empty` as default.
* WebConnectionStream.FlushAsync: override to return a finished task.
* HttpWebRequestTest.AllowReadStreamBuffering: removed this test.
* test-helpers/RemoteExecutorConsoleApp: silently ignore compiler-
generated helper methods.
Enabled tests from CoreFX:
--------------------------
Added the following tests from external/corefx/src/System.Net.Requests/tests:
* AuthorizationTest, FileWebRequestTest, GlobalProxySelectionTest,
HttpRequestCachePolicyTest, HttpWebRequestTest, HttpWebResponseHeaderTest,
HttpWebResponseTest, LoggingTest, RequestStreamTest, WebRequestTest
Not working yet:
* AuthenticationManagerTest, FtpWebRequestTest
We are currently using
../../../external/corefx/src/System.Net.Requests/tests/*.cs:AuthenticationManagerTest.cs,FtpWebRequestTest.cs
Summary of HttpWebRequest changes:
----------------------------------
* Host - we are now using the implementation from corefx.
* DefaultMaxResponseHeadersLength (unused) - fix default value.
* AllowReadStreamBuffering (unused) - allow this property to
be read/written.
* ContinueTimeout - likewise.
* DefaultCachePolicy (unused) - allow this property to be
read/written and set default value.
* DefaultMaximumErrorResponseLength (unused) - likewise.
* Connection - use implementation from corefx.
* Method - use implementation from corefx, which has additional
error checks.
* MaximumResponseHeadersLength - use implementation from corefx,
adding error checks.
* ReadWriteTimeout - likewise.
* ProtocolVersion - include parameter name in ArgumentException.
* TransferEncoding - use implementation from corefx.
* BeginGetRequestStream / GetRequestStreamAsync / GetRequestStream:
throw exceptions when called with incorrect arguments rather than
returning faulted tasks.
* Disable the corefx tests for the moment.
* Bump API snapshot submodule
* Update tests.make
* [acceptance-tests] Revert part of 1216780e83.
This didn't work as well as I'd hoped.
* [libgc] Export GC_start_blocking () and GC_end_blocking ().
* [libgc] Allow GC_start_blocking ()/GC_end_blocking () to be called unbalanced.
This makes things a bit easier in Mono.
* [libgc] Implement GC_start_blocking ()/GC_end_blocking () for Windows.
* [utils/event] Export the MonoOSEvent APIs for use in the profiler.
* [runtime] Implement thread info flags and get rid of tools threads.
The concept of a tools thread was originally a good solution to the problem of
some internal threads needing to be exempt from stop-the-world. Since they were
introduced, however, we've added more code in the profiler's internal threads
which require certain properties that don't hold true for tools threads. In
particular, we call into some APIs in the metadata layer that, while not
needing the managed heap, do need a domain to be set under certain conditions
(see #6188).
To avoid further complicating the semantics of tools thread by trying to set a
domain for them in a way that doesn't break things horribly, we'll instead do
away with the concept entirely. We already had mono_gc_set_skip_thread () to
flag a thread as being exempt from stop-the-world, which we used in thread pool
threads. This means we already have the infrastructure that is necessary for a
thread to be fully attached to the runtime as a managed thread while still
being exempt from stop-the-world.
So, we do the following:
1. Introduce a set of flags that can be set on a MonoThreadInfo at arbitrary
points (although not in async context). These can indicate that the thread
doesn't want to participate in stop-the-world, doesn't want to receive
sampling signals, etc.
2. Change the thread iteration macros to allow skipping threads with specific
flags set and use this where appropriate (e.g. SGen stop-the-world code).
3. Get rid of mono_gc_set_skip_thread () and make runtime code use the new
mono_thread_info_set_flags () instead.
4. Switch all internal profiler threads to using mono_thread_attach () and
mono_thread_detach (). Use mono_thread_info_set_flags () to disable
stop-the-world and sampling signals for these threads immediately after they
start.
With these changes, internal profiler threads are now fully attached threads
and can call any APIs in the runtime as long as they don't touch the managed
heap.
* [libgc] Add a note about how GC_start_blocking ()/GC_end_blocking () differ from upstream.
* [runtime] Use getters in IS_MONOTYPE()
* [metadata] Add m_class_offsetof_fieldName accessors
These look like:
```c
intptr_t
m_class_offsetof_someField (void) {
return MONO_STRUCT_OFFSET (MonoClass, someField);
}
```
When Mono is compiled with the definition of MonoClass
hidden (--enable-checked-build=private_types),
only the function prototypes are available via
mono/metadata/class-abi-details.h
When Mono is compiled without the checked build flag,
the functions are inlined into that header.
* [metadata] Add accessor function mono_class_set_nonblittable
This is needed by mono_marshal_load_type_info ()
* [marshal] Use m_class_get_ getters to access MonoClass fields
* OpenBSD hasn't have /dev/srandom anymore. See:
https://mastodon.social/@_xhr_/99389358375291806
* Crichton hasn't touched Mono since 2004, per logs. I
doubt they're who to consult about this issue anymore, if
someone somehow does.
* Always enable explicit null checks for AIX
AIX has a "null page" that allows reads (but not W|X) to occur on
*0; allegedly legacy crap for old stupid C programs that poorly
managed string handling. Because of this, we can't catch SIGSEGVs
to give out NREs with - we have to do null checks ourselves. As
such, turn this debug option on all the time; it's seemingly what
other managed runtimes have done, at least according to with what
one contact says.
* Make explicit null checking definable by architecture headers
Turns out other OSes do this too; so best to keep it generic.
To the poor souls on HP-UX and IRIX, good luck!
* Make arch-specific explicit null checks a backend option instead
Don't put ifdefs into JIT code except in that init_backend func;
also make ifdef name consistent with the debug flag name
* Rework the Win32 drag and drop bridge not to depend on Hwnd object.
* Avoid using Hwnd.GetBorderWidth directly.
* Unify GetParent calls to make same sense out of them. They should either consider form owners or not, which wasn't consistent across the XplatUI backends and uses.
Reimplement Control.FromChildHandle using XplatUI instead of relying on Hwnd class.
* Update GetParent parameters.
* Remove direct accesses to Hwnd objects from Control.
* Don't create the Hwnd object in the XplatUIWin32 backend.
* Split handling of Hwnd.GetNextStackedFormLocation for MDI windows into MdiClient to remove dependency on Hwnd objects.
We were previously passing to EH the address to the context that is being set up by the suspend mechanism. This context could get modified while we unwind, confusing EH (could raise `cfa_reg != -1` assertion)
This commit significantly reduces the race window and should mostly avoid crashes (if we get the wrong context we should just fail to invoke clauses from managed)
Don't assert when comparing if an "array special interface" is assignable from
an array.
The code assumed that the special interface is some sort of generic instance
like ``IList`1<string>``, but it could be a generic type definition
``IList`1``.
There is a case where we would be obligated to return TRUE:
If someone used reflection to get the generic param of ``IList`1`` and then made an
array:
```
var i = typeof (IList<>);
var iparam = i.GetTypeInfo().GenericTypeParameters [0]; // returns gparam T
var a = iparam.MakeArrayType (); // T[]
Console.WriteLine (i.IsAssignableFrom (a));
```
But that case is handled by the `MONO_CLASS_IMPLEMENTED_INTERFACE` check,
earlier in mono_class_is_assignable_from.
So we can return FALSE here.
Fixes https://github.com/mono/mono/issues/7095
* [metadata] Fix m_classdef_get_next_class_cache getter to be byref
Apparently the way this field is used is to internally chain cached classes, so
we need its address.
* [metadata] Use MonoClass getters in image.c
* [metadata] Allow debug-helpers to access MonoClass fields directly.
* [metadata] Use MonoClass getters in mono-error.c
* [sgen] Use MonoClass getters in sgen-debug.c
* [sgen] Use MonoClass getters in sgen-client-mono.h
* [metadta] Use MonoClass getters in appdomain.c
* [metadata] Use MonoClass getters in exceptions.c
The mkbundle VS toolchain build has never supported zlib and the -z argument.
Commit adds zlib.lib or zlibstaticlib (depending on use of --static) to the
linker command line when using -z argument.
NOTE, user still needs to make sure zlib.h, zconf.h, zlib.lib or zlibstatic.lib
is visible to cl.exe and link.exe when running mkbundle using VS toolchain.
* [metadata] Create transient ginst during parsing.
Allocate the instantiation types transiently so that they can be freed if
we're going to ultimately discard this MonoGenericInst candidate.
* [metadata] Store GenericParamInfo for anonymous generic params in a cache in MonoImage
The issue is that mono_metadata_parse_generic_param can be called from
mono_metadata_parse_method_signature_full without a MonoGenericContainer which
means we will image_alloc0 temporary MonoGenericParamInfo every time.
This happens, for example in method_from_methodspec in loader.c when we
parse a generic instantiation without having a generic container on hand.
* [metadata] Use MonoGenericParamFull for all generic params
We used to allocate a smaller MonoGenericParam for anonymous generic
parameters. Instead always allocate a MonoGenericParamFull now (which has the
extra MonoGenericParamInfo fields).
As a result, update call sites that checked whether mono_generic_param_info
returned non-NULL to check gparam->owner->is_anonymous instead.
As a fesult of that, update mono_metadata_load_generic_params to create
non-anonymous parameters right away if we know the class or method that will
eventually own them.
* [metadata] Remove anon gparam MonoClass caches from MonoImage
Now that all generic parameters are MonoGenericParamFull and have a pklass
field, cache the class corresponding to a generic param in the struct itself
instead of an external cache.
* [metadata] Remove gshared constraint gparam caches from MonoImage
Now that every gparam is a MonoGenericParamFull, we can always cache the
MonoClass for a gparam in MonoGenericParamFull:pklass.
* [wasm] Enable LTO in release builds. Change packaging to include both debug and release builds.
* [wasm/sgen] Make it possible to disable debug helpers and do so under wasm. Saves 2% on a release build.
* [Tailcall] Add 11 tests. They all run w/o exception or stack overflow, on all platforms.
They are self-checking and report if they were tail called.
All 11 pass on Windows .NET.
2 pass with Mono on Windows or Mac.
CoreCLR not tested as it is a difficult/unknown command line environment.
Mono has problems with at least:
virtual
non-managed pointers
generics
calli
managed references even if not to current frame
Tests originally written in C# and then run through ildasm and perl.
See https://github.com/jaykrell/mono/commits/tailcalltest2.gen.
* [Tailcall] Interpreter fails all tailcall tests.
SvcHttpHandler is supposed to be thread-safe so it shouldn't use plain
Dictionary without additional locking.
The problem is apparent when running test app from issue #7134 with
hyperfastcgi as the following exception sometimes surfaces:
```
[System.NullReferenceException]: Object reference not set to an instance of an object
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00111] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:441
at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (TKey key, TValue value) [0x00000] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:223
at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00048] in .../mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:82
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x008fd] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:1338
at System.Web.HttpApplication.Tick () [0x00000] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:927
```
* Add test for bug 18941
* Expand and update bug 18941 test because there are more problems with our handling of empty structs
* Remove array offset calculation from test because it uses unmanaged sizes. Fix calculation of struct sizes used in marshal struct layout (fixes SizeOf(TestOffsets))
* Correct Marshal.SizeOf implementation to use mono_marshal_type_size instead of returning native sizes
* Remove commented out code
* [sre] Remove S.R.E.FieldBuilder:table_idx field
The field was used in two ways:
1. as the temporary token returned by MemberInfo.MetadataToken
property
2. as a way for sre-save to record the field index in the dynamic assembly.
For (1) we now use the value returned by
ModuleBuilder.GetToken(MemberInfo) (ie a pseudotoken).
For (2) we lookup the field index in the dynamic assembly hash that maps
MonoClassField pointers to indices.
* [sre] Assign consecutive tokens to all fields in a class.
Ensure that a token and a Module are enough to uniquely identify every
MonoClassField.
Because of how metadata is represented in Mono, the fields defined in a
class must have consecutive tokens (because the MonoClass:field.first
and and MonoClass:field.count are used to index into the
MonoClass:fields array).
When the class is created we bump the "next available field token" value
in the ModuleBuilder. Any FieldBuilder objects that are still alive
after the type is created will use RuntimeResolve() to map from their
pseudotoken to the real token.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [sre] Change S.R.E.ModuleBuilder.get_next_table_index to take a count
Allow us to reserve more than one consecutive token.
(For now all the callers just have count == 1)
* [sre] Access S.R.E.ModuleBuilder:table_indexes from typebuilder_setup_fields
Use the ModuleBuidler:table_indexes array for assigning tokens to fields
when a TypeBuilder is constructing a type. Also register those tokens
with the runtime so that ResolveMember calls work.
* [test] System.Reflection.Emit.ModuleBuilder field tokens in a module should be distinct
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [runtime] Relax assertions in mono_class_{get,set}_first_field_idx
Removed the !klass->image->dynamic check. Classes created by SRE are
of kind MONO_CLASS_DEF and have a first field index.
* Fix issues due to API changes.
* Bump mscorlib version
https://github.com/mono/mono/issues/7200
Three styles:
1. LIBS="$LIBS -lfoo" -- common and probably works
2. LIBS+="-lfoo" -- was here and does not work
3. LIBS+=" -lfoo" -- should work
%p-formatted numbers already include '0x'
Fixes this output when dumping threads:
"Threadpool worker" tid=0x0x7000105cc000 this=0x0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
to become:
"Threadpool worker" tid=0x7000105cc000 this=0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
* [configure] Remove sgen_copying. It's dead.
* [configure] Add sgen_gc_bridge and sgen_split_nursery to the configure flags.
* [configure] Remove more dead configure flags.
* [configure] Par is now just a feature of conc, remove that too
* [sgen] Fix enable minimal for concurrent configuration.
* [sgen] Fix enable minimal for the split nursery.
* [sgen] Use the new enable minimal to compile the bridge code out.
* [wasm] Switch to the new enable minimal flagd and add mono-opt.js build. The new flags save 300k out of 2.8m.
* Fix *setup_async_callback and add *resume_sighandler_ctx on PPC
mono_arch_setup_async_callback didn't work on systems that use
function pointers. For consistency with other backends with
exception support, also add mono_arch_setup_resume_sighandler_ctx,
which we can use to support mono_arch_setup_async_callback, like
those other backends.
Also enable async callbacks on AIX, then enable
*resume_sighandler_ctx on PPC Linux (untested) and AIX. With this,
I can now ^C in the REPL with AIX and have it work; whereas before
it bombed out, with or without async callbacks enabled or disabled.
* Don't configure func descriptors twice, set args reg with user data
* No sense configuring configuring function descriptors if
the restore sigcontext call already set them up. (If Mac
OS supports is verified and added to the ifdef maze, it'd
be safe to remove this whole ifdef, and let the call in
`exceptions-ppc` handle it all, as all supported OSes
would have that call...)
* Set user_data in an arguments register, like what amd64
and z do.
These don't seem to cause any regressions, like the first patch.
* Remove unnecessary case for PPC
* mono_ppc_set_func_into_sigctx is unused now, remove it
* Everyone has MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX on PPC now
* Everyone has MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX on PPC too
mono_threads_is_safepoints_enabled is used to check if cooperative suspend safepoints are enabled, while mono_threads_is_blocking_transition_enabled is used to check if GC safe/unsafe transition are enabled.
* [mini] Change mono_arch_is_inst_imm () to receive the non-imm and imm opcode.
* [mini] Provide a stub for mono_arch_exceptions_init ().
* [mini] No need to define MONO_ARCH_FPSTACK_SIZE on platforms that don't use it.
* [mini] Remove some dead defines from backend headers.
* [mini] Remove the unused dummy_store opcode.
* [mini] Handle dummy init instructions in all backends.
* [mini] Implement live range instructions in all backends.
* [mini] Allocate trampolines from the domain code manager where appropriate.
* [wasm] Add server.py for those that want to experiment with streaming compilation.
* [wasm] Implement System.Threading.Timer.
Timer implementation is done in a somewhat convoluted way.
First, we change Timer to not depend on a scheduler thread.
What we do is call for the runtime to schedule a timed callback to be executed.
Next step, the runtime. We add enough plumbing to get this call to JS.
Finally, in JS we either call setTimeout or schedule it to be run on the next tick.
Oh, wait, timeouts are ignored on non-web environments? Yes, right now its only use case
is offline testing, so ain't no time to wait for all this timeouting.
* [aot] Add hybrid aot tests.
* [jit] Disable partial sharing during JITting, its only been tested in full aot mode, and doesn't seem to work with JITted methods. Fixes https://github.com/mono/mono/issues/7085.
Context: https://github.com/xamarin/xamarin-android/pull/1078
xamarin-android uses `mono-api-html` and `mono-api-info` in order to
perform API comparisons; see e.g. 4e459045.
A recent problem has arisen regarding "inter-API-level diffs": there
are many API changes which we consider to be acceptable, and thus
would like to ignore. Unfortunately, `mono-api-html` doesn't support
ignoring many of these constructs, e.g. base class changes:
<h3>Type Changed: Android.Preferences.CheckBoxPreference</h3>
Modified base type: <span class='removed removed-inline removed-breaking-inline'>Android.Preferences.Preference</span> <span class='added '>Android.Preferences.TwoStatePreference</span>
and property type changes:
<h3>Type Changed: Android.Views.InputEvent</h3>
<p>Modified properties:</p>
<pre>
<div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> int DeviceId { get; }
</div><div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> InputSourceType Source { get; }
Overhaul the `mono-api-html` "ignore" infrastructure:
* Introduce ignore "scoping". Previously, the ignore options would
only match the *member* text against any provided regular
expression. Thus, `mono-api-html -r ToString` would ignore *all*
members containing `ToString`. Furthermore, there was no way to
restrict the ignore to a particular type. Expand the regex
semantics so that the declaring type is used as a "prefix" for the
to-be-matched text. For example, if a class `Example` is removed,
`mono-api-html` will now match the following value against any
`-r` regular expressions:
Example: Removed type
* Add a `mono-api-html -v` option, to control output verbosity.
When specified, `mono-api-html` will print out available `-r`/etc.
option values:
$ mono-api-html expected.xml new.xml -v
Possible -a value: Android.Resource: Added fields: public static const int AccessibilityEventTypes;
Possible -r value: Android.Preferences.CheckBoxPreference: Modified base type: 'Android.Preferences.Preference' to 'Android.Preferences.TwoStatePreference'
Possible -r value: Android.Views.InputEvent: Modified properties: public int DeviceId { get; }
Possible -n value: Android.Views.UnavailableException: Added type
...
Additionally, allow `mono-api-html` to take a
`Mono.Options.ResponseFileSource`, which allows `@response-files` to
be used as command-line options.
Althought it was previously defined in a public API header, the macro was not
usable for the last several years since it was implemented in terms of
the MonoClass definition which was not visible in the public API.
There is a subtle semantic change here: mono_type_is_generic_parameter will
return FALSE if it's given a byref type parameter, the previous definition of
the macro would return TRUE. (E.g. if you had "class F<T>" then
IS_INTERFACE("T&") used to return TRUE but will now return FALSE. )
Also
- Move mono_class_set_failure definition to class-accessors.c
- Move a few functions that set up specific MonoClass fields to class-init.c:
- mono_class_setup_has_finalizer
- mono_class_setup_nested_types
- mono_class_setup_supertypes
Some terminals like vt220 don't have a format string for setting foreground
or background colors. In that case, the set*color members of the
TermInfoDriver are set to null and trying to set the background color throws.
Signed-off-by: Kai Ruhnau <[email protected]>
* [profiler] Document addition of MONO_ROOT_SOURCE_EPHEMERON.
* [profiler] Remove dead ELF traversal code.
This was buggy and hasn't been enabled for a long time.
The code uses reflection to access all the fields in the RuntimeFeatures
class. When running the linker we strip out these fields since
they're `const` and the test fails because it can't find the expected values.
Since the linker always removes all constant fields we can't simply
"use" the field in the test and instead we just bail out when encountering this case.
Also used Dictionary instead of tuples for the test since it renders
better in the nunit output.
Fixes https://github.com/mono/mono/issues/7145
* Assorted fixes for AIX and i
* Fix a bug I introduced when changing the MonoArray vector
type; array lengths wouldn't match up to what they
actually were on AIX/i.
* Use a custom mkdtemp implementation on Unices without
mkdtemp - and ones that do but don't necessarily have it,
like i 7.1, which lacks mkdtemp in its libc. We can't
determine this at runtime, so AIX will have to suffer
with i.
* Enhance PowerPC hwcap on AIX to detect features like
Linux does.
* Don't use clock_getres on AIX, because i 7.1 doesn't have
that syscall - it's in libc, but it'll bomb out with a
SIGILL; the way unimplemented opcodes are handled on i.
* Don't use PROT_NONE for hazard pointer alloc when on AIX
AIX and i 7.2 are OK with doing this, but i 7.1 is not and will
SIGSEGV because we violate access privleges; not even mprotect will
change this. As such, change to r/w protection for AIX/i.
* Fix Environment.OSVersion on AIX/i
Before, it would report "Unix 1.0.0.0" due to the fact AIX only
puts the minor version number where other Unices would put the
whole version in uname. Set up an ifdef for AIX and deal with this
semantic difference with a sprintf.
* Disable mffgpr on AIX
Reports of it not working on i 7.1 on POWER7; tester reports
disabling this in hwcap makes it run. This requires further
investigation.
* Fix threadpool errno delivering bogus values with _THREAD_SAFE
We didn't set this, and we need it so that errno is thread-local on
AIX/i. Oops!
* Make suggested changed to AIX branch
* use sizeof (utsname) for sanity's sake
* use a variable for hazard table protection
* match defines for CPPFLAGS -> libmono_cflags
In certain cases of having concurrent WCF requests
HttpReplyChannel.TryReceiveRequest can return true with the context
being null ("at closing phase").
This patch prevents crashing the whole application with a
NullReferenceException as reported in issue #7134.
Whether this is just covering the issue over or a real fix is yet to be
determined.
Fixes https://github.com/mono/mono/issues/7134
Assume a class implementing multiple generic I`1 interfaces. If a virtual call invocation is trying to resolve the correct interface using object O implementing I`1 also , the interface is resolved using a set of rules (not fully implemented in Mono), but a requirement is that the chosen interface is "variant-compatible" with object O, that is its generic parameters are set to the same types.
This last requirement is relaxed as an implementation-specific detail when I`1 is IEnumerator`1, in which case e.g. a virtual call on a class implementing IEnumerator<byte> can happen with an object of type IEnumerator<sbyte> by way of sharing IEnumerator`1 as a generic interface they define. Here, clearly the interfaces are not "variant-compatible", and this is allowed.
Resolution of classes implementing IEnumerator should still attempt to select a compatible interface using the standard rules before attempting to apply this special rule.
This is unnecessary and doesn't really make sense semantically in general as
some targets might define a different arch_target depending on bitness, while
still using the same arch/ subdir.
* Change first parameter of mono_nullable_box from guint8* to gpointer to avoid casts.
* [Coop] Provide object creation functions that return handles
and related. Existing functions are left unchanged
instead of layering over new to allay performance concerns.
Note that there are several variations new_object:
alloc vs. non-alloc
fast vs. regular -- fast does not handle finalization or weak fields and is external only
specific vs. non-specific -- specific is "vtable" and "non-specific" is "class"
"_handle" implies "_checked" if we can get away with it, as conversion continues
mono_gc_alloc_handle_array
mono_gc_alloc_handle_mature
mono_gc_alloc_handle_obj
mono_gc_alloc_handle_pinned_obj
mono_gc_alloc_handle_string
mono_gc_alloc_handle_vector
mono_gc_register_object_with_weak_fields(MonoObjectHandle) (raw "obj" vs. handle "object")
mono_gc_wbarrier_object_copy_handle
mono_nullable_box_handle
mono_object_clone_handle
mono_object_new_by_vtable "_by_vtable" instead of "_specific", and implies handle
mono_object_new_handle "_by_class" implied
mono_object_new_handle_mature "_by_class" implied
mono_object_new_pinned_handle "_by_class" implied
mono_object_register_finalizer_handle
mono_value_box_handle
* Combine mono_object_new_fast and mono_object_new_fast_checked.
Suppose we wanted to use coop handles to implement the following icall:
[MethodImpl (InternalCall)]
extern void GetGenericValueImpl<T> (int idx, T out value);
The question is: how should we pass the argument "value" to the C code?
If it was a reference type like "string" , we would use a coop handle:
void ves_icall_GetGenericValueImpl_string (gint32 idx, MonoStringHandleOut value, MonoError *error);
But if it was a valuetype, we would instead pin the memory with an interior
handle and pass the raw address:
void ves_icall_GetGenericValueImpl_int32 (gint32 idx, gint32 *value, MonoError *error);
But we don't have two different implementation on the C side - there's just one
icall - we have to choose a single mechanism.
So the mechanism we choose is to treat all the args like valuetypes - pin the
memory in the wrapper and pass a raw pointer to the C side.
The other troubling possibility is if someone writes:
[MethodImpl (InternalCall)]
extern void BadInternalCall<T> (Something s, T bad);
Now we really don't have any options. So we just assert that noone ever writes
such a call.
On interp we can't async abort since we cannot unwind from an ip in the interp, so the interpreter does explicit checks as part of branch instructions.
Note this can lead to increased stack usage when compiling with -O0.
* [offsets-tool] Add an '--output' argument to specify the output file directly instead of generating it from the target triple.
* [sdks] Add targets for the watch cross compiler.
* [mkbundle] Automatically bundle config files and machine.config files for the simple/cross compiler scenario, fixes one of the missing issues for #6230
When using the interp_wrapper to enter interp from native we don't need to save the lmf since it doesn't make sense to unwind to native. Also make sure we have the interp context set up if we weren't attached at interp transition time.
While Mono does copy the values of arrays back when they are marshaled
to unmanaged code, .NET does not seem to be doing this, and manifests
as the Syscall.poll invocation in Mono.Posix with .NET Core does not update
the values in the provided array.
The following example should print "Got 1 and 1" with the following command:
```
echo foo | dotnet run
```
But instead prints 0 and 1 on .NET Core, but the correct result with Mono.
This patch is going here for the sake of the Mono.Posix.NetCore package that
we publish.
Sample:
```
using System;
using System.Runtime.InteropServices;
class X {
private struct _pollfd {
public int fd;
public short events;
public short revents;
}
[DllImport("libc")]
static extern int poll ([In,Out]_pollfd[] ufds, uint nfds, int timeout);
static void Main ()
{
var p2 = new _pollfd [1] { new _pollfd () { fd = 0, events = 1 } };
var m = poll (p2, 1, -1);
Console.WriteLine ("Got: {0} and {1}", n, pollmap [0].revents);
Console.ReadLine ();
}
}
```
* [runtime] Unboxing of nullable enums should throw for boxed ints. Fixes gh #6666.
For some reason, one can't unbox the underlying type of an enum into a nullable.
This is counter intuitive to the unboxing rules of enums, but it's what dotnet does.
* [interp] Unboxing of nullable enmus should throw for boxed ints
fixes https://github.com/mono/mono/issues/6666 for the interpreter
Ensure that the callback to mono_domain_foreach_safe can actually do stuff with the domain argument like running code.
This new function make it possible to do so safely, unlikely the previous one.
This ensures that the process exit callback has a shot of correctly executing on domains racily being unloaded.
The ProcessExit event is fired before the threadpool is shutdown, so we can leverage that to run them
with a timeout.
The timeout is 3 seconds per appdomain. It could be improved by making that global to all domains if that
ever becomes an issue.
MonoError is simplified for MME by having the error message eagerly created, which simplifies things A LOT.
Managed Exception creation is simplified by only setting Message, as it's done by other runtimes.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* [utils] Fix swapped member and signature fields in error message.
* [runtime] Simplify MME by only setting the message field since ClassName/MemberName don't need to be set.
* [runtime] Add mono_error_set_method_missing to exceptions.c and collapse setting MME to a single function.
This implements the cleanup discussed in the PR.
* [runtime] Cleanup MonoError for BadImageFormatException.
Move mono_error_set_bad_image & mono_error_set_bad_image_name to exception.c.
Rename mono_error_set_bad_image_name to mono_error_set_bad_image_by_name.
Introduce mono_corlib_exception_new_with_args to be used when creating exception objects.
It's easier to consume than mono_exception_from_name_two_strings_checked as it takes string arguments as char*.
Fix usage of mono_error_set_bad_image_by_name to never dup the supplied image name as the callee does it.
Fix some empty error messages.
Finally, reduce the cruft in mono_error_prepare_exception by using the new exception creation function from above.
* [runtime] Cleanup MonoError of FileNotFoundException.
Move it to use the generic first_argument and make it a simple error - IE, get_message doesn't format anything.
* [runtime] Rework MonoError for MissingFieldException.
* Fix build issues
* [runtime] Ensure memory is freed using new MonoError set functions.
When unboxing nullable we call Nullable.Unbox which returns the valuetype, but CEE_UNBOX needs to return an address to it. Therefore we store the result in a local in the frame so we can get its address.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* Fix gshared support for default interface methods by always passing an mrgctx to them.
This is needed because these methods can be part of more than one inheritance hierarchy or
be present more than once in the same inheritance hierarchy so its not possible to
assign rgxtx slots to their gshared entries that would work in all cases.
* [jit] Add a mini_method_is_default_method () helper function.
Fix a regression introduced in the new web stack - when connecting
to a DNS host name that resolves to multiple IP addresses, we need
to probe them all.
On iOS, "localhost" will resolve to both "::1" and "127.0.0.1".
* [runtime] Make icall tables loadable.
Move the icall table code into a separate icall-table.c file, which is either linked into libmono or compiled into a
separate libmono-icall-table.a archive which can be linked into an app, and installed by calling mono_icall_table_init ().
* Change ClCompile to ClInclude for new .h file.
We must not push one vararg at a time since the alignment of the argument is not the same as the alignment of a value type in interp (which is always 8)
Detect conflicts caused by diamond inheritance during vtable construction, and throw an exception when a conflicting
methods is called.
Disable generic sharing for default interface methods, it doesn't work yet, probably
because these methods are called on classes, but the gshared information is associated with the interface.
Enable dim-diamondshape.exe test.
Setting ReadTimeout in WebResponseStream.ctor throws System.Net.Sockets.SocketException : Invalid arguments on iOS.
Set it in WebConnection.InitConnection() immediately after establishing a connection, before we read/write anything.
* [jit] Simplify some gshared code by calling mini_method_get_rgctx () in more places, make mono_method_lookup_rgctx () static. NFC.
* [jit] Get rid of the 'method' argument to emit_get_rgctx (), it should always be equal to cfg->method. NFC.
.. process. Version from:
https://github.com/dotnet/cli/blob/501e11d928c21608999c934f0a7078570b688c6c/build/DependencyVersions.props
```
<MicrosoftNETSdkPackageVersion>2.1.0-preview1-62414-02</MicrosoftNETSdkPackageVersion>
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
```
Also, update the list in the runtime and deniedAssembliesList.txt
installed for use by msbuild.
.. assemblies.
This is specifically required for handling .net assemblies in
`Microsoft.NET.Build.Extensions` nuget which don't work on mono. These
assemblies are bundled with msbuild and we want to be able to deny these
at runtime.
* [configure.ac] Add --enable-checked-build=private_types option
The idea is that when private_types is turned on, we will hide the definitions
of various structs in Mono and only allow access via getter/setter
methods.
If private_types is off, those same getters would be static inline functions
and also the struct definition would be visible (to allow for incremental
conversion of existing code).
* [metadata] Move _MonoClass definition to class-private-definition.h
* [metadata] Define a getter for every MonoClass field
in a checked build, the getters are just declared in class-internals.h and
defined in class-accessors.h
in a non-checked build, the getters are static inline functions in class-internals.h
For a field foo of type FooType define
FooType m_class_get_foo (MonoClass *klass) { return klass->foo; }
The exceptions are fields that are embedded structs, e.g. MonoType byval_arg,
for those we return a pointer to the field instead of a copy:
MonoType * m_class_get_byval_arg (MonoClass *klass) { return &klass->byval_arg; }
* [metadata] Rename MonoClass boolean getters to use is/has names
instead of the string m_class_get_fieldname pattern
- m_class_is_inited
- m_class_is_size_inited
- m_class_is_valuetype
- m_class_is_enumtype
- m_class_is_blittable
- m_class_is_unicode
- m_class_was_typebuilder
- m_class_is_ghcimpl
- m_class_has_finalize
- m_class_is_delegate
- m_class_is_gc_descr_inited
- m_class_has_cctor
- m_class_has_references
- m_class_has_static_refs
- m_class_has_no_special_static_fields
- m_class_is_com_object
- m_class_is_interfaces_inited
- m_class_is_simd_type
- m_class_is_has_finalize_inited
- m_class_is_fields_inited
- m_class_has_failure
* [metadata] (class-internals.h) Use m_class_get_ getters
* [metadata] (class-inlines.h) Use m_class_get_ getters
* [metadata] (class-accessors.c) Use m_class_get_ getters; setters not done
The setters are not converted.
Ultimately, I think that will sort itself out - a few of them are only used
from SRE and from MonoClass construction - we will eventually provide setters
for just two places and hide them elsewhere.
When doing a vararg call we push on the vtstack the current call signature followed by the params. The child_frame will have a pointer to this memory on the parents vt_stack from where it can linearly access the varargs using the same ArgIterator logic.
Use `git blame -C10 mono/metadata/class-init.c` to see attribution for most of the old code.
This PR comprises:
* [metadata] Move (some) MonoClass construction to class-init.c
So far moved MonoClassDef, MonoClassGtd and MonoClassGenericInst construction
functions.
The idea is to eventually isolate functions that needs write/setter access to
MonoClass fields in a separate translation unit and make MonoClass opaque and
only accessible via getters everywhere else.
* [metadata] Move pointer MonoClass creation to class-init.c
* Mark mono_ptr_class_get as external only, runtime should use
mono_class_create_ptr.
* [msvc] Add mono/metadata/class-init.c (and .h) to the .targets file
* [metadata] Rename mono_generic_class_get_class
to mono_class_create_generic_inst
* [metadata] Move array class creation to class-init.c
* Mark mono_array_class_get external only, runtime should use
mono_class_create_array
* Mark mono_bounded_array_class_get external only, runtime should use
mono_class_create_bounded_array
* [metadata] Move generic param creation to class-init.c
* Also move mono_class_setup_vtable_general, mono_class_init_sizes, mono_class_setup_methods
* [metadata] Move mono_class_setup_basic_field_info to class-init.c
* [metadata] Move mono_class_setup_fields to class-init.c
* [metadata] Rename mono_class_from_generic_parameter_internal
to mono_class_create_generic_parameter
* [metadata] Move mono_class_layout_fields to class-init.c
* [metadata] Move mono_class_setup_{properties,events} to class-init.h
* [metadata] Move mono_class_setup_interfaces to class-init.c
* Also move mono_class_setup_mono_type
* [metadata] Move mono_class_setup_parent to class-init.c
* [metadata] remove some extern statistics
* [runtime] Add a 'frame_addr' field to MonoStackFrameInfo, which is equal to either interp_frame or ctx->sp.
Use this field to compare frames with each other or with stack addresses instead of setting ctx->sp to
the interp frame address, which breaks mixed mode, since mixed mode assumes ctx->sp is the real
sp of the last native interpreter frame.
* [ci] Reenable mixed mode tests.
* [System]: WebResponseStream now correctly reads the chunk trailer when using gzip/deflate.
This should actually fix bug #59779.
* Add missing ConfigureAwait(false)
* Get autotools scripts for Mono and Boehm to recognize i
PASE is most similar to AIX, and perhaps I assume other commercial
Unices, as well as PowerPC Linux, so grab variables from them as
needed.
With this, we get glib failing to build due to missing mkdtemp.
* Use better cpp definition to grab more of what we want
* Fix random and 64-bit file offset support
* Set TARGET on IBM i on POWER
* Add hack to gfile-unix.c to work around flawed AIX header
From comment:
/* HACK: the preprocessor will not give us mkdtemp no matter
what and Mono (for good reason) does
"-Werror-implicit-function-declaration" so we error out;
instead declare mkdtemp here; the linker will find mkdtemp
anwyays. libuv has had similar issues, but they just ignore
the compiler warning instead of failing on it.
See: github.com/libuv/libuv/pull/740 */
* Work around missing definition on AIX/PASE
* Fix conflicting definition from due too AIX headers
* Initial work to get JIT working on AIX
* uncertain about NIP; is IAR the right register? need review from
PPC asm people
* needs calling convention work; AIX does NOT use ELF
* Fix lack of casting on sigcontext macros, fix errnos for AIX
* AIX doesn't distinguish between ENOTEMPTY and EEXIST without a
define. Handle this case with a conditional cpp directive..
* When ctx is a void pointer, dereferencing as a struct will fail.
Handle this case with a cast.
* Handle regular AIX as well as PASE
* Implement stack boundaries check for AIX, volume info func
* vol info should be like other Unix, just needs to bridge ifdef
* highly uncertain for the bounds checking, needs further review
* Fix typo in mono/utils/mono-threads-aix.c
* In boehm-gc.c, don't use pthread_getattr_np on AIX even if available
It's not available on IBM i, and even if available, toolchains for AIX
may "helpfully" swap out system headers with variants that remove
functions like pthread_getattr_np.
* Don't use "-export-dynamic" on non-GNU ld
IBM ld considers "-e" to be a flag for setting the entry point.
Detect non-GNU ld, and offer equivalents when possible.
The makefile in mini had to be changed as a result due to
hardcoded flags.
* Use pthread-stop-world.c on AIX
Remove an ifdef that gated this off to AIX. It seems the old AIX
specific files shouldn't be used, and that the changelog for libgc
says pthread should work fine on AIX instead; yet it was blocked.
Restore this, as it compiles and seems to let mono-boehm link fine.
* AIX workarounds for some of support dir
* fstab on AIX is there, but defines a struct more like other
platforms' checklist struct.
* AIX, like macOS and some BSDs, doesn't define some serial types.
* psignal is another victim of GNU; even then it isn't in PASE
headers anyways
* More support workarounds for AIX headers
* Replacement function body for syslog2 on vsyslog-less platforms
AIX lacks vsyslog; detect in autoconf and act appropriately.
* Final support hacks for AIX
* Fix problematic stack management on AIX
this gets us past ifdefs, after much handwringing
* get the right end of the stack; r1/stack pointer is on the wrong
end and ustk is just plain broken
* AIX doesn't seem to like the semantics of the mmap call valloc
does here; either we're allocating into an area we shouldn't be
or we're not passing the right flags. Until then, learn to live
without the stack guard?
* Disable Boehm GC on AIX
Focus on getting SGen working, and avoid legacy debugging nonsense
* Remove AIX ifdef-undef and replace with s/hz/uhz
* Don't use sigaltstack on AIX due to bugginess with guard sections
The valloc call on AIX has issues after issuing mprotect; don't do
do it. I believe it fails because we aren't issuing the right
flags on AIX, or because we're allocating inside of an already
allocated area.
* Perform a 64-bit build on AIX
We still crash at the same place, but probably for the best that
we switch to 64-bit. (Maybe we could make it configurable?)
* Fix func descriptor ifdef, add initial (likely wrong) defs for AIX
* AIX doesn't define __powerpc64__ or __ppc64__ when compiling as
64-bit. Use an alternate ifdef, and shuffle around that ifdef
anyways, as it could lead to wrong results on other platforms
too.
* AIX likely needs special definitions, especially on 32-bit. The
calling convention is closest to PPC64BE Linux, but not exactly.
* Fix stack size on AIX
Ruby dealt with this before: https://github.com/ruby/ruby/commit/a2594be783c727c6034308f5294333752c3845bb
* Set up initial PPC hwcap for AIX, fix ftnptr ifdefs, tweak AIX defs
* Fix hwcap to use better values on PPC AIX
Still needs more adjustment though
* Fix alignment issue on AIX, tweak mini-ppc values just a bit more
* On AIX, doubles are always aligned by 4 if they're in structs.
Since we need to have them aligned by 8 on 64-bit, this is bad,
so change the type on AIX.
* We can use this definition on AIX
Now we can bootstrap Mono!
* Shuffle MonoArray ifdef per suggestion of @vargaz
* Fix System.Decimal division on big endian systems
Before, we got non-sensical overflow on things like
`(Decimal)Int32.MaxValue / 1000`; now they get the same value,
comparing this POWER6 running AIX to my server's output running
OpenBSD/amd64.
* Fix dynamically linked build of Mono on AIX
nm wasn't seeing 64-bit symbools as it defaults to 32-bit mode,
also never try to use GNU nm
* Fix PPC64 define in mono-config
Interestingly, there was an AIX define already present, and that
definition is present in AIX's passed includes, so continue to use
it.
* Don't use __thread even if detected on AIX
tl;dr: The assembler gets angry with __thread and minimal-toc, and
changing options to replace minimal-toc causes linker issues; this
TLS option isn't important anyways if we have pthread instead,
like before when we were using Perzl's old GCC without __thread.
* Get lib.a(lib.o) type archives working with P/Invoke for AIX
AIX libraries are very, very strange compared to other Unices.
I'm not entirely sure if this is correct or optimal; it may need
to special case further. For now, it's enough to get gacutil
up and running.
Some resources I found useful for this charade:
<http://stromberg.dnsalias.org/~dstromberg/AIX-shared-libs.html>
Also set libc and libintl to their proper values.
* Scheduling priority hack for i
PASE doesn't accept anything other than SCHED_OTHER, and the funcs
for getting min/max don't work either. AIX suffers, but only a
little bit.
* Final polish on request
Remove Boehm changes if we don't use Boehm, tweak some defines,
remove some externs, tweak autoconf file
* Be aware of ERESTART, on OSes that use it
Instead of EINTR/EAGAIN, AIX uses ERESTART. Handle this, so things
like xsp are less chatty when performing async IO.
The `label` environment variable is set by Jenkins based on the
chroot/node configuration a given job is using.
This crept into the CI scripts while it should have been a
separate concern and caused all sorts of issues when we bumped
from e.g. debian-8-* to debian-9-* in some jobs.
Instead we should consistently use the CI_TAGS env var which we
control exclusively.
* [sdks] Fix build for llvm
* [sdks] Have .stamp-%-configure always depend on .stamp-%-toolchain
* [sdks] Dependencies on directories should always be order-only
This commit implements checking whether the compiler used to build mono supports
the recently added switches to generate code designed to mitigate the effects of
the Spectre/Meltdown bugs of the modern CPUs (https://meltdownattack.com/).
As of this commit the options are implemented for GCC 8.x, 7.3 and backported to
some older versions of gcc 7.x (e.g. in Ubuntu). The options tested for, and
used, here are:
-mindirect-branch (https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/x86-Options.html#index--mindirect-branch)
-mfunction-return (https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/x86-Options.html#index--mfunction-return)
Checks and usage of the above flags is hidden behind the
`--with-spectre-mitigation` configure option, defaulting to `no`.
Two additional options are implemented to specify the kind of thunk to implement
by each of the flags above:
--with-spectre-indirect-branch-choice=keep,thunk,inline,extern
Convert indirect branches to the specified kind of thunk (defaults to inline)
--with-spectre-function-return-choice=keep,thunk,inline,extern
Convert function return instructions to the specified kind of
thunk (defaults to inline)
The CoreFX version has a few error checks which are not in the
referencesource, switching to CoreFX allows us to enable their tests.
Use Path.GetRandomFileName() and Path.GetTempFileName() in tests.
We are now using nested streams to take care of buffering, chunked encoding and automatic decompression.
GZip / Deflate decompression have been moved inside `WebResponseStream`, the `HttpWebResponse` now always returns a `WebResponseStream` (and not a `GZipStream`) because we have to do extra book-keeping after reading the entire content.
Returns TRUE if the method flags indicate that it's not expected to have a
body because it is abstract, a PInvoke, an internal call or a
runtime method.
* Print combined stdout and stderr in console output.
* Print the RNG seed used for a test run on startup and in the test report.
* Set the individual test timeout back to 6 hours.
* Use the nodefaults profiler option.
* Allow configuration through environment variables:
- MONO_PROFILER_STRESS_OPTIONS: Specify a set of profiler options to use
instead of the randomly generated ones.
- MONO_PROFILER_STRESS_REGEX: Specify a regular expression to filter which
tests should be run.
- MONO_PROFILER_STRESS_SEED: Specify the RNG seed. Useful for reproducing full
test runs at a later point.
- MONO_PROFILER_STRESS_TIMEOUT: Specify a different individual test timeout
from the default.
it has the right logic to avoid this:
```
ld: -undefined and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
```
i.e. setting `-no-undefined`. However, this requires that we link
against `libmonosgen` on those platforms.
We've been using a certain pattern for the Windows .msi for a long
time but the build output used a different name which we simply
manually renamed before publishing.
Since we want to automate as much as possible we can change the
build to produce the correct name right away.
For mono_thread_get_undeniable_exception to work, it needs to unwind the stack and find the first managed frame. This is only possible if we push an interp LMF with a frame for the interp to native transition.
During interp frame unwinding, we were initializing the sp field (to the corresponding interpreter frame) starting with the parent frames of the first interpreter frame.
Debugger maintains it's own list of loaded classes. The unload/filter
logic does not handle composite types like arrays and generic instances.
Expose and reuse the logic from metadata that properly detects any
usage of an image within a type.
This prevents the cache from containing MonoClass values which have
already been freed by the metadata cleaning code.
* Minimal fix to Authenticode infrastructure to understand PE32+.
A number of other problems are noticed in the code but commented only.
This fixes https://bugzilla.xamarin.com/show_bug.cgi?id=56071
* Induce many array out of bounds accesses, and some other error paths.
* Tweaks.
* tweak
* Move braces, move addition, document constants and use them.
* whitespace
* fix comment
* remove diff-minimizing hacks
* cosmetic
* move braces and assume zero-initialization; adjust comment.
* improving Makefile but still a ways to go
* fix C# indent
* Change from C++ to C, and cleanup Makefile.
* update clean target in Makefile
* cleanup Makefile and C#
* remove test code that people don't like and it wasn't very useful
wordsmithing and new good information in comments
* Fix indentation
When an exception is thrown from jitted code, the EH mechanism correctly sets the interp resume data to the right interp frame that should catch the exception, but it resumes to the interpreter by force, setting the MonoContext. This context has invalid data (for example the SP points to a InterpFrame and it is not the real sp at interp exit)
This bug was exposed by inlining changes from d3763c6c1e
* Move machine handling of performance counters from native
to managed -- just slightly less native code therefore.
* PR feedback: Rename ValidMachine to IsValidMachine.
Use string::operator== instead of .Length/[].
Change InstanceExistsInternal to return bool/MonoBoolean directly instead of int.
Remove question mark on FIXME comment for more reliable grep.
Remove redundant zeroing of a pointer.
Also add two more variants
* mono_error_assert_msg_ok (err, msg) to print "msg, due to <err>" on failure
* mono_error_assertf_ok (err, fmt, args...) to print
"<formatted args>, due to <err>" on failure.
Avoid inlining some functions with high stack frame locals usage (ex functions that use MonoLMFExt which is a big structure).
No performance cost was observed on microbenchmarks, while stack usage decreased by over 3 times on amd64 and over 4 times on arm.
Give it 2.5 seconds.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64/10727/parsed_console/log.html
Tests run: 120, Passed: 119, Errors: 0, Failures: 1, Inconclusive: 0
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Elapsed time: 00:00:32.8320000
Errors and Failures:
EndBuildWaitsForSubmissionCompletion (MonoTests.Microsoft.Build.Execution.BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion)
#5
Expected: less than or equal to 00:00:02
But was: 00:00:02.0757916
at MonoTests.Microsoft.Build.Execution.BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion () [0x00126] in /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/BuildSubmissionTest.cs:105
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
Split mono_method_get_header_checked into internal and external forms. (#6609)
External form is mono_method_get_header_checked, the preexisting name.
Internal form is mono_method_get_header_internal.
External must initialize the MonoError for compatibility, internal can/should assume it is already initialized per the new pattern.
* g_assert should be an expression not a statement; provide g_assertf f is format like printf
- g_assert should be an expression, not a statement
ANSI C assert gets this correct, and I corrected
widely used NT ASSERT circa 2001 with no ill effects
Note that ANSI C assert is void, g_assert here is boolean.
- provide g_assertf
f is for format, like printf -- too terse?
Where you might previously say:
if (!(expr))
g_error(...); // like printf
now:
g_assertf(expr, ...)
Manual tests provided -- how to provide a test whose success is failure to compile?
Correct existing eglib/test to build and pass, but don't enable in build.
Enabling it is a line in toplevel configure.ac to add eglib/test/Makefile
after eglib/Makefile.
* Fix comment in test code.
* format with s instead of hs
* review
* [WASM] Fix System.Core issues and disable broken tests.
* [wasm] Fix cookie computation heap overflow. Use a local to make it thread safe.
* [wasm] Disable System tests that don't work under WASM. Change the wasm profile to disable BSD sockets.
* [wasm] Address reviewer feedback.
* [wasm] Disable test that requires multiple threads.
* [wasm] Add package target to wasm.
* [wasm] Modify the runner to exit(1) if the test suite fails.
* [wasm] Add CI configuration for WebAssembly.
* [wasm] Fix issues found over review.
* [runtime] Export mono_class_get_checked () for use in profilers.
* [runtime] Expand mono_method_get_header_summary () to collect more info.
It now collects all the trivially-accessible header data that doesn't require
chasing down other metadata.
* [profiler] Use mono_method_get_header_summary () in the coverage code.
We only need code start and size information, not all the data that is present
in the header. By switching to this function, we avoid all the side effects
that come with resolving local variables and exception clauses (which can even
result in loading assemblies in the worst case).
* [profiler] Write out all uncovered classes/methods in a loaded image.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60225
This required a bit of refactoring and some workarounds for various special
cases. This also fixes some race conditions with respect to how data was
inserted into the lock-free hash tables and queues.
In c7d8d247c3 I unified how we're
passing -arch in CFLAGS to "-arch=XXX" since the original change
in 63a49e9eb8 mixed the formats.
Turns out the correct syntax is "-arch XXX" instead and it broke
the ccache build in bockbuild because it complained about the
unknown format.
Also add LDFLAGS in the amd64 case to match what we have in bockbuild.
When we had a jit info table for aot images loaded in the domain, we would queue jit infos for freeing at domain unload time. This means leaking during entire application life.
Add comment for jit info freeing when having multiple tables.
Fixes#60986.
This cute hack allow us to cut the budget of perf irrelevant blocks[1] while massively boosting those that are perf relevant[2].
It has a ton of missing features, like it doesn't detect nested loops, it doesn't take hints from inlined methods and it doesn't compute EH info.
Beyond that, inlining budget is all but horrible, so there's ton of room for improvement here.
Results are promising.
A marginal improvements in benchmarks like Roslyn (2% user) while as much as 30% in micro benchmarks where the now bigger methods are in loop bodies.
Code size with Roslyn changed from 5433242 to 5501751, IE extra 68.5k, or 1.2% more.
[1] those ending in throw or in a catch handler
[2] Loops
we return the address of the StackOverflowException object in
`restore_soft_guard_pages`, so it ends up in the architecture specific
result register (e.g. %rax) where the exception handler expects it.
fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60862
* [test-runner] Record test duration in NUnit xml
This allows us to keep track of the time on Jenkins.
Also fix issue where we were recording .Seconds of a TimeSpan instead of .TotalSeconds.
* [tests] Bump timeouts in process-stress-?.exe runtime tests
We're seeing these fail sometimes on Linux Azure VMs, let's try
if bumping the timeouts helps.
* [class] Add Obsolete message to ICSharpCode.SharpZipLib.dll
Users should use the nuget package instead, we'll remove the assembly in Mono 6.0
Don't install it into the 4.7.1 reference assembly directory anymore.
* Bump API snapshot submodule
* [runtime] Allow access to protected default interface methods from classes which implement the interface.
* [interp] Add some automatic conversations between virtual and non-virtual calls that .net has. Fixes dim-valuetype.il.
* [bcl] Sort the MethodImpl table in PEAPI.
* [runtime] Enable dim-methodimpl.exe test.
* [runtime] Fix vtable construction tracing.
* [interp] Fix null checks on the receiver when converting virtual calls to non-virtual.
Rationale:
1. it asks for double faulting scenarios we can't do anything about
it anyway, exception just unmap yet another page
2. `mprotect(2)` behaves weirdly (at least on macOS) if you try to
change permissions for subsequent pages with different permissions.
With the previous code it happened that the requested memory range
would go from somewhere in the stack guard and overlap into the
regular, unprotected stack and end up with unpredictable behaviour.
We could be more careful about it, but it would complicate things
even more.
no longer needed. It remains only for register_icall.
Remove casts from void* to HANDLE, as HANDLE always and forever
will also be void*.
Add comments explaining the valid use of INVALID_HANDLE_VALUE (-1).
With CreateFileMapping, for the file handle, it means to
use physical memory / pagefile.
Previously, we tried to keep the intern status of a string consistent across domains. Meaning
that if you interned "FOO" in domain 0, it would return true for String.IsInterned in domain 1.
This behavior exists in the CLR because the string table is shared between domain as string are
what they call agile objects - those that can exit in multiple domains at the same time.
Mono appdomain isolation doesn't work that way and there's not visible advantage of keeping that property.
The reason for this change is to potentially reduce the amount of interned strings and, more importantly,
reduce the amount of domain lookups, which are quite expensive and unsafe.
This should speed up interning queries.
Follow up to https://github.com/mono/mono/pull/6431, we should
capture the exception that is passed to the methods.
Copied the SetResult() method that referencesource uses.
* [mini] factor out interp into a library
It enables us to ship the interpreter as an add-on to the runtime.
Embedder can statically link it into their application on demand.
Usage:
configure mono without the interpreter, such as:
```
$ ./autogen.sh --enable-minimal=interpreter ...
$ make; make install
```
run your favorite program with the interpreter and see it fail:
```
$ ./mono/mini/mono-sgen --interpreter ./mono/mini/basic.exe
Mono IL interpreter support is missing
```
despite `--enable-minimal=interpreter`, we can still build the interp
module:
```
% make -C mono/mini libmono-ee-interp-static.la
CC interp/libmono_ee_interp_static_la-interp.lo
CC interp/libmono_ee_interp_static_la-mintops.lo
CC interp/libmono_ee_interp_static_la-transform.lo
CCLD libmono-ee-interp-static.la
```
`libmono-ee-interp-static.a` can be statically linked into the target
application.
* [fixup] include libmono-ee-interp reference in runtime unit-tests
* [runtime] Mark mono_class_get and mono_class_get_full external only.
Runtime should use mono_class_get_checked and
mono_class_get_and_inflate_typespec_checked, respectively.
* [runtime] Mark mono_ldtoken external only
Runtime should use mono_ldtoken_checked
* [metadata] Mark mono_type_create_from_typespec external only
Runtime should use mono_type_create_from_typespec_checked
* [runtime] Remove mono_class_inflate_generic_method_full.
Mark mono_class_inflate_generic_method external only.
Runtime should use mono_class_inflate_generic_method_full_checked.
* [runtime] Mark mono_get_inflated_method external only
This function is obsolete. It should have no callers.
* [metadata] Mark mono_field_from_token external only
Runtime should use mono_field_from_token_checked
* [runtime] Add MonoError arg to mono_class_get_inflated_method
* [metadata] Mark mono_metadata_parse_method_signature external only
Runtime should use mono_metadata_parse_method_signature_full
* [metadata] Mark mono_metadata_interfaces_from_typedef as external only.
Runtime should use mono_metadata_interfaces_from_typedef_full
* [mini] Add MonoError arg to mono_class_get_method_generic
Also move its declaration from metadata/class-internals.h to mini/mini.h
since it's defined and used in mini/
* [class] Assert that mono_class_get_inflated_method never returns NULL
* [interp] Add missing param support for floating types in interp_entry
Remove some duplicated code
* [interp] Reenable thunks.exe on arm
It fails due to the known RGCTX register clobbering by trampolines.
* include netinet/in.h for in_addr_t
* there is no need for an openbsd specific implementation anymore
so you use the generic pthread one
* signal.h is required for sigaltstack
* add missing mono/utils/mono-threads.h include
* there is no malloc.h on OpenBSD either
* sys/socket.h is required for struct sockaddr
* add support for btls on openbsd and default to with_tls=pthread as there is only emultls support which is not enough for mono
* there is no need for pthread_attr_init/destroy anymore
* add -Wl,-zwxneeded to LDFLAGS on OpenBSD
W^X is strictly enforced by default on OpenBSD;
a program can only violate it if it is located on a filesystem mounted
with the wxallowed mount(8) option and has been linked with the
above flag
Since object-internals.h is included in a ton of places, we get one Centrinel warning
about mono_internal_thread_handle_ptr per translation unit every time the
header is included which is ridiculously noisy.
This commit will suppress the warning about the body of this function.
Note that uses of the function will still get a warning since it returns a
MonoInternalThread* and we haven't yet taught Centrinel that those calls are ok since
the thread object is pinned.
Otherwise we'd get a "directory not empty" exception in the
TestFixtureTearDown (which for some reason isn't shown in the log?).
This was added in https://github.com/mono/mono/pull/6272
They were set in https://github.com/mono/mono/pull/6272 but since
env vars are process wide we'd end up with non-existing paths once
the tests are done. It is safer to unset the variables after the test.
* [System] Add unit test for Xamarin-2315
* [System] Use temporary directory for saving settings files
This change modifies the ApplicationSettingsBaseTests so that they
store the settings files in a temporary directory. This reduces
the risk of failed tests because of stale files from previous test
run, or from a build that runs in parallel.
* [System] Improve Settings behavior (Xamarin-15818)
Improve behavior of ApplicationSettingsBase class to match Windows .NET
more closely.
* Implement Upgrade to allow Upgrading of settings
* Make SettingsPropertyValue serialization work for complex objects
* Make Save and Update throw in unimplemented configurations
* Changed Reload to clear PropertyValues so they are reloaded
and fire PropertyChanged event for all Properties
* Modified Reset to do what Reload used to do.
* Added a backup Type loading for custom SettingsProviders
* don't call SettingsSaving on Reset()
* [System] Fire SettingsSaving event (Xamarin-2315)
When calling ApplicationSettingsBase.Save() the SettingsSaving
event has to be fired.
* [System] Add unit tests for Xamarin-15818
* [interp] Check for exception at field address failure
For example if the static constructor throws an exception
* [interp] Run class cctor before allocating objects
Otherwise we could end up throwing TypeInitializationException from the finalizer thread. We do the same with jit (emit_class_init).
* [interp] Check for method access failure when doing a call
* Fix some ThreadPool performance counters.
https://bugzilla.xamarin.com/show_bug.cgi?id=41294
The bug is that some performance counters are always zero.
Because we do not update them.
This addresses two of them: Work items added and thread count.
There is PerformanceCounter class and you can Increment instances,
however its metadata and some of the implementation is in System.dll.
Most of the code is in native.
ThreadPool is in mscorlib.dll, so can't use System.dll.
A few options exist to address this.
We could move and forward the type. We could duplicate and rename
and possibly subset the type.
Here we add a new icall very specifically for the scenario.
There is slight cost for the icall, and for the atomic increment.
There is an attempt to measure but the results were unclear.
Note that the count of work items is not specifically for QueueUserWorkItem
as one might expect, but also for any async calls.
Fix a little bit of typos.
* Take command lines from command line per PR feedback.
* newline at end of file
* Adds support for nanosecond resolution file information where available.
This patch adds support to the runtime to use the nanosecond
information available on Mac and Linux on `struct stat`.
`stat.st_Xtimespec` strucutre on OSX, and `stat.st_Xtime` and
`stat.st_Xtim.tv_nsec` pair on Linux.
Additionally, this adds support in `Mono.Posix` for MacOS nanosecond stat
data, it already had Linux support before.
* Use ULL here to prevent the computation from overflowing
utf16 to ascii for equality.
g_utf16_ascii_equal takes lengths, which are checked first
and unequal length implies unequal strings, and then no characters are looked at.
"z"" for zero means nul terminated and requires scanning the string.
Still, an equality primitive is often desired vs. inverting inequality.
These can cleanup some code -- extracted from a larger not yet commited PR
that uses it.
I found out that we were packaging e.g. MonoPosixHelper.dll from
the gtksharp msi instead of the one we build in Mono :P
This only happened in the x86 build because we don't package
gtksharp in the x64 build.
* Remove duplicated code by factoring on endian parameter.
* Force inline to mimic previous.
* fix the forceinline part
* Do not forceinline utf32, we never use it.
This can happen when emitting code like:
```
class Foo<T> {
T elt;
public T getter () {
return elt; // ILGenerator.Emit (OpCodes.Ldfld, /*FieldBuilder of Foo::elt*/)
};
}
```
the old incorrect code emitted a fielddef token for Foo::elt, but it should be a
memberref for Foo<!0>::elt.
Likewise, if we have
```
class Foo<T> {
public T f () { /*...*/}
public void g () {
var x = f (); // ILGenerator.Emit (OpCodes.Call, /* MethodBuilder of Foo::f */)
/*... */
}
}
```
Fixes https://github.com/mono/mono/issues/6192
the old incorrect code would emit a fieldref token for Foo::f but it should be
a memberref for Foo<!0>::f
They contain files with very long names which causes issues with `tar`.
We simply remove them from the dist directory before creating
the tarball since we don't use them in the Mono build anyway.
Fixes https://github.com/mono/mono/issues/6349
On some distros the number of strings you can pass to execve()
is limited which means you get the following error when trying
to create the tarball:
```
make[5]: execvp: /bin/sh: Argument list too long
make[5]: * [../../build/rules.make:303: dist-default] Error 127
```
To solve this we split the DISTFILES variable into groups of 100
entries and invoke the shell for each group instead of adding all
into the same invocation. Also removed looking for 'makefile' and
'GNUmakefile' since those don't exist in Mono and simplifies the logic.
Found during investigation of https://github.com/mono/mono/issues/6349
Revert the embedding API behavior change introduced by dcdfb3c500
mono_string_new will:
* return NULL if the given byte sequence is not a valid UTF-8 sequence
* assert if there is not enough memory to allocate a new MonoString.
This only changes the behavior of the API function. The runtime will continue
to use mono_string_new_checked which sets MonoError* for both sorts of
failures.
* [runtime] Bring jemalloc to mono
Jemalloc is known to have much better performance than system memory
allocators, and is safe in concurrent/re-entrant situations.
To use, provide the following options to configure:
--with-jemalloc to enable optionally. To use at runtime,
export MONO_USE_JEMALLOC to the environment.
--with-jemalloc-always to enable and make the default
--with-jemalloc-assert to enable with assertions to catch memory
unsafety. It adds overhead, but an overhead that's much less than
valgrind or asan.
If you export
MONO_JEMALLOC_CONF="stats_print:true"
You will see detailed memory statistics for mono at exit.
Now note that jemalloc is used through an explicit registration, so
C libraries called through pinvoke calls will not use jemalloc unless
they configure themselves to do so separately.
To understand the build work, I'm statically linking jemalloc.a into
the compilation unit for mono/utils/mono-jemalloc.c, which is
responsible for registering it with mono at startup. No further
copying out of the submodule is necessary at installation time.
* [runtime] Fix OSX 32-bit build definition
* Unbreak XMM register handling on platforms without MonoContextSimdReg
Platforms like Haiku (and glibc-less Linux, but that was unbroken a few
weeks ago) don't have this implemented on Mono. (yet?) Restore old
behaviour behind an #ifdef (same one as on mono-context.h) - perhaps it
could be a nicer ifdef, but I'm keeping this consistent for now.
* Attempt at a universal ifdef for MonoContextSimdReg presence
Suggestion of @kumpera. I've put #ifdefs in the obvious places, and
verified that the commit ensures we're still in the same position as
before.
* Fix non-MonoContextSimdReg calls in tramp-amd64.c
Follow advice of @joncham wrt the type and function to use instead.
* "Fix" a case of an error being ignored.
* And then remove mono_string_to_utf8_image_ignore which is not used.
And then remove the gboolean ignore_error parameter which is always FALSE.
Unlike on the jit (where we set a local variable on the stack frame of the last finally block), use the simple explicit abort protecting code which is used also for cctors. We can't use handler block guard logic since we can't async unwind from the interpreter.
* cooperative suspend babystep wrt mono_domain_try_type_resolve(MonoObject*).
No reduction in warnings, but remove one call to a function that has
warnings, leaving sre.c alone for now.
We have:
mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb)
mono_domain_try_type_resolve_checked (MonoDomain *domain, char *name, MonoObject *tb, MonoError*)
The MonoObject* tb parameter causes a warning under cooperative suspend static validation.
Between name and tb, only one is ever used -- i.e. the non-null one, favoring name.
The non-checked function is embedded, so it survives for the time being.
Internally, we have reflection.c calling _checked(name != null, tb == null) and sre.c the opposite.
So, this fix refactors the function such that one takes const char* and the other MonoObject* (or MonoReflectionTypeBuilder*).
Some calls to a function with a warning are therefore replaced by calls to a function without a warning.
sre.c is left alone for now, therefore the number of warnings does not go down.
The caching within of System.AppDomain.DoTypeResolve is refactored into mono_class_get_appdomain_do_type_resolve_method.
Should we have GENERATE_GET_METHOD_WITH_CACHE like GENERATE_GET_CLASS_WITH_CACHE? Or GENERATE_GET_METHOD_CACHED?
A few stylistic experiments:
ternary operator?
const?
Some name shortening?
Non-anonymous struct tags?
Forward declaration to increase type safety?
_checked suffix optional if not differentiating from other?
* Cleanup MonoError initialization and usage.
Thread MonoError through a bit -- add mono_class_get_method_from_name_checked.
Could also be named mono_class_get_method_from_name_flags_checked.
Rename tb to typebuilder.
rename _builder to _typebuilder.
Reduce but don't eliminate struct/typedef change.
Remove extra braces.
* More MonoError tweaking -- the existance of cleanup breaks the model.
* remove a newline that was added
* Remove line breaks.
Put struct forward declaration among others.
Restore g_warning.
i.e. code review feedback
* Remove some newlines.
* more newlines
* Move from public class.h to private class-internals.h.
* Move new forward declarations out of public header object.h
and into new internal header object-forward.h.
waitpid(-1,...) reaps all zombie child processes of the calling process (see `man waitpid`). After a child process is reaped, it can no longer be queried. Because this reaping step is invoked via the `SIGCHLD` signal, all zombie children of the calling process are reaped every time any child process terminates, regardless of whether that child process was tracked by Mono.
The impact of this bug is that apps using Mono that spawn their own child processes (outside of Mono's `w32process` API) cannot query the exit state of its children. For example, a call to `waitpid(my_child_pid,...)` will return `ECHILD` for "no such child" because Mono has already cleaned up the child the moment `SIGCHLD` was raised.
* Minor cleanup split out and expanded from another larger change.
- Spelling in comment.
- 'l' is a short identifier that looks like '1' -- use "len".
- Remove extra braces.
- Add some g_assert (error) before error_init (error).
* remove unuseful asserts
* [ios-sdk] Rename test-runner directory to 'runtime' to be consistent with xamarin.ios.
* [ios-sdk] Add missing xamarin_log () icall used by Console.Write ().
* [ios-sdk] Change the run-ios-sim target so it works on ios11 as well, the --console option to simctl appears to be broken.
* [ios-sdk] Add a test harness.
The test harness is resposible for starting the emulator, installing the app on the emulator, running it, and
collecting application output using the osx logging facilities.
* [ios-sdk] Fix detection of the app exiting with an unhandled exception.
* [ios-sdk] Add CI support for running some test suites on the simulator.
* [ios-sdk] Kill the log reader process on shutdown.
* [ios-sdk] Disable android on CI because the make targets error out if the android sdk is not installed.
* [ios-sdk] Fix error checking in make targets.
* [ios-sdk] Remove accidently commited binary.
* [ios-sdk] Switch to using os_log instead of NSLog (), the latter doesn't seem to show up in the logs anymore. Switch to using the default ios sdk instead of hardcoding 11.1.
* [ios-sdk] Don't hardcode the ios version when creating a simulator.
* [ios-sdk] Parse the output of simctl list runtimes as json.
* [ios-sdk] Use 'syslog' style logging, its supported by older osx versions.
* [ios-sdk] Fix logfile parsing.
* [ios-sdk] Fix log filtering.
* [ios-sdk] Add test exclusions file for System.
* [ios-sdk] Redirect runtime logging to os_log ().
* [ios-sdk] Link libMonoPosixHelper and zlib into the test runner.
* [ios-sdk] Fix the target64 and cross64 builds.
* [ios-sdk] Build target64/cross64 on CI.
* [ios-sdk] Add device support to the runtime lib. Mark strings in os_log () calls as public.
* [ios-sdk] Log stdout messages using a separate subsystem for easier filtering.
* [ios-sdk] Add an 'appbuilder' tool which can generate simulator and device apps.
* [ios-sdk] Build device tests on CI.
* [ios-sdk] Add a test-runner instead of using nunit-lite-console.exe. The two are identical right now, but they might diverge in the future.
* [ios-sdk] Add a script to download prebuild llvm binaries.
* [ios-sdk] Run the runtime initialization on a separate thread, not the UI thread.
* [ios-sdks] Fix the build.
* [ios-sdk] Build the cross compiler against llvm.
* [ios-sdk] Add missing file.
* [ios-sdk] Add llvm support, enabled by passing LLVM=1 to make build-ios-dev-<app>.
* [bcl] Enable System.Security tests on the MOBILE profile.
* [ios-sdk] Enable more test suites.
* [ios-sdk] Fix device builds.
* [ios-sdk] Make some test steps non-fatal.
* [ios-dev] Use ad-hoc signing to sign device apps.
* [ios-sdk] Decrease the timeout on run-sim to 20m.
* [ios-sdk] Send back the test results using a tcp connection, parsing the ios logs is too fragile.
* [ios-sdk] Mark System.Net.Http tests as notworking, they seem to fail on CI.
* [ios-sdk] Compile the 32 bit cross compiler against llvm as well.
* [ios-sdk] Package up the binaries which can be uploaded to storage.
* [ios-sdk] Fix the download-llvm.sh script.
* [ios-sdk] Compile cross32 on CI.
* [ios-sdk] Use Options.cs from the mcs sources instead of making a copy.
* [ios-sdk] Avoid hardcoding the xcode sysroot, obtain it using 'xcode-select -p'.
* [ios-sdk] Fix the previous change.
* [ios-sdk] Add an option to appbuilder to cache aot compilation results between building different apps.
* [ios-sdk] Build device apps with llvm as well on CI.
* [ios-skd] Use XCODE_ROOT in a few more places, update README.md.
Triggering a forced collection means that it should to an immediate full collection of that generation. If we were having a running concurrent collection we were only finishing it. We should also trigger a new serial gc.
After minor or concurrent collections, we can have dead objects (can not be referenced starting from the current root set) still alive on the heap which can confuse profiling tools.
If we have a heapshot requested and we can't do it on the current collection, defer it to the finalizer.
Lack of it causes a build error in XA:
CMake Error at [..]mono/external/boringssl/util/android-cmake/android.toolchain.cmake:800 (message):
Specified Android native API level 'android-12' is not supported by your
The set of minimum API levels in `configure.ac` is incorrect. The current
NDK (r16) requires minimum API level of 14 for the 32-bit targets and level 21
for the 64-bit targets.
For a m2n transition we expect that we are already in managed (interp) and the delegate's method_ptr expects an InterpMethod. Refactoring will be needed in the future.
Mirror mono_marshal_get_struct_to_ptr. These methods can also handle non valuetypes (with certain attributes), which CEE_UNBOX doesn't logically handle.
There is no need to use BSTR marshaling to convert a SecureString to a
string. On some platforms, BSTR marshaling is not implemented, but we
still want to be able to convert a SecureString to a string on those
platforms.
So instead, use Unicode string marshaling.
https://github.com/mono/mono/pull/5599 fixed a race condition during shutdown
when runtime threads have come parts of their way through detach, but still
depend on runtime resources, like GC memory. The fix added runtime threads
to the joinable thread list just before they vanished from mono_thread_manage
radar making sure shutdown waited upon the thread before cleaning up.
The above fix slightly changed the behavior of the finalizer thread since it
waits on joinable threads and will now potential block on threads still
executing code (that involves runtime resources). There’s was an assumption
around the threads on the joinable thread list that they should be very close
to complete when added, so join calls coming from the finalizer thread should
almost never block and if it does, the code that remains to execute should not
involve runtime operations risking deadlock situations. Adding the thread to
the list earlier than previously done expose the shutdown to some potential
theoretical problems.
To mitigate the risk and still solve the race condition this commit adds a
mechanism to keep track of active runtime threads until they park on joinable
thread list. The pending counter will be waited upon by the shutdown
thread, just before it does its regular wait on all joinable threads
(after finalizer thread has stopped) to make sure all runtime threads have
been added to the joinable thread list before waiting upon them. Threads are
added to the joinable thread as late as possible, exactly how it’s been done
in the past by sgen_client_thread_detach_with_lock. Shutdown thread will wait
on runtime threads to appear on the list for a short time and if timeout (pending
runtime thread count not reaching 0 before timeout), it will just print a warning
and continue shutdown.
Getting into a wait state during shutdown due to runtime threads not yet added to
joinable threads list should be very rare (hitting previous race condition that was rare),
triggering the timeout should be even more rare, and if that ever happens, we are exposed
to shutdown race condition as we have had in the past, but now we at least get a warning in
the log making it simpler to analyze further.
This commit also fixes a problem with the debugger thread hitting the same race condition as above.
The shutdown thread stopping the debugger thread didn't completely wait for it to stop using runtime
resources before continue shutdown sequence. This triggers the same race condition as when shutting
down regular runtime threads. This commit makes sure stop_debugger_thread waits on the debugger thread
handle to become signaled (happens at the very end of thread lifetime) before continuing the shutdown
logic.
* [jit] Remove unused mono_arch_instrument_mem_needs () function.
* [jit] Remove unused mono_arch_instrument_epilog_full () function, only the non-full version is used.
* [jit] Remove some unused arch specific functions previously used by the global regalloc prototype.
This is a follow on to mono/roslyn-binaries#3 which adds the Roslyn VB.NET compiler to the roslyn-binaries repo. This will then install the binaries to the mono installation.
This change re-implement GC roots reporting in a way that allows users to correctly track the source of a GC root.
The new design is based on emitting GC root information upfront and only report addresses during heap dumps.
When a GC root is registered we emit an event that is an address range, the root kind, a key and a text description.
A decoder can use this information to match a reported root address with all registration addresses to figure out what they mean.
A GC Root key is used to further its meaning. For example, if kind is thread, key is a tid, if kind is static variables, key is the vtable pointer and so on.
The build of the change is introducing this key argument across all root registration code and rework our root reporting code to encode their addresses.
Some roots use pseudo-addresses when they are not registrable. This is the case of thread stacks/registers and the finalizer queue.
Finally, root reporting was changed to happen only once per collection and at the end, leading to correct and useful data being produced.
* Compile on amd64 Haiku
Use sigcontext (somewhat like win32, or x86) on Haiku amd64.
On amd64, Haiku doesn't have issues with marshalling 64-bit values,
but it currently does have issues with SGen either causing a stall
or a core dump. As such, while it can compile the stdlib (further
than x86 got), it's still a work in progress.
* Use set_real_time_clock for sys-time.c on Haiku
* Get mono-boehm compiling on Haiku again
It still doesn't work. Initialization will call GC_mark_from, which
will cause a segmentation fault as it decrements pointers. (Mono
will enter an infinite loop in mono_get_hazardous_pointer as a result.)
For now, mono-sgen will continue to be used by default.
make update-solution-files works but actually throws an ArgumentOutOfRangeException and as a result - corrupted csproj (fails on System.Runtime.CompilerServices.Unsafe -
System.Runtime.CompilerServices.Unsafe.dll.sources is empty)
* [linker-analyzer] added --flat option
This options allows to see all dependencies per vertex at once, with
displayed distance in the graph between the vertex and dependent
vertex.
An example of flat output:
Loading dependency tree from: linker-dependencies.xml.gz
--- Type dependencies: 'Android.App.Activity' --------------------------
Distance | TypeDef:Android.App.Activity [total deps: 7]
------------------------------------------------------------------------
1 | TypeDef:XA.App.MainActivity
2 | Assembly:XA.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
3 | Other:Mono.Linker.Steps.ResolveFromAssemblyStep
3 | Other:Mono.Tuner.CustomizeActions
3 | Other:MonoDroid.Tuner.MonoDroidMarkStep
2 | TypeDef:XA.App.MainActivity/<>c__DisplayClass1_0
* [linker-analyzer] Get back to using "unnamed" tuples
Use unnamed tuples to workaround mcs bug. We can revert this change,
once mcs is updated.
The build with mcs was failing like this, because of mcs bug:
```
MacBook:linker-analyzer rodo$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-local
MCS [net_4_x-darwin] linkeranalyzer.exe
Unhandled Exception:
System.NotImplementedException: named tuples for .interfaceimpl
at Mono.CSharp.TypeDefinition.Emit () [0x00028] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ClassOrStruct.Emit () [0x00025] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeDefinition.Emit () [0x002e8] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ClassOrStruct.Emit () [0x00025] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Class.Emit () [0x00000] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeDefinition.EmitContainer () [0x0000f] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ModuleContainer.EmitContainer () [0x0009c] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.AssemblyDefinition.Emit () [0x00098] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00126] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Driver.Compile () [0x002f3] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00052] in <e953cb7042ea446195951c3e14c2cc5a>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: named tuples for .interfaceimpl
at Mono.CSharp.TypeDefinition.Emit () [0x00028] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ClassOrStruct.Emit () [0x00025] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeDefinition.Emit () [0x002e8] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ClassOrStruct.Emit () [0x00025] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Class.Emit () [0x00000] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeDefinition.EmitContainer () [0x0000f] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00007] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.TypeContainer.EmitContainer () [0x0001e] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.ModuleContainer.EmitContainer () [0x0009c] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.AssemblyDefinition.Emit () [0x00098] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00126] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Driver.Compile () [0x002f3] in <e953cb7042ea446195951c3e14c2cc5a>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00052] in <e953cb7042ea446195951c3e14c2cc5a>:0
make[1]: *** [../../class/lib/net_4_x-darwin/linkeranalyzer.exe] Error 1
make: *** [do-all] Error 2
```
Bug was caused by wrong values in enum because `string` is parsed only when type is `SpecificTrampoline` but with mismatching values between C and C# enums it didn't parse string when it should causing parsing next event throwing random exceptions because there was still unexpected string data.
* [w32handle] Don't enter GC SAFE around calls to w32handle_wait_{one,multiple}
On non-Win32, the mono_w32handle_wait_{one,multiple} implementation is
coop-aware, so there's no need to enter/exit GC Safe.
On Win32, mono_win32_wait_for_{single_object,multiple_objects}_ex is not coop
aware (and can't be - because it's called from utils/os-event-win32.c which is
not supposed to use coop machinery), so do GC transitions around these calls.
Fixes cooperative GC regression due to f5fc773512
* [w32process] Use coop concurrency primitives
for exit_sem and processes_mutex.
With OS semaphores we could deadlock under coop GC if a GC happens at the same time that
a thread is waiting on the exit_sem - the finalizer thread gets suspended and
the incoming SIGCHLD never posts, so the waiting thread never suspends and the
GC STW never happens.
fixup! [w32process] Use coop semaphore for exit_sem
* [test] assembly_append_ordering.cs: mark methods with NoInlining
if TriggerLoadingSystemCore is inlined into Main, System.Core will be loaded
when Main is JITed, which throws off the assembly loading ordering that the
test cares about: that the SRE assembly is loaded before System.Core.
When we leave a try block and invoke finally blocks, we need to add try holes also for catch handlers, since they can invoke the previously handled finally blocks.
This has the following advantages:
* There is only one implementation instead of two
* The C version no longer needs to be compiled/recompiled.
The disadvantage is the additional build time dependency on python.
The windows build will keep using the C version for now.
* [jit] Extract AOT definitions from mini.h to aot-runtime.h.
* [jit] Remove some dead declarations from mini.h.
* [jit] Extract some non-JIT related functions and MonoJitDomainInfo/MonoJitTlsData into mini-runtime.h
- 1 pixel for right and bottom to compensate cells CellBounds overlapping;
- one more pixel for top, right and bottom to have one pixel gap between text and border. Left border had a good gap already (why?).
No call DrawText for cell if there is no rectangle at all.
The AOT profiler is not meant to be loaded during AOT compilation.
The coverage profiler does not currently support instrumentation of AOT code.
The log profiler does support enter/leave instrumentation of AOT code, but no
other functionality should be enabled in this case. We only want to set the
call instrumentation filter callback and then return control to the runtime.
* [interp] disassembler for mint instructions should return a string instead of printing char by char
otherwise logs are unreadable on products like XI
* [fixup] free `ins`
With the revamped GC root reporting work, some GC root unregister events will
arrive after the thread_stopped event. This will cause the thread to be
re-added to the thread list in the profiler, and never be removed until program
exit. This meant that if such a thread had actually exited and a new thread
would reuse its thread ID, that new thread would fail to add itself to the
thread list, leading to failures like this one:
init_thread: failed to insert thread 0x70000b761000 in log_profiler.profiler_thread_list, found = true
By using the new thread_exited event, we remove the thread from the thread list
after these GC root unregister events have arrived, thereby ensuring that the
thread won't be incorrectly 'resurrected'.
thread_stopping occurs earlier than thread_stopped, before any of the detach
code has run. thread_exited occurs after thread_stopped, once all detach logic
has finished.
* [runtime] Implement a few broken getters on ModuleBuilder
* [runtime] Implement ModuleBuilder.GetCustomAttributes
* [runtime] Test GetMethods, GetCustomAttributes, and GetFields for ModuleBuilder
* [runtime] Specify and test use of typebuilders with Custom Attributes + add more tests
* [w32find] Remove use of w32handle
* [w32handle] Ref handle when looking it up so it doesn't get destroyed while using it
* [w32handle] Ref handle when accessing its MonoW32HandleBase
* [w32handle] Make MonoW32Handle public
* [w32handle] Return MonoW32Handle as part of mono_w32handle_lookup_and_ref
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_own
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_isowned
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_signal
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_prewait
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_specialwait
* [w32handle] Pass MonoW32Handle from mono_w32handle_ops_details
* [w32handle] Pass MonoW32Handle from mono_w32handle_foreach
* [w32handle] Pass MonoW32Handle to own_if_{owned,signalled}
* [w32handle] Pass MonoW32Handle to mono_w32handle_issignalled
* [w32handle] Pass MonoW32Handle from mono_w32handle_set_in_use
* [w32handle] Pass MonoW32Handle to mono_w32handle_{lock,trylock,unlock}_handle
* [w32handle] Remove dead mono_w32handle_ref
* [w32handle] Pass MonoW32Handle from mono_w32handle_set_signal_state
* [w32handle] Pass MonoW32Handle to mono_w32handle_test_capabilities
* [w32handle] Remove dead mono_w32handle_get_type
* [w32handle] Pass MonoW32Handle to mono_w32handle_ops_signal
* [w32handle] Pass MonoW32Handle to mono_w32handle_ops_isowned
* [w32handle] Pass MonoW32Handle to mono_w32handle_ops_specialwait
* [w32handle] Pass MonoW32Handle to mono_w32handle_timedwait_signal_handle
* [w32handle] Fix some typos and ref/unref imbalance
* [w32handle] Rename mono_w32handle_{trylock,lock,unlock}_handle to mono_w32handle_{trylock,lock,unlock}
* [w32handle] Rename numhandles to nhandles
* [w32handle] Return MonoW32Handle instead of index when creating the handle
* [w32handle] Remove gpointer handle parameter for mono_w32handle_{ref,unref}_core
* [w32handle] Remove gpointer handle parameter for mono_w32handle_timedwait_signal_handle
* [w32handle] Remove gpointer handle parameter for mono_w32handle_duplicate
* [w32handle] Remove gpointer handle parameter for w32handle_destroy
* [w32handle] Remove gpointer handle parameter for mono_w32handle_unref
* [w32handle] Remove dead function
* [w32handle] Remove gpointer handle parameter for own_if_{owned,signalled}
* [w32handle] Remove gpointer handle parameter for mono_w32handle_{wait_one,wait_multiple,signal_and_wait}
* [w32handle] Remove gpointer handle parameter for mono_w32handle_foreach callback
* [w32handle] Remove gpointer handle parameter for mono_w32handle_ops_{signal,own,isowned,specialwait,prewait,details}
* [w32handle] Make mutex and cond coop friendly
* [w32handle] Check for ref before type in mono_w32handle_lookup_and_ref
* [w32handle] Allocate the private_handles array on the heap, to reduce mono executable and library size
If nodefaults is passed as the first argument, we would print `Could not parse argument: nodefaults` due to how it's parsed differently.
If nodefaults is passed after the first argument we would not print a warning that this was wrong.
This commit fixes both usability issues.
* [sdks] Fix Android pick of mono runtime
* [android] Have Console.{Out,Error} go through the runtime log mechanism to ease their interception
* [sdks] Intercept runtime logs instead of Console to send back for instrumentation
* [sdks] Intercept Android test runner logging
[profiler] Some documentation improvements
* Update and rewrite profiler-related `man` pages.
* Update profiler API documentation for the new API.
* Extend the `exdoc` tool to support some more Doxygen features.
* Document the AOT profiler's file format.
* Clean up the sample profiler module and add a makefile.
* Include context/domain reports in `mprof-report`'s default report set.
* Exit the process when the `help` option is passed to the profilers.
* Remove the IOMap profiler.
* Remove some deprecated options from the log profiler's `help` output.
* Clean up the AOT profiler and bring its user interface in line with the others.
* Allow comments in coverage filter files.
In 22f0977132 it was disabled
but we can actually just run a shorter version in PRs.
Also reenable the precompilation target for the managed CoreCLR tests.
[LogProfiler] Removed GcRoot events logging from start
GcRoots should only be reported/captured during heapshot. We already set callback when heapshot collection starts and unset it when heapshot is finished. Which means after 1st heapshot is taken we don't log them outside heapshot. Hence we shouldn't be logging them from start...
GcRoots should only be reported/captured during heapshot. We already set callback when heapshot collection starts and unset it when heapshot is finished. Which means after 1st heapshot is taken we don't log them outside heapshot. Hence we shouldn't be logging them from start...
The test was added in https://github.com/mono/mono/commit/375471820c02ff0bab025bff75b5da7efc95d3cd.
We were seeing some flakyness in the this test, looking at it I
noticed that we were passing executeOnlyOnce = false to
(Unsafe)RegisterWaitForSingleObject. This means that the delegate
would be executed again whenever the AutoResetEvent `evt` is signaled or
the timeout elapsed. The problem is that evt is never signaled by design
and we set a timeout of 1ms which means we'd execute it in a tight loop.
Setting executeOnlyOnce = true fixes this and I verified it doesn't
change the intent of the test (i.e. the test still fails after the
original commit is reverted).
Bumped the timeout for the CountdownEvent as well to be safe
since it's quite short.
When doing an OP_CALL_HANDLER for a clause (from a leave opcode), all following instructions, up until the actual branch out of the try block, should be part of a hole for that clause. We were failing to account for a single leave instruction invoking multiple finally clauses sequentially, in which case a basic block can be a try hole for multiple clauses.
* [bcl] Build some assemblies with -warnaserror
This ensures that we keep the build warning free.
We'll only opt-in a few assemblies that already have zero warnings.
We also only apply this when using csc as mcs might raise different warnings.
For now just opt-in assemblies in the net_4_x profile.
* Use the same option parsing logic as the other profilers.
* Support the same output file syntax as the other profilers.
* Use output.aotprofile as the default output file name.
* Open the output file on startup rather than shutdown.
* Use runtime logging functions instead of printf/fprintf.
* Don't print anything unless the verbose option is given.
* Fix an endianness issue with writing ints to the output file.
* Move all profiler state into MonoProfiler structure and store it statically.
* Remove outdated comments and includes.
* Separate profiler module documentation into a new mono-profilers(1) page.
* Add documentation for the aot and coverage profilers.
* Rewrite the mprof-report(1) page to only talk about mprof-report itself.
* Rewrite and update the profiler-related sections of mono(1).
* Conform to man page formatting conventions.
* Move doc comments to profiler.c so they're picked up by exdoc.
* Rewrite mono-api-profiler.html for the new profiler API.
* Clarify some aspects of the doc comments.
Some generic instances were not generated because they were only referenced by METHOD_RGCTX patches, and the gsharedvt
fallback didn't work because the method in question Unsafe.Add<T> uses a sizeof opcode on a gsharedvt type which is currently
not supported.
Testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Runtime.CompilerServices;
public class Tests
{
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void Foo55<T> () {
byte[] arr = new byte [10];
ref byte data0 = ref arr [0];
Unsafe.Add (ref data0, 0);
}
interface IFace {
void Foo55 <T> ();
}
class AClass : IFace {
public void Foo55 <T> () {
byte[] arr = new byte [10];
ref byte data0 = ref arr [0];
Unsafe.Add (ref data0, 0);
}
}
public static int Main () {
IFace iface = new AClass ();
iface.Foo55<int> ();
return 0;
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
* [ci] Fix testing of msbuild in run-test-mac-sdk.sh
It contained the old version number and failed on bots that didn't
have leftover old build result.
* [ci] Fix msbuild paths in Windows packaging
They changed with 73bd521c07.
mono_class_setup_interface_offsets and mono_class_setup_interface_id should
only be called for interfaces.
mono_class_setup_interface_offsets is incorrect for classes, and
mono_class_setup_interface_id would be a no-op.
* [ci] Add Jenkins pipeline script for building OSX and Windows packages
This replaces the current Jenkins freestyle jobs.
We no longer need the signing inside of the MacSDKRelease profile
since we're now signing on a separate service and having the signing
certificates locally is discouraged anyway.
* [ci] Update embedded gtk-sharp in Windows msi to 2.12.45
This matches what we ship on www.mono-project.com
* [sdks] Match xamarin-android targets flags and parameters
* [sdks] Only compile BCL profiles that are needed
* [sdks] Add release and debug out directories for android
* [sdks] Add Android SDK and NDK paths from xamarin-android
* [sdks] Match xamarin-android x86 SDK version
* [sdks] Use make_standalone_toolchain.py to provision the Android toolchain
* Bump nuget-buildtasks
cherry-pick 304d785bd0
* [msbuild] Install importbefore/after hooks for nuget
cherry-pick 4c935964b2
* [msbuild] Fix build - create the directories before installing .. (#5980)
.. to them.
cherry-pick d711efdd90
* [msbuild] Fix build (#5981)
- Don't copy 14.0/Imports to 15.0 now, as we do that in nuget-buildtasks.
- And don't create symlinks for Microsoft.NuGet.targets as it is not
required anymore.
cherry-pick ef1ea85c0f
* [tools] Fix .apps generated by MacPack not running when Mono 5 is installed on macOS
The current script used by the generated .app only checks for Mono in /usr/local/bin, but not in /Library/Frameworks/Mono.framework/Versions/Current/Commands (the default location for new installations of Mono 5 on macOS)
* [tools] Fix WinForms .apps generated by MacPack not running when Mono 5 is installed on 64-bit macOS
Latest Mono now defaults to running mono64 on a 64-bit OS but there is currently no WinForms support on 64-bit Mono. Pass --arch=32 to mono when wrapping a WinForms app with MacPack.
* Localized * FileDialog. Fixed missing Locale.GetText for the displayed strings.
* Fixed padding and size of buttons in the PopupButtonPanel class. This was done to remove the workaround "Recently\nused" and similar in futher localizations.
* Changed width of PopupButtonPanel to prevent sticking buttons to the separator.
Instead of using find_method which relies on method name and exact signature
matching (and thus can't work for variant interfaces), use the vtable and the
interface offset to find the constrained method.
Terminology:
base method - a method of the base class to be called
base class - some general class or interface that declares a method
constraint class - a more specific class that also implements the method.
constrained method - the version of the base method in the constraint class.
To find the constrained method given the base method:
- if the base class is a class:
the constraint class can't be an interface. it's either the base class or
some subclass of it. If the base method isn't virtual there's nothing to do
the constrained method is the same one.
If the base method is virtual, get its vtable slot and find the corresponding
method in the constraint class's vtable.
- if the base class is an interface:
in this case the constraint class is either another interface or a class.
if the constraint class is an interface, since interfaces can't have
implementations, there's nothing to do.
if the constraint class is a class, then to find the constrained method
get the interface slot offset of the base method and find the base interface offset
of the base interface and look in the constrained class vtable.
(the base interface offset gives the starting vtable slot for the base
interface in the constraint class vtable; the slot offsets go consecutively
for each of the methods of the interface).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60545
They are not generated by a ruby script.
The commit includes the generated file and the generation script for now to ease development.
We can later discuss generating it at build time.
In Unix, assume our current directory contains:
`test`, a directory
`test/test2`, another directory
`test/test2/test_file`, a file
`test3`, a symbolic link pointing to `test/test2`
Then the path "test3/../test3" has two interpretations depending on the processor:
* The OS (the `lstat` syscall, `ls`, etc.) will find it invalid (as it evaluates to: enter `test/test2`, go up one level, try to enter `test3` which is another level down
* We (.NET, at least CoreCLR) should find it valid (enter `test3`, go up one level, enter `test3`).
This ensures that for Directory.Exists, we process the path `..`'s on the .NET level before passing it for native processing.
this test case was broken for an unknown time, but surfaced with a
recent change in nunit-lite (2255c54966)
that runs every test in a new `ExecutionContext`. Previously, the
pre-condition for this test was implicility fulfilled by another test.
The test failed already when executed only on its own. With the change
around `ExecutionContext`, each test is "isolated" regarding said
pre-condition.
The fix is to explicitly fulfil the pre-condition in the test.
ModuleBuilder::GetArrayMethod returns a fresh MonoArrayMethod instance each
time it's called, even if you ask for the same method multiple times. On the
other hand, mono_image_get_array_token caches tokens by method signature.
Therefore mono_image_create_token should expect collisions.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60238
* [runtime] Fix mkbundle compilation on OSX
* [runtime] Add aot arguments to mkbundle
* [runtime] Enable compiling aot with mkbundle
* [runtime] Add new dedup interface to mkbundle
* [runtime] Fix path resolving for mkbundle
* [runtime] Use mkbundle in BCL tests
* [runtime] Skip building System.Security, System.IdentityModel tests on testing_aot_full
* [runtime] Fix in-tree building for mkbundle
* [runtime] Move testing dll into profile
* [runtime] Add target to mkbundle all tests before CI
* [runtime] Build stripper and use with mkbundle
Preliminary linker support ran into dependency-finding bug
with the monolinker.exe binary. Fix postponed until later.
* [runtime] Skip not supported tests with mkbundle
* [runtime] Don't re-aot when running BCL tests
* [runtime] Provide config to mkbundle
* [runtime] Fix mkbundle internationalization test results, build all
* [runtime] Clean up temp mkbundle aot directory
* [runtime] Add mkbundle support for dedup
* [runtime] Fix tracking of dedup module in mkbundle
* [runtime] Document mkbundle AOT options in man pages
* [runtime] Fix CADMessage generic method argument marshalling
* [runtime] Support excluding or choosing to emit only inflated methods
* [runtime] Only write cache if changed, so can be used by Makefiles
* [runtime] Thread state through multiple mono_compile_assembly calls
* [runtime] Emit skipped methods in dedup module
* [runtime] Use AOT attribute to mark dummy dedup module
* [runtime] Expose and use can_dedup for AOT compiler+runtime
* [runtime] Add missing cases to the mangler
* [runtime] Fix direct calls with dedup
* [runtime] Implement runtime support for finding deduped code
* [runtime] Refactor dedup state setup into new function
* [runtime] Add in dedup debugging aid / external visibility
Gives a demo on how to make mangled method names externally visible
* [runtime] Log dedup statistics
This fix is a bit weird but it's due to some restrictions of the managed API.
MissingMemberException & friends require both ClassName and MemberName to be supplied independently, so the signature
can't simply be applied to MemberName. So we pass it on a separate field.
The next thing is that we want C#'esque signatures, where the return type comes before ClassName.MemberName, so we pass
a format string and apply it in managed.
it was fine on CI, but developers can run into build errors if they
don't follow a strict order (due to autotools fighting with
`winconfig.h`).
`basic.exe` passes, but everything involving native transitions crashes.
This introduces the following changes.
By default, enable more events. Exceptions and Counters are on by default.
By default, if alloc or heapshot are enabled, we emit root events as well.
New `nodefaults` argument that disables the above changes to default arg processing.
Added "nocalls" argument for compat only purposes.
Restored "cycles/" prefix to sample frequency argument. It was already a dead argument, but kept for compat.
We restored that as existing clients pass that flag.
* [tests] Appdomain assembly loading regression test for #49308
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=49308
We try to trick the remoting code into causing an assembly from a bad directory
to be loaded too eagerly into an appdomain. If we succeed, we call a method
that doesn't exist. Expected behavior is that the bad assembly is not loaded
and instead we can do an Assembly.LoadFrom of a good assembly.
* [tests] Add appdomain-marshalbyref-assemblyload.exe to KNOWN_FAILING_TESTS
This is a regression test for
https://bugzilla.xamarin.com/show_bug.cgi?id=49308, it should be re-enabled
when the bug is fixed.
.. of 15.x. It doesn't really affect anything and makes it simpler on
wrench to specify directory from which to run the tests!
(cherry picked from commit 3f3b106aca)
# Conflicts:
# packaging/MacSDK/msbuild.py
* [Tests] Make Mono.Data.Sqlite tests more robuts.
There are cases in which the tests are ran in parallel and the files
used for the db are writte/read by several tests at the same time. This
changes ensures that we do have a diff test file per test case to ensure
that we do not have false negatives.
Any translation unit that includes a Mono header should include <config.h>
first to ensure that all of our configuration defines are available.
In particular, config.h defines MONO_INSIDE_RUNTIME which, in mono-publib.h causes
MONO_RT_EXTERNAL_ONLY to be defined to an attribute that causes a compilation
error if you use a function that is internally deprecated for the runtime.
Also change a couple of places that used non-_checked functions.
Handles macro bodies are allowed to operate on raw pointers to managed memory.
The macro arguments must be UNSPUPPRESSed because we want warnings if the
arguments are doing bad things.
Marking a struct definition or a typedef with MONO_RT_MANAGED_ATTR will cause
Centrinel to treat pointers to the struct as residing in managed memory and to
issue warnings when raw pointers to such managed objects occur in the runtime.
(Also Centrinel knows that if the first field of a struct is a `MonoObject`,
then the struct is definiting a subtype of a managed object and so pointers to
_that_ struct also point into managed memory)
This is a candidate fix for:
https://bugzilla.xamarin.com/show_bug.cgi?id=60317
The bug was introduced by 1b5e0f7331.
Preliminary verification
========================
If I make just this _one_ change to a "bad" commit of Mono from after
commit 1b5e0f7, rebuild System.dll in the `xammac` profile, and then
overwrite that file in the MonoBundle directory of a Xamarin.Mac test
app, then I restore the old "good" behavior. (I started with
38da0b3b49 as the "bad" version for my
tests.)
I believe this confirms that the cause of bug 60317 was the usual
deadlocking issue when awaiting Tasks on the UI thread. As discussed on
https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html, if
any Tasks awaited anywhere up the call stack are missing
`ConfigureAwait (false)`, then you can run into trouble on the UI
thread.
Additional little checks
========================
1. Do the other `await` statements in commit
1b5e0f7331 all look OK? Yes, it looks
like this was the only `await` statement that was missing
`ConfigureAwait (false)`:
```
$ git show 1b5e0f7331 | grep await
+ await ProcessOperation (cancellationToken).ConfigureAwait (false);
+ var ret = await InnerRead (cancellationToken).ConfigureAwait (false);
+ await Parent.InnerWrite (RunSynchronously, cancellationToken);
+ var ret = await Parent.InnerRead (RunSynchronously, requestedSize, cancellationToken).ConfigureAwait (false);
+ result = await asyncRequest.StartOperation (CancellationToken.None).ConfigureAwait (false);
+ result = await asyncRequest.StartOperation (cancellationToken).ConfigureAwait (false);
+ var ret = await task.ConfigureAwait (false);
+ await task.ConfigureAwait (false);
```
2. Is it a concern that mcs/class/System did not contain any calls to
`ConfigureAwait ()` until commit 1b5e0f7:
```
$ git grep ConfigureAwait 1b5e0f73316ee7b83c8947bc738015443fabd7af^ -- mcs/class/System || echo 'None'
None
```
I do not think this is a concern. For example,
System.Net.Http.HttpClient has been using `ConfigureAwait (false)` for
several years, so there is a precedent for it.
This occasionally happens:
```
System.NullReferenceException : Object reference not set to an instance of an object
at System.Diagnostics.Win32EventLog.NotifyEventThread (System.Threading.ManualResetEvent resetEvent) [0x00001] in D:\j\workspace\w\mcs\class\System\System.Diagnostics\Win32EventLog.cs:739
at System.Diagnostics.Win32EventLog.<EnableNotification>b__44_0 () [0x00000] in D:\j\workspace\w\mcs\class\System\System.Diagnostics\Win32EventLog.cs:729
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in D:\j\workspace\w\mcs\class\referencesource\mscorlib\system\threading\thread.cs:68
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in D:\j\workspace\w\mcs\class\referencesource\mscorlib\system\threading\executioncontext.cs:957
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in D:\j\workspace\w\mcs\class\referencesource\mscorlib\system\threading\executioncontext.cs:904
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in D:\j\workspace\w\mcs\class\referencesource\mscorlib\system\threading\executioncontext.cs:893
at System.Threading.ThreadHelper.ThreadStart () [0x00008] in D:\j\workspace\w\mcs\class\referencesource\mscorlib\system\threading\thread.cs:105
```
We'll get it because there's a race as the lamdba capturing
_notifyResetEvent in EnableNotification() is outside of the
_eventLock so _notifyResetEvent can be null by the time it is called.
We need to check for that case in NotifyEventThread().
* [interp] clear stack on resuming into the main loop
fixes `System.Collections.Generic.DictionaryTest.IDictionary_Add3`.
The problem is that resuming into an handler requires the evaluation stack to be emptied, which didn't happen with the new unified exception handling.
The frame layout looks like this in memory:
| sp | vt_sp | locals | ... |
|----|-------|--------|-----|
If we don't empty `sp` properly, we will eventually overflow into the `vt_sp` area (which is the evaluation stack for value types). So things get funny if `sp == vt_sp` and you do stuff like this:
```c
sp->data.p = vt_sp;
```
Kind of amazing that it almost passed the whole test suite with that bug.
* [interp] clear eval stack for value types as well when entering a handler
* [interp] disable more tests in corlib suite
* [Facades] Use same assembly company/product/copyright attributes as other BCL assemblies
We can't use Consts.cs since it'd bloat up the facades too much.
Also remove ".dll" suffix from AssemblyTitle/Description to match
what the Facades in the .NET Framework Reference Assemblies pack
are using.
* Bump API snapshot submodule
* [interp] enable it by default in configure
can be disabled via --enable-minimal=interpreter, like other components in the
runtime.
* [interp] use DISABLE_INTERPRETER in Makefile.am.in so it is closer to what we had before
* [interp] improve handling of interpreter flag and also check if we are on a cross-compile runtime
* [configure] add interpreter to the list of --enable-minimal
* [ci] remove --enable-interpreter from script
* [windows] disable interpreter for now
* [driver] add output about availabilty of interpreter in --version
* [man] add entry to mono.1 about --interpreter
* [driver] update --interpreter handling
Race only observed on Windows and current solution adds dependency between detach
and finalizer thread. Disable on none Windows platforms until we have an alternative
solution to the race condition. Keep on Windows until we have alternative solution
since race is manifesting itself on Jenkins builds.
This removes the duplicate code from the interpreter and makes it possible to support exception debugging.
Also fix the the basic block construction code so CEE_THROW begins a new bblock.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=59909
WebChannelFactory doesn't add the WebHttpBehavior on mobile:
https://github.com/mono/mono/blob/4272b68b769951c221ec39d3e844f8f715e1df62/mcs/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs#L87-L90
This makes the WebInvokeAttributeTest.RejectTwoParametersWhenNotWrapped
test fail on mobile since it doesn't reach the normal validation
method where it'd fail with InvalidOperationException, e.g. here''s
the stack on net_4_x profile:
```
System.InvalidOperationException : Operation 'Join' has multiple message body parts. Add parameters to the UriTemplate or change the BodyStyle to 'Wrapped' or 'WrappedRequest' on the WebInvoke/WebGet attribute.
at System.ServiceModel.Description.WebHttpBehavior.ValidateOperation (System.ServiceModel.Description.OperationDescription operation) [0x000f9] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs:249
at System.ServiceModel.Description.WebHttpBehavior.Validate (System.ServiceModel.Description.ServiceEndpoint endpoint) [0x00028] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs:268
at System.ServiceModel.Description.ServiceEndpoint.Validate () [0x0007f] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs:129
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) [0x0002b] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:148
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address) [0x00000] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:115
at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00006] in /Users/alexander/dev/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:110
```
We can fix this by adding the WebHttpBehavior in the test manually.
NB: I'm actually not sure why this isn't done by default on MOBILE?
According to MSDN it should.
rpm-find-provides is a mess, this makes it a bit less of a mess by adding not only stuff from the GAC, but also Facades and 4.5 directories. Doesn't help with version mismatches for facades though.
This fixes bug #60435, where the DataGridViewRow.CreateCellsInstance method is never invoked. Now value of the Cells property is initialized by calling the CreateCellsInstance method.
Removed unused localization resource files.
Added default resources for English locale. Updated makefile and System.Windows.Forms-net_4_x.csproj.
Class Locale now uses ResourceManager.
The zip tests were not using temp files which created bug #60480 when
trying to read the embeded resources. This also fixes the situation in
which tests are run in parallel for the Mac since we could have tests
that step on each other files.
Both on jit and interp, the full corlib message sink path does not work on some testcases. Apparently we rely on the xdomain wrappers for correctness there.
The object creation of some types (like ContextBoundObject) can return a transparent proxy. When calling the constructor on the returned object we might need to go through the remoting wrappers.
* [interp] Add infrastructure code needed for unified exception handling between the interpreter and the JIT.
* Pass the clause to mono_interp_set_resume_state ().
* Add a mono_interp_run_filter () function to run filter clauses.
* Add a 'ji' field to ExceptionTraceIp which is used to avoid an ip->ji lookup in ves_icall_get_trace ().
* Rename mono_handle_exception_internal_first_pass () to handle_exception_first_pass () and make it return the
StackFrameInfo for the frame which caught the exception.
This allows the removal of the duplicate and hard to understand interpreter EH code
and makes it easier to add debugger support to the intepreter.
* [sdb] Pass the already computed StackFrameInfo to mono_debugger_agent_handle_exception () so it doesn't have to be recomputed in ss_create (). This approach works both for the JIT and the interpreter.
* [interp] Generate seq points for async methods too.
* [interp] Rename ves_exec_method_with_context () to interp_exec_method_full (), add a interp_exec_method () helper with less arguments.
* [interp] Set ctx->sp for interpreter frames to the address of the InterpFrame structure, code in debugger-agent.c uses it to order frames.
* [sdb] Fix the support for filter clauses in the interpreter by running them in a new interpreter frame.
* [sdb] Add DEBUGGER_INVOKE frames for the interpreter.
* [interp] Add a mono_interp_frame_get_parent () function, use that instead of the 'new_sp' argument to mono_interp_frame_iter_next ().
* [sdb] Run the test code for the ClassLocalReflection () test only for that test since it doesn't work with the interpreter.
* [interp] Fix the build.
* [jit] Move the code handling the MonoLMFExt structures from exceptions-<ARCH>.c to mini-exceptions.c, its the same on all platforms.
* [jit] Remove mono_arch_init_lmf_ext (), it does the same on every platform.
Use getrandom() instead of /dev/urandom on Linux
getrandom() was introduced in version 3.17 of the Linux kernel and glibc has implemented it since version 2.25.
After a user requested minor collection we need to check if the new size of the heap exceeds the allowance, in which case we need to also do a major collection.
Fixes bug (#60168) where, if user triggers minors repeatedly, we never get to collect the major space (which is normally checked after the nursery is full, which never happens in this case)
d9922895d4 removed Mono.Unix.Native/SocketTest.cs
from the exclude list on the monodroid profile.
It turns out that some tests don't work there however,
they fail with an ArgumentOutOfRangeException on some socket options.
The latest NDK doesn't support platform 9 anymore, the minimum it accepted was 14 thus I changed both arm and x86 to it.
This is harmless as 14 covers all but gingerbread which XA plans on stopping to support.
Added a android-toolchain target that configure all android toolchains.
On my system, XS installs android sdk/ndk on different places.
This patch probe the default places and fallback to the places I got.
It does verify if the paths are bad and fail building ASAP.
Finally, in includes sdks/Make.config that will include defines to trim what things you actually want to build.
When matching a class in match_class() debug helper, avoid maching the class
if the matched-against descriptor's class name is only
a prefix of the class name, but the class name is actually
longer (e.g. don't match Foo2 against Foo).
Add a unit test for callspec parsing and evaluation.
call specifications are being used with the --trace command line
argument and with the log profiler 'callspec' parameter. This test
suite verifies that call specifications are correctly parsed and matched
against methods at runtime.
Jemalloc is known to have much better performance than system memory
allocators, and is safe in concurrent/re-entrant situations.
To use, provide the following options to configure:
--with-jemalloc to enable optionally. To use at runtime,
export MONO_USE_JEMALLOC to the environment.
--with-jemalloc-always to enable and make the default
--with-jemalloc-assert to enable with assertions to catch memory
unsafety. It adds overhead, but an overhead that's much less than
valgrind or asan.
If you export
MONO_JEMALLOC_CONF="stats_print:true"
You will see detailed memory statistics for mono at exit.
Now note that jemalloc is used through an explicit registration, so
C libraries called through pinvoke calls will not use jemalloc unless
they configure themselves to do so separately.
To understand the build work, I'm statically linking jemalloc.a into
the compilation unit for mono/utils/mono-jemalloc.c, which is
responsible for registering it with mono at startup. No further
copying out of the submodule is necessary at installation time.
* Exclude a couple of sources currently not building anything useful on Windows.
* Added MONO_EMTPY_SOURCE_FILE to a couple of source files ending up empty by default.
* Excluded API's not included on UWP targets.
* Explicitly declared import project paths in target files.
* Added support to define x64 MASM build outside default targets file.
Roslyn looks only inside `$msbuild_bin/Roslyn/` and does not fallback to
the framework path. msbuild worked around this by setting `CscToolPath`:
https://github.com/mono/msbuild/commit/157a0f4d1a7aadd4e561e3ca8c784cbc2529926f
But this kicks in only if the default msbuild target files are imported!
If the `Csc` task is being used without importing them, then we fail
with
`error MSB3082: Task failed because "csc.exe" was not found.`
`Microsoft.CodeAnalysis.VisualBasic.dll` is the only file not being
symlinked, after this change. So, instead we will symlink all the files.
Fixes bxc #60340 .
Preserve
`System.Runtime.Remoting.Activation.ActivationServices.CreateProxyForType`. It
is called from `object.c:mono_object_new_specific_checked` when
constructing remoting or com objects.
I didn't add `feature="remoting"` because it is used also for com
objects.
Added linker test. Without the LinkerDescriptor addition, it fails
like this:
Unhandled Exception:
System.NotSupportedException: Linked away.
at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_object_new_specific(intptr)
at C.Main () [0x00001] in /Users/rodo/git/mono/mcs/tools/linker/Tests/mscorlib/test-remoting.cs:11
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException: Linked away.
at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_object_new_specific(intptr)
at C.Main () [0x00001] in /Users/rodo/git/mono/mcs/tools/linker/Tests/mscorlib/test-remoting.cs:11
* Only null check target for delegate if method is not static. Fixes regression introduced by 1cfd52452a.
* [interp] pass first stack arg to transform, so we get the correct delegate wrapper
the wrapper logic detects if the target method of a delegate is a static
method with an argument bound, and handles it properly in the generated
code.
fixes mono/tests/delegate14.cs
This broke "make dist" after 61559965a1
because comments were added to System.Data_test.dll.sources
and they weren't stripped when TEST_FILES was computed so it tried
to include them in the tarball as files.
We count on the fact no threads are created or switched to foreground between the time we waited for all foreground threads to exit and the time we abort all running threads (except for the finalizer and DONT_MANAGED threads). This is racy and we should suspend all threads, them being foreground or background.
Removing the thread from the `threads` array in `remove_and_abort_threads` goes against the lifetime expectation that a thread is removed from `threads` when it is being detached. This 2 ways of having the thread removed complicates the lifetime management and expectations of the thread.
* [mini] Fix spiller when the dest membase optimization intereferes with lvreg caching. Fixes#20562
Given this IR sequence:
int_add R18 <- R18 R18
move R37 <- R18
The spiller would use the dest membase optimization and change the `add` to `add_membase_reg` and assume that the value in R18 would still be valid afterwards. This was the case cuz the code handling sreg2 won't check whether R18 would be mutated but not kept in a register.
The fix is to disable lvreg caching if the dest membase optimization is used. It forces later uses to reload from memory, which is not great, but it's correct.
* [mini] Add regression test for #20562 and re-enable ratests.cs.
* [runtime] Rename atomic functions from the win32 style naming to mono_atomic_<op>_<type>, with a consistent signature on all platforms. This fixes a large number of warnings on windows.
* Add Windows implementaiton of mono_atomic_*.
* Windows implementation of mono_atomic_* inline functions.
* Changed naming typo in mono_atomic_xchg_i32Add and mono_atomic_xchg_i32Add64.
* Fixed some additional signed/unsigned/volatile warnings when using mono_atomic_*
* Fixed some smaller additionl warnings.
* Fix Interlocked* to mono_atomic_* name change in signal.c
* Additional name adjustment of atomics.
Aligning more towards C11/C++11 standard namings:
mono_atomic_xchg_add_i32|i64 -> mono_atomic_fetch_add_i32|i64
Changed from mono_atomic_add to mono_atomic_fetch_add in cases when return
type is not used.
Also includes small mingw build fix on Windows.
* Aligned loads with C++11 implementation using explicit compiler barrier.
On x86/x64 Windows, reading a properly aligned 8,16,32 bit volatile variable
(using /volatile:ms extension) should have acquire semantics. On x64
this also includes 64-bit properly aligned volatile variables.
The C++11 implementation does however include an explicit _ReadWriteBarrier in
its sequentially consistent implementation to instruct compiler to not reorder
load/stores. Since compiler supports two modes of volatile behavior (ms/iso)
this additional barrier is probably there for consistency, independent of the
behavior of volatile keyword.
NOTE, the x86/x64 CPU architecture has strong guarantees regarding load/store of
memory operations, so issuing a CPU memory barrier for loads should not be needed
(and is not done in C++11 atomics implementation).
This commit also adds a couple of optimizations for 32-bit loads and for x64,
64-bits loads. The C++11 implementation uses the same pattern loading them as 8
and 16 bits variables, so no need for Interlocked* calls to load 32-bit and for x64
64-bit variables.
These tests classes are already included in the corlib test assembly.
Having them duplicated in System.Core causes issues in XA because
both test assemblies are in the same process.
To solve this we introduce abstract *TestBase classes that we can
share between the test assemblies and only mark the concrete test
class implementations with [TestFixture]
* [bcl] Remove AssertExtensions helper classes
Since we're on nunitlite now we can use the proper `Assert.Throws<>()`
instead and remove the helper class (which we actually duplicated!)
This may not be the final fix; the Mono-only workaround was introduced in b5dc9a4951 to fix a crash with Unicode paths in TryCreate. However the test case for that issue now succeeds without the workaround.
* [test] ILGenerator test for duplicate methodspec tokens
Regression test for [Bugzilla #60233](https://bugzilla.xamarin.com/show_bug.cgi?id=60233)
* [sre] mono_dynamic_image_register_token: Change asserts to warnings
This partly relaxes the changes in 792b5367cd
which added the assertions.
In practice the assertions introduced a crash in heavy uses of
System.Reflection.Emit such as unit testing frameworks and dynamic languages.
We still want to know if there are surprising uses of
mono_dynamic_image_register_token, but we don't need a crash. SRE used to work
before 792b5367cd, so no need to break it.
* [sre] Register a canonical reflected method for a methodspec token (Fixes#60233)
This is like the fix for [bugzilla
59364](https://bugzilla.xamarin.com/show_bug.cgi?id=59364) but this time it's a
methodspec token, not a memberref token.
quote from the darwin man page:
> The functions getpwnam_r(), getpwuid_r(), and getpwuuid_r()
> return 0 if no error occurred, or an error number to indicate
> failure. It is not an error if a matching entry is not found.
> (Thus, if result is NULL and the return value is 0, no
> matching entry exists.)
* [System.IdentityModel] Add excludes for tests that don't compile on monodroid profile
Also add a new test for X509CertificateValidator so the assembly
isn't empty on monodroid.
* [System.ServiceModel] Add excludes for tests that don't compile on monodroid profile
* [System.Security] Add excludes for tests that don't compile on monodroid profile
Also reduce duplication between common.sources and System.Security.dll.sources
* [System.Web.Services] Add excludes for tests that don't compile on monodroid profile
* [System.ComponentModel.DataAnnotations] Make tests compile on monodroid profile
* [mini regressions] enable aot-tests.cs also on non-fullaot
* [interp] handle Nullable in cee_unbox
* [interp] fix cee_ldobj when top of stack is a value type
fixes test_0_dyncall_nullable
* [mini] require aot-tests regression tests to run only with OPT_INTRINS
Just over a year ago Xamarin.Android switched to running BCL tests straight
from the Mono sources but at the time we decided we didn't want to enable
a number of "new" tests (in the sense - never previously ran on XA) to avoid
introducing new failures in time which required focusing on more important
goals.
Currently, Xamarin.Android no longer uses Mono **sources** to build its tests
but, rather, it uses test **assemblies** built by Mono. This commit restores
the previously excluded tests in preparation for full BCL test coverage in
the near future.
There was very little test coverage of the I18N encodings before.
This adds a bunch of tests based on Latin1EncodingTest.cs since
latin1 is quite similar to these encodings.
A few of the added tests fail in some encodings due to what looks
like bugs in the implementation, disabled those temporarily, see FIXME's.
(filed https://bugzilla.xamarin.com/show_bug.cgi?id=60216 for tracking)
When I added temp dir handling to SaveTest in https://github.com/mono/mono/pull/5727
I copied the Setup/TearDown from TypeBuilderTest.
However that class doesn't actually save+load the assemblies so
it doesn't run into the issue on Windows where assemblies can't
be deleted because they're still loaded in the AppDomain.
To fix this follow CustomAttributeBuilderTest and ModuleBuilderTest,
i.e. just catch all Exception's in teardown...
We need this because XA is now starting to use the test assemblies
we build in the Mono repo instead of using the .cs source directly
and this would conflict.
ARMv8 ARM [cf. C6.2.65] says:
> All other encodings of CRm that are not listed above are reserved, and can
> be encoded using the # syntax. It is IMPLEMENTATION DEFINED whether options
> other than SY are implemented. All unsupported and reserved options must
> execute as a full system barrier operation, but software must not rely on
> this behavior
That means, before we would rely that chip implementations fall back to
SY, which is explicitly stated that software must not rely on. Also, ISH
is enough, as a "inner shareability domain" contains all PEs controlled
by a single hypervisor or operating system. That is what GCC, linux
kernel and so forth do as well.
Some broken versions of WSL don't set the mcontext_t::fregs field to a valid
pointer. We work around this by checking if the pointer is NULL, and if so,
not making the fpstate available. This is not ideal as we won't scan XMM
registers on these broken WSL versions, but accessing the
ucontext_t::__fpregs_mem layout is more complicated than it seems, so this
workaround will have to do.
Random failures in Jenkins tests, more frequent in sgen stress test due to the following assert:
Assertion at ..\mono\mini\mini-trampolines.c:842, condition `mono_thread_is_gc_unsafe_mode ()' not met
When investigating this a little deeper revealed a race when switching thread states from ASYNC_SUSPENDED
to RUNNING. The assert would fire on a running thread due to having a ASYNC_SUSPENDED state, but when thread
state was inspected in debugger it was showing correct RUNNING state.
Looking through the code indicated that this should not be possible, since caller would suspend thread before
setting ASYNC_SUSPENDED using atomic ops and set back to RUNNING before thread was resumed using atomic ops.
So based on this the only way to get wrong state and fire assert would be if the thread was not immediately
suspended when Win32 SuspendThread API returned, and read the ASYNC_SUSPEND value before really suspended by
the kernel. Nothing in the API documentation indicates that the SuspendThread actually behaves this way, but
current implementation assumes that SuspendThread actually suspends the thread and only return when no more
user mode code is executed by the thread.
Turns out that this is not 100% accurate and SuspendThread is just a suspend request to the scheduler, so when
SuspendThread call returns the “suspended” thread might still execute user mode code and that breaks the assumption
in current implementation opening up for the observed race condition triggering the assert. This behavior of SuspendThread
has been described in this article, https://blogs.msdn.microsoft.com/oldnewthing/20150205-00/?p=44743/.
The fix is to make sure thread is really suspended before continue executing. The way to do so is by requesting the threads
context right away after SuspendThread call returns. This will force the kernel to wait until thread has really been suspended
since it need to return back a valid context record to the caller.
Fix also includes a smaller optimization. Since we retrieved the context later in the execution of mono_threads_suspend_begin_async_suspend,
the fix opens the possibility to pass a sigctx to thread_state_init_from_handle and then the implementation of thread_state_init_from_handle
could use passed sigctx in its work instead of request it again (if passed in). Since we need to get the context early on Windows, we could
reuse that, passing it into thread_state_init_from_handle aving us from several unnecessary kernel mode context switches otherwise needed
to open thread and get thread context. NOTE, this optimization is only used on Windows and other platforms will use default behavior.
When I simplified MONO_CORLIB_VERSION to only include major.minor
instead of major.minor.build in https://github.com/mono/mono/pull/5449
I forgot to apply the same change to the msvc copy of that logic.
Application hosting self-hosted website over https crashes when attempting to access a webpage over http. The patch described in the bug report below resolves the crash, and the commit in this pull request implements the fix.
https://bugzilla.xamarin.com/show_bug.cgi?id=52675
in some scenarios the reference could be loaded via some unsafe
constructs (i.e., it doesn't live on `vt_sp`), so we have to
distinguish that use case, otherwise we could underflow `vt_sp`.
fixes test-301.cs and test-305.cs
In the C parser check for empty at the outset.
In the managed parser, copy an empty string component to the built-up TypeSpec
and handle it in the Type.GetType (..., asmResolver, typeResolver) implementation
Field types are now lazily resolved and this breaks the RuntimeHelpers::InitializeArray icall.
The solution is to use mono_field_get_type_checked to ensure the type is there.
ASan has very few false-positives, quoting the ASan documentation
(https://github.com/google/sanitizers/wiki/AddressSanitizer#turning-off-instrumentation):
> In some cases a particular function should be ignored (not instrumented)
> by AddressSanitizer:
>
> [...]
>
> * Ignore a function that does some low-level magic (e.g. walking through
> the thread's stack bypassing the frame boundaries).
>
> [...]
Assume you have something like this:
```
$ cat invokecrasher.cs
using System;
using System.Reflection;
public class InvokeCrasher {
readonly static object[] default_args = new object[1] { new string[] {} };
public static void Main (string []args) {
Assembly assembly = Assembly.LoadFile ("crasher.exe");
try {
assembly.EntryPoint.Invoke (null, default_args);
} catch {
}
assembly.EntryPoint.Invoke (null, default_args);
}
}
```
```
$ cat crasher.cs
using System;
public class Crasher {
unsafe public static void Main (string []args) {
int i = 1337;
CrashMe (&i);
throw new Exception ();
}
unsafe static void CrashMe (int *p) {
// p = (int *) 0;
*p = 0;
}
}
```
On the first `Invoke ()` the interpreter goes through `ves_pinvoke_method`:
```
interp_push_lmf (&ext, frame);
mono_interp_enter_icall_trampoline (addr, margs);
interp_pop_lmf (&ext);
```
The LMF is needed for unwinding by mini. In this situation though,
`Crasher` throws an exception and goes through the exception handling machinery
of the interpreter which leads to missing out of the `interp_pop_lmf ()` call.
On the second `Invoke` we would therefore push the same address as an LMF
again, which leads to a LMF that points to itself as `previous_lmf`. If we
encounter a native crash in this state (as hinted with `p = (int *) 0; *p = 0;`),
the unwinding machinery would end up in an infinite loop.
It'd fail to find System.Runtime.dll and System.ValueTuple.dll.
Changed the csi.rsp to include those from the Facades/ dir and added a test.
Workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=58965
[profiler] Clean up the makefile and address some issues with it.
* Don't link the profilers to libmono, except on mobile.
* The coverage profiler doesn't use zlib. Don't link to it.
* Fix the LIBADD variable for the VTune profiler.
* Add some comments for certain non-obvious aspects.
* Some style cleanup.
Also introduce a HOST_IOS variable in the build system which covers iOS, watchOS, and tvOS.
WSL, being Linux, declares IP_MTU_DISCOVER in its headers, but does not
actually support it. This is fixed in newer (preview) builds of WSL, but add
this workaround so Mono will work on older (stable) WSL versions.
https://github.com/mono/mono/pull/5680 added mmap/sendfile prototypes
but we should only use those when ANDROID_UNIFIED_HEADERS is defined
to avoid getting errors like:
```
/Users/alexander/dev/xamarin-android/external/mono/mono/utils/mono-compiler.h:157:7: error: conflicting types for 'mmap'
void* mmap (void*, size_t, int, int, int, __mono_off32_t);
^
/Users/alexander/android-toolchain/toolchains/arm-linux-androideabi-clang/bin/../sysroot/usr/include/sys/mman.h:47:15: note: previous declaration is here
extern void* mmap(void *, size_t, int, int, int, off_t);
^
/Users/alexander/dev/xamarin-android/external/mono/mono/utils/mono-compiler.h:166:9: error: conflicting types for 'sendfile'
ssize_t sendfile (int out_fd, int in_fd, __mono_off32_t* offset, size_t count);
^
/Users/alexander/android-toolchain/toolchains/arm-linux-androideabi-clang/bin/../sysroot/usr/include/sys/sendfile.h:36:16: note: previous declaration is here
extern ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
```
It was writing to the current working directory before which
doesn't work on platforms where that directory is read-only.
Using the same setup/teardown methods as TypeBuilderTest we
instead create a directory in the temporary location and put
the files there.
* Don't link the profilers to libmono, except on mobile.
* The coverage profiler doesn't use zlib. Don't link to it.
* Fix the LIBADD variable for the VTune profiler.
* Add some comments for certain non-obvious aspects.
* Some style cleanup.
Also introduce a HOST_IOS variable in the build system which covers iOS,
watchOS, and tvOS.
* [jit] Don't insta-fail on faulty cominterop invocations.
* [runtime] New test for bug 8477.
* [jit] Implement mono_error_get_exception_name() and mono_mb_emit_exception_for_error()
* [jit] Throw an exception when a static method on a ComImport class is called.
Emit very basic codeview information into full AOT builds on Windows x64. The codeview information is far from complete and
is currently just initial work needed to get function symbol names to appear in native callstack that includes managed functions.
Described functions does not include parameters, local variables or line info at the moment, but could be extended in the future.
Fix also make sure linker will emit PDB files including information that can be picked up by debuggers. It is possible to disable
codeview info by passing "nodebug" to AOT compiler, this will also disable the generation of PDB files, if a DLL would have been build.
Emit needed sections when building Windows x64 full AOT targeting Clang for MS codegen in order for linker to
include entries in process unwind tables for full AOT:ed managed functions and trampolines. Implementation also includes
a cache used to minimize the number of duplicated unwind data section in each object file, reducing final image size.
On the CLR, two enumerators containing zero elements will
have reference equality if they are inflated with the same
generic type.
If comparing two enumerators which are not inflated (Array.Empty, for
instance), they are not equal when they contain zero elements.
This reference equality behavior is not compatible with treating
the enumerators as structs, as value types will not have reference
equality.
* [runtime] Avoid collecting coverage data for wrappers.
* [runtime] Return sensible information for methods which have no coverage info in mono_profiler_get_coverage_data ().
* [profiler] Emit coverage info for uncovered methods as well.
* Add new profile for monodroid tools
This allows the XA build to use these instead of needing to build net_4_x.
We build the assemblies against the .NET 4.6 reference assemblies.
* Skip monodroid_tools in verify (aka mcs-compileall)
Exclude it from the test_profiles since running tests makes no sense there.
Also refactor to exclude binary_reference_assemblies as well,
it was already excluded manually in mcs-compileall before.
TestHelper was previously excluded because the XA tests weren't built
as part of Mono but rather as part of XA test suite which included
its own version of the helper. Now, however (https://github.com/xamarin/xamarin-android/commit/e9daf5ea35709ce1bc6ba81c7c37d72d385bace2),
XA uses BCL+friends test assemblies built by Mono itself and so
we need to restore TestHelper in the build.
* [coverage-profiler] Collect coverage data at IL seq point locations.
* [coverage-profiler] Emit IL offsets instead of offsets between IL offsets. Bump format version.
Up until NDK release 14 Android SDK included a separate set of C header
files for each supported platform. NDK 14 introduced a new set of those
headers (they are NOT the same as the old ones) which unifies support
for all of the platforms so that bug fixes are available for all the
API levels without having to backport etc. With NDK 15 the unified headers
become the default ones (including when creating standalone toolchains)
and with NDK 16 (in beta currently) the old per-platform headers are removed.
Unfortunately, the new headers introduce breaking changes which made it
impossible to build Mono with NDK configured to use them. This commit makes
a handful of changes to Mono which make it build with unified headers.
Make libmono-static lib file include all needed runtime libs making it easier to
link and distribute as part of Mono SDK.
Commit also updates linking of vcxprojs in mono.sln to use merged static lib.
* [ci] Allow setting custom mono flags for test runs via MONO_TEST_FLAGS.
* [ci] Make the handling of CFLAGS a bit more flexible in run-jenkins.sh.
* [ci] Generalize collect-coverage to handle more targets.
* [trace] remove code that has no effect
* [trace] move program assembly out of MonoTraceSpec
The assembly member represents the program assembly. It's
information the trace spec is matched against, not part of
the trace spec per-se (if two trace specs exist for two purposes
we would still have one program assembly)
* [trace] remove side effects from get_string()
On the way towards supporting multiple trace specs,
remove side effects from get_string() function.
* [trace] remove side effects from get_token()
Remove side effects from get_token() to allow handling
multiple trace specs.
* [trace] fix handling of double exclusion and disabled
When encountering "disabled", do not add an entry to
the trace spec
Fix error handling around double "-" - get_spec()
never returns TOKEN_EXCLUDE and the recursion can
be easily avoided.
* [trace] remove side effects from get_spec()
Another step in making the trace options reusable.
* [trace] rename mono_trace_parse_options() to mono_trace_set_options()
This routine actually sets the tracing options, not just parses an
option string, so set_ is more suitable. This frees up the
mono_trace_parse_options() name for pure parsing, when we later
reuse the parsing code.
* [trace] make tracing options API reusable
Add APIs that parse tracing options and evaluate a method
against the parsed options. The tracing functionality now uses
this API, but other components can use this to apply an operation
to a method based on policy (e.g. profiling)
* [trace] rename MonoTraceSpec to MonoCallSpec
In preparation for reusing call specification beyond the
tracer, rename the data structure - it now only specifies
a set of calls, without indication what should be done with
them.
* [trace] rename mono_trace_set_assembly to mono_callspec_set_assembly
As it becoming a reuse candidate, we remove the "trace" component
from the name.
* [trace-metadata] move callspec code into its own module
Introduce callspec.c/h which encapsulate the call specification
functionality.
* [profiler] add "callspec" option to log profiler
The callspec option define which methods get instrumented
at JIT time with entry/exit calls to the profiler. The
syntax is same as the tracer (--trace=) syntax. To
distinguish between profiler options and callspec, wrap the
callspec with double quotes, as in:
--profile=log:callspec="all-mscorlib",calls
Since this typically runs from a shell, the double quotes have to be
escaped or wrapped in single quotes, as in:
mono '--profile=log:callspec="all-mscorlib",calls' prog.exe
* [metadata] add an error return string to callspec parsing
Instead of printing parsing error messages to standard error,
return an error string. That allows the client to do the right thing
with the error.
Current implementation of Windows builds in mkbundle is not supporting
Visual Studio toolchains and Windows SDK's in a working way. Windows version
of mkbundle also lacked support for 64-bit builds together with a dependency on
GCC assembler etc.
This commit improves things in many different areas. The following toolchains
are intended to work together with this commit:
VS2013, VS2015, VS2017.
NOTE, default Mono SDK distribution is build targeting VS2015/VS2017 and static
version of libmono-static.lib won’t work with VS2013. If static use case is needed
with VS2013, a custom build mono under VS2013 must be used. Dynamic use case is
working as expected for all three versions.
The commit also improves the support for Cygwin GCC compatible toolchains on Windows.
The commit adds support to use installed versions of both Windows 8.1 as well
as Windows 10 SDK's together with all above VS toolchains.
The commit extends support to include 64-bit mkbundle builds (using all supported
Windows toolchains). The target is decided based on mkbundle process type, 32-bit
mono builds 32-bit bundle and 64-bit mono builds 64-bit bundle.
mkbundle might still need to have a working GCC as.exe when running, but this commit
also adds support for Clang for VS CodeGen as assembler available in VS2015 Update3
and VS2017 (separate option in VS setup). When using this option there is no needed
for available GCC toolchains when running mkbundle on Windows.
A recommended way of running mkbundle on Windows is by using one of the targeted toolchains
development consoles. This way mkbundle will get all needed paths and installation folders
directly from the development consoles environment, matching a predefined setup.
Old mkbundle environment variables on Windows will continue to work. There are also a number
of new variables that can be set (or are set by the VS development consoles). The important ones
are:
VisualStudioVersion: set to pick a specific VS version, like 12.0, 14.0 or 15.0. If a none existing
version is specified, mkbundle will fallback to latest installed version.
WindowsSdkVersion: set to pick a specific Windows SDK version, like 8.1, 10.0.10240.0, 10.0.15063.0 etc.
If a none existing version is specified, mkbundle will fallback to latest installed version.
AS: If Clang for VS CodeGen is not installed this must point to a working as.exe assembler.
MONOPREFIX: set to pick a custom Mono SDK install root directory (need to match the architecture of mkbundle
process running). If not set, mkbundle will look for installed Mono SDK’s matching targeted architecture.
MONOLIB: if a different library name is used, it can be specified here. It is also possible to add an absolute
path to the mono library used in linking. NOTE, correct library needs to be supplied for static/dynamic use cases.
INCLUDE: override all custom include path handling, normally set by VS developer consoles.
LIB: override all custom lib path handling, normally set by VS developer consoles.
VCCRT: Gives possibility to use static or dynamic C-Runtime linking. By default mkbundle will use dynamic C-Runtime
linking on Windows to be compatible with default Mono SDK distribution. If a custom build Mono
using static C-Runtime linkage is used, setting this variable to MT (default MD), will link using static
C-Runtime.
VCSUBSYSTEM: mkbundle will by default use windows subsystem. If console subsystem is preferred this variable
can be set to console.
Should resolve:
https://bugzilla.xamarin.com/show_bug.cgi?id=57893
and partial resolves (needs https://github.com/mono/mono/pull/5656 as well):
https://bugzilla.xamarin.com/show_bug.cgi?id=57892
null is a valid value in a JSON array, so there is no reason forbid
adding null to the array. JsonArray.Save() already handles null values in
the array.
* [corlib] Make Marshal.BufferToBSTR(Array, int) non-public again
It was accidentally made public in https://github.com/mono/mono/commit/c5cdfaec1e0973ced3f97ef589cd0bece56067ad.
Unfortunately this was before we had the API diff check on Mono and the manual checks in XI/XA integration didn't catch it either.
* Bump API snapshot submodule
In mono_image_create_token we are passed in a managed reflection object and we
need to create a token for it and optionally register it so that we can resolve
that token back to a runtime structure and managed object later.
For a MonoReflectionMethod object that refers to a method from outside the
current dynamic image, we need to generate a memberref token. It will be the
same token for the same underlying MonoMethod*. When we go to register the
token with mono_dynamic_image_register_token we need to pass a managed object.
Unfortunately two MonoReflectionMethod objects could refer to the same
MonoMethod* but differ in their ReflectedType, so just registering the
passed-in MonoReflectionMethod means we could assert in
mono_dynamic_image_register_token because previously we may have registered the
same method via a different ReflectedType.
So what we do is we cal mono_method_get_object_handle with NULL for the
reflected type - which corresponds to just using the DeclaringType of the given
MonoMethod*.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=59364
Previously, we mapped fieldref tokens to MonoReflectionField managed objects,
But the object is just used as a key for caching the token so we may as well
use the native field instead of a managed object.
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=59364
We need to cause SRE to generate the same methodref/fieldref token from two
different reflection objects. That happens if you get the same method or field
via a base and a derived class so that the MemberInfo:DeclaredType is different
but the underlying MonoMethod* or MonoClassField* is the same.
HttpRequestListener throws on incorrect cookie name. It throws CookieException ("Name contains invalid characters"). There are many cookies out there that unfortunately do not conform to the guidelines and HttpRequestListener will kill the request in such a case. The .Net framework under windows lets the request through however.
Included is a patch HttpListenerRequest as well as a test with a bad cookie name.
I have tested this under linux(master branch) and .net (4.0), they now both have the same behavior.
Without it you get errors like the following in old-style mkbundle:
```
Undefined symbols for architecture x86_64:
"_CFLocaleCopyCurrent", referenced from:
_ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntimesgen_la-locales.o)
"_CFLocaleGetIdentifier", referenced from:
_ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntimesgen_la-locales.o)
"_CFLocaleGetValue", referenced from:
_ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntimesgen_la-locales.o)
"_CFRelease", referenced from:
_ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntimesgen_la-locales.o)
...
```
We actually documented this in the 3.4 release notes: http://www.mono-project.com/docs/about-mono/releases/3.4.0/#breaking-changes
However this means that you had to use the "-c" mkbundle option
to only generate the .c stub so you could pass those additional libraries.
* [jit] Add a mono_arch_dyn_call_get_buf_size () arch specific function which returns the size of the buffer required for a given dyn call. Use this instead of a fixed size buffer, to allow backends to use variable sized buffers later.
* [amd64] Add support for unlimited size/number of arguments to the dyncall code.
* [arm64] Add support for unlimited size/number of arguments to the dyncall code. Part of the fix for #59184.
In case StringToHeap (string, Encoding) was called with a null string, it would unconditionally reference the string when trying to query the string's length.
Bug 10074 - Error while updating status of command: MonoDevelop.Ide.Commands.ViewCommands.LayoutList
Suppose we want to know C.IsAssignableFrom (T1):
```
class C { }
class G<T1, T2> where T1 : T2, T2 : C { }
```
Previously, we would get `False`, because we only checked the constraints of T1
if C was an interface or another gparam. Now Instead we always consider the
constraints in `A.IsAssignableFrom (B)` whenever `B` is a gparam.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=58809
Check that generic parameters's constraints properly affect the subclass and
interface relationships even when the constraints relate several of the generic
parameters themselves.
* Add support for mono_threads_add_joinable_thread and friends on Windows.
Current Windows implementation doesn't have support for the joinable thread
implementation in threads.c. Joinable threads are used by the runtime during
shutdown to coordinate with exit of platform threads.
Since threads detaching and exiting during shutdown could still use or provide
important resources, like GC memory, lacking support for this feature could
potentially expose the implementation to various shutdown race conditions.
Commit also change requested permission on a thread handle when opening it for
synchronization purposes. No need to request all thread access when handle is only
used for synchronization, like in WaitForXXX API calls.
* Fix race between mono_thread_detach_internal and mono_thread_manage.
There is a race during shutdown when main tread is running mono_thread_manage and
attached threads are running mono_thread_detach_internal. The problem is related to
the removal from the registered threads list since mono_thread_manage will pick
threads to wait upon from that list. If a thread removes itself from the list
using mono_thread_detach_internal it will then race against runtime shutdown
and the removal of used resources still in used by mono_thread_detach_intenral,
like MonoInternalThread.
This race could trigger the assert seen in bugzilla:
https://bugzilla.xamarin.com/show_bug.cgi?id=58770
or other undefined behavior depending on where the detached thread resume execution
after main thread has shutdown the runtime, but not yet terminated the process.
The fix makes sure threads that are detaching during shutdown ends up on the joinable
threads list. Threads on that list will be waited upon by the main thread during shutdown,
mono_thread_cleanup. This will make sure the detached thread finishes the remaining of
mono_thread_detach_internal and potential other code still using GC memory during shutdown.
Threads already on the threads list will already be waited upon by mono_thread_manage during
shutdown (if not removed by mono_thread_detach_internal triggering this race), so this change
won't add additional threads to be waited up by the runtime. It just makes the shutdown more
reliable using already available concepts (like the joinable threads list).
* Fix warning C4141 on Windows MSVC compiler.
* Updated with review feedback.
* Prevent race between finalizer and main thread to join same thread multiple times.
Checking against joinable_threads list in mono_threads_add_joinable_thread is not enough.
There is a small chance that the same runtime thread could get on the list twice since
mono_threads_add_joinable_thread could be called multiple times for the the same tid.
This will work under Windows but is undefined behavior on POSIX's platforms.
This could happen if the finalizer thread calls mono_threads_join_threads when a thread
is detaching and have added itself to the joinable_threads, but before unregister_thread
has been called. Finalizer thread will then take tid from list and wait, this will cause
the second call to mono_threads_add_joinable_thread to not find itself in the joinable_threads
and add tid a second time. NOTE, this race only applies to runtime threads added to the
joinable_threads list.
Fix adds an additional method to add runtime threads to the list. This method will only add to
list if its indeed a runtime thread and doesn’t already have an outstanding pending native join
request. This method is called by code previously checking runtime_thread flag before adding to
joinable_threads list. This will prevent the scenario when the same MonoThreadInfo add its tid to
the joinable_threads list multiple times due to above race condition.
A DynamicMethod can be placed in a SRE module and it must respect any RuntimeCompatibilityAttribute set on that assembly.
We do that by updating the runtime side list of cattr in the AssemblyBuilder when a RuntimeCompatibilityAttribute is set using SetCustomAttribute.
and also setup_interface_offsets.
A gparam is never a real interface so we can just short circuit
if we see a gparam during interface collection. (A gparam may be instantiated
with an interface --- but ginst interface offsets are processed anew when the
ginst is initialized in mono_class_init, not somehow extracted from the gtd and
the MonoGenericContext).
Introduce MonoDynamicMethod that holds the assembly of a DM (and TB).
Use it to determine the RuntimeWrappedException policy for exceptions.
This is needed cuz the assembly of a MonoMethod is normally found using method->parent->image->assembly.
But this doesn't work with DynamicMethods that don't define an owner type as they are forced to corlib's policy.
The default policy for DM's is to not wrap those exceptions and in the case a Module is provided, the policy of that module must be respected.
This commit handles all cases but when a Module is a SRE module.
Mono.Debugger.Soft has low frequency hangs in InspectThreadSuspenedOnWaitOne test.
This method launch the debuggee (dtest-app.exe), sets a breakpoint on a method just
doing an infinite OS wait, validate that the breakpoint gets hit and resumes debuggee.
After resume from breakpoint debuggee will hit the infinite OS wait and the debugger test
will suspend and shutdown the process.
In order for mono debugger to handle the shutdown request it will suspend all managed threads
using mono_thread_suspend_all_other_threads. This method uses a pooling schema until all threads
have reported that they are suspended. Since one of the threads are doing an infinite OS wait we
entered the land of APC (Asynchron Procedure Calls) used on Windows to alert waitable threads.
The reason for the hang is the fact that the OS won’t return from the wait until all queued APC’s
have been executed. Since the loop sending async suspend requests to the
threads mono_thread_suspend_all_other_threads can run faster (including suspending/resuming the
thread that need to consume APC’s in the process) then the dequeue and execute of the queued APC’s, the
wait won’t break, meaning that the thread won’t be able to set the mono suspend state causing the
mono_thread_suspend_all_other_threads to run forever. This is highly timing dependent and will only reproduce
sporadic, but I was able to isolate and do a solid repro locally while working on the fix.
The fix makes sure we don’t post a new suspend APC if there is already one in flight with a pending unhandled
interruption. This will make sure we won’t flood the APC queue on Windows preventing the thread from suspending.
Tests that we can unload domain where the threads reset the abort exception and that this exception is converted to AppDomainUnloadedException in the caller domain.
- have all counters in a global place and initialise them in `mono_trampolines_init ()`
- use `Unlocked* ()` and `mono_trampolines_lock ()` to mark / synchronise all racy counters
[TSan] Unlock mono_g_hash_table_max_chain_length
I would suggest using `Unlocked* ()` here. `mono_g_hash_table_find_slot ()` is called relatively often and, unlike increment or add operations, read and write operations (without a global surrounding lock) do not gain much (if anything) by being interlocked as long as they can be read and written by one instruction. That should be true for 32-bit integers and Mono's supported platforms.
[TSan] Unlock fastpath when checking domains_to_finalize
I understand that the affected line is a fastpath which seems absolutely fine to me as it is properly checked later. It is, however, rightfully, detected as a data race by Clang's ThreadSanitizer. I would, therefore, suggest using `UnlockedReadPointer ()` to mark this race as known + accepted.
This should reduce the amount of I/O system calls we do, and should be fine
in terms of memory usage since the profiler tries to keep buffers small (64k),
and latency since the profiler flushes buffers every second.
This changes the API somewhat so that users no longer have to construct a
LogReader; this is now done internally, and the type is no longer public. Also,
the LogProcessor now leaves the given stream open, so it's up to the user to
close it.
The problem was that the base Stream.ReadByte () method allocates a temporary
byte array and then calls Read (..., 1) on it. To solve this, we override
ReadByte () in LogStream and use a private buffer to hold the result.
It's a bit of a mystery to me why Stream.ReadByte () does it this way. The
documentation for Stream explicitly says that instance methods aren't thread
safe, so it would be perfectly fine for Stream.ReadByte () to do what we do
here...
* [loader] If signaling recursive type initialize, don't double free
If we detect that a recursive type initialization is happening, we should leave
without removing the class from the init_pending_tld_id list. Otherwise we get
a double-free when the outer recursive call finally finishes and tries to
remove the same element.
Also re-load the init_list from TLS since a recursive call to mono_class_init could
have modified it between the time the current mono_class_init call started and
when it is finishing.
* [loader] Improve error message when a field's type is a failed class
Add the class failure to the field failure error message.
* [tests] Check that runtime can represent recursive structs
Regression tests for https://bugzilla.xamarin.com/show_bug.cgi?id=43563
* [loader] Init MonoClass:sizes.element_size lazily (Fixes#43563)
Originally mono_bounded_array_class_get () would populate
MonoClass:sizes.element_size as soon as the MonoClass for the array was needed.
This is a problem because we cannot call mono_class_array_element_size () on
the element class on a valuetype until mono_class_layout_fields () finishes
initializing it.
That means that structs which contain an array of themselves would hit the
recursive initialization check in mono_class_setup_fields and the MonoClass for
the element class would be marked as failed to load.
Instead we rely on the MonoClass:size_inited bit to tell us whether the array
class has been initialized and if not, we set the array element size in
mono_class_layout_fields.
This is possible because MonoClass:sizes.element_size is only really needed to
know how to allocate space for an array. When laying out a class that contains
an array we don't need the element size - they array is just a reference type.
Example:
```csharp
struct S {
static S[][] foo;
}
```
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43563
This change fixes a crash we get in resgen when building without
X11 installed. The bug got introduced when fixing Xamarin-395.
Change-Id: If81a4a3ca4db7a1b0156480ad49bd61610ecebf0
Internal version number (not in any way related to the TLS Version).
Used by the web-tests to check whether the current Mono contains certain
features or bug fixes.
Negative version numbers are reserved for martin work branches.
This comes in reverse order, compared to other backtraces in the MLPD, so
reverse it before sending it to visitors, so that it comes in the same
format as the rest of backtraces.
Running the MonoTests.System.Net.HttpRequestStreamTest under debugger reveals this
problem. WSACleanup is freeing an invalid handle as part of network shutdown.
This happens since mono_w32socket_close calls incorrect win32 API when closing sockets.
It currently calls CloseHandle, while it should call closesocket. This probably cause
problems in winsock book keeping of active sockets, and when closing the network layer,
winsock will try to close handles that it still open, but since the handles have already been closed
by incorrect call to CloseHandle, it will close an “invalid handle” either causing the exception
or even worse, close a different handle currently in use, causing undefined behavior
during the rest of mono shutdown.
Fix is to switch to correct API when closing sockets on Windows, closesocket instread of CloseHandle.
MonoTests.System.Net.HttpRequestStreamTest suite has sporadic failures on Windows x64
with following exception:
System.Net.Sockets.SocketException : An operation was attempted on something that is not a socket.
This happens due to a data type and constant size mismatch. w32socket.h defines
INVALID_SOCKET and SOCKET_ERROR for all platforms. On Windows x64, SOCKET is defined
by winsock2.h as 64-bit type as well as INVALID_SOCKET constant, but above code will
define INVALID_SOCKET as a 32-bit constant value. This will in turn cause code to sporadically
fail to detect invalid sockets as returned by win32 API's. This will in turn cause the socket
exception when code continues to use socket as argument to win32 socket API’s.
Current “invalid” x64 codegen for expression:
if (sock == INVALID_SOCKET)
mov eax,0FFFFFFFFh
cmp rsi,rax
and with fixed defines, correct 64-bit cmp instruction:
cmp rsi,0FFFFFFFFFFFFFFFFh
Fix makes sure we get the defines of INVALID_SOCKET and SOCKET_ERROR from winsock2.h
on Windows platforms to be consistent with define of SOCKET type.
The differences from v14 are small, and given it is the current "stable"
MLPD version, it's worth supporting it. The differences are:
* ImagePointer field not present in v13 Assembly*Event's
* In MonitorEvent, LogMonitorEvent is not in a separate field, but included
as a flag in the extType field.
* SampleHitEvent's have a type field in v13, which was removed in v14, because
only cycles samples are emitted.
* MONO_GC_EVENT_{MARK,RECLAIM}_{START,END} were removed in v14
* SampleUnmanagedBinary's SegmentPointer is not based on ptr_base in v13
* In v13, HeapRootsEvent's Attributes is (wrongly) a byte, in v14 this was
fixed and changed back to a uleb128
We had previously responded to bad performance on android by stubbing out
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack
on android. This was necessary because the call to pthread_attr_getstack ()
will read /proc/self/maps. When used inside of a hot function, the performance is terrible.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=58911
Globally loaded modules would previously call LoadLibrary on Windows, but never FreeLibrary. This would result in said library keeping an internal reference counter of 1 until the application exited its entry-point, resulting in possible shutdown issues.
This commit makes sure that we correctly free modules (and unload them in the platform-specific APIs) whenever Mono itself is shutting down, ensuring the expected result of Mono-loaded libraries being correctly freed.
The verification algorithm is inspired on internal specs by the Roslyn team but adapted to what it generates today.
Here's how this patch works:
We introduce a new verification type, SAFE_BYREF, that's used for a byref value that is safe to return from the stack.
It's unverifiable to return a byref value that is not marked SAFE_BYREF.
We mark the following values are SAFE_BYREF:
- byref arguments, unless it's the `this` arg of a valuetype instance method
- return values of method calls when all byref arguments have SAFE_BYREF values - the this arg is ignored.
- the address of a static field (LDSFLDA)
- the address of an array element (LDELEMA)
- the address of a field if the receiver is either a SAFE_BYREF value or a reference
Notoriously from the above is the value of local variables. We took a conservative approach of unsafe tainting.
We do this by associating 3 states to a local: unassigned (initial value of zero), assigned and safe (SAFE_BYREF_LOCAL), assigned and unsafe (UNSAFE_BYREF_LOCAL)
When loading a local, we set its value as SAFE_BYREF if the local is in the SAFE_BYREF_LOCAL state.
When storing to a local, we set it to SAFE_BYREF_LOCAL if, only if, it's not marked as UNSAFE_BYREF_LOCAL and the value is SAFE_BYREF.
If we store a non-safe value to a local, we mark it as UNSAFE_BYREF_LOCAL.
If we store a non-safe value to a SAFE_BYREF_LOCAL local, we mark the method as unverifiable.
This algorithm makes sure we don't mix safe and unsafe byref and side with safety in case of control-flow dependent values.
[TSan] Interlock and unlock MonoJitStats
This is the first part of telling TSan what to do with `MonoJitStats`; I dealt with all the `gint32` values and partly touched the `gboolean` value (see `FIXME`). However, `MonoJitStats` also contains `gdouble` which can (1) probably be interlocked and (2) will be updated in a later step, together with the `FIXME`, as soon as an updated version of the atomic interface exists.
I did my best to distinguish between perf. critical parts and parts where `Interlocked* ()` seems to work perfectly fine. As before, if I misjudged anything, I would kindly ask to comment the affected operations, and I will update them accordingly.
More (technical) details can be found in the commit messages.
The ManualResetEvent wouldn't be signaled when an exception happens
in the reader loop so we'd deadlock in Read().
I'm still investigating where the exception comes from but this
should at least help unblocking CI.
https://bugzilla.xamarin.com/show_bug.cgi?id=46683
* Revert "[threads] Fix leaking threads: SGen Worker and Finalizer (#5284)"
The sgen-specific cleanup cannot be run before the sgen-agnostic cleanup
This reverts commit 7db0fb0c88.
* [threads] Make sure we do not leak the finalizer and sgen threadpool threads
* [Tests] Fix Mono.Data.Tds tests on iOS
The modified tests failed on iOS following PR:
https://github.com/xamarin/xamarin-macios/pull/2580 that adds support
for Xharness to run the Mono.Data.Tds on Xamarin.iOS. With the changes
the tests run a expected.
* Close Listener when done.
[TSan] Tackle MonoPerfCounters
With `MonoPerfCounters` taking part in many races, I thought it's finally time to attend to it. If I am not mistaken, most (if not all) load / store operations can be interlocked. If I am wrong, I would kindly ask to quickly comment the respective perf. critial operations and I will change them to `Unlocked* ()`.
Furthermore, a few details:
* updated all fields to signed types as `Interlocked* ()` functions exist for these types already
* upgraded a few values to `64-bit` as other `64-bit` values are assigned to them
* fixed a few `FIXME`s in `predef_writable_update ()` that were connected to `Interlocked* ()` functions
[TSan] Mark racy counters in metadata.c
- using `gint32` instead of `int` should not be an issue
- `img_set_count` is interlocked by `image_sets_lock ()` - `UnlockedIncrement ()` is just used for completeness / documentation
- `++img_set_cache_(hit|miss)` is called quite often and is connected to caching: it seems to me as if interlocking these counters would be a bad idea (at least for cache hits)
* Fix leaking threads: SGen Worker and Finalizer
- https://bugzilla.xamarin.com/show_bug.cgi?id=58317
- stop SGen workers before the finalizer stops
- clean up SGen workers with the Finalizer
- remove `mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));` as we detach the Finalizer with `mono_threads_join_threads ()` within `mono_gc_cleanup ()`
* [fixup!] Move counting variable into the loop initialiser and add a `(gpointer)` cast
* Reorganise counters:
- use `Interlocked* ()` and `Unlocked* ()` to fix / mark (possible) races
- change the initialisation location and the visbility of some counters
- fix a few typos
* Extend the warning when re-registering counters
* also print counter address if we have a duplicate
Make sure all events have all fields initialized. This was missing setting
Buffer and Timestamp properties when creating the different LogEvent* subclasses.
* [Mono.Security]: Remove some unused `Mono.Security.Interface` classes.
* Mono.Security.Interface: removed `IBufferOffsetSize` and `BufferOffsetSize`
(these were not general-purpose BOS APIs, but depend on the internal
`SecretParameters` class).
* Mono.Security.Interface: removed `SecretParameters`, `SecureBuffer`,
`IMonoTlsEventSink`, `TlsBuffer` and `TlsMultiBuffer`.
* Bump API snapshot submodule
[TSan] Interlocking loader.c
`loader.c` contains four statistics counters and all of them are invovled in data races. This PR focuses on dealing with them:
- All of them can be `gint32` as they are registered as `MONO_COUNTER_INT` anyways.
- Since there is already a lot of locking involved in `loader.c` (including an approved usage of `Interlocked* ()` with with `mono_stats`), I think that `Interlocked* ()` can be used here instead of `Unlocked* ()`. If this assumption is wrong, I would kindly ask to correct me by commenting the affected rows and I will change it to `Unlocked* ()`.
* [bcl] Use RuntimeHelpers.GetHashCode () for getting the hash code of the delegate target to avoid calling user defined hash code implementations which can throw exceptions. Fixes a regression introduced by a48bc43985.
* add test for #59235https://bugzilla.xamarin.com/show_bug.cgi?id=59235
* [fixup] RuntimeHelpers.GetHashCode handles null
This is the behavior of .NET. After this patch the code on Mono for Windows
will make sure the underlying native thread of a managed thread has died
before Thread.Join() returns.
This PR builds on PR #5454 but makes it Windows specific. PR #5454 was
reverted since it caused crashes on some Unix platforms.
With the introduction of magic array interfaces, they must be handled as if they
were variant if they are being dispatched against an array.
This was not being done in common_trampoline and resulted in the IMT thunk never
getting rebuilt and getting decent perf.
With this patch, dispatch to simple methods such as Array::Count over a magic interface
in a covariant case (such as IList<object> dispatch onto string[]) will accrue gvi's.
On a trivial benchmark of executing Count 1M times, perf goes from 760ms to 50ms.
- use `Unlocked* ()` for `class_gparam_count`, `classes_size` and `inflated_methods_size`
- dead code: `class_ext_size`
- fix a typo: "the the" -> "let the"
Whenever a test fails we retry it five times and then decide the
overall result based on that. If three or more of the five retries
fail too then the overall result is FAIL, two or lower means PASS.
We're modifying nunitlite here so this only works for those tests
right now, we'd need to add it to the other test runners too.
The cominterop_get_function_pointer icall has a wrapper which has a
trampoline. When we enter the trampoline mono_marshal_emit_native_wrapper
already switched us to blocking.
This fixes assertions due to d0e103fcb4 in
cooperative GC mode.
mono_marshal_set_last_error is called from a P/Invoke wrapper just after the
pinvoked method returns before we transition the thread state back to running
from blocking. If mono_marshal_set_last_error had a wrapper, we would invoke
the trampoline (mono_magic_trampoline) to JIT the wrapper while in blocking
mode, which would trigger the assertion.
* [System] Fix a few hardcoded socket ports in tests
Those could've shown up as "address already in use" in CI.
* [System.Runtime.Remoting] Fix a few hardcoded socket ports in tests
Those could've shown up as "address already in use" in CI.
Additionally remove a copy of RemotingServicesTest.cs from corlib
which also exists in System.Runtime.Remoting in updated form.
* [System.ServiceModel] Fix a few hardcoded socket ports in tests
Those could've shown up as "address already in use" in CI.
* [System.Net.Http] Fix a few hardcoded socket ports in tests
Those could've shown up as "address already in use" in CI.
The additional "keep-alive" header in Send_Complete_NoContent() and
Send_Transfer_Encoding_Chunked() is because we were using the same
port for all tests before so other tests would clear the header.
This doesn't happen now that we use distinct test ports.
* [System.ServiceModel.Web] Fix a few hardcoded socket ports in tests
Those could've shown up as "address already in use" in CI.
* The sizes of `glong` and `gsize` differ on 64-bit Windows.
* In order to avoid uninitialized data in the high four bytes of the `bytes` argument to `mono_unicode_from_external`, call `g_utf8_to_utf16` with a `glong`, then copy the result.
They are implemented via a global lock, which can lead to deadlooks in
some situations, e.g.
```
-0 0xb6c92e14 in sigsuspend () from /lib/arm-linux-gnueabi/libc.so.6
-1 0x0043f3b4 in suspend_signal_handler (_dummy=35, info=0xb4afe6d0, context=0xb4afe750) at mono-threads-posix-signals.c:177
-2 <signal handler called>
-3 0xb6de6bc4 in __pthread_mutex_unlock_usercnt () from /lib/arm-linux-gnueabi/libpthread.so.0
-4 0x00440f00 in InterlockedCompareExchange64 (dest=0x530700 <worker+64>, exch=0, comp=0) at atomic.c:578
-5 0x002f228c in InterlockedRead64 (src=0x530700 <worker+64>) at ../../mono/utils/atomic.h:398
-6 0x002f29a0 in COUNTER_READ () at threadpool-worker-default.c:194
-7 0x002f3320 in worker_park () at threadpool-worker-default.c:426
-8 0x002f3774 in worker_thread (unused=0x0) at threadpool-worker-default.c:488
-9 0x002e66b0 in start_wrapper_internal (start_info=0x0, stack_ptr=0xb4b00000) at threads.c:982
-10 0x002e6894 in start_wrapper (data=0x5a8f38) at threads.c:1044
-11 0xb6de31a8 in start_thread () from /lib/arm-linux-gnueabi/libpthread.so.0
-12 0xb6d3a1bc in ?? () from /lib/arm-linux-gnueabi/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Thread 4 (Thread 0xb40ff440 (LWP 10198)):
-0 0xb6deb56c in __lll_lock_wait () from /lib/arm-linux-gnueabi/libpthread.so.0
-1 0xb6de584c in pthread_mutex_lock () from /lib/arm-linux-gnueabi/libpthread.so.0
-2 0x00440e6c in InterlockedCompareExchange64 (dest=0x559868 <gc_stats+8>, exch=2855648, comp=2844091) at atomic.c:570
-3 0x0039bdcc in InterlockedAdd64 (dest=0x559868 <gc_stats+8>, add=11557) at ../../mono/utils/atomic.h:392
-4 0x003a1b50 in collect_nursery (reason=0x5083f4 "Nursery full", is_overflow=0, unpin_queue=0x0) at sgen-gc.c:1865
-5 0x003a3794 in sgen_perform_collection (requested_size=4096, generation_to_collect=0, reason=0x5083f4 "Nursery full", wait_to_finish=0, stw=1) at sgen-gc.c:2539
-6 0x003a35f0 in sgen_ensure_free_space (size=4096, generation=0) at sgen-gc.c:2505
-7 0x00389db0 in sgen_alloc_obj_nolock (vtable=0xb4d174d0, size=64) at sgen-alloc.c:256
-8 0x0036e330 in mono_gc_alloc_vector (vtable=0xb4d174d0, size=64, max_length=12) at sgen-mono.c:1743
-9 0xb6c16a38 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
```
fixes https://bugzilla.xamarin.com/show_bug.cgi?id=59039
Encountered this message while running the new mkbundle simple-cross functionality introduced recently. "Function not supported" is seen on both Mac OS X and Ubuntu. Will possibly file a separate bug since HAVE_MKDTEMP should be true... but it should be "Function mkdtemp not supported" in any case.
It's causing unnecessary complexity because we need to create a new
monolite when bumping the .build number in a major.minor.build
version like from 5.2.0 -> 5.2.1
corlib version bumps are very rare in those cases and even then
you can just increment the MONO_CORLIB_COUNTER variable.
* Cleanup debugging and use the same technique from the new web stack.
* The MARTIN_DEBUG conditional has been renamed into MONO_TLS_DEBUG.
* Moved the actual implementation into MNS.MonoTlsProviderFactory.
* We now use an environment variable called 'MONO_TLS_DEBUG' to
enable debugging (so to get debugging, you need to both compile with
-define:MONO_TLS_DEBUG and set that environment variable).
The new web stack has a conditional and environment variable called
'MARTIN_WEB_DEBUG'.
* Use [Conditional] instead of #if.
Fixes ParameterDirection.InputOutput type parameters not sending
the "output" modifier to server which creates a conflict resulting
in an exception server side.
* [btls]: Bind new native APIs to support renegotiation.
* mono_btls_ssl_set_renegotiate_mode(), mono_btls_ssl_renegotiate_pending():
New native methods.
* MonoBtlsSsl: Added SetRenegotiateMode() and RenegotiatePending().
* MonoBtlsSslRenegotiateMode: New internal enum.
* [System]: Cleanup internal Mono.Net.Security.MobileTlsContext APIs.
Use tuple `(int ret, bool wantMore)' return value instead of out variables.
* [System]: Check for pending exceptions in MobileAuthenticatedStream.
This should fix some issues where we're hanging instead of throwing
an exception if something went wrong.
The wasm backend is inspired on the x86 one with a few key differences:
1) It assumes a different aot runtime will be used to deal with all the weirdness of wasm.
In particular, it can run under MONO_AOT_MODE_INTERP_LLVMONLY without an actual working AOT compiler.
2) It's the only non-ISA based backend, so lots of weird things.
Like, no registers or addressable stack - for realsies.
The z13 supports some useful instructions that can be exploited
by the JIT. Most notably the compare-and-branch instructions can
reduce a two instruction sequence to one. The load-and-add command
eliminates the more complex compare-and-swap sequence.
The z13 also supports three operand instructions dst,src1,src2
which eliminate checks and loads for instructions like add and subtract.
The unaligned.cs test has been changed to cater for big-endian platforms.
For s390x only, the --trace option will result in a file per thread
being created rather than the traces being written to stdout and
sometimes intermixing incomplete trace entries.
[TSan] Unlocking MonoStats, GCStats and JITGCStats
As the `Unlocked* ()` functions have been approved in https://github.com/mono/mono/pull/5310, I used them to blacklist some of the most obvious counting variables whose data races should be ignored: `MonoStats`, `GCStats` and `JITGCStats` (more to follow if approved).
Please find details about all changes within the commit messages.
Added -t:library since mcd does not interpret output filename for dll suffix.
Without -t:library option, it fails to compile.
{code}
mono$ mcs -debug+ -r:System.Core Options.cs -o:Mono.Options.dll
error CS5001: Program `Options.exe' does not contain a static `Main' method suitable for an entry point
Compilation failed: 1 error(s), 0 warnings
{code}
The exception message of a MethodAccessException was changed in 7b88115737.
This caused the method-access.exe test to fail since it checked for the old format.
Unfortunately using mono_set_assemblies_path is not much of an option as it disables the MONO_PATH env var
and that's needed when working with an in-tree pedump - cuz having to `make install` all the time is BS.
Originally we used a C90-style struct initializer `{ (index), (offset), (type)
}`. Unfortunately, SpecialStaticOffset is defined with fields in a different
order on big-endian and little-endian machines. Using a designated
initializer, we don't have to care about the order.
This fixes Xamarin-10321. This change fixes the problem in SWF rather
than in libgdiplus which has the advantage that it works with both
Cairo and Pango renderers.
Without the additional NoWrap flag the text will wrap at a word boundary,
which results in the combo box showing lines with potentially a lot of
empty space at the end. With the NoWrap flag we render only one line,
displaying as many characters as possible in that one line.
... assemblies.
msbuild tries to filter out the denied assemblies, which mono refuses to
load, during a build. It uses the `deniedAssembliesList.txt` installed
to `$mono_prefix/lib/mono/xbuild` to identify them.
This was generated with:
`$ mono tools/nuget-hash-extractor/nuget-hash-extractor.exe nugets guids_for_msbuild > mcs/tools/xbuild/data/deniedAssembliesList.txt`
This file needs to be kept in sync with any changes in the assemblies
denied by the runtime.
msbuild PR that adds support for this -
https://github.com/mono/msbuild/pull/23 .
Commit message: Allow for non-fatal shell execution, and turn “install_name_tool” staging failures to warnings as we find a more permanent solution to AOT dylibs not always having enough field space for the new path (all other dylibs made in the build with the XCode toolchain typically do, as they are built with the “-headerpad_max_install_names” flag.
interface Type, not MarshalByRefObject. (Fixes#17325)
If a RealProxy instance is created (using the protected RealProxy(Type)
constructor) for an interface, mono internally sets up a MonoRemoteClass which
looks like a proxy for a MarshalByRefObject instance that happens to implement
the given interface. However mono_class_proxy_vtable just does a memcpy() to
setup the MonoVTable:type field of the transparent proxy's vtable. That type
field is hit by the JIT when System.Object.GetType() is called - and on .NET
Framework GetType for a transparent proxy of an interface returns the interface
not (as Mono used to) typeof(MarshalByRefObject).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=17325
.. directory, which is `$mono_prefix/lib/mono/msbuild/15.0/bin/Roslyn/`
Mono installs `csc.exe` but the corresponding
`Microsoft.Build.Tasks.CodeAnalysis.dll` required for supporting msbuild C#
projects is installed by msbuild. But these two can get out of sync,
like they did and had to be worked around in
https://github.com/mono/msbuild/pull/19 .
Instead, we now install all the relevant roslyn bits (C# and VB) from the same
source. Only the msbuild specific files are copied to the Roslyn folder.
VBCSCompiler, csi and their dependencies are symlinked from `lib/mono/4.5`.
Also:
- csi.exe is included since the tool is surfaced as an msbuild task,
and that requires the *Scripting.dll assemblies.
- VBCSCompiler* - shared compiler is installed
- vbc.exe doesn't work on mono currently, so skipping that
- And `Microsoft.DiaSymReader.Native.{amd64,x86}.dll` are dropped.
- add USE_STRERROR_R_XSI to use the feature test macros conveniently later
- deal with the GNU-specific version of `strerror_r ()` separately (leave the code for the XSI-compliant version untouched)
- make `buff_len` size_t as this is ISO compliant (even though it should not really matter in this case)
- export TSan flags that are used by the compiler and the compiled program
- introduce `make_timeout` to set individual timeouts for `make` based on the config (e.g. TSan will only get 30 minutes to complete)
* Introduce racing.h
- introduce the `RacingIncrement* ()` functions
- test the `RacingIncrement* ()` functions with races of `mono_stats` in class.c
- add racing.h to Makefile.am, libmonoutils.vcxproj and msvc/libmonoutils.vcxproj.filters
* [fixup!] Rename "racing" to "unlocked"
- rename racing.h to unlocked.h
- update new file name in Makefile.am and *.vcxproj* files
- rename the functions from Racing* to Unlocked*
- update the macro logic
The checked in test files which the test suites in mono-symbolicate
and mdoc verify their output against have a few roslyn-specific
things in them and would fail when running in mcs mode.
While in theory we could check in both mcs- and roslyn-specific
test files it seems not worth the effort and we should just skip
the tests in mcs mode so we get greener builds on platforms
where we still use mcs by default.
* [mini] fix xdebug null pointer dereferencing
Some trampolines are nameless, avoid crashing when generating their
debug info.
This change is released under the MIT license.
* [mini]: image-writer - move definition of USE_BIN_WRITER to header file
USE_BIN_WRITER is being used by xdebug for conditional compilation.
This change is released under the MIT license.
* [mini]: xdebug - obtain definition of USE_BIN_WRITER from header file
This re-enables xdebug on supported platforms.
This change is released under the MIT license.
With this, profilers can distinguish between the two, and also know what the
target method of a tail call is.
The call instrumentation flags have been renamed accordingly and a new flag has
been added for instrumenting tail calls. I've also added a flag for exceptional
leave events, and method_exception_leave is only raised if this flag is given
for a method.
Also refactored the relevant JIT code a bit so it's easier to follow.
Code coverage must now be explicitly enabled. This simplifies initialization
of some coverage-related structures and also lets us enable debug info which
is needed to produce good data.
Also change the signature of mono_profiler_get_coverage_data so it returns a
value indicating whether coverage data was available.
[mono-threads-posix] Fix a buffer overflow (rather an information leak / over-read)
While testing Clang's AddressSanitizer, I found and fixed a buffer overflow.
Up for discussion: it might be worth importing `strlcpy` (http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.c?rev=1.11) for similar purposes as it provides additional safety and also helps with the readability?
An inlined method does not require instrumentation (if it
did, it would not have been inlined). The flags that
control instrumentation options are valid for the caller
method and are not to be consulted.
This patch replaces an assertion with a check and early
return. A method that "wants to be instrumented" does not
get inlined, but a method that "doesn't want to be instrumented"
can get inlined. However, the flags that control instrumention
options have been calculated against the caller method, hence
they should not be consulted at all. The extra check renders
the assertion unnecessary.
* [w32file] Remove io_ops indirection
* [w32file] Replace use of w32handle by a GHashTable for File, Console and Pipe
* [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Remove force closing of sockets on shutdown
* fixup! [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Replace use of w32handle by a GHashTable
* [w32handle] Remove dead function mono_w32handle_new_fd
* fixup! [w32file] Replace use of w32handle by a GHashTable for File, Console and Pipe
* [w32handle] Remove dead variable mono_w32handle_fd_reserve
* [fdhandle] Factor w32file and w32socket common fdhandle code
* fixup! [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Fix GC safe/unsafe transitions
* fixup! [w32handle] Remove dead variable mono_w32handle_fd_reserve
- Fix the Linux build instructions.
- Remove eglib dependencies, as they complicate the build of an
extenral module.
- Make instance static instead of heap-allocated.
- Make the call counter 64 bits.
- Adjustments to accommodate the new profiling API.
* [w32file] Remove io_ops indirection
* [w32file] Replace use of w32handle by a GHashTable for File, Console and Pipe
* [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Remove force closing of sockets on shutdown
* fixup! [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Replace use of w32handle by a GHashTable
* [w32handle] Remove dead function mono_w32handle_new_fd
* fixup! [w32file] Replace use of w32handle by a GHashTable for File, Console and Pipe
* [w32handle] Remove dead variable mono_w32handle_fd_reserve
* [fdhandle] Factor w32file and w32socket common fdhandle code
* fixup! [Socket] Avoid relying on MonoIO.DuplicateHandle
* [w32socket] Fix GC safe/unsafe transitions
* fixup! [w32handle] Remove dead variable mono_w32handle_fd_reserve
1. Fix off by one in size check.
Largest usable size is 0x3effff, first unusable size is 0x3f0000
(Also change order of ArgumentException arguments - param name is second.
Set it to null because of misguided CoreFX SRE test that expects a null name)
2. Check for empty string field name.
.NET Framework says:
> If you specify 0 (zero) for iSequence, this method returns a ParameterBuilder
> instead of throwing an exception. There is nothing useful that you can do
> with this ParameterBuilder.
So let's do that.
* [bcl] Grab free ports randomly in NetworkHelpers
We're frequently seeing "address already in use" errors on Jenkins.
The theory is that when we're running tests and grab the next free
port via our custom NetworkHelpers we're getting a port which will
also be returned to a simultaneously running test (e.g. another chroot)
because we're closing the TcpListener and thus releasing the port until
we start using it in actual test code. By that time the other test
might've already opened the port, causing our test to fail.
Instead we now try to use a random port in the range 10000-60000
and try if it's available. This doesn't completely fix the inherent
race but should hopefully make it way less likely.
In principle, mono_verifier_verify_cattr_content should prevent malformed custom
attribute blobs from being passed in here.
In practice:
1. The verifier is not on by default
2. System.Reflection.Emit allows an arbitrary byte[] to be passed in which
means that code like this can cause mono to read past the end of the array.
```
// "1 1-byte constructor argument and then 65280 named properties follow"
assembly.SetCustomAttribute(constructor, new byte[] { 1, 0, 1, 0x00, 0xFF });
var attributes = assembly.GetCustomAttributes(true);
```
On llvm aborts can happen during finally blocks. This test was not failing before because the method in question had llvm disabled, which has recently changed.
[metadata] Fix racy next_generic_inst_id
Like suggested by @luhenry, I would like to propose this fix which was discussed in https://bugzilla.xamarin.com/show_bug.cgi?id=58423. As `next_generic_inst_id` is `int`, `InterlockedIncrement64 ()` seems to be the right choice.
Also, I cannot add any reviewers or assignees, which is why I would kindly ask @lambdageek to review this as well :)
These symbols weren't being properly exported in the final mono executable on
Mac because no code in the runtime called these functions. As long as they're
defined in an object file that contains used functions, they'll be exported.
When this feature is enabled for a method, the enter/leave event receives an
additional argument, a so-called 'call context'. This call context contains
enough information about the stack frame of the instrumented method to allow
the enter/leave callback to inspect the 'this' reference, method arguments,
local variables, and the return value (for non-void methods).
This feature enables some interesting scenarios that were not possible with
the regular enter/leave events. For example, a profiler could instrument
well-known methods in the managed thread pool code to get an idea of how an
application is using the thread pool, or it could instrument network-related
methods to gather statistics or even log all network traffic.
This is implemented by storing a MonoProfilerCallContext on the stack, whose
MonoContext field is populated by executing an OP_FILL_PROF_CALL_CTX opcode
which stores the stack pointer, frame pointer, and all callee-saved registers
to it. For the epilogue, a pointer to the return value (for non-void methods)
is also stored in the MonoProfilerCallContext. An address to this context is
then passed to mono_profiler_raise_method_enter/leave. Based on debug info,
all arguments and locals can then be looked up in the instrumented method's
stack frame.
For the interpreter, we just store an InterpFrame pointer on the
MonoProfilerCallContext and look everything up from that. We don't need debug
info in this case.
This feature is currently not supported with LLVM (for regular LLVM mode, it
will fall back to Mono's JIT, while for LLVM-only mode, it's not available).
I also refactored the interpreter code so that enter/leave events are generated
not only when interpreter debugging is enabled. Also, the interpreter will only
call mono_profiler_get_call_instrumentation_flags () once per method now.
Finally, I made the interpreter also generate exception leave events.
GenericTypeParameterBuilder:InternalResolve (Fixes#58454)
When the parameter belongs to a method builder, we need to pass the declaring
type (appropriately resolved) to GetMethodFromHandle to avoid an
ArgumentException.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=58454
* [runtime] Integrate eglib's configure into mono's configure to simplify and speed up the configure process.
* [runtime] Delete some duplicate eglib configure code.
Cause the creation of a token for an EnumBuilder object. Test both typedef
tokens (EnumBuilder from same assembly) and typeref token (EnumBuilder in another assembly)
The new argument controls what should happen when the given token is already
present.
In some situations it's expected that we either see the same object, or we
unconditionally want to replace it (for example if we previously registered a
TypeBuilder or a MethodBuilder, after the type or method is created, we will
re-register the RuntimeType or MonoMethod in its place). In other cases (for
example when a module references a MonoMethod from a different assembly), we
may still call `mono_image_create_token()` multiple times but we expect to see
the same MonoMethod object.
* [runtime] Move the sre source files to 'common_sources', they no longer have compile time gc dependencies after the Boehm GC root changes. sre.c still depends on the gc dependent caching code in reflection-cache.h.
* [runtime] Remove compile time gc dependencies from the reflection caching code.
* [runtime] Move reflection.c/sre.c to 'common_sources', they no longer have compile time gc dependencies.
* [runtime] Remove compile-time gc dependencies from domain.c/appdomain.c.
* [runtime] Move domain.c/appdomain.c to 'common_sources' since they no longer have compile time gc dependencies.
Instead of hijacking the return address when suspending a thread in a finally block for an abort, do an explicit check in managed code when we are returning from the handler in order to see if we need to abort. Hijacking the return address is arch specific and it doesn't work if we are suspended before it is initialized in handler start.
Fixes#5798
* [mempool] Annotate functions for ThreadSanitizer
Whitelist `mono_mempool_alloc`, `mono_mempool_new_size` and `mono_mempool_destroy` according to https://bugzilla.xamarin.com/show_bug.cgi?id=57936
* [fixup!] Test the NO_SANITIZE_THREAD macro
* [fixup!] Merge comments / documentation
This follows the reference source in understanding `EndpointBehaviors` to be an alias of `Behaviors` with a more general type.
Note that although an alias might not seem necessary to implement, when using netstandard1.3 the [`System.ServiceModel.Primitives`](https://www.nuget.org/packages/System.ServiceModel.Primitives) package exposes `EndpointBehaviors` but not `Behaviors`.
These are used by XA/XI/XM and because XM in particular needs to work with
both old and new versions of system Mono, we need to make sure these functions
still exist.
Using the cardtable scan and finish_gray_stack start and end events is cumbersome to parse and require a lot of logging, especially in the case of the parallel collector.
If a worker is stuck doing work in another context, it might not be very responsive in transitioning its own state from WORK_ENQUEUED to WORKING and finally to FINISHING. When joining worker threads, we check whether we have any threads working in the corresponding context and, if there aren't any, change their state directly from the gc thread.
We can do this because work is distributed from centralized pools (worker_distribute_gray_queue and the job_queue), instead of per worker. Therefore we don't need all the workers to perform actual work in the context.
fixes this compilation error
MonoAotOffsetsDumper.cs(279,59): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
The runtime has ~always supported having multiple profilers loaded, so it
didn't make much sense that only the last --profile option given would be used.
I intend to move code coverage support to a separate profiler module, so these
events will eventually be removed from the log format. As such, I'd rather not
commit to having these event classes in the API.
This won't affect users of the library who don't enable code coverage.
So mono_profiler_init becomes e.g. mono_profiler_init_log.
This allows us to link together multiple profilers into a single module and
load them selectively. This is especially useful for XA/XI/XM.
Calling this function could cause us to miss some profiler events.
In the past, we needed to call this function so that SMR and mono-threads were
initialized. Since then, 8dec9848f6 changed
profiler initialization to happen later during startup, so this is no longer
necessary.
TypeTest.GetGenericMethodDefinitionOverInflatedMethodOnGTD accesses
List<T>.ConvertAll() via reflection but doesn't use the method
elsewhere so the linker can remove it. Added some usage to avoid that.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=56242
MONO_GC_EVENT_START is actually sent _after_ all the 'stop world' events. The
heapshot logic being in this switch case only worked by accident previously.
* Remove the mark/reclaim events as they've been broken for a long time and
aren't particularly useful.
* Reorder the enum member declarations to the order they actually arrive in.
ValueAdd was added over a decade ago and all the tests marked with this category are passing now.
We have *tons* of tests that rely on working DNS/Internet that aren't marked with
InetAccess (and they actually provide good value so we don't want to exclude them).
Since these categories don't really make sense and just causes confusion
it's better to just remove them.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=57691
For keys longer than 1024 bits, we encoded the length incorrectly as
0x80 (length & 0xff)
instead of the correct algorithm:
if (length < 0x80)
length
else if (length < 0x4000)
0x80|(length>>8) (length & 0xff)
else
0xc0|(length>>24) (length>>16)&0xff (length>>8)&0xff length&0xff
which is provided by mono_metadata_encode_value.
See ECMA-335 II.24.2.4 #US and #Blob heaps
N.B.: we now always allocate the memory for the key as (keylen + 4) which
over-allocates by a couple of bytes in the cases where the key is shorter.
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=57691
We build a library that has an InternalsVisibleTo attribute that references an
executable that is signed with a long (>128bytes) public key. Previously we
were using an incorrect method of encoding the key length.
This commit does a few different things.
First, metadata event options have been removed. We now always emit these
events. This is done because they contain important data that must be present
in order for dynamic event mask changes at runtime to result in useful data.
Also, almost all uses of the profiler require this data to be present, so
letting it be turned arguably just adds confusion for users.
Second, the PROFLOG_*_FEATURE flags have been removed. These made the code a
bit confusing because it was unclear whether code in log.c should be checking
the PROFLOG_*_FEATURE flag or the PROFLOG_*_EVENTS flag for a particular kind
of event. For heapshot in particular, the heapshot mode is now a separate enum
configuration variable. For enter/leave and coverage, switching those on and
off in the log profiler at runtime is not something we want to support at this
time.
As a result of the above change, some options are now processed manually rather
than being part of the event_list array.
Third, the way we turn off GC root events when needed is now by setting the
callback to NULL. This is more efficient as it signals to the runtime that it
doesn't have to gather root information. This will especially matter later on
when the profiler root info revamp lands, as it collects a lot more data than
we do today. Also, GC roots are no longer gathered unless we're doing a
heapshot.
Fourth, the profiler now always starts the sampling thread in idle mode. This
is so that we can reconfigure and enable/disable it at runtime as needed.
Finally, the alloc alias option now includes GC move events, and GC resize
events are only emitted if the gc option is given.
We've seen this test failure a few times:
```
MESSAGE:
#2
Expected: greater than or equal to 00:00:01
But was: 00:00:00.9544900
+++++++++++++++++++
STACK TRACE:
at MonoTests.Microsoft.Build.Execution.BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion () [0x000d8] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-amd64/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/BuildSubmissionTest.cs:110
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-amd64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
```
Rewriting the test to use Stopwatch instead of DateTime
for measuring elapsed time should make it more reliable.
Previously, the profiler's state was spread all over the place. Some stuff was
in the MonoProfiler structure, some stuff was in global variables littered
throughout log.c. Now everything is stored in MonoProfiler and ProfilerConfig.
The call to GetDiskFreeSpaceEx passes uninitialized pointers to GetDiskFreeSpaceEx
instead of pointers to stack variables. This will cause random memory corruption and random
crashes on Windows builds.
This is a regression caused by the refactoring work done in this PR:
https://github.com/mono/mono/pull/4255
Location of ml.exe and ml64.exe is different in VS2017 compared to VS2015.
By removing the partial path from the command, the VS environment will locate
the tool depending on selected build configuration and VS version.
This should work for both VS2015 and VS2017.
LanmanWorkstation and SamSs services don't depend on the Browser
service anymore, at least in the Windows Server build that our
Azure VM agents on Jenkins are using now. This started failing a
few days ago so I assume a new build was rolled out.
It shouldn't throw in that case.
Helps cover https://bugzilla.xamarin.com/show_bug.cgi?id=57629
(note that we don't explicitly test on a readonly FS as that is hard
to do in a unit test, but running this test on Android should suffice).
Instead of using fragile lockless code in the sigchld signal handler, wake up the finalizer thread and make it call back
into the process code to signal finished processes.
* Profiler callbacks can now be changed and disabled at any point.
* API users no longer have to set event flags. The API instead uses a counter
internally for each type of callback.
* Filter functions for enter/leave instrumentation can be installed, and they
can choose whether to instrument the prologue, epilogue, or both.
* Managed allocators can now be instrumented for allocation profiling.
* A profiler must now declare that it wishes to use allocation profiling and/or
sampling in its init function.
* Sampling parameters can now be changed at any point, and the sampling thread
can be put into an idle mode when no sampling is needed.
* Only one profiler can have control over the sampling parameters. Whichever
profiler enables sampling first gets control.
* Adding new events is now very easy: One line in profiler-events.h and one
line wherever the event should be raised.
* Lifted the restriction that enter/leave instrumentation would cause an abort
in full AOT mode.
* Support for call chain sampling has been removed.
* Support for the old, platform-specific code coverage mode has been removed.
* The new profiler module entry point is mono_profiler_init. If a module has
a mono_profiler_startup symbol (the old entry point), a warning will be
printed and the module won't be loaded.
* Updated the profiler test suite to work with instrumented managed allocators.
After the refactoring in 9aaa0083d0
CppCheck complained about using 'result' uninitialized (looks like
it can't deduce that g_error will abort the process anyway).
Console.Error.WriteLine ("Got a bad hardware address length for an AF_PACKET {0} {1}",...
This Console.WriteLine interferes with Apache Storm that reads from the console I/O.
See bug: https://bugzilla.xamarin.com/show_bug.cgi?id=57887
[sre] Deal with ResolveEventHandler returning an AssemblyBuilder (Fixes#57850, #57851)
Fix a couple of bugs in the situation where a `ResolveEventHandler` happens to return an `AssemblyBuilder`.
* [#57850](https://bugzilla.xamarin.com/show_bug.cgi?id=57850) - if the `ResolveEventHandler` returns a reflection only assembly, throw a `FileNotFoundException`
* [#57851](https://bugzilla.xamarin.com/show_bug.cgi?id=57851) - don't look for a `ReferenceAssemblyAttribute` on assemblies returned by a `ResolveEventHandler` if they happen to be an `AssemblyBuilder`. (the native code path to get there is to try and instantiate a custom attribute in some other assembly, hence the fairly convoluted test in `assemblyresolve_event5` and its helper files)
In particular this makes sure that AssemblyBuilderAccess.ReflectionOnly aren't
allowed to run. And AssemblyBuilderAccess.CollectAndRun aren't allowed to save.
mono_w32handle_new_fd: We must hold scan_mutex while initializing an unallocated handle otherwise
mono_w32handle_foreach might think it's a valid handle.
mono_w32handle_timedwait_signal_handle: We must increment the refcount before installing the interrupt handle
as the other end can be called right after we finish installing and would trigger a failure.
* [w32handle] Fix handle dumped ref
* [w32handle] Replace exposing mono_w32handle_{ref,unref} by mono_w32handle_{duplicate,close}, it is closer to what the win32 API exposes.
* [w32handle] Remove unrefing of handles on shutdown
If one of the handle is a file handle for example, then w32file has already be cleaned up, so we cannot guarantee that the handle we are going to close is not going to call into w32file code.
We're checking out a specific commit for both now so the git branch
is no longer required.
Also fixes warnings that a 2017-06 branch doesn't exist in mono-extensions.
While this is not an issue yet, sgen_thread_pool_wait_for_all_jobs is logically expected to be called by the main thread and resume execution after all jobs have been executed. Concurrent M&S can enqueue additional jobs as part of its finishing phase, which means that we could detect early that no more jobs are to be processed. Make sure this is not the case.
* Fix compiler warnings (w32)
- add explicit (long long (unsigned)) type casts
- change %ld to %lld once, to match the general style of these logging messages
* Fix compiler warnings (threadpool)
- add explicit (void *) type casts
* Fix compiler warnings (boehm)
- add an explicit (long) type cast; the values are defined as gint64, an upgrade to at least "%ld" seems like a good idea
- about dropping const: const does not seem to be necessary as g_getenv() returns pointers to freshly allocated buffers whenever called. const might have been used to protect the return value of g_getenv() on unix systems with earlier versions of Mono (as a comment in gmisc-unix.c suggests). keeping const here causes a compiler warning, as the const qualifier gets dropped when *env is being used with g_free(). that led to the decision to drop the qualifier altogether.
* Fix compiler warnings (sgen)
- specify the arguments (void) to avoid -Wstrict-prototypes warnings
* Fix compiler warnings (misc - metadata)
- specify the arguments (void) to avoid -Wstrict-prototypes warnings
* Fix compiler warnings (misc)
- specify the arguments (void) to avoid -Wstrict-prototypes warnings
- add an explicit (void *) type cast; changing the return type to char* might be more usable and could be discussed
- ret is not being used and can be removed; fixes a -Wunused-but-set-variable warning
* Fix compiler warnings (mini)
- specify the arguments (void) to avoid -Wstrict-prototypes warnings
* [fixup!] Correct indentation
* [fixup!] Correct (void *)
- use GUINT_TO_POINTER and MONO_NATIVE_THREAD_ID_TO_UINT instead of (void *) to cast mono_native_thread_id_get () to %p
* [fixup!] Correct indentation of boehm-gc.c and add FIXME
* include <inttypes.h> and test the G_GINT64_FORMAT macro
* [fixup!] Use G_G*_FORMAT and PRIx32 macros instead of type casts wherever possible
Reuse the existing icall infrastructure to give the same handle back.
This PR implements all OpenExisting methods (with the access rights parameter discarded) and the SafeHandle property.
In the runtime, we don't check the capacity parameter if we try to open a mmap file, and we fallthrough the handle refcount case.
- Had to borrow a gchandles implementation from mono/metadata/boehm-gc.c
- Added coop handles support for NULL GC
- Fixed typos in configure.ac
- To use: `./configure --with-libgc=none --without-sgen --enable-boehm`
You get a mono-boehm which actually is not collecting anything.
We need to run jobs on the thread pool threads for parallel minor, parallel major, concurrent mark and concurrent sweep, some of which can run simultaneously. Instead of making separate threads reserved for each type of work, we create a work context abstraction (this contains a set of pending jobs to run and the sgen-worker callbacks). When a thread pool thread looks for work, it searches for work (jobs and idle work) through all contexts and finishes work from each one of them, from the highest to the lowest priority.
This is implemented by having different thread pool contexts (which contain the job list, work callbacks that indicate whether it should work and its ineherent priority), overall unrelated to the GC. The sgen worker infrastructure also creates separate worker contexts (which contain the object ops to be used and information about each worker, like the state and the private gray queue). We use at most two worker contexts (for minor and for major) and each worker context makes use of a sgen thread pool context.
Concurrent mark doesn't normally scan objects in the nursery since they can be moved. At the end of the concurrent mark, we were locking over the entire gc pause in order to make sure that the we can scan the latest pinned object list (aka none of those objects can be moved). Lock only over the pinning phase of the collection, since it is enough.
This reduces regressions for switching from MS_BLOCK_SIZE compile time constant
to ms_block_size variable by 85% on the tests where this was showing up. In the
future we should implement a block allocator, which would, amongst other benefits,
enable us to remove the block-size/page-size dependency.
The block size must be a multiple of the system page size. Page size simply
cannot be determined reliably at compile time, so we must obtain the page size
through a system call on startup and use it as the block size. We still enforce
a minimum block size of 16kb on systems where the page size is smaller than
that.
The old code hardcoded page sizes for certain architectures with large pages.
THe problem is that those architectures don't necessarily have to have large
pages and on systems where this wasn't the case, we'd end up with a block size
much larger than needed.
Rebase of @alexrp's work.
Linux has this particular behavior of returning ENOFS when unlinking from an read only FS.
Even if the file doesn't exists! Darwin does the sane thing and return ENOENT in this case.
To workaround this, if unlink returns EROFS, we stat the file and deal with that.
This fixes an issue we see on the BCL test suite when run in the context
of Xamarin Android:
```
I/mono-stdout( 2534): Certificate1 [FAIL] : TearDown : System.UnauthorizedAccessException : Access to the path "temp.b64" is denied.
```
It seems like those files aren't generated anymore. Not sure why this
starts to be a problem now.
This avoids situations where we could end up filling the signal queue
completely, leading to the undocumented EAGAIN return value from pthread_kill,
which breaks ~everything in the STW/GC code because it thinks an error return
value from pthread_kill means the thread has exited.
The actual reason why this happened is that when a thread is suspended, we mask
all signals except the restart signal for that thread. This means that a
program with a large number of threads or where GC collections could take
longer than usual would end up with tens of thousands of sampling signals
queued up, eventually reaching the limit of the user-level signal queue (see
`ulimit -i` and `RLIMIT_SIGPENDING`).
We only do this on systems where we use real time signals. Non-RT signals do
not have this problem as the kernel will throttle them.
These will be used in the log profiler.
Also, make mono_thread_info_register_small_id () only allocate a new small ID
if one isn't already allocated for the current thread. This is necessary so
that we can allocate a small ID for a thread and not have it be overwritten
if/when that thread is later attached probably (which also results in this
function being called).
This hardens the profiler against cases where an unattached thread causes some
event callback to be invoked. This is particularly relevant when embedding.
If a program is idle, we likely won't get enough samples to prompt the dumper
thread to send its log buffer to the writer thread. This can make it seem like
the profiler isn't working when it actually is. So, just send the dumper
thread's log buffer every second to make sure data is delivered in a timely
fashion.
* [threads] Make mono_thread_attach_full static
* [threads] Remove prefix on MonoThreadInfoCallbacks callbacks
* [threads] Rename mono_threads*_init functions to mono_thread_info*_init
* [threads] Remove dead method mono_runtime_is_critical_method
* [threads] Move MonoThreadInfoCallbacks to metadata/threads
* [threads] Store MonoInternalThread in MonoThreadInfo for use when detaching
When the native thread would exit, the TLS keys are destroyed. There is a TLS destructor for MonoThreadInfo, but not for MonoInternalThread. If MonoInternalThread is destroyed before MonoThreadInfo, then MonoThreadInfoCallbacks.thread_detach wouldn't successfully detach the current MonoInternalThread as mono_thread_internal_current would return NULL. This would lead to MonoInternalThread still laying around, while their corresponding MonoThreadInfo has already been destroyed. This fixes this problem, since we now rely on MonoThreadInfo to store the MonoInternalThread for detach.
- Create a unique temporary directory for each test in TypeBuilderTest and delete
it on TearDown.
- Change tests to use tempDir instead of Path.GetTempPath ()
- Change IsSerializable () test to how it was 11 years ago and have it write to a
file with a simple name (but now in a directory where noone else is writing)
- Change FieldsWithSameName (), FieldsWithSameNameAndType () and
MethodsWithSameNameAndSig () to use the default temp assembly (now in a
unique tempDir) instead of using the CreateTempAssembly ()
- Remove CreateTempAssembly function. It is dead code.
* [threads] Use MonoThreadInfo.{stack_start_limit,stack_end} in more places
* [threads] Remove dead code
* [threads] Rename MonoThreadInfoCallbacks.thread_{register,detach,unregister} to MonoThreadInfoCallbacks.thread_{attach,detach,detach_with_lock} respectively
This error can occur on mobile devices during network operations
as evidenced in https://bugzilla.xamarin.com/show_bug.cgi?id=56653
and having an actual description of the error printed in this case
makes it easier for the user to discover what's going on.
mono_thread_info_suspend_lock () can be called from boehm-gc.c
on_gc_notification before the new thread's start_wrapper calls
mono_thread_info_attach but after pthread_create calls the start wrapper.
As a result, the asserts in mono_thread_info_suspend_lock_with_info can catch
the new thread in an inconsistent state.
They now are produced every time a GC spills heap events such as roots, moves and objects.
Additionally, I changed GC syncpoints to happen in case any GC events are active.
It's a safer choice with little penalty. Figuring out the actual combinations that would require them is non-trivial.
Suppose we have two versions of an assembly: AsmA 1.0.0.0 and AsmA 2.0.0.0 that
we want to load into the same domain at the same time (for example we want to
load AsmB and AsmC that statically reference the two versions, respectively, or
maybe we used reflection). Suppose version 1 got loaded first (and we found it
on our MONO_PATH in "somepathdir/AsmA.dll"). Now we want to load version 2.
The problem is that if version 1 is on MONO_PATH first, we'll find a filename
that matches ("somepathdir/AsmA.dll") and try to open that image. Then we'll
end up here in mono_assembly_open_predicate() after the mono_image_open_a_lot()
call hits the image cache. So we get back an image and image->assembly is
version 1.
The old behavior would just return any non-NULL image->assembly. The new
behavior is to check the predicate and reject opening the propose file if the
predicate doesn't match. (If we're not using the strict loader, or if there's
no predicate set, return the existing image->assembly as before).
They lived in https://github.com/mono/release before, moving them
into the main repo allows us to version them more easily.
Note: I intend to do more cleanup on those scripts in the future,
this is just the first step.
Group gc params configurations into general gc modes. The default mode (SGEN_MODE_NONE) is what we've been using so far, meaning old default features. The other modes can include experimental features.
We the profiler now emiting a lot less events by default, all the existing polling no longer makes sense as they won't matter in the common path.
Instead we make sure the finalization end callback is always installed and poll from it.
This introduces the risk of a heapdump never happening or experiencing long delays because there are either too many finalizers or one of them hung.
It's an acceptable risk.
* Fix System.Numerics xunit tests and add them to CI
Xunit.Extensions.NetCore.dll is available as a net46 version now
so we can just use it instead of building it from our buildtools fork.
This also allows us to remove the fork from our submodules.
We were missing running the System.Numerics xunit tests in CI,
this adds them so we catch breaks like these earlier.
* Skip tests on Windows, they seem to fail there
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=57222
Although methods aren't affected by this bug, I added a regression test for
this case anyway in case the implementation changes.
Currently MethodBuilder.RuntimeResolve() goes through a different codepath - it
calls RuntimeType.GetMethod (MethodInfo) which calls into an icall which looks
for a method with a matching token rather than a matching name.
We can't pass RuntimeMethodHandle across AppDomains since that can lead to memory corruption.
The way this happens is that when Domain (A) passes a method handle (M) to Domain (B), (B) will get the reflection object for
which will add that MonoMethod to the per-domain reflection hashtable. This won't cause the assembly of (M) to be registered with (B).
When (A) is unloaded, it might be the only domain referencing the assembly of (M), cause it to unload resulting in (B) having a dangling
pointer to (M) on its reflection hashtable.
The fix is to serialize enough lookup data across the wire so we can do type/method lookup using reflection on the target domain.
It might be slower, but this only happens on some remoting slowpaths anyways.
Finally, we can't simply register the assembly of (M) into domain (B) as that list (MonoDomain::domain_assemblies) is used for type loading,
thus breaking the target domain in some scenarios.
RuntimeType:GetField (FieldInfo) looks up the field by name and attributes,
which doesn't work for SRE because it is legal to create multiple fields with
the same name and type and attributes. So lookup using the
RuntimeFieldHandle (aka MonoClassField*) instead.
* [System]: Correctly implement close and shutdown in SslStream.
* Cleanup.
* Cosmetic.
* More ReferenceSources/SR2.cs into common.sources to make it build.
When creating a bundle on Windows to run on Android, macOS/iOS or Linux we need
to use the target system's path separator when storing satellite assemblies in
the bundle instead of the host system's one. Failing to do so will embed (on
Windows) the satellite assemblies with paths like
fr_FR\myassembly.resources.dll
while at runtime Mono will try to look up the assembly by
fr_FR/myassembly.resources.dll
and fail to find it, obviously. The `--style` parameter is now consulted to see
what path separator character should be used.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=55603
MonoInternalThreadHandle is not really needed - all MonoInternalThread
instances are supposed to be pinned. But for uniformity, the icall marshaller
makes handles anyway. This function lets us get back to a raw ptr.
- Use coop handles for create_object_from_sockaddr
Eventually want to rewrite its callers to use
create_object_handle_from_sockaddr directly.
- Use coop handles for
- LocalEndPoint_internal
- RemoteEndPoint_internal
- inside create_sockaddr_from_object
Eventually callers should be updated to use create_sockaddr_form_handle
directly.
- Use coop handles for
- ReceiveFrom_internal
- Bind_internal
- Connect_internal
- SendTo_internal
- Remove dead code (create_object_from_sockaddr, create_sockaddr_from_object)
- Use coop handles for
- Receive_internal WSABUF[]
- Receive_internal byte[]
- Send_internal
- Send_array_internal
- SetSocketOption_internal
- GetSocketOption_arr_internal
- GetSocketOption_obj_internal
- IOControl_internal
- SendFile_internal
- Remove more dead code
- Use coop handles for
- Socket_internal
- Select_internal
- Trivial coop handles conversion for several icalls in System.Net.Sockets.Socket
None of these functions use managed objects, so just add a MonoError* argument.
Previously we only had "out" reference args working - they get a handle that's
initialized to NULL on entry and then writes back to the out arg on icall
return.
For "ref" reference args, do the same thing but initialize to the initial
argument value.
* [Mono.Options] Fix test and add suite to CI
We missed running Mono.Options tests on CI so we didn't catch
this error which was introduced with: https://github.com/mono/mono/pull/4719
```
CSC [net_4_x-darwin] net_4_x_Mono.Options_test.dll
Test/Mono.Options/CommandSetTest.cs(231,16): error CS7036: There is no argument given that corresponds to the required formal parameter 'error' of 'CommandSet.CommandSet(string, TextWriter, TextWriter, Converter<string, string>)'
```
* [Mono.Options] Stop hardcoding \n to fix tests on Windows
With the new bockbuild in place we can finally remove the
implicit dependency on a point-in-time state of mono-extensions
and instead explicitly pin the desired revision.
This removes all [no]foo weirdness and flag dancing in favor a simpler model.
Users can enable/disable both events and profiling modes. We expose pretty much all individual events.
A profiling feature is a group of flags that enable a specific profiling scenario.
Right now we have code coverage, perf sampling, gc alloc and heap dump as features.
All events can be prefixed with 'no' and cause them to be disabled. We'll later introduce some sanity
checking around misconfiguration.
Finally, this changes the default set of enabled events to threads and gc. Everything else must be added on top.
Experience has shown that the vast majority of those events are just noise when profiling and the current configuration
design made it quite awkward to introduce quieter modes.
We would previously mix 2 SocketAsyncResult, and in case we would succeed asynchronously, we would return one that would not be updated afterwards.
The solution consists in using only 1 SocketAsyncResult that we ensure to update accordingly.
After looking at https://github.com/mono/mono/pull/4949 I did a
quick pass through the other config sections and found two more
cases where we missed adding to the properties list.
Otherwise, while we are clearing the domain, another domain might be created that has the same id as the current one. This would lead to crashes due to releasing of data from the newly created domain (ex gchandles).
* [S.R.I.RuntimeInformation] Fix FrameworkDescription on Android
It turns out using `DllImport ["__Internal"]` doesn't work on
XA (and other cases where Mono is embedded) because it searches
for the method in the host which embeds Mono and doesn't find it,
resulting in an EntryPointNotFoundException.
We need to switch to an icall instead. However there's already
an existing icall+BCL wrapper: Mono.Runtime.GetDisplayName().
Added IVT from corlib to S.R.I.RuntimeInformation so we can call it.
* Update API snapshot
we got a couple of bug reports, all with the same failure:
https://bugzilla.xamarin.com/show_bug.cgi?id=44907https://bugzilla.xamarin.com/show_bug.cgi?id=46482https://bugzilla.xamarin.com/show_bug.cgi?id=51791
The bugs are private, therefore here what I wrote:
```
Thank you Matthias, this was very helpful.
>>> 09-30 12:24:50.347: A/DEBUG(6211): pid: 6191, tid: 6209, name: Thread-4 >>> com.distech.x50.ui.droid <<<
>>> 09-30 12:24:50.347: A/DEBUG(6211): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
>>> 09-30 12:24:50.347: A/DEBUG(6211): r0 d6b58728 r1 00004001 r2 00000000 r3 d6b58738
>>> 09-30 12:24:50.347: A/DEBUG(6211): r4 00000008 r5 ea97427c r6 00001f3c r7 00000015
>>> 09-30 12:24:50.347: A/DEBUG(6211): r8 00001f38 r9 00000015 sl d6b58728 fp d67fed90
>>> 09-30 12:24:50.347: A/DEBUG(6211): ip ea9742c0 sp d67fed60 lr ea7a4504 pc ea716a58 cpsr 800e0010
The crash happens on this assignment:
https://github.com/mono/mono/blob/de1865dad5c0350f391fedcaa08f02f610530d3f/mono/mini/mini-generic-sharing.c#L418
Here the according disassembly:
https://gist.github.com/lewurm/b1094749027c9e5ea19fdc4fac7905a7
The crash happens in the last loop iteration (`r9=i`, `r7=slot`). Looking
at the machine code it just _cannot_ happen, which is confirmed by the C
code as well: `*oti` successfully happens in the if check, but after
returning from `alloc_oti()`, `oti` doesn't contain a valid address anymore.
I suspect some weird hardware issue that fails to restore all registers
properly from the stack.
```
[...]
```
Thanks again Matthias. Unfortunately, I'm out of ideas, and I can't
blame anything but the hardware. The situation we see is too weird. We
segfault at offset `0xdda60: str sl, [r4]`, but really we should
already segfault at offset `0xdda2c: ldrge sl, [r4, #8]!"`. So I
suspect two things why this could happen:
(1) The instruction at `dda2c` fails to do the post-increment correctly
for *whatever* reason.
(2) Something along the execution path corrupts the stackslot, where
`r4` is saved, in such a way that it *exactly* masks it with `0xf`.
Everything else on the stack looks fine, so this is sort of very
unlikely to be honest.
This only happens on a very specific device: The Nexus 9 is the only
device that was ever shipped with the Tegra K1 T132. I suspect an issue
in the binary translation layer of `armv7` instruction set to the internal
micro-ops of the CPU. I tried to stress test the instruction in
question (see https://github.com/lewurm/ldrinsntest), however I was not
able to trigger a crash. So either, I'm missing some context in order
to trigger the bug or I'm on a completely wrong track.
That said, even if we could proof that it is indeed a hardware issue,
the workaround is also non-trivial (it would then either need a fix in
gcc or require a microcode update by the chip vendor).
```
And then we saw:
https://github.com/golang/go/issues/19809#issuecomment-290804472
Another hint that this device is buggy.
This change massively improves reflection query scalability.
Given this benchmark and my 4 cores laptop:
```
const int T_C = 4;
var list = new List<Thread> ();
bool done = false;
int count = 0;
for (int i = 0; i < T_C; ++i) {
var t = new Thread(() => {
while (!done) {
typeof (Driver)
.GetMethods (
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Static);
Interlocked.Increment (ref count);
}
});
t.Start ();
list.Add (t);
}
Thread.Sleep (5000);
done = true;
foreach (var t in list)
t.Join ();
Console.WriteLine ("Got {0} lists done", count);
```
This change makes us go from 166.725 queries/s to 5.140.821 queries/s. Or 30x faster.
* [interpreter] Add beginnings of debugger support.
Handle debugger support similarly to the JIT:
- Add a MINT_SDB_SEQ_POINT instruction to the debugger IR. Replace it with a MINT_BREAKPOINT instruction when a breakpoint is placed.
- Store the sequence point information in the existing sequence point data structures.
* [interp] Add support for debugger stacktraces.
* [interp] Add support for debugger frame info.
* [interp] Connect seq points inside the same basic block so simple single stepping works.
* [interp] Link sequence points in different basic blocks the same way the JIT does it.
* [interp] Allocate some bitsets from a mempool.
* [interp] Rewrite the patching in the transform pass to make it a bit easier to understand.
* [interp] Add interruption support for sdb.
* [interp] Add support for mkrefany,refanytype and refanyval.
* [interp] Fix debugger failures.
* Add support for setting byref variables.
* Fix thread interruption when the top frame is an interpreter frame.
* Allow stack walks when a thread is suspended while transforming a method.
* Implement method entry/exit events.
* Fix ldstr+dynamic methods.
* [interp] Implement support for Debugger.Break.
* [interp] Change the offsets in MonoJitInfo/seq points into byte based from short based to reduce the amount of special casing needed in other parts of the code.
* [interp] Factor out the push/pop lmf code into a pair of helper functions.
* [mixed] Fix mixed mode EH.
* [interp] Implement support for MONO_VERBOSE_METHOD. Improve sequence point placement.
* [interp] Implement support for SetIP ().
Pass the target thread as an additional argument to mono_interp_set_resume_state (). Check the resume state after single
stepping/breakpoints in the interpreter.
* [interp] Disable the usage of the STLOC_NP opcodes when running under the debugger, it doesn't work if the ip is changed when the execution is stopped.
* [interp] Fix async stack walks in the debugger when the thread is in native code called from interpreter code.
* [interp] Fix the disable interpreter build.
* [interp] Fix the calculation of native offsets in the line number info.
* [interp] Fix the build.
* [interp] Make CMD_STACK_FRAME_GET_THIS behave the same when called on managed-to-native frames, with the interpreter, frame->has_ctx is set.
* [interp] Fix typos, remove some dead code, use g_print instead of printf in a few places, move some interpreter stubs to interp-stubs.c.
- Make a new mono_w32event_create_full on unix
- Convert the MonoString to utf8 (unix) or utf16 (win32) in the icall, then
call an implementation func.
- transition to GC safe mode around the win32 api call on Windows
Remove 10000 size check in mini_emit_memory_copy_bytes, this is no longer needed now that the memcpy expansion logic in mini_emit_memcpy_internal was fixes.
Use a define for 10000.
Remove useless debug spew.
Problems with the current code:
It's wrong on 64bits if align == 4
It's wrong on 64bits if offset is not 0 or 4.
It generates bad code if align > 1 && align < SIZEOF_VOIDP
This PR implements unaligned based on the following set of assumptions that are true for the current set of platforms we support:
- A load/store of size X works with data aligned on X. IE, a short store can handle addresses aligned to 2
- Unaligned access is either disallowed or plain slower.
- Both source and dest abide to the supplied alignment.
The way we emit unaligned access is by emitting the widest possible access based on alignment and offset.
TBH: use unaligned access on targets like x86 that support it and are profitable.
When using "fat" session (~2MB) and multiple (~20) simultaneous calls
the retrieval sometimes fails and lock the session.
The original code blocks on the calling thread (AutoResetEvent.WaitOne())
and uses another thread with the timer to do the polling.
If the polling succeeds, the TimerCallback AutoResetEvent.Set(),
with no guarantes that it will wake up the thread.
(see Remarks in http://msdn.microsoft.com/en-us/system.threading.eventwaithandle.set%28v=vs.110%29)
In this patch we simply replace all this code with an equivalent
loop + sleep, which give us the same behaviour
(we still block the calling thread with the sleep, but we didn't use another one)
Signed-off-by: Frederic Mestayer <[email protected]>
Signed-off-by: Etienne CHAMPETIER <[email protected]>
2014-12-22 09:20:01 +01:00
6625 changed files with 415250 additions and 371798 deletions
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
Loaded 100 of 6625 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.