Context: https://bugzilla.xamarin.com/show_bug.cgi?id=56275
Recent Cecil 0.10 changed to not reading the assembly in memory but
instead reads directly from the underlying stream [0]. This however
means that the file handle is not freed until the AssemblyDefinition
is disposed.
Xamarin.Android is using the pdb2mdb source as part of
Xamarin.Android.Build.Tasks.dll and hit an issue where the file
would be locked inside of VS.
[0] http://cecil.pe/post/149243207656/mono-cecil-010-beta-1
This function calls mono_class_get_ref_info which allocates a coop handle.
However it is called from an icall that wasn't converted to use coop handles
yet, so nothing was saving/restoring the handle stack mark, and consequently
the handles leak.
Move the call to SslStream.AuthenticateAsServer() into the constructor because
we don't want to call it again when Init() is called from Close().
(cherry picked from commit 5e08742b5c)
(cherry picked from commit abfb9a00a7)
We trigger degraded mode when we are unable to properly build the nursery fragments due to excessive nursery pinning. This is done by initializing degraded_mode at the end of a minor. alloc_degraded is used to do allocation to major heap either as part of mature allocation or as part of degraded mode (when we bump the degraded_mode so we can detect when the next minor should be triggered).
When failing to allocate from the nursery after doing a minor (because the other threads might have already consumed the nursery) we need to do a mature allocation (as a fallback) instead of a degraded mode allocation so we don't uselessly enable the mode.
The code expected that a custom attribute was specified as a MonoCMethod and
was calling mono_image_create_token(). However that function expects to be
called from the managed S.R.E.ModuleBuilder:GetToken (MemberInfo) which handles
all the builders in managed code. Consequently mono_image_create_token () was
asserting.
So now we encode the token for a ConstructorBuilder in place.
We change AppContextSwitches to hardcode values on mobile and use the full stack on desktop.
We still have all strings in AppContextDefaultValues as this reduces the ifdef mess in AppContextSwitches.
It's only used on desktop, where an extra kb is not the end of the world.
* Update nuget-buildtasks from upstream's `dev15.1` branch
dev15.1 branch + fixup import paths
This was prompted by needing to support nuget restore for projects with
`PackageReference`.
* [nuget] Bump reference to NuGet.BuildTasks to pick up a build fix
* Bump nuget-buildtasks
We previously recursed through the entire directed cyclic graph
of the type passed to SRE. When given a (legal) circular type reference,
we encountered stack overflows. This was particularly easy to trigger
with fsharpi and with FAKE.
By creating everything about the type before searching for the parent,
and by defering all type hierarchy establishment until the type must be
surfaced to manage code, we tease out the data dependencies caught up in
the cycle.
Note the bounded lifetime of the unmanaged object hidden in the SRE
module, which acts as a global reference for all types reachable from
the TypeBuilder passed to the runtime through the icall.
* [appletls]: Use SecIdentityCreate() to avoid using the Mac keychain. (#4671)
Reading Certificates from the Mac Keychain
==========================================
Reading the private key from the keychain is a new feature introduced with
AppleTls on XamMac and iOS. On Desktop Mono, this new feature has several
known issues and it also did not received any testing yet. We go back to the old
way of doing things, which is to explicitly provide an X509Certificate2 with a
private key.
Keychain Dialog Popups
======================
When using Xamarin.Mac or Xamarin.iOS, we try to search the keychain
for the certificate and private key.
On Xamarin.iOS, this is easy because each app has its own keychain.
On Xamarin.Mac, the .app package needs to be trusted via code-sign
to get permission to access the user's keychain. [FIXME: I still have to
research how to actually do that.] Without this, you will get a popup
message each time, asking you whether you want to allow the app to access
the keychain, but you can make these go away by selecting "Trust always".
On Desktop Mono, this is problematic because selecting "Trust always"
give the 'mono' binary (and thus everything you'll ever run with Mono)
permission to retrieve the private key from the keychain.
This code would also trigger constant keychain popup messages,
which could only be suppressed by granting full trust. It also makes it
impossible to run Mono in headless mode.
SecIdentityCreate
=================
To avoid these problems, we are currently using an undocumented API
called SecIdentityRef() to avoid using the Mac keychain whenever a
X509Certificate2 with a private key is used.
On iOS and XamMac, you can still provide the X509Certificate without
a private key - in this case, a keychain search will be performed (and you
may get a popup message on XamMac).
If we don't take the finished_lock when starting workers, the workers that we started could have already finished the work and switch to non-parallel context before we are even able to signal all of them.
It is used as the "verify" step on Jenkins/Wrench and I noticed
it didn't run recently.
Looks like it was broken a while ago by 695e8f53ae.
Moving the verifiable_files variable at the top is wrong since
the $$profile variable is only defined inside the for loop and
so we'd get an empty list.
When that was fixed it still didn't work as piping to `echo`
doesn't work. Replaced it with a Makefile solution instead.
(cherry picked from commit 3bfff911dd)
If you're building with monolite currently the build system
checks for the existence of mcs/class/lib/monolite and just
uses it in that case.
It becomes a problem when bumping corlib version since if you
pull the update and try to build it'll use the old monolite
and you'll hit the "corlib version not in sync" error.
By making the monolite directory include the version this can
be avoided and everything works out of the box.
Also removed the confusing "You need Mono version 4.8 or better"
message since we actually require a newer version in
basic-profile-check.cs now and keeping them in sync is error prone.
(cherry picked from commit 500765a5d3)
Getenv doesn't use heap memory, it uses static memory.
Mono's usage is consistent with a view of getenv memory contents
that are durable and can be stored and manipulated.
In a multithreaded context, getenv calls can race and corrupt
string buffers as they are read. In a single threaded context,
subsequent calls to getenv will lead to overwriting the memory
that pointers to previous calls point to.
In order to bring memory safety back, we duplicate memory and
manage it at each call-site.
Note: this changes the API semantics of g_getenv. This is necessary
because the locking around the getenv buffer is safest when confined to
the function in eglib.
- Ensure all AOT options are both documented and listed in
alphabetical order in both the manpage and --help line
- Ensure all exceptoins are commented in the aot-compiler.c source
with "intentionally udnocumented"
Pass the payload of the coop handle as the 'this' object, not the handle
itself.
Add asserts in ves_icall_Remoting_RealProxy_InternalGetProxyType that
remote_class and the proxy_class are non-NULL.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=53890
This could result in a unecessary wait on shutdown where the selector thread would have exited, and the finalizer thread would try to dispose a Socket, which would try to remove the socket from the IOSelector. This removal operation would wait on the selector thread to acknowledge the removal, but because the selector thread would have alreday exited, we would wait on an event that would never happen.
If we have a pending abort then we know we will have the thread_state set and the thread_interruption_requested bumped. We used to consume this request and set the MonoError with the exception. The problems with this is that not all callsites handle the passed MonoError and handling it means converting it back to a pending exception anyway. We just leave the interruption request untouched now.
If the cctor self aborts it means that we consumed the abort exception so we do need to call mono_thread_resume_interruption to reactivate it. We need to make sure that we still don't throw a TypeInitializationException if we had a self abort.
When aborting a thread we set the thread's interruption request and we also increment the global interruption request. If we were trying to abort a thread when it is in an abort protected region, it will just set an interruption deferred and not do anything else (in async_abort_critical). When the thread exited the abort protected region, it was missing the abort request since we didn't increment the global interruption request.
Refactor thread_interruption_requested modifications, making sure we always bump it when requesting an interruption and decrease it when we clear an interruption.
The problem with previous implementation was that we were not able to account for two pending exceptions at the same time, since when we execute an interruption request we clear all the state and there is no clear way to account for two exceptions at the same time. This means that, if we have a pending abort in a cctor, all exception handling inside the cctor will be broken (for the provided test case we were only throwing the cctor internal exception outside of it).
In order to fix this, we split into two types of interruptions SYNC and ASYNC (in order to separate mainly between abort and pending exceptions). Sync interruptions are interruptions requested by the thread itself (pending exceptions and self aborts) and they are processed as soon as possible. Async interruptions are requested by other threads (abort, interrupt, suspend) and we defer them as we were doing before (we have a deferred interruption if we have an async exception and abort block count is non zero).
* [AppleTls]: Use correct definition of `SecTrustResult`.
We need all the values in this enum because `SecTrustResult.Unspecified`
means success - which currently has an integer value of 4, not 0.
* Oops, make it build.
* Don't make it public.
* Revert whitespace change.
(cherry picked from commit 4638c98ba0)
It can be the case that we have two different System.MonoMethod objects that both
point to the same native MonoMethod* but have two different reflected types.
(For example if we call derivedType.GetMethod("f") where f is virtual and
derivedType corresponds to a class that did not override a base definition. In
that case, the MonoMethod* corresponds to the parent type's f method, but the
reflected type is derivedType)
In this case, GetBaseDefinition will return the same MonoMethod* but the
reflected type of the result should be the base type, not the derived type.
This adds a command line argument preprocessor that splits command line
arguments into two groups, delimited by the "standard" `--` "stop
processing" argument, or by the `-s` argument which can be used with
Unix shebang syntax (where the path of the file being executed will
be appended to the command line specified on the shebang line).
- anything before `--` or `-s` will be passed to mcs/csharp as usual
- anything after `--` or `-s` will _not_ be processed by mcs/csharp,
and will be made available in an `Args` builtin, like `csi`
This _finally_ (after almost 10 years) allows `csharp` to be used for
proper script authoring!
Document the new arguments in the man page. Also remove references to
'gsharp' from the man page.
This makes it possible to version the runtime<->corlib interface
for each version branch independently and fixes the problem
of monolite getting overwritten by changes in different branches
when corlib version is still the same.
We're moving definition of the corlib version into configure.ac
so we can more easily bake the Mono version into it.
(cherry picked from commit c0dd559ee4)
This makes it possible to version the runtime<->corlib interface
for each version branch independently and fixes the problem
of monolite getting overwritten by changes in different branches
when corlib version is still the same.
Android on 32bits arm shipped broken headers that made sigset_t be 32 bits instead of 64.
This means that it's not possible to use signals whose value are >= 32. The default implementation
uses RT signals when available (and they are on Android). But RT signals don't work as expected
as their value is >= 32.
This fix hardcodes some safe signals on Android and add asserts about their values to avoid regressions.
See 5005c6f3fb for more details.
When storing satellite assemblies, mkbundle prefixes their names with a
directory name derived from the language/locale of the assembly. It uses the
platform's default directory separator character which on Windows defaults to
'\' and that causes problems when building such a bundle on Windows since \ is
an escape sequence prefix inside strings and not escaping it with another \
leads to gcc errors when building the genrated source.
This commit fixes the problem by quoting the directory separator character
properly on Windows.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=52845
We would observe crashes like the following:
```
* Assertion at mono-threads.c:1009, condition `mono_thread_info_run_state (info) == STATE_ASYNC_SUSPENDED' not met
Debug info from gdb:
[New LWP 26793]
[New LWP 26792]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00002b0ff3481ee9 in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
Id Target Id Frame
3 Thread 0x2b0ff3e6c700 (LWP 26792) "SGen worker" 0x00002b0ff347e414 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
2 Thread 0x2b0ff633e700 (LWP 26793) "Finalizer" 0x00002b0ff347e414 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
* 1 Thread 0x2b0ff2b67c40 (LWP 26780) "mono" 0x00002b0ff3481ee9 in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
Thread 3 (Thread 0x2b0ff3e6c700 (LWP 26792)):
#0 0x00002b0ff347e414 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x0000000000661bdf in mono_os_cond_wait (mutex=0x9dee40 <lock>, cond=0x9dee00 <work_cond>) at ../../mono/utils/mono-os-mutex.h:146
#2 thread_func (thread_data=0x2b0ff2bcb008) at sgen-thread-pool.c:129
#3 0x00002b0ff347a182 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#4 0x00002b0ff39a130d in clone () from /lib/x86_64-linux-gnu/libc.so.6
Thread 2 (Thread 0x2b0ff633e700 (LWP 26793)):
#0 0x00002b0ff347e414 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00000000005caff3 in mono_os_cond_wait (mutex=<optimized out>, cond=<optimized out>) at ../../mono/utils/mono-os-mutex.h:146
#2 mono_coop_cond_wait (mutex=<optimized out>, cond=<optimized out>) at ../../mono/utils/mono-coop-mutex.h:87
#3 mono_threadpool_io_remove_socket (fd=134239440) at threadpool-io.c:628
#4 0x00000000005ae4f4 in ves_icall_System_Net_Sockets_Socket_Close_internal (sock=42, werror=<optimized out>) at w32socket.c:708
#5 0x0000000041e8101f in ?? ()
#6 0x00002b1014abe070 in ?? ()
#7 0x0000000001615860 in ?? ()
#8 0x0000000001615860 in ?? ()
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 0x2b0ff2b67c40 (LWP 26780)):
#0 0x00002b0ff3481ee9 in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00000000004ac5e6 in mono_handle_native_crash (signal=<optimized out>, ctx=<optimized out>, info=<optimized out>) at mini-exceptions.c:2557
#2 <signal handler called>
#3 0x00002b0ff38dcf79 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00002b0ff38e0388 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x000000000066b459 in mono_log_write_logfile (log_domain=<optimized out>, level=<optimized out>, hdr=<optimized out>, message=<optimized out>) at mono-log-common.c:137
#6 0x00000000006805e0 in monoeg_g_logv (log_domain=log_domain@entry=0x0, log_level=log_level@entry=G_LOG_LEVEL_ERROR, format=<optimized out>, args=args@entry=0x7ffc7324ea78) at goutput.c:115
#7 0x0000000000680736 in monoeg_assertion_message (format=<optimized out>) at goutput.c:135
#8 0x00000000006759b8 in mono_thread_info_setup_async_call (info=info@entry=0x2b0ff80008c0, target_func=target_func@entry=0x5bac20 <suspend_for_shutdown_async_call>, user_data=user_data@entry=0x0) at mono-threads.c:1009
#9 0x00000000005bad50 in suspend_for_shutdown_critical (info=info@entry=0x2b0ff80008c0, unused=unused@entry=0x0) at threads.c:5019
#10 0x00000000006763ae in mono_thread_info_safe_suspend_and_run (id=47347555100416, interrupt_kernel=interrupt_kernel@entry=0, callback=callback@entry=0x5bad40 <suspend_for_shutdown_critical>, user_data=user_data@entry=0x0) at mono-threads.c:979
#11 0x00000000005c2e71 in mono_thread_internal_suspend_for_shutdown (thread=<optimized out>) at threads.c:5028
#12 0x00000000005e9100 in mono_gc_cleanup () at gc.c:1015
#13 0x00000000005e108e in mono_runtime_cleanup (domain=domain@entry=0x1615860) at appdomain.c:423
#14 0x00000000004228cb in mini_cleanup (domain=0x1615860) at mini-runtime.c:4111
#15 0x000000000047b99f in mono_main (argc=10, argv=<optimized out>) at driver.c:2167
#16 0x00000000004200db in mono_main_with_options (argv=0x7ffc7324ef68, argc=10) at main.c:45
#17 main (argc=10, argv=0x7ffc7324ef68) at main.c:338
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
```
It might be possible that the callback modifies the current SocketAsyncResult via the Init method. We observe it with AcceptAsync with a ReceiveAsync in the callback.
mono_class_create_from_typedef: When loading a GTD, we track what ginsts' of it were loaded in the meanwhile
so we can fix some information that will be wrong (such as if it's a VT or not).
Were not stopping the recording when a GTD type failed to load its parent. This would result in *A LOT* of ginsts
being captured and would cause issues during domain unload.
It's possible for two threads to modify the same MonoMethodPInvoke.addr
in mono_lookup_pinvoke_call, with one thread setting it to NULL inside the
loop, and the other thread having completed the loop and expecting it to
be non-NULL.
Use an intermediate variable to prevent addr becoming non-NULL.
The following can happen:
* Thread T1 starts initialization of C1
* Thread T2 starts initialization of C2
* T2 starts initialization of C1, it gets blocked on T1.
* T1 finishes initializing C1.
* T1 starts initialization of C3.
* T1 starts initialization of C2. It sees that T2 is
still blocked on T1, but its not actually blocked, since
C1 is finished. Still, we record that T1 is blocked.
* T3 starts initialization of C2, it gets into an infinite
loop in the while loop, since the blocked_thread_hash
now indicates that T1 and T2 are blocked on each other.
The solution is to not mark a thread as blocked, if its waiting
for a thread which is waiting on a finished lock. Fixes hangs
when running csc.
In multiple occasions we had bugs due to framework_assemblies not being correctly sorted.
Instead of just fixing the ordering again, I'm moving it a hashtable so future generations won't have to fix this for System.SpaceTravel.dll.
monodis was not calling the mono_tls_init_runtime_keys function, which
was causing it to crash the first time it attempted to access the
current domain (ie almost immediately).
Either interrupt or set the interrupt_deferred flag, so the thread can handle the request later in the future. Otherwise we are left with a thread that has an AbortRequested set on its state that it is never processed and future abort requests are ignored due to the presence of this flag.
Allocation functions from object.c correctly throw OOM when sgen allocation returns NULL. When allocating with the managed allocator we invoke sgen directly (as a fallback) and we didn't handle the NULL return case.
Fixes#52437
The recent sed update in cygwin [1] changed the way sed handles
carriage returns. This meant that every .in file we processed
still contained CR, which doesn't work for .sh files.
Force LF line endings for those files (and also other shell scripts).
[1] https://cygwin.com/ml/cygwin-announce/2017-02/msg00036.html
(cherry picked from commit 8d0e921d8b)
`/nologo`. It is not controlled by logging levels now.
But we also show the deprecation notice if we couldn't parse
the arguments, which would be more likely to be noticed by a user.
We haven't been consistent in keeping those version numbers
up to date as we bump Mono's version so it's less confusing
to not show them in the manual pages.
`mono --version` is and has been the source of truth.
(cherry picked from commit b117a53b8f)
* [btls]: Partial merge of #4318 and #4337.
Partially merged commits 4ecb683 and 4c6c6f0 from master without adding
'MonoTlsSettings.CertificateSearchPath'.
* Add MonoBtlsProvider.SetupCertificateStore(MonoBtlsX509Store,MonoTlsSettings,bool)
overload, which adds 'settings.TrustAnchors' if applicable.
* MonoBtlsContext: call it instead of having our own custom implementation.
* [btls]: Fix MonoBtlsX509Store.cs.AddTrustedRoots(). (#4340)
This internal method is only called from Mono.Btls.Interface.BtlsStore
and used by the web-tests.
Call MonoBtlsProvider.SetupCertificateStore(store) to make its
behavior consistent with the internal implementation.
(cherry picked from commit 8b18c84289)
* [btls]: Partial merge of #4318, #4337 and #4340.
Partially merged commits 4ecb683, 4c6c6f0 and 8b18c84 from master
(without adding 'MonoTlsSettings.CertificateSearchPath').
* Add MonoBtlsProvider.SetupCertificateStore(MonoBtlsX509Store,MonoTlsSettings,bool)
overload, which adds 'settings.TrustAnchors' if applicable.
* MonoBtlsContext: call it instead of having our own custom implementation.
* Fix MonoBtlsX509Store.cs.AddTrustedRoots(). (#4340)
This internal method is only called from Mono.Btls.Interface.BtlsStore
and used by the web-tests. Call MonoBtlsProvider.SetupCertificateStore(store)
to make its behavior consistent with the internal implementation.
We don't use the global executable.make install logic for the tools
in security so we missed updating this to copy .pdb's as well.
(cherry picked from commit b17ddc5c15)
The code in X509Store only checked the legacy X509StoreManager.LocalMachinePath
when deciding whether CspProviderFlags.UseMachineKeyStore should be
set when dealing with private keys.
However, with BTLS we now also have X509StoreManager.NewLocalMachinePath.
This caused an issue/regression in the recent 4.8 builds that
started importing into the BTLS cert store when using cert-sync:
https://github.com/mono/mono/commit/968c60a0f32c7a4c92568c3feda7503f99b98c94
Because cert-sync is ran at package installation time as root
on Linux we would erroneously not pass UseMachineKeyStore (because
the paths between legacy and BTLS store are different), which in turn
causes KeyPairPersistence to look into the user directory, e.g.
~/.config/.mono/keypairs. Since on a clean machine that directory
hierarchy doesn't exist, it goes on and creates it -> we now have
the ~/.config directory owned by root which means a normal user
application can't write to it anymore (like NuGet) and crashes.
The fix is to check for the BTLS store path as well so KeyPairPersistence
uses the machine path and ~/.config is not created on package installation.
See e.g. https://github.com/travis-ci/travis-ci/issues/7271
(cherry picked from commit 12b44a0e94)
To get a process by name, we need to access the other process ProcessName, but it can fails on non-win32 platforms. This failure wouldn't be caught in the referencesource implementation trigerring this bug.
The exception we would observe would be:
Unhandled Exception:
System.InvalidOperationException: Process has exited, so the requested information is not available.
at System.Diagnostics.Process.get_ProcessName () [0x0002d] in /Users/alexander/dev/mono/mcs/class/System/System.Diagnostics/Process.cs:336
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ProcessName ()
at Program.Main (System.String[] args) [0x0003b] in <9c838a66cdc44c81b38c974edcc9c029>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Process has exited, so the requested information is not available.
at System.Diagnostics.Process.get_ProcessName () [0x0002d] in /Users/alexander/dev/mono/mcs/class/System/System.Diagnostics/Process.cs:336
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ProcessName ()
at Program.Main (System.String[] args) [0x0003b] in <9c838a66cdc44c81b38c974edcc9c029>:0
Fixes bug https://bugzilla.xamarin.com/show_bug.cgi?id=52345
Waiting for the threadpool threads to exit on shutdown triggers a hand. The simplest solution is to not wait for them, and let the general runtime shutdown mechanism wait for them (see `mono_thread_manage`).
This means that the thread will be part of the stw (not skipped), so if the stack pointer is not between the expected ranges we dont scan the thread. In other parts of the runtime, suspending here is handled by the suspend_can_continue flag.
* [runtime] Add the missing MONO_BB_FOR_EACH_INS_REVERSE macro.
* [runtime] Use ins->prev instead of building reverse ins array in mono_analyze_liveness.
This hack should not be required now, as roslyn emits the correct debug
files with /debug:full and /debug:pdbonly, on non-windows platform.
This manifested as https://bugzilla.xamarin.com/show_bug.cgi?id=50710 ,
where the Xamarin.Mac targets override `$(CscToolExe)` to use `mcs`, but
xbuild's `ManagedCompiler` *always* converts `DebugType={full,pdbonly}`
to `/debug:portable`, which would cause mcs to complain.
When suspending a thread, we were only saving the callee save registers in the context. Therefore SGen was failing to pin some objects. In order to store the registers in order, a code refactoring was necessary.
* Add new native mono_btls_error_peek_error_line() and
mono_btls_error_get_error_line().
* Add `MonoBtlsError.PeekError(out string, out int)` and
`MonoBtlsError.GetError(out string, out int)` overloads.
* MonoBtlsContext.GetException(): use it here.
* [System.Data] SQLTypes from corefx
* [System.Data] DataStorage + subclasses from corefx
* [System.Data] remove dead referencesource.sources references
* [System.Data] Generate SR.cs from corefx using resx2sr tool
* [System.Data] move common references to corefx.common.sources
* [System.Data] remove /ReferenceSources/SR.cs
* [System.Data] remove duplicates in corefx.common.sources (accidentally were added)
* [System.Data] simple types & enums from corefx
* [System.Data] referencesource -> corefx
* [System.Data] Referencesource -> corefx
* [System.Data] re-order (sort) files in corefx.common.sources, DbCommandBuilder from corefx
* [System.Data] Referencesource -> corefx
* [System.Data] DataRow, DataSet, Filters, etc from corefx. XmlDataDocument is internal in corefx but used to be public in mono.
* [System.Data] rollback referencesource changes
* [System.Data] Wrap /referencesource/DataSet.cs with #ifdef COREFX in order to include missing DataSetSchemaImporterExtension and ignore DataSet
It failed since we introduced this profile and it was disabled
on Mac a few years ago. A bug is filed to investigate why it only
fails on FullAOT on Linux but works on non-FullAOT builds.
Disable the test for now to get closer to a green build.
https://bugzilla.xamarin.com/show_bug.cgi?id=52157
Also reverts the changes done to support/map.c. This is a generated file which
shouldn't be changed directly. An alternate fix for the problem in map.c on
Windows was to make sure L_SET et al are defined in mph.h which was already
done for Solaris.
Fix assemblyresolve/Makefile.am so it correctly AOTs the
dependency of assemblyresolve_event4.exe (CLASS was empty before).
Disable reference-loader.exe since we can't AOT the
TestingReferenceAssembly.dll assembly which is a dependency
of the test so it would fail. Discussed with Aleksey, this is OK
because even if we could AOT the assembly we wouldn't use it since
the assembly loader looks at the managed assembly first, finds the
attribute and bails out before looking at the AOT image.
This got broken in ee048db72f
when the winaot profile was added to FULL_AOT_TESTS since we
enable that profile for building with runtime_preset=all which
means that FULL_AOT_TESTS would be defined and the runtime tests
would try to AOT the test assemblies.
Instead, we now only try to AOT if we're actually testing
a profile that needs it. Also introduced a new HYBRID_AOT_TESTS
variable and replaced the existing INSTALL_TESTING_AOT_HYBRID
since that profile would run into the same issue if we included
it in runtime_preset=all (using the INSTALL_ variables to decide
about tests is misleading!)
Most of them used multiline C# string literals which
means they contained the line ending character of the file.
Updated to make the tests resilient to having CRLF instead of LF.
Some of the mcs tests used a checksum to compare files,
ensured those are checked out using LF.
Loading profiling modules from the build tree fails on OSX because libmonosgen usually is not present in the install prefix.
This change is slightly overly complicated as I explicitly don't want to change iOS&friends.
the interpreter handles the `this` argument in the frame explicitly.
This doesn't align well with mini which treats `this` as normal
parameter on the stack. That's just asking for troubles, e.g. for
native wrappers we convert signatures from virtual to static.
It'd not be recognized as a shell file so it'd get CRLF line
endings on Windows which doesn't work. Also added a shebang.
Also remove get-cygwin-deps.sh, it is long outdated.
Correct instructions are on the Mono website.
…hods
method-to-ir.c: Added sequence points on IL offsets yieldOffsets and resumeOffsets since we need stepping to stop yieldOffset and ability to set breakpoint on resumeOffset
seq-points.c: This change is needed since we need to know if we are at last non-empty SeqPoint in method, but without this change is_last_non_empty method in debugger-agent.c would loop forever since blocks point between each other in cycles
doest-app.cs and dtest.cs: unit test
debugger-agent.c: I will explain how stepping over `await` and stepping out of `async` method works in commit message, code itself should be self explaining with comments
Step-In and Step-Out case: inside `async` method we do everything same except two things:
1. At end of method we switch to step-out logic
This is important because normal stepping-in/over would step out into “thread pool” calling code. Which is not what we want, we want to continue stepping where .Wait, .Result or `await` is waiting for our Task to finish. `is_last_non_empty` is needed because last non-empty SeqPoint is placed before SetResult(see line 33 in decompiled method below) so we can do StepOut logic before SetResult method is called. I will explain how step-out works below.
2. When stepping is finished we check if we stepped on yieldOffset(this happens when user is about to step over `await` call) and Task has IsCompleted false(didn’t finish immediately)(line 11 in decompiled method). If we stopped on yieldOffset we put breakpoint on resumeOffset SeqPoint(line 19 in decompiled method) and resume execution so when our AsyncStateMachine is called back after Task(the one that our `await` call triggered) is finished we hit breakpoint and user is just after `await` call. It’s important that we set `async_id` before resuming at yieldOffset so we can check when breakpoint is hit if this is our Task or some other that is executing at same time, since we can’t check threads since threads can change before and after `await` call.
Step-Out case: When user requests step-out or user requests step-in/over and we are at end of method, we set breakpoint in special .Net framework method called “NotifyDebuggerOfWaitCompletion” and call “SetNotificationForWaitCompletion” method so after Task is finished(when we call .SetResult, line 33 in decompiled method).
Method that called our `async` method and got our Task(on which we called “SetNotificationForWaitCompletion”) returned. When it calls .Wait(), .Result, or `await` on our task it will call “NotifyDebuggerOfWaitCompletion”(framework does this). At that point our breakpoint(inside “NotifyDebuggerOfWaitCompletion”) is hit and we do step-out until we get to where user called .Wait(), .Result, and `await`.(Of course if ProjectCodeOnly is enabled, otherwise it’s in 1 method above “NotifyDebuggerOfWaitCompletion”).
I added also ppdb dump and monodis if anyone wants more data:
C# code:
public static async Task<int> ss_await_1 () {
var a = 1;
await Task.Delay (20);
return a + 2;
}
C# decompiled:
1: void IAsyncStateMachine.MoveNext ()
2: {
3: int num = this.<>1__state;
4: int result;
5: try {
6: TaskAwaiter taskAwaiter;
7: if (num != 0) {
8: this.<a>5__1 = 1;
9: taskAwaiter = Task.Delay (20).GetAwaiter ();
10: if (!taskAwaiter.get_IsCompleted ()) {
11: this.<>1__state = 0;
12: this.<>u__1 = taskAwaiter;
13: Tests.<ss_await_1>d__90 <ss_await_1>d__ = this;
14: this.<>t__builder.AwaitUnsafeOnCompleted<TaskAwaiter, Tests.<ss_await_1>d__90> (ref taskAwaiter, ref <ss_await_1>d__);
15: return;
16: }
17: }
18: else {
19: taskAwaiter = this.<>u__1;
20: this.<>u__1 = default(TaskAwaiter);
21: this.<>1__state = -1;
22: }
23: taskAwaiter.GetResult ();
24: taskAwaiter = default(TaskAwaiter);
25: result = this.<a>5__1 + 2;
26: }
27: catch (Exception exception) {
28: this.<>1__state = -2;
29: this.<>t__builder.SetException (exception);
30: return;
31: }
32: this.<>1__state = -2;
33: this.<>t__builder.SetResult (result);
34:}
ppdb dump for this method:
<method containingType="Tests+<ss_await_1>d__90" name="MoveNext">
<sequencePoints>
<entry offset="0x0" hidden="true" document="1" />
<entry offset="0x7" hidden="true" document="1" />
<entry offset="0xe" startLine="744" startColumn="46" endLine="744" endColumn="47" document="1" />
<entry offset="0xf" startLine="745" startColumn="3" endLine="745" endColumn="13" document="1" />
<entry offset="0x16" startLine="746" startColumn="3" endLine="746" endColumn="25" document="1" />
<entry offset="0x23" hidden="true" document="1" />
<entry offset="0x7c" startLine="747" startColumn="3" endLine="747" endColumn="16" document="1" />
<entry offset="0x87" hidden="true" document="1" />
<entry offset="0xa1" startLine="748" startColumn="2" endLine="748" endColumn="3" document="1" />
<entry offset="0xa9" hidden="true" document="1" />
</sequencePoints>
<scope startOffset="0x0" endOffset="0xb7" />
<asyncInfo>
<kickoffMethod declaringType="Tests" methodName="ss_await_1" />
<await yield="0x35" resume="0x50" declaringType="Tests+<ss_await_1>d__90" methodName="MoveNext" />
</asyncInfo>
</method>
monodis:
.method private final virtual hidebysig newslot
instance default void MoveNext () cil managed
{
// Method begins at RVA 0x41f0
.override Could not decode method override class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext due to (null)
// Code size 183 (0xb7)
.maxstack 3
.locals init (
int32 V_0,
int32 V_1,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiterV_2,
class Tests/'<ss_await_1>d__90' V_3,
class [mscorlib]System.Exception V_4)
IL_0000: ldarg.0
IL_0001: ldfld int32 Tests/'<ss_await_1>d__90'::'<>1__state'
IL_0006: stloc.0
.try { // 0
IL_0007: ldloc.0
IL_0008: brfalse.s IL_000c
IL_000a: br.s IL_000e
IL_000c: br.s IL_0050
IL_000e: nop
IL_000f: ldarg.0
IL_0010: ldc.i4.1
IL_0011: stfld int32 Tests/'<ss_await_1>d__90'::'<a>5__1'
IL_0016: ldc.i4.s 0x14
IL_0018: call class [mscorlib]System.Threading.Tasks.Task class [mscorlib]System.Threading.Tasks.Task::Delay(int32)
IL_001d: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter class [mscorlib]System.Threading.Tasks.Task::GetAwaiter()
IL_0022: stloc.2
IL_0023: ldloca.s 2
IL_0025: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter::get_IsCompleted()
IL_002a: brtrue.s IL_006c
IL_002c: ldarg.0
IL_002d: ldc.i4.0
IL_002e: dup
IL_002f: stloc.0
IL_0030: stfld int32 Tests/'<ss_await_1>d__90'::'<>1__state'
IL_0035: ldarg.0
IL_0036: ldloc.2
IL_0037: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter Tests/'<ss_await_1>d__90'::'<>u__1'
IL_003c: ldarg.0
IL_003d: stloc.3
IL_003e: ldarg.0
IL_003f: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32> Tests/'<ss_await_1>d__90'::'<>t__builder'
IL_0044: ldloca.s 2
IL_0046: ldloca.s 3
IL_0048: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32>::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter, class Tests/'<ss_await_1>d__90'> ([out] !!0&, [out] !!1&)
IL_004d: nop
IL_004e: leave.s IL_00b6
IL_0050: ldarg.0
IL_0051: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter Tests/'<ss_await_1>d__90'::'<>u__1'
IL_0056: stloc.2
IL_0057: ldarg.0
IL_0058: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter Tests/'<ss_await_1>d__90'::'<>u__1'
IL_005d: initobj [mscorlib]System.Runtime.CompilerServices.TaskAwaiter
IL_0063: ldarg.0
IL_0064: ldc.i4.m1
IL_0065: dup
IL_0066: stloc.0
IL_0067: stfld int32 Tests/'<ss_await_1>d__90'::'<>1__state'
IL_006c: ldloca.s 2
IL_006e: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter::GetResult()
IL_0073: nop
IL_0074: ldloca.s 2
IL_0076: initobj [mscorlib]System.Runtime.CompilerServices.TaskAwaiter
IL_007c: ldarg.0
IL_007d: ldfld int32 Tests/'<ss_await_1>d__90'::'<a>5__1'
IL_0082: ldc.i4.2
IL_0083: add
IL_0084: stloc.1
IL_0085: leave.s IL_00a1
} // end .try 0
catch class [mscorlib]System.Exception { // 0
IL_0087: stloc.s 4
IL_0089: ldarg.0
IL_008a: ldc.i4.s 0xfffffffe
IL_008c: stfld int32 Tests/'<ss_await_1>d__90'::'<>1__state'
IL_0091: ldarg.0
IL_0092: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32> Tests/'<ss_await_1>d__90'::'<>t__builder'
IL_0097: ldloc.s 4
IL_0099: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32>::SetException(class [mscorlib]System.Exception)
IL_009e: nop
IL_009f: leave.s IL_00b6
} // end handler 0
IL_00a1: ldarg.0
IL_00a2: ldc.i4.s 0xfffffffe
IL_00a4: stfld int32 Tests/'<ss_await_1>d__90'::'<>1__state'
IL_00a9: ldarg.0
IL_00aa: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32> Tests/'<ss_await_1>d__90'::'<>t__builder'
IL_00af: ldloc.1
IL_00b0: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int32>::SetResult(!0)
IL_00b5: nop
IL_00b6: ret
} // end of method <ss_await_1>d__90::MoveNext
Fixes the issue from a4b3ba6177
and 6f4f3643c6.
When building those profiles as part of runtime_preset=all,
the AOT_BUILD_FLAGS variable is not set so AOTing doesn't work
because the command line flag in rules.make is incomplete.
We don't really need/want to AOT for runtime_preset=all,
the point is just to make sure these BCL profiles still build.
* [runtime] Use coop handles for ves_icall_System_AppDomain_GetData
* [runtime] Add mono_string_new_utf16_handle function that returns a MonoStringHandle
* [runtime] Use coop handles for ves_icall_System_AppDomain_InternalGetProcessGuid
* [runtime] Use coop handles for System.AppDomain icalls
- ves_icall_System_AppDomain_InternalIsFinalizingForUnload
- ves_icall_System_AppDomain_InternalPushDomainRef
- ves_icall_System_AppDomain_InternalPushDomainRefByID
(This one is slightly non-trivial because we switch from MonoException to MonoError)
- ves_icall_System_AppDomain_InternalPopDomainRef
- ves_icall_System_AppDomain_InternalSetDomainByID
* [runtime] Use coop handles for ves_icall_System_AppDomain_InternalSetDomain
* [runtime] Use coop handles for ves_icall_System_AppDomain_SetData
* [runtime] Coop handles for some AppDomain icalls
- ves_icall_System_AppDomain_getCurDomain
- ves_icall_System_AppDomain_getFriendlyName
- ves_icall_System_AppDomain_getRootDomain
- ves_icall_System_AppDomain_getSetup
* [coop handles] Add mono_string_handle_length function
* [marshal] Add mono_marshal_xdomain_copy_value_handle
* [coop handles] Add mono_aray_new_full_handle
* [appdomain] Use handles in mono_array_clone_in_domain
* [runtime] Use coop handles for ves_icall_System_AppDomain_createDomain
* [appdomain] Use coop handles for ves_icall_System_AppDomain_InternalUnload
* Enabling windows specific code for winaot profile
which were disabled with MOBILE define.
* Making sure Win32_FIXED_INFO struct can get marshalled
correctly for AOT builds.
Introducing a `MONO_FEATURE_CONSOLE` to be used instead of disabling
Windows specific Console related classes using `MOBILE` ifdef. The
`MONO_FEATURE_CONSOLE` will be set for profiles not setting `NO_CONSOLE`
which currently monodriod and monotouch profiles do.
It breaks on Jenkins with:
```
23:53:28 make aot-all-profile
23:53:28 MONO_PATH="class/lib/orbis/" /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-amd64/runtime/mono-wrapper ,temp-path=class/lib/orbis/I18N.CJK.dll_bitcode_tmp --verbose class/lib/orbis/I18N.CJK.dll > class/lib/orbis/I18N.CJK.dll.so.aot-log
23:53:28 Cannot open assembly ',temp-path=class/lib/orbis/I18N.CJK.dll_bitcode_tmp': No such file or directory.
```
In 56edb3357c the call to ves_icall_System_IO_MonoIO_Open
was changed to mono_w32file_create, but that function uses a different parameter order:
```
mono_w32file_create (name, fileaccess, sharemode, createmode, attrs)
ves_icall_System_IO_MonoIO_Open (filename, mode, access_mode, share, options, error)
```
Fix the order so the parameters we pass are the intended ones.
should fix https://bugzilla.xamarin.com/show_bug.cgi?id=41133
The bug exposed itself as System.MethodAccessExceptionMethod which is
thrown when a method isn't allowed to call another method. Several
things are checked for this: Among other things, the runtime checks if
the public key in the friend list of the caller assembly matches the
public key in the callee assembly.
The issue here was that two threads computed the SHA1 at the same time,
using the same buffer and therefore computing garbage.
Previously it waited for the initialization to be done using a mutex lock/unlock, which needed some additional checks before acquiring the lock. Use a normal cond variable instead. Remove some code duplication from the lock cleanup code.
* [reflection] Use coop handles for MonoMethod.GetGenericArguments
* [reflection] Use handles for ves_icall_MonoMethod_GetGenericMethodDefinition
and two more trivial functions:
- ves_icall_MonoMethod_get_IsGenericMethod
- ves_icall_MonoMethod_get_IsGenericMethodDefinition
* [runtime] Add mono_method_get_base_method function
- Internal function in class-internals.h, for now.
- Code factored out from ves_icall_MonoMethod_get_base_method
- ves_icall_MonoMethod_get_base_method just calls this utility and wraps on
reflection objects, using handles.
* [reflection] Use coop handles for ves_icall_MonoMethod_MakeGenericMethod_impl
* [reflection] Use coop handles for ves_icall_MonoMethod_GetPInvoke
* [reflection] Use coop handles for ves_icall_MonoMethod_get_core_clr_security_level
* [reflection] Use coop handles for ves_icall_MonoMethod_get_name
The way this works is that when we install a protected block, we change a interrupt requested to interrupt request deferred.
Then, when protected block count drops to zero, we switch back and inform the caller to poll for interrupts.
Additionally, when interrupting, we set it to deferred if there's a protected block in effect and it's not a self interrupt.
We have the infrastructure to use multiple concurrent workers, but, in theory, this could starve the mutator threads. In the future, we should do additional research and consider using multiple concurrent workers.
A parallel phase starts with enqueuing of jobs and of sections to the distribute gray queue. In order to have a good work distribution we split jobs into multiple smaller jobs. We now do the same with the initial gray queue sections, by trying to always have a minimum number of starting sections.
When a worker is out of work, it tries to steal a section from the bottom of another workers' private gray queue. This operation takes a lock. Pushes/Pops done by the owner thread on its own private gray queue are done in lock free fashion, using membar/CAS (at section level).
Non-parallel context is significantly faster since it doesn't require CAS-ing. Use it when we are left with only one worker so we don't regress performance.
We used to support the case where workers are running and when the main gc thread populates the redirected gray queue, these queue sections are moved to the workers distribute gray queue from where they are distributed to all the workers. In order to simplify the process, the main gc thread should never do any relevant gc work concurrently with the workers. This means that we no longer need to handle the above case.
Parallel copying should happen only when the world is stopped and the gc thread is not running. Each thread allocates from its own block freelist, which he obtains by pop-ing the global block free list.
When a worker has to copy an object, it first allocates a new object in a major block and initialises its contents. Afterwards it tries to forward the vtable, using a CAS operation. If the vtable already contains a forwarded object, we just return the forwarded address, and the object that we allocated will be left to die (we expect this case to be extremely unlikely, otherwise we could re-enque the free object in its block's freelist).
After the copying is done, the caller has the duty to update references and mark the new object (which we have to do it also with a CAS).
FIXME : This means that an object can reside on a gray queue without being marked, so another thread can enque again this same object. We should refactor this copying/mark/enqueing mechansim to avoid these issues.
We allow spliting a major_scan_cardtable into multiple smaller jobs. For precleaning, we enqueue num_workers precleaning jobs, each one precleaning one in every num_workers blocks from the list.
When marking an object we need to make sure we are not unmarking other objects (since marking is stored as bits). This also allows us to make sure that we never enqueue the same object multiple times on separate gray queues.
* Convert ves_icall_RuntimeType_MakeGenericType to use handles.
* The above necessitates converting mono_reflection_bind_generic_parameters and
mono_reflection_type_get_handle (renamed to
mono_reflection_type_handle_mono_type) to use handles.
* From there we have to touch a lot of builder internals:
- ves_icall_DynamicMethod_create_dynamic_method
- ves_icall_ModuleBuilder_RegisterToken
- ves_icall_ModuleBuilder_basic_init
- ves_icall_ModuleBuilder_getMethodToken
- ves_icall_ModuleBuilder_getToken
- ves_icall_ModuleBuilder_getUSIndex
- ves_icall_TypeBuilder_create_runtime_class
* As well as runtime functions
- mono_image_insert_string
- mono_image_create_token
- mono_class_{get,has,set}_ref_info
- mono_reflection_is_usertype
- mono_dynimage_encode_reflection_sighelper
- mono_dynamic_image_register_token
This will enable us to to parallel block allocation, which is useful when doing parallel copying. We no longer compact the array (using the default array list allocator instead) so we need to account for unallocated slots (slots with null value) in the array at any time (see FOREACH_BLOCK).
We cannot free the threadpool, because there is a race on shutdown where a managed thread may request a new threadpool thread, but we already destroyed the threadpool. So to avoid a use-after-free, we simply do not free the threadpool, as we won't be able to access the threadpool anyway because the ref count will be 0
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=51219
image.c (do_mono_image_load): Ignore refonly images when checking for ignorable assemblies.
icall.c (ves_icall_System_Reflection_Assembly_InternalGetAssemblyName): Load the image in ref only mode.
This tool takes a folder full of nupkg file and print macro invocations to add to image.c:ignored_assemblies.
Usage:
make download
make run
The download.sh script downloads all nugets we want to ignore. So update it before running if you have more you want to add.
Matching is done by assembly name and GUID. This should be enough to narrow
down the effect.
This approach is not very efficient as it waits for quite some of the loading
process to be on its way before detection. It works in the case that only a few
rare images are matched.
`mono_object_isinst_mbyref_checked` was removed recently. however, this
code unnecessary checks cases that are covered by
`mono_object_isinst_checked` anyway.
We need to use the mcs/class/lib/build directory so Roslyn
works (it runs into AOT bugs in net_4_x).
This was fixed in a few other places already, fix more.
cert-sync already knew how to import into the BTLS cert store,
update it to always import into both stores so we don't need
the btls-cert-sync tool anymore.
We would observe gsharedvt being disabled on desktop, even after passing --hybrid-aot. This would happen because we would call `mono_set_optimizations` without the `gsharedvt` optimisation enabled, thus calling `mono_set_generic_sharing_vt_supported(FALSE)` disabling again gsharedvt.
The elif for the interpreter was done after the elif
that catches (almost) all cases so it was ignored.
Simplify and condense the CI_TAGS checking so it's
easier to understand and more readable.
This change implements retrieving a list of DNS server addresses from Android
instead of attempting to parse `/etc/resolv.conf` which doesn't exist on
Android.
The list is retrieved by calling native function in Xamarin.Android that gets
the data from the system.
Part 2 of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=48016
* Initial version of lldb support code.
* [lldb] Keep all the debug entries in a linked list so lldb can read it after attaching to the process.
* [lldb] Add an --enable-minimal=lldb option to disable the code. Add locking.
* [lldb] Add support for dynamic methods by adding a new protocol entry for unloading code regions.
* [lldb] Add beginnings of a test suite using the lldb python bindings.
* [lldb] Emit line number info for methods, not used yet.
* [lldb] Add dummy fields to structures to make sure 64 bit fields are 64 bit aligned.
* [lldb] Finish emission of line number info.
* [lldb] Use mono_method_full_name () for computing method names.
* [lldb] Emit info for specific trampolines as well.
* [lldb] Add tests for line number info.
* [lldb] Fix unwind info encoding on x86.
* [lldb] Skip seq points with no native offset.
* [lldb] Add tests for breakpoints.
* [remoting] Use coop handles in several functions
- icall System.Runtime.Remoting.Proxies.RealProxy.InternalGetTransparentProxy
- mono_remote_class
- mono_remote_class_vtable
- mono_upgrade_remote_class
- mono_object_handle_get_virtual_method
- mono_object_handle_isinst
- mono_object_handle_isinst_mbyref
* [reflection] Use handles in System.RuntimeTypeHandle.IsInstanceOfType
* [runtime] Rewrite mono_object_castclass_mbyref
in terms of mono_object_handle_isinst_mbyref.
This is an external API function that isn't used inside the runtime.
* [runtime] Remove mono_object_isinst_mbyref_checked
It was a runtime internal funciton.
All of its former callers have been converted to use mono_object_handle_isinst_mbyref.
We compute the size of the array based on how many live ephemerons it stores, and not based on the previous size of the array which doesn't indicate anything.
Fixes leak from #47388.
When setting X509CertificateImplBtls.PrivateKey we'd previously just
update the fallback instance. This causes problems if other code
internal to System.dll like MonoBtlsContext.SetPrivateCertificate()
tries to fetch the NativePrivateKey since it'd be null at that point.
This scenario happens e.g. with HttpListener, it supports a special
directory in ~/.config/.mono/httplistener which contains <port>.cer
and <port>.pvk files (public and private key) that will be used
as the server certificate. In that code we're reading the private
key from the file and assigning it to X509CertificateImplBtls.PrivateKey
without ever having a native BTLS handle.
The fix is to create such a native BTLS handle from the managed
private key when needed.
Note that we can't simply always do this e.g. in the PrivateKey
setter because the setter will be used with instances that
don't actually contain a private key. We can't throw in those
cases so instead we do it only when NativePrivateKey is accessed.
To make the code clearer and easier to read, `privateKey` was
renamed to `nativePrivateKey` in X509CertificateImplBtls.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=46602
* [sre] Add typed coop handle declarations
* [reflection] Implement mono_reflection_get_token_handle
Rewrite mono_reflection_get_token_checked to use it.
* [reflection] Use handles for ves_icall_reflection_get_token
- Get rid of mono_reflection_get_token_checked
- Rename mono_reflection_get_token_handle to mono_reflection_get_token_checked
* [reflection] Use handles for ves_icall_GetCurrentMethod
* [reflection] Use handles for ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType_native
* [reflection] Use handles for ves_icall_System_Reflection_Module_ResolveSignature
* [reflection] Use handles for ves_icall_System_Type_internal_from_name
* [reflection] Use handles for ves_icall_System_Type_internal_from_handle
* [runtime] Use coop handles for System.Object.GetType ()
* [reflection] Use handles for ves_icall_MonoField_GetParentType
* [reflection] Use handles for ves_icall_MonoField_ResolveType
* [reflection] Use handles for most icalls in System.RuntimeTypeHandle
- GetArrayRank
- GetAttributes
- GetBaseType
- GetElementType
- HasInstantiation
- IsArray
- IsByRef
- IsComObject
- IsGenericTypeDefinition
- IsGenericVariable
- IsPointer
- IsPrimitive
- type_is_assignable_from
* [reflection] Use handles for ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl
and ves_icall_RuntimeTypeHandle_GetGenericParameterInfo
The MonoMethodSignature:pinvoke bit causes the IR translation to clear the
upper bits of return values that are smaller than a register. (See
mono_emit_widen_call_res)
Without this change, any icall returning a boolean (8 bits on .NET) might have
non-zero upper bits which will cause branches to misbehave.
* [aot] Rewrite the AOT profiler.
The AOT profiler is used to collect the methods/instances used at runtime.
Usage:
* mono --profile=aot:output=out.aotprof <app>
* mono --aot=profile=out.aotprof <assembly>
The first command will run <app>, collecting the list of methods it uses into the out.aotprof file.
The second command passes the profile file to the AOT compiler to have it generate additional generic instances.
* [docs] Add a section for AOT profiling to the mono(1) man page.
* [build] Collect AOT profile info from building mscorlib in the build profile, and use it when aot-ing the csc assemblies.
* [runtime] Add missing mono-profiler-aot.h file.
* [runtime] Tidy up usage of MONO_PROFILER_API.
* [aot] Improve error handling in the aot profiler.
* [aot] Improve error handling, add more diagnostics.
the managed wrapper already does everything properly, don't replicate
the logic. For example, since recently some icalls marked with `HANDLE`
require a MonoError object.
this trampoline is supposed to handle an arbritrary amount of arguments.
The trade-off is that this is a bit slower, however, it only requires
one instantiation as opposed to an instantiation for every method
signature.
Previously we'd just throw the catched exception again
which overwrites its stacktrace, making it less useful
since all you can see is e.g. a NullReferenceException
(re)thrown at MobileAuthenticatedStream:218.
We now capture the original exception information so
the stacktrace is more complete.
The path ".mono/certs/NewTrust" doesn't actually exist,
it's called ".mono/new-certs/Trust". Look it up from
MonoBtlsX509StoreManager instead.
This API isn't used anywhere in the BTLS code, that's
probably why it wasn't noticed.
* [sre] Add typed coop handle declarations
* [reflection] Implement mono_reflection_get_token_handle
Rewrite mono_reflection_get_token_checked to use it.
* [reflection] Use handles for ves_icall_reflection_get_token
- Get rid of mono_reflection_get_token_checked
- Rename mono_reflection_get_token_handle to mono_reflection_get_token_checked
* [reflection] Use handles for ves_icall_GetCurrentMethod
* [reflection] Use handles for ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternalType_native
* [reflection] Use handles for ves_icall_System_Reflection_Module_ResolveSignature
* [reflection] Use handles for ves_icall_System_Type_internal_from_name
* [reflection] Use handles for ves_icall_System_Type_internal_from_handle
* [runtime] Use coop handles for System.Object.GetType ()
* [reflection] Use handles for ves_icall_MonoField_GetParentType
* [reflection] Use handles for ves_icall_MonoField_ResolveType
* [reflection] Use handles for most icalls in System.RuntimeTypeHandle
- GetArrayRank
- GetAttributes
- GetBaseType
- GetElementType
- HasInstantiation
- IsArray
- IsByRef
- IsComObject
- IsGenericTypeDefinition
- IsGenericVariable
- IsPointer
- IsPrimitive
- type_is_assignable_from
* [reflection] Use handles for ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl
and ves_icall_RuntimeTypeHandle_GetGenericParameterInfo
Previously we would only look into files ending in libraryname.sources.
This breaks down in cases where we used e.g. "#include common.sources"
because those files don't match the pattern and would be left out.
To fix this we could either start resolving includes in the .sources,
but the simpler fix is to just dist files from all normal .sources files.
This helps to get rid of the messages like these:
```
/Applications/Xcode8.1-beta1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libmonosgen-2.0.a(libmonoruntimesgen_la-coree.o) has no symbols
/Applications/Xcode8.1-beta1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libmonosgen-2.0.a(libmonoruntimesgen_la-file-mmap-windows.o) has no symbols
/Applications/Xcode8.1-beta1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libmonosgen-2.0.a(libmonoruntimesgen_la-lock-tracer.o) has no symbols
/Applications/Xcode8.1-beta1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .libs/libmonosgen-2.0.a(libmonoruntimesgen_la-mono-endian.o) has no symbols
[...]
```
That is what is in `libtool`:
```
# Commands used to build an old-style archive.
old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib"
```
`ar` is calling `ranlib`, and then `libtool` calls `ranlib` again. We
cannot control how `ar` calls `ranlib` (that is, we can't tell it to
pass `-no_warning_for_no_symbols`), but we can control to not call it
at all. Let's to that then.
As a reference, source code of `ar`:
https://opensource.apple.com/source/cctools/cctools-895/ar/ar.c.auto.html
This was introduced in 9d5de96b0f since
we would now call the csproj-local target without `intermediate`
being set which results in an infinite loop.
Overriding the target doesn't seem to be necessary anymore, so remove it.
CMake doesn't pick up the compiler from the PATH by default,
it only looks in default locations so without this we might
end up using a different compiler for BTLS than for the main
Mono build which we don't want.
BTLS also requires a fairly new GCC which includes C++11
features, added a quick check for stdalign.h which BTLS
requires and disable it if the header isn't found.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=46712
Somehow mcs.exe disappeared from monolite even though it was added
in 68d56e8027 and worked for a while.
See if bumping corlib version (i.e. generating a new monolite) fixes it.
Before this change step-in and step-out didn’t place breakpoints on catch handlers which caused code to continue execution instead of stopping since it missed all breakpoints…
build_init project doesn't detect changes done in config.h. This is needed in order
for build_init to replace config.h with winconfig.h and backup cygconfig.h. This is
normally an issue if you do a reconfigure and build using make and then msbuild. The msbuild
will then fail, since config.h is still the cygwin version. Solution is to do a rebuild all
that will trigger build_init. This fix will make sure that build_init gets invoked if there has been a change to config.h.
There was also a very old issue with the first copy of config.h -> cygconfig.h. This is only done
if there is no cygconfig.h in the directory. This means that the cygconfig.h will not be update until
deleted and a new build_init has been invoked. This fix will make sure cygconfig.h is always updated
if config.h is the cygwin generated version (not already replaced with winconfig.h).
mcs.exe didn’t emit some NOPs after method calls needed when doing StepOut, now that Roslyn emits this we correctly step out to line that called hence, some unit tests needed correcting
* [runtime] Remove MonoReflectionGenericMethod typedef.
- It's not used in the runtime,
- Unlike other defs in object-internals.h it doesn't seem to have a
corresponding managed object.
* [reflection] Add mono_field_get_object_handle.
Reimplement mono_field_get_object and mono_field_get_object_checked in
terms of it.
* [reflection] Add mono_property_get_object_handle
Reimplement mono_property_get_object and
mono_property_get_object_checked in terms of it.
* [reflection] Use handles for FieldInfo,MonoPropertyInfo,ParameterInfo.GetTypeModifiers
* [reflection] Use handles for MonoMethodInfo.get_parameter_info
- Change mono_param_get_objects_internal to use handles
* [reflection] Cleanup in method_object_construct
* [reflection] Use handles for System.Refleciton.EventInfo.internal_from_handle_type
- Replace mono_event_get_object_checked by mono_event_get_object_handle
which uses handles.
* [reflection] Use handles for System.Reflection.MethodBase.GetMethodBodyInternal
- Replace mono_method_body_get_object_checked by
mono_method_body_get_object_handle
* [reflection] Remove CHECK_OR_CONSTRUCT, it's dead code.
All former callers now use CHECK_OR_CONSTRUCT_HANDLE
* [reflection] Use handles for FieldInfo.get_marshal_info and MonoMethodInfo.get_retval_marshal
- Change mono_reflection_marshal_as_attribute_from_marshal_spec to
return a handle; fix callers
* [metadata] Add mono_metadata_get_canonical_generic_inst utility function
* [reflection] Use handles for System.Reflection.Module.ResolveMemberToken and 3 more icalls
- ResolveFieldToken
- ResolveMethodToken
- ResolveTypeToken
If a task calls native code that uses handles before completing, we should
dispose of any handles that it may have used before we park the worker.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=49423
This addresses a regression here:
https://bugzilla.xamarin.com/show_bug.cgi?id=45761
The commits
97e51abfcf and
d35b5d2188
changed control flow such that if the host can't be resolved
and host is set to null, then the later check will return null
for the duration that HasTimedOut is false.
A try finally set looks like :
try:
...
call finally
E: exit try_block
finally:
...
call E
If we get aborted in the finally block, instead of calling to E, we call to a handler block trampoline which will throw the exception using a context that has the ip at E (since we need to execute the finally block first). We need to make sure that E is not logically part of the try block, otherwise we will end up calling the finally block again when unwinding the stack.
Some XML tests enabled as part of 93e845de16 failed
on Linux because of the lowercased system.dll reference in referencesource:
```
1) CompileNoLineInfoSource (MonoTests.System.Xml.Xsl.MsxslScriptTests.CompileNoLineInfoSource)
System.Xml.Xsl.XsltException : Script compile errors:
error CS0006: Metadata file `system.dll' could not be found
at System.Xml.Xsl.XsltOld.Compiler.CompileAssembly (System.Xml.Xsl.XsltOld.ScriptingLanguage lang, System.Collections.Hashtable typeDecls, System.String nsName, System.Security.Policy.Evidence evidence) [0x00229] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Data.SqlXml/System/Xml/Xsl/XsltOld/Compiler.cs:823
at System.Xml.Xsl.XsltOld.Compiler.CompileScript (System.Security.Policy.Evidence evidence) [0x00016] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Data.SqlXml/System/Xml/Xsl/XsltOld/Compiler.cs:749
at System.Xml.Xsl.XsltOld.Compiler.Compile (System.Xml.Xsl.XsltOld.NavigatorInput input, System.Xml.XmlResolver xmlResolver, System.Security.Policy.Evidence evidence) [0x0009d] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Data.SqlXml/System/Xml/Xsl/XsltOld/Compiler.cs:200
at System.Xml.Xsl.XslTransform.Compile (System.Xml.XPath.XPathNavigator stylesheet, System.Xml.XmlResolver resolver, System.Security.Policy.Evidence evidence) [0x00022] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs:264
at System.Xml.Xsl.XslTransform.Load (System.Xml.XPath.XPathNavigator stylesheet, System.Xml.XmlResolver resolver) [0x0000e] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs:82
at System.Xml.Xsl.XslTransform.Load (System.Xml.XPath.IXPathNavigable stylesheet, System.Xml.XmlResolver resolver) [0x0000e] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs:69
at System.Xml.Xsl.XslTransform.Load (System.Xml.XPath.IXPathNavigable stylesheet) [0x00000] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs:63
at MonoTests.System.Xml.Xsl.MsxslScriptTests.CompileNoLineInfoSource () [0x00018] in /mnt/jenkins/workspace/test-mono-mainline-linux/label/ubuntu-1404-i386/mcs/class/System.XML/Test/System.Xml.Xsl/MsxslScriptTests.cs:210
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-i386/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
```
`directory` is already a directory. It's in the name.
`Path.GetDirectoryName ("/path/to/a/thing")` returns `"/path/to/a"`, whether
`thing` is a directory or not. If there's a trailing `/` then it returns
the directory, not the parent - but we don't have a trailing `/`.
This fixes an issue where the path needs to be created by hand before an
SDK can be downloaded.
Commit 41272d634b removed mono/mini/mini-
exceptions-native-unwinder.c from the source tree but didn't update msvc
/libmono-static.vcxproj accordingly causing the VS build to fail.
we will rely on the output of debuggerd in order to get a native stack
trace. The arguments to support that:
(a) native stack trace by debuggerd is at least as good as the one we get via
libunwind (most of the time the trace provided by libunwind is useless?)
(b) we cannot screw up by accident (e.g. we have seen issues with a too small altstack)
(c) we don't need to maintain the libunwind integration into mono (which we
sort of had to do because of the upcoming dlopen limitation in Android 7.0
Nougat).
(d) the libmonosgen-2.0.so had about one megabyte more footprint (16mb ->
17mb). I'm talking about a debug build here though.
See mailing list discussion for more information:
http://lists.dot.net/pipermail/android-devel/2016-December/000026.html
First the bug fix.
If we hit a method with a nested type as argument, we would not include the outer types and fail to match.
Now for the big change.
The runtime now includes mvid and aotid in the stacktraces it generates. This makes them symboficatable but
with the side effect that the runtime adopts a more compact and slightly different format. Differences includes:
- short name for primitives (int, object, string, etc)
- <> for generic instances
- / for type nesting
- generics vars are appended with _REF
Current glibc's <sys/types.h> headers are included into
many C standard headers.
The problem here is that makedev()/major()/minor() macros
defined in <sys/sysmacros.h> leak into C standard headers
and poison global namespace.
The plan is to get rid of <sys/sysmacros.h> inclusion
in <sys/types.h>:
https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html
On such system without implicit <sys/sysmacros.h> mono fails
to build as:
CC libmonoruntime_la-w32process-unix-default.lo
w32process-unix-default.c: In function 'mono_w32process_get_modules':
w32process-unix-default.c:225:12: error: implicit declaration of function 'makedev' [-Werror=implicit-function-declaration]
device = makedev ((int)maj_dev, (int)min_dev);
^~~~~~~
autoconf has a AC_HEADER_MAJOR macro to autodetect
header for major() and friends.
This change switches to AC_HEADER_MAJOR.
Signed-off-by: Sergei Trofimovich <[email protected]>
We observed that this assertion would sometimes be triggered on CI in case of intensive load. This would be possible because we wouldn't necessarily decrease the outstanding_request in a new worker. To decrease resource usage, we also want to limit the amount of new worker we request.
This changes mono_mach_arch_get_thread_fpstate_size to return a value,
rather than asserting. The actual float state isn't used yet. This also
assumes NEON, which may not be correct.
Using MONO_ARCH_ENABLE_MONO_LMF_VAR requires that we have means of getting the address of a tls variable (which is always the case when using __thread, but not necessarily when using pthread). Make sure that using it is properly guarded.
In the future we might want to remove MONO_ARCH_ENABLE_LMF_VAR and always try to use a tls variable for the lmf. Additionally we should benchmark what combinations work best and stick to them on all platforms. (ex when using fast tls we might consider using lmf_get + lmf_set if possible, when using fallbacks we might always want to use the lmf_addr to void multiple calls, always use lmf_ir etc).
If the compiler optimized it so that we would unregister the thread->thread_pinning_ref GC root before we would destroy the thread fields, we could run into "* Assertion at threads.c:1081, condition 'thread->suspended' not met"
The methods were added in .NET 4.6 but couldn't be done abstract so instead
they were added virtual which just throws an exception telling you to override
it in the subclass.
We implemented this for RSACryptoServiceProvider in https://github.com/mono/mono/pull/3770
(the methods were already overriden in that case because we moved to referencesource)
but DSACryptoServiceProvider is still using the Mono code so we need to
implement it there too.
This reverts commit 59b8a5d3ba.
It breaks the mcs build:
```
20:35:27 MONO_PATH='./../../class/lib/build/' > build_aot.log 2>&1 /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/runtime/mono-wrapper --aot=bind-to-runtime-version,outfile=/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Collections.Immutable.dll.so --debug /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Collections.Immutable.dll || (cat build_aot.log; exit 1)
20:35:27 Failed to load method 0x6000001 from '/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/System.Collections.Immutable.dll' due to Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:<none>.
20:35:27 Run with MONO_LOG_LEVEL=debug for more information.
20:35:27 AOT of image /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Collections.Immutable.dll failed.
20:35:27 Mono Ahead of Time compiler - compiling assembly /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/System.Collections.Immutable.dll
20:35:27 AOTID 368C895D-F9C7-38E7-C0BA-F9B6964CD1A0
20:35:27
make[7]: *** [/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Reflection.Metadata.dll.so] Error 1
20:35:27 make[7]: *** Waiting for unfinished jobs....
20:35:27 Failed to load method 0x6000001 from '/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/System.Collections.Immutable.dll' due to Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:<none>.
20:35:27 Run with MONO_LOG_LEVEL=debug for more information.
20:35:27 AOT of image /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Collections.Immutable.dll failed.
20:35:27 Mono Ahead of Time compiler - compiling assembly /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/System.Collections.Immutable.dll
20:35:27 AOTID 368C895D-F9C7-38E7-C0BA-F9B6964CD1A0
20:35:27 make[7]: *** [/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools//System.Collections.Immutable.dll.so] Error 1
20:35:27 Failed to load method 0x600000c from '/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/csc.exe' due to Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:<none>.
20:35:27 Run with MONO_LOG_LEVEL=debug for more information.
20:35:27 AOT of image /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/csc.exe failed.
20:35:27 Mono Ahead of Time compiler - compiling assembly /mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/external/roslyn-binaries/Microsoft.Net.Compilers/Microsoft.Net.Compilers.1.3.2/tools/csc.exe
20:35:27 AOTID 44CBE5F8-37FA-0F68-B472-47E2F4209FC5
20:35:27 System.Collections.Immutable.dll
20:35:27 AOTID 368C895D-F9C7-38E7-C0BA-F9B6964CD1A0
20:35:33 make[7]: Leaving directory `/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/mcs/class/aot-compiler'
20:35:33 make[6]: Leaving directory `/mnt/jenkins/workspace/test-mono-mainline-mcs/label/ubuntu-1404-amd64/mcs/class/aot-compiler'
20:35:33 make[6]: *** [do-all] Error 2
```
* [process] Rename MonoProcess to Process as it's not public anymore
* [process] Replace setting process->pid = 0 by process->signalled = TRUE
* [process] Remove processes_mutex lock when unrefing process->handle
We do not need to synchronize it here because we do not modify `processes`, and the only other place where we access process->handle is before adding it to `processes`.
* [process] Fix race condition
Without this memory barrier `process->next = processes` and `processes = process` could be reordered, and when accessing `processes` in mono_sigchld_signal_handler, we could observe a NULL processes->next. This would make us not find a pid in `processes`, and because of the posix API, we would never mark this process as exited.
This would trigger a hang in `process-unref-race.exe` test.
Thank you to @kumpera for the help figuring this out!
By default all platforms will call into native getters/setters whenever they need to get access tls value. On certain platforms we can try to be faster than this and avoid the call. We call this fast tls and each platform defines its own way to achieve this. Fast tls should normally be inlined, otherwise there is little point to doing anything else in the first place (on linux, __thread access is 2-3 instructions, on mac pthread_getspecific is 2 instructions, other platforms also having decent implementations). For this, a platform has to define MONO_ARCH_HAVE_FAST_TLS, and provide alternative getters/setters for a MonoTlsKey. In order to have fast getter/setters, the platform has to declare a way to fetch an internal offset (MONO_THREAD_VAR_OFFSET) which is stored in the tls module, and in the arch specific file probe the system to see if we can use the offset initialized here. If these run-time checks don't succeed we just use the fallbacks.
In case we would wish to provide fast inlined tls for aot code, we would need to be sure that, at run-time, these two platform checks would never fail otherwise the tls getter/setters that we emitted would not work. Normally, there is little incentive to support this since tls access is most common in wrappers and managed allocators, both of which are not aot-ed by default. So far, we never supported inlined fast tls on full-aot systems.
The purpose of this commit is to unify tls access across all platforms. We had tls information spread out throughout the entire code which was guarded with many defines/capabilities which made very hard to follow what was going on. Also this made switching between pthread and __thread very unstable since there were a lot of dependencies between different pieces of the tls infrastructure. Also it was not very clear what happens if one of the tls pieces failed.
Now we are moving all the tls variables to a single module that provides getters/setters and initialization API. Runtime code now knows that we can always access a tls variable (from managed code, we just do a nowrapper icall into the same global geters/setters). Even though we used to these type of calls all around before, it is worth mentioning that runtime should account for a thread to be in this type of unregistered code without m2n wrapper and no register jinfo.
On average this makes common tls intensive methods (m2n wrappers and managed allocator) 20% slower, with potential for more regression if we use tls getters/setters recklessly. As a consequence we will re-enable the most important pieces of fast tls code in the future.
there is not much point in trying to recover from it and even worse,
wrapping it into a managed exception might hide it if the application is
sloppy with exception handling (cf. Pokémon Exception Handling).
* [threadpool] Increase and decrease refcount when removing domain
* [threadpool] Fix unload-appdomain-on-shutdown.exe
If the threadpool is not initialized, there is no need to initialize it, as no worker is going to start in the domain because mono_domain_is_unloading would return TRUE.
Per .NET documentation, DynamicMethod does not support custom attributes
exception the MethodImplAttribute pseudo-custom attribute.
Also change GetMethodImplementationFlags to include NoInlining as on .NET
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=49686
These functions are cast and invoked as a MonoThreadStart (which requires to receive on arg, return one arg and be WINAPI on windwos), which could lead to cconv problems if the prototype is not matching.
* [threadpool] Remove `-ms` suffix
* [threadpool] Split domain and worker management
This will allow us to use native threadpool more easily: we will simply have to implement a threadpool worker with the specific API.
On windows, we will use the Win32 Threadpool, and on OSX we will explore using GCD (Grand Central Dispatch).
In an out-of-tree build the Makefile which contains get-monolite-latest
doesn't exist in the source directory (which $(topdir)/.. would point to)
but in the build directory.
In order to invoke get-monolite-latest we need to actually call the Makefile
in the correct directory which requires exposing the build directory to the
mcs build system.
Get rid of WORKSPACE which is set by Jenkins, this allows one to
more easily run the run-jenkins.sh script locally e.g. on cygwin.
The only thing that needs to be passed in is CI_TAGS and label.
* [ci] Run aot-test on more platforms
Now that https://github.com/mono/mono/pull/4096 is merged, we should be able to run it on Linux too.
* [ci] Don't run aot-test on Windows
It's broken there.
Boehm would use SIGPWR on linux 32/64bits for its suspend signal, but that would conflict with utils/threads suspend signal.
The fix consists in looking for an available realtime signal in utils/threads, and fallback to the default SIGXFSZ, SIGPWR and SIGXCPU
Xbuild currently fails with 'CSC: error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll'
Xbuild should be passing "/debug:Portable" to csc in order to work. There is a possibly broken attempt to this in 2d08353991.
This reverts commit 06088609b0.
It was breaking the build on i386 Linux:
```
Unhandled Exception:
System.ExecutionEngineException: System.Threading.SynchronizationLockException: Object synchronization method was called from an unsynchronized block of code.
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression (Microsoft.CodeAnalysis.CSharp.BoundExpression expression, System.Boolean used) [0x00070] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement (Microsoft.CodeAnalysis.CSharp.BoundStatement statement) [0x000ad] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions (Microsoft.CodeAnalysis.CSharp.BoundStatement statement) [0x0000c] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement (Microsoft.CodeAnalysis.CSharp.BoundSequencePoint node) [0x0002d] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement (Microsoft.CodeAnalysis.CSharp.BoundStatement statement) [0x00087] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock (Microsoft.CodeAnalysis.CSharp.BoundBlock block) [0x0009d] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement (Microsoft.CodeAnalysis.CSharp.BoundStatement statement) [0x0007a] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementList (Microsoft.CodeAnalysis.CSharp.BoundStatementList list) [0x00023] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement (Microsoft.CodeAnalysis.CSharp.BoundStatement statement) [0x000b4] in <8d5a2b6695c6475bb1cb5b9a9f9c8dd7>:0
...
```
It could happen that we unref a handle that we are currently looping over. This could be the case if we are calling Process.GetProcessById (which loops over all handles) and mono_w32handle_unref on a MonoW32HandleProcess handle.
* [reflection] Use handles for System.Reflection.Assembly.GetFilesInternal
* [reflection] Use handles for System.Reflection.Assembly.InternalGetType
* [reflection] Use handles for System.Reflection.Assembly.GetManifestResourceNames
* [reflection] Use handles for System.Reflection.Assembly.LoadPermissions
* [reflection] Add mono_method_get_object_handle
Reimplement mono_method_get_object_checked in terms of the handles one.
* [reflection] Use handles for System.Reflection.Assembly.get_EntryPoint
* [reflection] Use handles for four more icalls in System.Refleciton.Assembly
That's the lot of them.
* get_ReflecitonOnly
* get_code_base
* get_fullname
* get_global_assembly_cache
* [security] Use handles for System.Security.Policy.Evidence.IsAuthenticodePresent
* [runtime] Use handles for System.Web.Util.Icalls.GetUnmanagedResourcesPtr
* [runtime] Use MONO_HANDLE_GETVAL instead of MONO_HANDLE_RAW in a few places
* [runtime] Use handles for System.AppDomain.ExecuteAssembly
* Don't allow Join to return due to an APC
On Windows, Thread.Join does an alertable wait. If the thread calling
Join gets an APC during the call, Join will incorrectly return. Instead,
the code should handle the APC and continue waiting.
* Do an uninterrupted wait during thread join.
Mimic the behavior of mono_wait_uninterrupted, but for a single thread
that we want to join.
* Make some style changes suggested in the PR.
"Makefile:25: *** multiple target patterns. Stop.", according to web searches
this is because of colons in the file path. install-local always runs so we
don't really need the source files as dependency -> removing.
* [ci] Add aot-test step like on Wrench
* [tests] Fix mktemp argument to work on Linux
* [ci] Only run aot-test step on OSX
It seems to crash on linux with the boehm configuration.
Looks like commit f3bbd799f0 that added type-checking.c
to the windows builds broke it since it includes mini.h and ir-emit.h using
<> syntax instead of "". All other include of these files uses "" syntax. Fix
makes sure the includes in type-checking.c uses "" syntax.
* [runtime] Move domain icall declarations to appdomain-icalls.h
* [coop] Use handles for System.AppDomain.GetAssemblies icall
* [coop handles] Add HANDLE_FUNCTION_RETURN_REF macro
* [runtime] Handles for AppDomain.LoadAssemblyRaw and Assembly.LoadFrom
* [reflection] Coop handles for RuntimeTypeHandle.GetAssembly
* [runtime] Change mono_try_assembly_resolve to return MonoAssembly
instead of managed MonoReflectionAssembly. Update call sites.
Also implement it in terms of mono_try_assembly_resolve_handle (which
also returns MonoAssembly*, not a managed object)
* [runtime] Use handles for System.AppDomain.LoadAssembly
* [reflection] Use mono_assembly_get_object_handle instead of mono_assembly_get_object_checked
Convert all its callers to use handles and get rid of mono_assembly_get_object_checked
* Reuse a single empty string instance
* Undo string empty change to mono_string_new_size_checked and add new embedding api for string empty instead
* Add & use mono_string_empty_checked to fix build error on Linux
* Revert "Add & use mono_string_empty_checked to fix build error on Linux"
This reverts commit 47cafae6573115333fa04776c21e5ddc49fe4b40.
* Remove MONO_RT_EXTERNAL_ONLY to fix build error on linux
The babysitter script used for CI results was previously able to run
either on Windows or standard UNIX. However, the builders run Cygwin,
which turns out to need special support. To make Cygwin work two
changes were made:
1. Paths which are exported to Mono get filtered through `cygpath`.
Paths received back from Mono are filtered in reverse. The script now
tracks two sets of path strings.
2. Under certain circumstances in Cygwin, pgkill() attempts to close a
process group and finds it does not exist. My assumption is that this
is because it has already been closed. I dealt with this by simply
catching the failure and printing a warning.
We already had implementations of the Windows APIs like FindFirstFile/FindNextFile
in native code but we wrapped it with some convenience functions for our implementation.
The referencesource code works directly against those APIs so I added new icall functions
that are just used for passing data to/from native code.
Note that we have the same problem in the DirectoryInfo.GetFiles() implementation.
Right now that one still uses the old Mono implementation, switching it over to
the referencesource implementation will be done in a separate commit.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42715
SafeArray implementation is not available under all Windows API families. This commit
extracts SafeArray methods making it possible to exclude them under Windows API families
not supporting SafeArrays.
Renames the flag to be more explicit on the intended purpose. Also,
document the new configuration flag.
The default will probe the right compiler to use.
* [reflection] Refactor managed object caching
Split up all the mono_XXX_get_object_checked functions into a generic
cache check and a specific construction function that's called if
there's a cache miss.
* [reflection] Add mono_assembly_get_object_handle
* [reflection] Add mono_module_get_object_handle
* [reflection] Use mono_module_get_object_handle everywhere
instead of mono_module_get_object_checked.
Also implement mono_module_file_get_object_handle instead of mono_module_file_get_object_checked
The additional profiles like monotouch, monodroid etc. are normal
managed code anyway and are the same no matter where they're built
so we can save a lot of CI time by not building them e.g. on slower
ARM bots.
This can happen if TypeBuilders are used to construct something like
class S<T> {
...
}
class R {
public S<int> SI;
}
And then CreateType() is called for R and GetField("SI") is called on
the result before CreateType() is called on the builder for S.
The "cil" attribute seems to indicate that the data should be placed
in the .text section, along with the code.
Like the tls attribute, the cil attribute is only implemented insofar
as to recognize it as a valid keyword that can occur in a .data
declaration.
* [runtime] Fix naming scheme for check if stack grows upward
It was very counter-intutitive to have a file-local preprocessor variable
with a name that sounds like it should have the same truthiness as a given global
preprocessor variable but was defined as the negation of the global variable.
* [runtime] Prevent ThreadAbort from terminating function calls in catch body
ThreadAbortExceptions are special in that if the thread has not
had it's abortion reset, when it reaches the end of a catch block it
must throw.
Consider the situation where a thread has been aborted and the
ThreadAbortException has been caught. If this catch block calls
a method that has a try/catch combination, the current implementation
will throw the ThreadAbortException at the end of the catch in that
function.
Usually you only care that Thread abortions are prompt, but this bug
could result in dramatic program behavior changes when this is combined
with lazy class initialization.
```
Example:
Console.WriteLine inside a thread abort with an uninitialized Console.
```
This fix records the stack pointer when a catch clause is entered, and
only rethrows the abortion if we're exiting a catch clause above or at the
level of the catch clause previously entered.
We have the following set of problems:
Arrays implement interfaces that are invariant but behave like covariant.
Those are IList`1, ICollection`1, IEnumerable`1
Arrays of primitive types are type equivalent based on their underlying type.
This means int[], uint[] and IntEnum[] are all interchangeable. And so is casting among their interfaces.
Meaning this is valid: `(IList<IntEnum>)(object)new int[1]`.
Finally, the way we implement IEnumerator`1 for arrays forces it to behave just like the other 3 interfaces.
Implementation:
Introduce MonoClass::is_array_special_interface, set for all the above interfaces. This allow fast checking of the interfaces in question.
mono_class_is_assignable_from now includes the array casting rules.
Change mono_class_interface_offset_with_variance to take arrays into account when looking for a candidate iface.
The JIT implements casting of those interfaces using the cast with cache wrapper.
Finally, to handle the weird primitive rules, set the cast_class of sbyte, ushort, uint and ulong to their same-size buddies.
This makes it easier for the casting code to resolve this problem.
Problems:
Casting performance is terrible, anywhere from 60% to 1000% slower on a micro-benchmark.
Can be improved by extending our casting wrapper to handle those interfaces (probably would have to give up inlining as they would be huge)
The code in domain.c is icky, but not sure where to put it otherwise.
IEnumerator could be solved in Array.cs by not forcing it to be magic as well. Meaning the folowing
```
object array = new int[1];
var a = array as IList<int>;
var b = array as IList<uint>;
a.GetEnumerator().GetType () != b.GetEnumerator().GetType ();
```
The last line is false today but it's harmless to change it to avoid the casting penalty for such central type.
* [runtime] Store the class failure data as a property.
* [runtime] Store the list of nested classes as a class property.
* [runtime] Move the property relation information from MonoClassExt into a class property.
* [runtime] Move the event relation information from MonoClassExt into a class property.
* [runtime] Move the field_def_values field from MonoClassExt into a class property.
* [runtime] Move the declsec_flags field from MonoClassExt into a class property.
* [runtime] Remove unused MonoClassExt infrastructure.
* [runtime] Add some API docs.
Mono assumes the same calling convention for icalls as the default P/Invoke
calling convention which is __stdcall on Windows. But none of the icalls are
marked with the required __stdcall attribute on Windows so there will be a
mismatch between the caller and callee.
This is the reason why the System.Web.HttpUtilityTest.JavaScriptStringEncode()
test crashes on Windows 32-bit. It generates a call to an icall
(char.ToString() inlines to new string(char,int)) which is assumed to be
__stdcall while it's actually __cdecl. The caller will decrement ESP as if the
callee was __stdcall resulting in ESP decreasing on each iteration. After a
couple of thousand iterations in the loop in that test the stack guard page is
hit and a stack overflow occurs.
It needs special logic like the other monotouch profiles in the products
since we don't have a System.Drawing assembly/types for these profiles in Mono
and don't embed the types in the facade anymore after 1074fe91bd.
Added support to pass in an instance of a TestDriverReporter class. If this
an instance of this class is passed in it will get the number of executed, skipped
and failed tests. This could be very useful for external runners that would like
to present the result of TestDriver executed tests.
We decided it's a better name since we're using the profile to
test FullAOT scenarios on desktop (as opposed to the mobile profiles).
While doing the rename I saw that a lot of the #ifdefs were using
MOBILE_STATIC even though the code should actually be included/excluded
in all FullAOT scenarios, e.g. System.Reflection.Emit. I replaced those
cases with FULL_AOT_RUNTIME instead.
For cases where code is specific to this profile, I added a new
AOT_ONLY_DESKTOP define.
This test is occasionally taking over 15 minutes to complete. This
could be a hang in the runtime, but the test has a scheduling fairness
issue which could also have the same result (if the GC thread wakes up
much more often than the join thread). Patch slows down the GC rate to
give the join thread a chance to work, and extends the test to a fixed
30 second runtime.
PR #3998 fixes an error handling issue in poll_event_wait(). This new change
fixes a minor code style problem in that PR, the condition in a ternary wasn't
enclosed in parentheses.
* Fixed issue 47425
This fix simply ensures that the `m_Handle` value is not processed by the GC after a call to `DuplicateAndClose` as that causes the duplicated socket to close.
A potential issue is that this will leak sockets if the sockets are never re-created.
* Implemented ref-counting as suggested by @ludovic-henry
Use managed AssemblyName.FillName to make a
System.Reflection.AssemblyName from a Mono.MonoAssemblyName
Delete native fill_reflection_assembly_name implementation. It's dead code.
When copyBlobs is true, duplicates the
name, culture and public_key fields of MonoAssemblyName.
If copyBlobs is false, point those fields into the MonoImage.
Change mono_assembly_fill_assembly_name to call the full version with
copyBlobs == FALSE.
Runtime should use
- mono_error_set_assembly_load for mono_get_exception_file_not_found2
- mono_error_set_bad_image_name for mono_get_exception_bad_image_format2
This test creates an HttpListener for every IP address of all network
interfaces. On Windows disconnected network interfaces have unroutable IP
addresses (169.254.XXX.XXX) and this test fails when it tries to listen to
such an IP address. This patch adds a check to the test to ignore network
interfaces which don't have OperationalStatus == Up.
* [runtime] Move the threadpool related data from MonoDomain to ThreadPoolDomain.
* [runtime] Simplify the waiting for tp threads in the domain unload code. Use a condvar to wait for the active+outstanding number of jobs to reach 0.
On Windows poll_event_wait() in threadpool-ms-io-poll.c checks
WSAGetLastError() when mono_poll() fails. However, mono_poll() sets errno
after converting the WSAXXX error code (e.g. WSAEFAULT->EFAULT). Occasionally
(maybe 1 in 100) the System test suite fails due to mono_poll() returning an
error and poll_event_wait() not handling the error code correctly on Windows.
This patch changes poll_event_wait() to use the same code path which checks
errno on all platforms including Windows. It also fixes a few other places
which used to check WSAGetLastError() rather than errno after a call to
mono_poll(). Also, the Socket.Poll_internal() and Socket.Select_internal()
icalls had to be patched to convert back the errno value to a corresponding
WSAXXX error code by adding WSABASEERR on Windows.
* [simd] Rename SimdIntrinsc->SimdIntrinsic.
* [ji] Add beginnings of support for the SIMD types in the System.Numerics assembly.
Add intrinsics for the methods marked [JitIntrinsic] in the System.Numerics.Vector2 class. Generalize some code in simd-intrinsic.c
so it works both with System.Numerics and Mono.Simd types.
* [jit] Add support for System.Numerics.Vector4.
* [jit] Add support for System.Numerics.Vector3.
* [jit] Add tests for the JIT intrinsics in System.Numerics.Vectors.
* [jit] Implement System.Numerics.Vector.IsHardwareAccelerated intrinsics.
* [jit] Fix the implementation of System.Numerics.Vector.IsHardwareAccelerated, it should return true.
* [jit] Implement some support for the SIMD intrinsics in System.Numerics.Vector<T>.
* [jit] Disable the usage of the Vector SIMD intrinsics when using r4fp until support for it is implemented.
* [jit] Fix llvm support for the Vector<T> intrinsics.
* [jit] Disable the Vector<T> tests since they don't compile yet.
* [jit] Add an optimization for the typeof(T)==typeof(<concrete type>) construct common in some generics code.
* [simd] Only return true from IsHardwareAccelerated () if simd_supported_versions is non-zero.
* [simd] Add support for add/sub/mul/div operations on Vector<T>.
sgen_qsort sometimes had pathological behavior due to a poor choice of
pivot. This implementation uses the median-of-three strategy, and limits
stack depth by avoiding recursive calls when possible.
* [amd64] Use a GArray to collect field information in add_valuetype ().
* [amd64] Fix the marshalling of fixed buffers by treating them as an array of elements.
Cleaned up Mono_Posix_FromSeekFlags() in support/map.c. It didn't properly
handle the case when L_INCR, L_SET, L_XTND aren't available, like on Windows.
Added Mono_Posix_Stdlib_GetLastError() to support/errno.c and changed
Stdlib.GetlastError() use it. Without this Stdlib.GetlastError() wouldn't take
errno in the C runtime used by libMonoPosixHelper.dll into account.
On Windows the Syscall class failed to initialize due to missing functions,
e.g. Mono_Posix_Syscall_get_at_fdcwd(), in libMonoPosixHelper.dll. Those
readonly static fields which were initialized at class initialization have now
been converted to static readonly properties so that the Syscall class can be
initialized despite those functions not being defined.
Cleaned up temp file handling in StdioFileStreamTest to avoid failures due to
sharing violations on Windows.
Fixed a bug in the StdioFileStreamTest.Write() test method when reading back
the batch of bytes written in the second part of the test.
Enabled the Mono.Posix test suite to run on PR builds. This test suite should
from now on be green.
.. `Project.Build(..)`. For example, in:
```
<MSBuild Projects="bar.proj" Targets="foo;foo" />
```
The second invocation of `foo`, in the *same* `Project.Build(..)` call,
would get skipped, but BuildTarget assumed that no previous `outputs`
entry existed in the `targetOutputs` dictionary.
System.Exception: MSBuild operation failed ---> System.ArgumentException: Item has already been added. Key in dictionary: 'foo' Key being added: 'foo'
at System.Collections.Hashtable.Insert (System.Object key, System.Object nvalue, System.Boolean add) [0x00200] in <94fd79a3b7144c54b4cb162b50fc7761>:0
at System.Collections.Hashtable.Add (System.Object key, System.Object value) [0x00000] in <94fd79a3b7144c54b4cb162b50fc7761>:0
at Microsoft.Build.BuildEngine.Project.BuildTarget (System.String target_name, System.Collections.IDictionary targetOutputs) [0x0007e] in <b1524340ac7e4c06b22fac1b2db62c08>:0
at Microsoft.Build.BuildEngine.Project.BuildInternal (System.String[] targetNames, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags) [0x00134] in <b1524340ac7e4c06b22fac1b2db62c08>:0
at Microsoft.Build.BuildEngine.Project.Build (System.String[] targetNames, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags) [0x0004b] in <b1524340ac7e4c06b22fac1b2db62c08>:0
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=44549
Since libMonoPosixHelper.dll is linked against ucrtbase.dll the C runtime
wrapper functions in it will call into ucrtbase.dll. Some pinvokes in
Mono.Unix.Native.Stdlib, however, bind directly to C runtime functions in
msvcrt. This is problematic if a resource (heap memory, file pointer, etc) is
allocated using one C runtime and then operated upon using funcitons form the
other C runtime. E.g., Stdlib.malloc() calls into a wrapper in
libMonoPosixHelper so it will use the ucrtbase heap while Stdlib.free() calls
directly into msvcrt's free() which will abort the process since it's called
with a pointer in an unknown heap.
This commit adds libMonoPosixHelper wrappers for all memory and file related
functions in Stdlib to ensure that all such functions use the same C runtime.
Some of the Mono.Posix tests still fail but at least the test suite doesn't
crash after this change. The test failures will be addressed in a future PR.
* [runtime] Change the thread wait code to use cond variables instead of events.
Instead of waiting for the thread handles to be signalled, wait for a cond variable signalled which is signalled by the code which calls pthread_join ().
* [runtime] Synchronize access to njoined_threads. Only use the background_change_event on windows.
* Fix a warning.
mono_monitor_ensure_owned used to throw exception directly and not return. After switching the runtime to use pending exceptions, monitor code would continue running assuming we owned to monitor.
Fixes 46994
PR #3955 removes mono_dl_open() and mono_loader_register_module() from
msvc/mono.def and msvc/monosgen.def which causes VS linking error. This change
readds the symbols to the def files as a temporary solution to get the VS
builds to build successfully again.
PR #3936 adds the mono/metadata/property-bag.c file but doesn't add it to
msvc/libmonoruntime.vcxproj, resulting in linking errors when building the VS
solution.
* Making sure `marshal_alloc`and `marshal_free` is used in libtest.c so
memory is allocated/freed with `CoTaskMemAlloc`/`CoTaskMemFree`.
* Now returning correct type for `MONO_NATIVE_UTF8STR` in `mono_type_to_unmanaged`.
Fixes the EntryPointNotFoundException when running the Mono.Posix tests on Windows.
This check was introduced in 249ee0686b but the .def file wasn't updated.
With this the tests still crash so switching them off on PRs again for now.
Print a message when running nunit-console about the deprecation.
Additionally, throw a compilation error if compiling against the
TestFixtureAttribute from old NUnit.
Needed changes in ms-test-suite as well since it was still using NUnit.
These two headers are required by loader.h which is installed in
$prefix/include/mono-2.0/mono/metadata and their lack breaks compilation
of any software that includes loader.h
RemotingServices::SerializeExceptionData started to fail as TAE was being raised
from within the serialization code and this triggered the completely wrong abort protection code.
This happened because a recent change that made .cctors raise TAE at their end and the stack trace
code would hit System.Reflection.Module's cctor to fetch its GUID for the purpose of symbolification.
The fix is to use the correct protection against aborts, which is to run code from finally blocks.
This fixes multiple failures in the runtime test suite.
Mono returns null for disconnected interfaces with 169.254.X.X address while
refsources returns 255.255.0.0. This patch copies the relevant pieces from the
refsources to make Mono behave the same.
There was a crash on Windows x64 in Win32ServiceController when enumerating
devices and services. Also fixed the ServiceControllerTest to succeed on .NET
as well Mono on Windows. Had to replace the services used by the test since
most of them have been removed from recent Windows versions.
This PR also enables the System.ServiceProcess tests in Windows PR builds.
.. item.
If we have a project, that sets some properties or items at runtime,
like in a target:
```
<Target Name="Build">
<PropertyGroup>
<Bar>Bar01</Bar>
</PropertyGroup>
```
.. such a property can be accessed as `$(Bar)` subsequently.
Then at later point, a target tries to update metadata on an item group
with existing items, like:
```
<ItemGroup>
<FooItem Include="xyz" />
</ItemGroup>
<Target Name="Foo">
<ItemGroup>
<FooItem>
<SomeMetadata>MetadataValue</SomeMetadata>
</FooItem>
</ItemGroup>
```
.. then it is seen that the value for the earlier created `$(Bar)` disappears!
So, if we try to print the value of `$(Bar)` right after that item
group, it would appear as `''`!
The issue is that the metadata update in target `Foo` caused the project
to get re-evaluated, which meant that items/properites created after the
project load were lost! We should not be reevaluating the project when
setting metadata on the basis of dynamic items, like in the target
`Foo`.
These dynamic item groups in a target are represented as
`BuildItemTask`, and these create BuildItems which have their
`IsDynamic` property set. And this is used to avoid re-evaluating the
project in `BuildItem.SetMetadata`.
But when updating metadata (`BuildItem.UpdateMetadata`), we need to
update metadata on the *existing* items, which might not have been
created from such dynamic item groups! So, their `IsDynamic==false`.
Hence, trying to `SetMetadata` on such items would cause the project to
be reevaluated, and thus properties/items like `$(Bar)` would be lost!
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=45137
In this particular case, `Bar` was the `DesignTimeBuild` property, which
was losing it's value when `ProjectReference`'s `AdditionalProperties`
metadata was set in:
```
<Target Name="BclBuildAddProjectReferenceProperties"
<ItemGroup>
<ProjectReference>
<AdditionalProperties>$(_BclBuildProjectReferenceProperties);%(ProjectReference.AdditionalProperties)</AdditionalProperties>
</ProjectReference>
</ItemGroup>
```
ELF v2 ABI (aka. ppc64le) defines two entry points per function.
The global entry point (offset 0) sets up the TOC (r2) itself, while the
local entry point (offset 8) is a fast entry point if the TOC is
already set up properly.
When the global entry point is used, the address of the global entry
point is required in r12 according to the ABI.
`--with-tls=__thread` is broken on PowerPC.
`--with-tls=pthread` didn't work on PowerPC, but disabling
MONO_ARCH_HAVE_TLS_GET fixes it.
Instead of guarding the define with `HAVE_KW_THREAD`, let's just
disable it. We want to get rid of `--with-tls=__thread` anyway.
* [stw] Refactor to treat error/success cases first
* [threads] Always use the `suspended` MonoOSEvent for self-suspend
The previous self-suspend mechanism was inherently racy:
- T1 self suspend:
- T1 calls mono_thread_info_begin_self_suspend, but doesn't call mono_thread_info_end_self_suspend yet
- T2 suspends T1 <-- the suspend_count is > 0, trigerring the assertion at mono-threads.c:184
* [threads] Destroy suspend MonoOSEvent when detaching
It could happen that we destroy the managed InternalThread object, before we actually detach the thread (in mono/tests/threadpool-exceptions1.exe for example).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=46536
* [threads] Close thread handle once done with it
* [w32handle] Inline only use of mono_w32handle_search
* [w32handle] Make special_wait return MonoW32HandleWaitRet
This is to avoid a unnecessary translation from WAIT_* to MonoW32HandleWaitRet
* [process] Use some more referencesource
* [process] Rename mono_processes to processes
* [process] Allocate a handle even for non-child processes
* [process] Create the handle only once the process has started
This fixes `appdomain_unload.exe` test timeout. The following would happen:
- T1 unload the current domain
- T1 launch T2 to unload domain
- T1 waits on T2 to finish
- T2 tries to abort T1 <-- because the wait on T2 is not alertable, T1 is not going to be aborted
In order to reduce dependencies on external toolchains when doing full AOT on Windows
targeting x64 Windows platforms we would like to use what's available in
VS 2015 MSVC toolchain. Mono's full AOT compiler need an assembler and a linker from
available toolchain in order to do different full AOT scenarios, emitting assembler, compile
objects or link complete shared library.
Since the current emitter emits GNU assembler it is beneficial to reuse that assembler
syntax without the need to adopt to a different syntax. In VS2015 Update 1 a new toolchain
option has been released utilizing the Clang parser combined with MSVC code gen. This will
produce object files fully compatible with MSVC linker. It turns out that VS2015 Clang version
also supports GNU assembler and since Mono just uses simple constructs in the assembler
(all code is already compiled and emitted as byte streams in assembler) it is possible to use Clang
for VS to compile our emitted assembler files.
This PR switches to Clang for Microsoft VS2015 and MSVC linker when doing full AOT targeting Windows x64
platforms hosted on a Windows platform. It requires an installation of at least Microsoft VS2015 Update 1
with Clang component selected. NOTE all other scenarios is currently left as is.
This PR also makes adjustments to AOT compiler in order for above scenario to work, supporting asm only output, static output
and regular shared libraries using MSVC linker.
* Changes to process.c triggered errors on none desktop API builds.
* Implementation of memory mapped files caused build errors on none desktop API builds.
* Adjustments to disable JIT caused build errors on none JIT builds.
Continuation work on previous none desktop Windows API family PR's adjusting all
changes to similar patterns used over previous PR's. This PR also move the logic
to silence a MS VS linker warning on empty source files into a macro. It also includes
the use of the macro in a couple of more source files causing linker warnings when build
on none desktop API families excluding JIT support.
Since other Windows API family work is still in progress it also disables build capabilities
for none desktop API families.
The SecureStringHelper from referencesource I added in https://github.com/mono/mono/pull/3887
relies on this to convert from SecureString to plaintext.
It failed on mobile because we always throw a NotImplementedException there,
but we actually have an implementation on the runtime side (even in the DISABLE_COM case).
Because we wouldn't return the correct ThreadPoolDomain for the requested domain, we would simply wait on the last inserted MonoDomain. This would lead to a hang when unloading the domain, as we wouldn't wait on the correct domain.
* [BTLS]: Use `int64_t` instead of `long` in the native API.
* Copy time64.c from Android's source code to get a 64-bit timegm64().
* Rename into btls_timegm64() and remove everything we don't need.
(cherry picked from commit 2365067bda)
This makes the System.Runtime.Remoting test suite fail in various places on
Windows due to the TestFixtureTearDown method in BaseCalls throwing an NRE.
PR https://github.com/mono/mono/pull/3776 renamed `mono_string_to_lpstr`
to `mono_string_to_utf8str` without updating the Windows version.
This fix renames `mono_string_to_lpstr` to `mono_string_to_utf8str` to
make sure the string is allocated using `CoTaskMemAlloc` on Windows
since it will be freed using `CoTaskMemFree`.
It's an optional element according to [1] and we were simply
throwing a NotImplementedException when encountering it.
Fixed by reading the element value instead. I noticed that we
had a 'details' variable that was never assigned, so the check
for `details == null` was always true and can be removed.
This makes inlining the body of the CreateFault() call easier
since we no longer need to choose different overloads and makes
the code consistent with the CreateFault12 method.
Also added a better exception in case of an unrecognized element.
The CreateFault12 method (handles SOAP 1.2) does not need a similar
fix since actor is not an element in that version [2].
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42226
[1] https://www.w3.org/TR/soap11/#_Toc478383507
[2] https://www.w3.org/TR/soap12/#soapfault
This is a logic bug where we would only wake up one of the threads that are waiting for the manual MonoOSEvent to be set. This would be a problem only if more than one thread is waiting.
* [threads] Refactor how we create Thread and InternalThread in native
* [threads] Add coop support for async call
* [threads] Use MonoOSEvent for Thread.Suspend/Resume
By using a MonoOSEvent we avoid relying on the utils/threads suspend mechanism to suspend a metadata/threads. This reduce coupling between both mechanism, and that would allow us to remove a bunch of code from utils/threads when switching to coop.
This only works with coop suspend, as we need the ability to return from an async call, and that's not possible with preemptive suspend.
[custom-attrs] Add a low level iterator for custom attributes on assemblies
And use it to check for the reference assembly attribute.
Using the low level APIs means we don't trigger load of referenced
assemblies and we don't need to take locks, so it is safe to call this
during assembly loading.
Follow up work for https://bugzilla.xamarin.com/show_bug.cgi?id=42584
The verbose mode can be enabled with TEST_HARNESS_VERBOSE=1 like before.
We now also print the full test name including namespace in verbose mode again.
To make this possible, two accessor functions were added/augmented:
mono_class_get_generic_class: Gets the generic_class and aborts if the MonoClass is of the wrong kind.
mono_class_try_get_generic_class: Gets the generic_class or return NULL if the MonoClass is of the wrong kind.
The bulk of this change is converting all checks for generic_class into calls to mono_class_is_ginst.
Now that we're using a metadata-only ReferenceAssemblyAttribute check,
we can treat corlib the same as any other assembly - if we see
ReferenceAssemblyAttribute when loading a candidate assembly, skip it.
And use it to check for the reference assembly attribute.
Using the low level APIs means we don't trigger load of referenced
assemblies and we don't need to take locks, so it is safe to call this
during assembly loading.
If we fail to send the signal, we should not add a pending operation, as the signal handler is never going to answer this operation (via mono_threads_notify_initiator_of_resume).
The test correctly fails, as the staging code fails to replace some instances of the destination prefix with the staging prefix. This is a benign error that was already there (the test was just not working) so we are ignoring for now. We must however fix this before e.g. shipping mono in arbitrary staged locations.
This is a followup to e9205142b2.
Monodroid is missing the Cng and CryptoServiceProvider variants of the SHA
algorithms as well so we need to map to the Managed variants there too,
like on monotouch.
This showed up when switching to nunit-lite since it runs all tests in the same AppDomain,
meaning it won't exit when any foreground threads are still running. This was the case
with the thread created by ChannelDispatcher which was still waiting on a connection.
Also try to Join() the thread for a bit so it exits gracefully before trying to abort,
might resolve issues like in https://github.com/mono/mono/pull/3819
With nunitlite the test is executed even though it's marked as ignored when the attribute is there.
This is probably the same bug as https://github.com/nunit/nunit/issues/741 (we're passing -exclude for some categories to nunit).
It causes an infinite loop because nunit-lite restarts itself over and over when running the test
as the tests don't run in a separate AppDomain so the host process is restarted.
It is already called in TestFixtureTearDown, and calling it twice results in an exception in UnregisterChannel
the second time because the channel is no longer registered.
nunitlite does not contain Assertion class.
nunitlite does not implement Is.InstanceOfType, replaced usages of:
Assert.That (type, Is.InstanceOfType(typeof(T))) with Assert.IsInstanceOfType.
Because nunit-lite runs everything in the same AppDomain, we can't use dll.config files for settings anymore.
Since a few test suites rely on being able to read those settings we need to patch them into the main
nunit-lite-console.exe.config file instead before the test.
Remove all _test.dll.config files and replace with nunit-lite patcher equivalent
Get rid of TEST_HARNESS_VERBOSE and enable verbose logging by default
nunit-lite doesn't have the "dot when test runs" progress indicator anymore,
so we need to enable "verbose" output by default otherwise we don't get
any progress until the test run is over.
Also remove the TestResult_$(PROFILE).log and nunit-summary.xsl files,
they're not needed anymore.
* [mono-threads] Make thread wait platform specific
* [mono-threads] Replace thread w32handle use by event
This allows use to remove the MonoThreadInfo dependency on the w32handle on posix.
* [w32handle] Move them to metadata
w32handle are purely for managed support, and they shouldn't be used in the runtime.
* [mono-threads] Factor open/close thread handle
* [mono-threads] Factor exit thread
* [mono-threads] Factor platform register/unregister thread
* [mono-threads] Use ThreadHandle on all platforms
* [threads] Fix mutex abandonning for main thread
According to the comment, the intent is to abandon the mutex hold by the current thread. This intent was conveyed by the previous code when the threading code was still in the io-layer.
* [runtime] Introduce a new mono_class_init_sizes () function which initializes only the instance fields without initializing fields if possible. Use it in a few places instead of mono_class_init ()/mono_class_setup_fields ().
* [runtime] Simplify mono_class_has_references (), it doesn't have to special case the init_pending case.
* [runtime] Use a TLS list instead of the 'init_pending' flag to detect recursion in mono_class_init ().
* [runtime] Reduce the size of the critical section in mono_class_init () by doing most of the work outside the lock.
* [runtime] Avoid loading cached class info for pointer etc. types.
* [runtime] Reduce the locking inside setup_interface_offsets ().
Because certain platform (such as WatchOS) do not support syscall abort, we need to ensure that it is supported before we call the `mono_threads_suspend_abort_syscall` function.
* [sgen] Add stress test
This hope to suspend a thread while it is in the process of attaching or detaching.
* [sgen] Fix unified suspend
This would cause a crash with unified suspend: if a thread would be suspended at mono-threads.c:1168, the stack_start would be greater than the stack_end, triggering the g_error at sgen-stw.c:351. The stack_end would initially be initialized in `sgen_client_thread_register`, but it would be overriden in start_wrapper at threads.c:893.
What was happening is that we set the stream EOF flag to true when we
could not read any more input data, and that made us early out before
fully finishing the processing of the compressed data.
Now the only EOF flag is set to true is if zlib's inflate() has actually
finished processing the data.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44994#c2.
* [suspend] Remove sgen specific suspend code
* [sgen] Remove unused SgenClientThreadInfo->stopped_domain field
* [sgen] Remove unused SgenClientThreadInfo->stopped_ip field
* [threads] Unsplit code for syscall abort
* [threads] Reuse posix suspend signal handler function for abort
* [mono-threads] Move debug printf to separate file
This is to avoid recompiling half of the runtime for every change to these printf.
* [stw] Slightly improve logging
* [mono-threads] Fix unified thread suspend
`mono_threads_suspend_begin_async_suspend` return FALSE iff it coudn't successfully suspend the thread, not if the thread is not in the correct state. The latter is checked by calling `mono_threads_suspend_check_suspend_result` which will return FALSE if we couldn't initialize the state of the suspended thread.
* [mono-threads] Fix unified thread suspend
If we try to suspend a thread that is still attaching, we might suspend it after it allocated the MonoInternalThread and MonoThread, but before it set the current domain or lmf. This would lead us to not scan the thread stack, which would lead to collect the newly allocate MonoInternalThread/MonoThread, leading to a crash. By letting sgen deal with the thread, even if the domain or the lmf is not set, we avoid this bug.
This makes unified suspend have the same behaviour as the previous sgen specific suspend.
* [mono-threads] Fix compilation
This implements the icalls in file-mmap-windows.c used by MemoryMappedFile.
The implementation has been inspired by the CoreFX MemoryMappedFile
implementation.
This patch also fixes a few incompatibilities between .NET and Mono:
* The default MemoryMappedFileOptions has been changed from DelayAllocatePages
to None.
* mono_pagesize() on Windows now return SYSTEM_INFO.dwPageSize, the same as
.NET and CoreFX.
* Added mono_valloc_granule() which returns
SYSTEM_INFO.dwAllocationGranularity and changed mono-codeman.c to use it
when trying to allocate adjacent virtual memory.
* MemoryMappedFileTest has been updated to succeed on .NET.
* A test has been added to test correct DelayAllocatePages behavior (only
supported on Mono on Windows, the flag is ignored on other platforms).
* The posix MemoryMappedFile code has been changed to throw
UnauthorizedAccessException rather than IOException when trying to create a
view outside of the bounds of a MemoryMappedFile.
* Creating a named mapping larger than 4GB on 32-bit systems now throws
ArgumentOutOfRangeException.
After 2fb07d6c6d BTLS can be used as a shared lib,
but this caused an issue in some monotouch tools which grepped the P/Invokes for `__Internal`
since these icalls wouldn't resolve on monotouch since BTLS is disabled there.
Instead, we now completely leave out building the managed parts of BTLS when
BTLS is not enabled.
The MacProxy class uses CFNetwork, but since CFNetwork is not a public
framework on watchOS, we can't use it.
So remove MacProxy completely (it only contains internal classes), and throw
PlatformNotSupportedException in any API that used it (the managed networking
stack is not supported on watchOS anyway, so this should be safe).
https://bugzilla.xamarin.com/show_bug.cgi?id=45847
* [btls] Convert BTLS icalls to pinvokes by invoking them using [DllImport("__Internal")], which will make it easier to redirect them to a separate dylib in the future.
* [btls] Add a --enable-dynamic-btls configure flag to enable compiling btls into a separate shared library instead of embedding it into the runtime.
In mono_assembly_load_from_full, the call to
mono_assembly_has_reference_assembly_attribute has to come after
image->assembly is set. This is because image->assembly->base_dir is
used for probing for referenced assemblies, and the reference assembly
attribute check will probe for assemblies referenced by the custom
attributes on the assembly in image being loaded.
Add 'ignore_missing' argument to mono_custom_attrs_from_index_checked:
if it is TRUE, a single custom attribute constructor that can't be
resolved to a MonoMethod won't cause the whole method to return NULL.
if 'ignore_missing' is FALSE, use existing behavior.
Updated all the call sites to pass FALSE, except
mono_custom_attrs_from_assembly_checked which also gets a new
'ignore_missing' arg.
Updated 'mono_assembly_has_reference_assembly_attribute to pass TRUE for
ignore_missing.
* Use Windows Runtime event related classes from Reference Source and implement couple missing methods needed for Windows Runtime event suppor
* Add native stubs for newly added icalls.
* Attempt to fix build on non-windows
* Attempt to fix mscorlib build when COM is disabled.
* Revert "Attempt to fix mscorlib build when COM is disabled."
This reverts commit 5befc13b5ee7283fc4f19bd706389496c139790f.
* System.Type::IsWindowsRuntimeObjectProperty is under "FEATURE_COMINTEROP || MONO_COM", so its callers should be under it too.
* Fix build failure due to a semantic merge conflict with b313769878
The ReleaseHandle() methods tries to deallocate the handle as if it was a
pointer to heap memory. But on Windows it's a HANDLE. The call to
Marshal.FreeHGlobal() causes a crash on Windows. It doesn't crash on other
platforms probably due to the emulated handles which are indeed heap allocated
memory objects. But the underlying file descriptor is never closed so there
should be a file descriptor leak on other platforms.
This patch fixes the issue by calling MonoIO.Close() on the handle rather than
Marshal.FreeHGlobal()
SecPolicyCreateSSL() distinguishes between an empty string (validation will fail
if the certificate contains host name constraints) and a null pointer (no host name
checking will be performed) for the hostname.
We incorrectly used `string.IsNullOrEmpty (host)` in a few places.
* UTF8 Marshaling APIs (#3736)
Adds support for the new UTF8 marshaling functionality in .NET, there
is support for the new MarshalAs(UnmanagedType.LPUTF8St) as well as a
handful of convenience methods in Marshal.cs
In Mono, this is mostly a pass-through as we have historically only
done UTF8, so this merely adds the constant processing to the runtime.
This fixes a few bugs that the new test suite exhibited: when we
marshaled UTF8 strings, we assumed Chars() == Bytes() and we would end
up chopping when marshaling out, and marshaling in.
There is also an additional behavioral bug that was fixed in
Marshal.cs, unlike the rest of the runtime that treated Ansi as Utf8,
StringToCoTaskMemAnsi behaved as ascii. This brings the API in line
with the rest of the runtime.
The equivalent CoreCLR changes were:
dotnet/coreclr#4793dotnet/coreclr#6561
This has also surfaced two limitations in Mono's marshaling code,
which is why two sets of tests are disabled: StringBuilder return
types are not handled specially (char * needs to be turned into a new
StringBuilder when present) and StringBuilders with an Out attribute
should update the StringBuilder in place, not make a new copy of it.
This is done by adding a new argument to install specific named custom handlers,
--handlers=. There is also an argument to describe the supported handlers on current
platform, --help-handlers.
The supported handlers can be different depending on implementing platform and currently
only Windows uses this feature to install an atexit handler waiting for a keypress
before exiting process. This is however a generic concept that could be used to run handler
code early in the boot process on any platform for other purposes. Adding the argument first
in command line makes it possible to do the installation very early in the boot process, this
is used by the waitkeypress atexit handler in order to be used in cases where the arguments
itself are unsupported or incorrect formatted causing an exit of the process.
When running under Visual Studio debugger the console window will not be kept
open when the debugee process terminates. Normally this is not a problem, but there are scenarios,
especially when having errors in configuration, when you would like the console to be kept open so
you can read the output in order to detect the error.
Normally there is an option to start the console application from within Visual Studio but
not attaching the debugger (CTRL+F5) and by default Visual Studio will then inject a pause
in the execution of the process holding up the console, but for some reasons, having more
complex solutions like mono, this feature stops working, so it is not possible to keep the console
open in that scenario for more complex solutions.
This makes it a little problematic to hold the process when working within the debugger in order
to look for console output and errors. Since mono can exit the process using exit command and not
only by returning from main, the developer needs to set breakpoints on both end of main and in c-runtime
exit methods. Even if that is a possible workaround this option won't work when running the process outside
the debugger (CTRL+F5).
This commit adds a handler argument that can be used on Windows (potential on other platforms as well), atexit-waitkeypress.
The waitkeypress will hold the console and process open until a key is pressed and is very
useful when running and debugging mono from within Visual Studio. Example of output when running mono’s mono-mini-regression-test
with an assembly not found together with –handlers=atexit-waitkeypress command line argument:
failed to load assembly: gshared-nofound.exe
Overall results: tests: 0, 100% pass, opt combinations: 25
Press any key to continue . . .
Currently this is only implemented for Windows, but could be enabled for other platforms,
if similar need exist elsewhere.
Since this is a standard mono command line option it is possible to inject it using the MONO_ENV_OPTIONS environment variable as well.
* [aot-compiler] Cleanup GSharedVT check
* [aot-compiler] Enable partial sharing for hybrid AOT
* [aot] Enable GSharedVT for Android
* [aot] Ensure GSharedVT is supported at runtime as well as compile time
* [aot] Factor aot mode setting
An assembly with a System.Runtime.CompilerServices.ReferenceAssemblyAttribute
may be loaded in a reflection-only context, but not for execution.
When loading assembly refs, or when loading assemblies by name (as
opposed to file path), a reference assembly will be skipped over and
other assemblies from the GAC and the load path will be tried.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42584
The code in RemoveAt doesn't update the focused item index, if the focused
item is the last item in the list and another item is removed.
The next time an item is removed, the focused item index is equal to Count
and an ArgumentOutOfRangeException is thrown.
Removing a selected item from one ListView and adding the same item to
another ListView, an IndexOutOfBounds exception was thrown, if the second
ListView has fewer elements than the first one. That's because the
DisplayIndex still contained the index from the first ListView.
information about network interfaces from the /sys filesystem. Google
placed restrictions on two files used by the Mono BCL to read
information about the interface:
/sys/class/net/[DEVICE]/flags
/sys/class/net/[DEVICE]/operstate
The information we used to read from `flags` let us determine whether
the interface supports multicast and the `operstate` file provided us
with detailed information on the current device state.
Additionally, it is now impossible to read the hardware MAC address used
by any interface. This bit of information is also unavailable when using
the Java APIs and therefore applications running on devices with API
24 (and possibly newer) will not be able to access this information.
More details about the issue are available from the upstream Android
bug:
https://code.google.com/p/android/issues/detail?id=205565
In order to obtain the required information, we now need to use the Java
APIs on devices with API 24+ and this commit implements the backend to
retrieve this information. It is done in C in order to avoid overhead of
creating mirror .NET objects when calling Java, thus saving time and
memory during an operation which may be performed by some applications
quite frequently.
This patch implements code that calls into the Xamarin.Android
runtime when runnin under API24 or newer to obtain the information.
Part of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=44296
Without it mcs would've printed the following error for code like `const int val = 1.42f`
on a system where the decimal separator is not the dot, e.g. German:
```
test.cs(3,18): error CS0031: Constant value `1,42' cannot be converted to a `int'
```
It was replaced with --full-aot in ba99fd8334,
but there were still two places left that talked about the old option which leads to confusion.
Also updated the link to Xamarin docs to the current URL.
* [runtime] Improve the locking in mono_class_setup_basic_field_info ().
Compute all the required information outside the lock and install it inside the lock. Remove mono_class_setup_basic_field_info_locking () function which is no longer needed.
* [runtime] Move the special case of no fields from mono_class_setup_fields () to mono_class_layout_fields ().
* [runtime] Move the computation of klass->blittable and klass->element_class/cast_class for enums to mono_class_layout_fields () so it can be used for dynamic types as well.
* [runtime] Make typebuilder_setup_fields () initilize the same data as mono_class_setup_fields ().
* [runtime] Move more common code into mono_class_layout_fields () from mono_class_setup_fields () and typebuilder_setup_fields ().
* [runtime] Avoid infinite recursion in mono_class_setup_fields () by storing the classes under initialization in a TLS list instead of using the racy klass->setup_fields_called flag.
* [runtime] Reduce the amount of locking in mono_class_setup_fields () to the call to mono_class_layout_fields (). Remove mono_class_setup_fields_locking ().
* [runtime] Remove a special case for no fields from mono_class_layout_fields (), the normal code can handle it.
* [runtime] Reorganize mono_class_layout_fields () so it makes all modifications to the MonoClass instance in one place.
* [runtime] Reduce the amounrt of locking in mono_class_layout_fields ().
* [runtime] Remove some compiler context code.
Adds support for the new UTF8 marshaling functionality in .NET, there is support for the new MarshalAs(UnmanagedType.LPUTF8St) as well as a handful of convenience methods in Marshal.cs
In Mono, this is mostly a pass-through as we have historically only done
UTF8, so this merely adds the constant processing to the runtime.
This fixes a few bugs that the new test suite exhibited: when we marshaled UTF8 strings, we assumed Chars() == Bytes() and we would end up chopping when marshaling out, and marshaling in.
There is also an additional behavioral bug that was fixed in Marshal.cs, unlike the rest of the runtime that treated Ansi as Utf8, StringToCoTaskMemAnsi behaved as ascii. This brings the API in line with the rest of the runtime.
The equivalent CoreCLR changes were:
dotnet/coreclr#4793dotnet/coreclr#6561
This has also surfaced two limitations in Mono's marshaling code, which is why two sets of tests are disabled: StringBuilder return types are not handled specially (char * needs to be turned into a new StringBuilder when present) and StringBuilders with an Out attribute should update the StringBuilder in place, not make a new copy of it.
This includes all distributable packages,patches etc. Toolchain packages remain part of the bockbuild repository.
The profiles were also renamed:
'mono-mac-release' -> 'mac-sdk'
'mono-mac-xamarin' -> 'mac-sdk-xamarin'
* [System]: Move MonoBtlsProvider.IsSupported() -> MonoTlsProviderFactory.IsBtlsSupported().
Move the intern-call which is used to determine whether we're using BTLS out of MonoBtlsProvider
to allow the managed linker to eliminate the Mono.Btls.* classes when it's not supported.
* Fix Android build.
(cherry picked from commit 90699022b6)
Enviroment::get_bundled_machine_config icall should be ves_icall_System_Environment_get_bundled_machine_config.
Mark all icalls doing get_bundled_machine_config as ICALL_EXPORT so maccore can link them in/out.
When connecting to an FTP server we weren't handling the RFC2428
extension to the FTP protocol which allows connections over IPv6
for the data channel.
We'd try to connect via IPv4 and the server would return an error
saying that this protocol is not supported.
The fix is to add handling for the protocol extension, namely
to use EPSV (for passive FTP) or EPRT (for active FTP) when opening
the data channel and send/parse the IPv6 addresses.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44025
Note: we're now using the IP address of the the control channel we connected to for the
data channel instead of the address that is returned by the server in the FTP response message.
The reason is that for EPSV there's no IP returned by the server, and it should be
more reliable for normal PASV as well since the server might not know the
correct external address. This is also what MS does in referencesource.
Without arguments, 'cert-sync' now operates on the old certificate store
again, like it was before. To test BTLS, you need to explicitly run it
with '--btls'.
(cherry picked from commit 46379bda6d)
This patch adds the zlib functions needed by ZipSharp to the VS
MonoPosixHelper.def export file.
This patch also changes the ZipSharp code to use different code paths
depending on the size of the C long type on the underlying platform. On
gcc/clang the C long type follows the bitness of the targeted architecture,
it's 32-bit on 32-bit systems and 64-bit on 64-bit systems. With the VS
compiler however, the C long type is always 32-bit regardless of the target
architecture. zlib and minizip uses C long in a number of different function
signatures and structs.
There is no point in asserting if we encounter an unhandled long op. These ops may still get removed, if emulated later on, or maybe from other passes. Asserting happens as a last resort when emitting the native code for the method.
The epoch is specified as being in UTC, but the DateTime(int, int, int) constructor
creates a DateTime with an 'Unspecified' timezone, which could lead to problems later on.
In mono_btls_x509_get_serial_number(), first call i2c_ASN1_INTEGER()
which takes care of padding and computing the 2s complement for negative
numbers, then reverse the buffer.
(cherry picked from commit 1a55680bfa)
There seems to be a race in some tests in the System test suite that use
SocketResponder on Windows. Some tests fail with an exception that the socket
has been closed before they get a chance to see the response sent by the
SocketResponder. The same happens occasionally when using SocketResponder on
.NET. This patch changes the order of the Socket.Shutdown() calls and adds a
Socket.Receive() before Shutdown() is called to give the sender a chance to
actually send any data before the responder shuts down and closes its side of
the connection.
We weren't checking whether a PE file is in PE32 or PE32+ format,
causing us to use the PE32 offsets on the newer format as well.
This means that using Process.Start() on a managed assembly didn't
always work when a PE32+ file was in play. Such a file is created
when targeting x64 e.g. via the -platform:x64 csc.exe/mcs option.
The reason why we probably didn't notice until now is that in an
assembly produced by mcs there happens to be some data at the PE32
CLR header offset even in a PE32+ file, causing the check to "work".
This doesn't apply to csc.exe/roslyn though and so we couldn't
execute those assemblies via Process.Start() even though they're
perfectly managed. Since the .NET Core project.json toolchain
produces x64-targeted assemblies by default more people ran into
the issue trying to run those on Mono: https://github.com/cake-build/cake/issues/1247
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=44937
PE/COFF spec at https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx
* [SRE] Set the wastypebuilder flag on completed generic param builder classes to remove a workaround from mono_type_get_object_checked ().
* [SRE] Remove unused verify_safe_for_managed_space () function.
In https://github.com/mono/mono/pull/1528 the DoAssemblyResolve method was changed
from two parameters to three, but the code in aot-compiler.c was not updated to match.
This second commit adds functions to socket-io.c which uses
WSAEventSelect()/WSAWaitForMultipleEvents() or overlapped I/O to make
potentielly blocking socket calls interruptible (alertable).
On Windows the MonoToolsLocator tries to determine which mono.exe
to use by looking at the current process. Due to problems with
AppDomains and shadow copying (which happens in System.Web) we
could not use this approach. Instead we now call GetModuleFileName
directly using p-invoke to get the exe file of the running process.
This is only used when running on Windows.
This first commit changes the signatures of the icalls for blocking socket
calls in Socket to propagate whether the socket call should block or not. This
is required since it's not possible on Windows through any native API to
determine whether a socket is in blocking or non-blocking mode.
This commit also adds the necessary RegisterForBlockingSyscall() guards to the
Socket.SendFile_internal() method which takes a WSABUF array. Without this
calls to this method won't be signaled when the Socket is closed.
This commit also fixes the error handling in the Socket.SendFile() method to
not rely on WSAGetLastError(). It's likely to have been overwritten between
when the error is generated and the WSAGetLastError() call from managed code.
Setting the MONO_TLS_PROVIDER env var in the testing script makes it opaque to the
babysitter and other processing scripts. By setting it in a new subshell we can
ensure that the scripts see the whole invocation.
needs HANDLES
The method (which also goes by
System.Configuration.DefaultConfig:get_bundled_machine_config) was
converted to use coop handles earlier, but we missed this declaration.
The symbolicate tests compare stack traces generated by the mono-symbolicate
tool against expected stack traces. The expected stack trace files have been
preprocessed to remove absolute paths and the Makefile does the same with the
output from the tool. However, the preprocessing doesn't take different
directory separator characters into account. This patch adds a 'tr' command to
the Makefile which converts \ -> / before the absolute paths are filtered out
from the actual output from the tool to make the comparison succeed on Windows
as well.
RS takes the stance that redirected streams should not be closed by the Process class because they might
be referenced from the outside.
That would be ok if it was true. If you use Process::BeginOutputReadLine, the output stream becomes inaccessible
with no way to dispose them by any mean but GC.Collect. You get an exception when accessing Process::StandardOutput
once async reading starts.
This change addresses the case where the streams are not accessible. This is tracked by the *StreamReadMode variables
that are set on stream getters or Begin*ReadLine.
These tests are sensitive to differences in line endings between Windows and
other platforms. This patch changes the diff commands used on Windows to
ignore changes in whitespaces at end of lines.
* [BTLS]: Allow fallback to MX.X509Certificate in X509CertificateImplBtls.
* [BTLS]: Fix X509Certificate2.MonoCertificate.
* X509Certificate2Impl.FallbackImpl: make abstract.
* X509Helper2.GetMonoCertificate(): new internal helper method.
* X509Certificate2.MonoCertificate: use X509Helper2.GetMonoCertificate().
This is only used by X509ChainImplMono; we should investigate whether we
could implement the missing APIs in BTLS.
* [BTLS]: Fully implement X509CertificateImplBtls.Import() and use correct semantics.
.NET's X509Certificate2.Import() uses several implicit fallbacks which we previously
did not handle in BTLS.
* you may provide a (unused) password when importing an unencrypted PKCS#8.
* when using null as password, it will attempt to use string.Empty if importing
without password fails.
* [BTLS]: Implement X509CertificateImplBtls.PrivateKey.
* [BTLS]: Implement X509CertificateImplBtls.Export().
* [BTLS]: Implement X509CertificateImplBtls.Verify().
* [BTLS]: Fix X500DistinguishedName quoting.
* MonoBtlsUtils: don't quote special chars in UTF-16 strings.
* X500DistinguishedName: don't decode raw data when passed in a name.
* [ci] Test System.dll with both the legacy and btls TLS provider
* [ci] Only run the additional btls System.dll test run on OSX for now
Otherwise we might run it on platforms where btls isn't supported yet and get errors.
(cherry picked from commit 9638ee9ece)
Use a single bit MonoClass::has_failure to represent whether a class has
failed. Store detailed error message in MONO_CLASS_PROP_EXCEPTION_DATA property
in the MonoImage of the class.
Disable WebOperationsContextTest.Current like on monotouch, it relies on dynamic code generation.
The namedmutex-destroy-race.cs runtime test doesn't work on mobile_static since we don't have named Mutexes.
The usual MonoError is suitable as a short-lived stack-allocated error
with a lifetime confined to a function call.
Internally it performs allocations using g_malloc/g_free.
The MonoErrorBoxed is a mempool-allocated error whose lifetime is tied
to the lifetime of a MonoImage.
We provide two operations:
1. MonoErrorBoxed* mono_error_box (MonoError *ierror, MonoImage *image);
Creates a new boxed error in the given mempool from MonoError.
It does not alter ierror, so you still have to clean it up with
mono_error_cleanup or mono_error_convert_to_exception or another such function.
2. gboolean mono_error_set_from_boxed (MonoError *oerror, MonoErrorBoxed *from_box);
Sets the error condition in the oerror from the contents of the given
boxed error. Does not alter the boxed error, so it can be used in a
future call to mono_error_set_from_boxed as needed. The oerror
should've been previously initialized with mono_error_init, as usual.
The block size for a slot size is the minimum block size that can fit two slots. Make sure the computation accounts for the fact that even though a slot size might fit twice in the block, it still has to be allocated at aligned addresses, so it can end up using a higher block size.
Fixes 44922.
The MonoBtlsProvider.IsSupported() icalls ves_icall_Mono_Btls_Provider_IsSupported()
needs to be available whether BTLS is available or not because it is used at
runtime to decide whether or not to enable BTLS.
(cherry picked from commit 7b2a96fbd3)
* [System.Data] System.Data.SqlClient is not supported in watchOS.
System.Data.SqlClient is not supported in watchOS, because it depends on a
working managed networking stack, which we don't have on watchOS.
* [System] Throw PlatformNotSupportedExceptions in the networking stack for watchOS.
* [System] Don't reference/build Mono.Security.dll when building for watchOS.
This means we can't build Mono.Data.Tds.dll either, since it uses
Mono.Security.dll extensively. In any case Mono.Data.Tds.dll is useless
without a working networking stack, and since it's a Mono-only dll (i.e. not
part of netstandard or facades), just remove the entire assembly from the
watchOS profile.
System.Security.dll uses Mono.Security.dll as well, but the required classes
are available inside mscorlib.dll (as internal classes), so just open up
mscorlib internals to System.Security.dll.
* [System] Update tests after API change for watchOS.
* [System.Data] Update tests after API change in watchOS.
* Revert "Fix build break from 81fb20737f810def6dde88d87a1b2f23cdb736c3"
This reverts commit f4475ff013.
* Fix missing trailing newline in monotouch_watch_System.dll.sources
It breaks the build on Linux if the newline is missing.
* Don't invoke undefined behavior if an fd is >= FD_SETSIZE.
* Allow multiple command sockets.
* Close the command socket(s) on shutdown.
* Properly run cleanup logic on shutdown.
We need it in all cases now that we use it to periodically flush all buffers.
The only platforms it was disabled on was NaCl, which we haven't bothered to
support in a while anyway.
This also has the nice effect of reducing the amount of times we attempt to
take the reader lock. Now we take it and release it once for a single event.
Only in very few situations is it okay to access this field without first
taking the reader lock or exclusive lock.
Fixes some crashes observed in the profiler stress tests.
This avoids exposing the SGen worker threads through the profiler APIs. Doing
so had two main problems:
* It's easy for a user of the profiler API to accidentally mess with the state
of the worker thread in all sorts of ways, which could break the GC.
* It's been a long-standing guarantee that any profiler API callback will be
invoked on a thread that is, at the very least, attached to the runtime via
the mono-threads infrastructure. This is not the case for SGen workers.
This fixes a deadlock in the log profiler when using major=marksweep-conc.
* Emit an NUnit test report file.
* Set a timeout of 6 hours per test.
* Do a thread dump for timed-out tests.
* Don't print stdout/stderr for passing tests.
* mono_gc_enable_events: This did nothing for SGen and we called it
unconditionally for Boehm. So no point in having it around.
* mono_gc_enable_alloc_events: The performance difference between checking
a static alloc_events variable versus checking mono_profiler_events is
marginal at best and doesn't justify the indirection, especially now that
we support managed allocators while profiling.
Found by checkbashisms(1) as "unsafe echo with backslash". Some shells don't expand embedded \n in a string by default,
which broke the build on systems like ArchLinux or Alpine where /bin/sh points to those shells because the generated .lo
file contained just a single line instead of two.
Thanks to @JustArchi for researching this on the Mono Gitter channel, it made fixing the issue a lot easier!
Expands to __attribute__((format(printf,X,Y))) with gcc and clang.
Use it to check that printf-like format strings get the correct number
and type of arguments.
* external/boringssl: unmanaged code from Google (added earlier).
* mono/btls: unmanaged BTLS lives here (added earlier).
* System/Mono.Btls: managed BTLS lives here.
* Mono.Btls.Interface: The purpose of this assembly is to allow test suites
such as xamarin/web-tests to test parts of the BTLS APIs without making
System.dll's internals visible. It is not a stable and maintained API.
BTLS uses a different format and naming scheme for the local certificate store.
Before using BTLS for the first time on desktop, you need to convert the local
certificate store by either using the new `btls-cert-sync` tool (which will convert
your existing certificate store to the new new format) or `cert-sync` with the
`--btls` argument.
The new format and naming scheme is identically to what you'll find in
'/system/etc/security/cacerts/' on an Android device. It stores the certificates
in PEM format (with a human-readable text section added) using filenames which
are based on the certificate's subject name hash.
Previously, Mono stored the certificates in binary DER format, using a filename
based on either the Subject-Key-Identifier (if available) or the thumbprint.
We cannot access this from BTLS because computing these filenames requires
reading the entire X509 certificate (including the X509v3 extensions), but
their native lookup code only gives us the SubjectName.
This transitioning won't affect Android users as we're using the system
certificate store (including the user certificate store, via a Java callback).
* Mono.Security.X509.X509Store and X509Stores:
Support both the old and the new format. Using the new format requires BTLS.
* Mono.Security.X509.X509StoreManager:
Add `NewCurrentUserPath` and `NewLocalMachinePath` properties for the
new path names (~/.config/.mono/new-certs).
* Mono.Security.X509.X509StoreManager:
Add `NewCurrentUser` and `NewLocalMachine` properties. Requires BTLS.
* tools/security/cert-sync:
Add new `--btls` argument to use the new store.
Initial work to build libgcmonosgen under none desktop Windows API families.
Changes are mainly related to header files included by libgcmonosgen sources and shared
by other libraries.
* [SRE] Assign pseudo tokens to SRE objects in the BCL instead of doing it in the runtime.
Real tokens are assigned after the dynamic types they depend on have been created, by creating the corresponding finished reflection object
(i.e. a MonoMethod for a MethodOnTypeBuilderInst etc.) and obtaining its token.
In Save mode, this is done in ModuleBuilder.Save ().
In Run mode, this is done on-demand when the JIT tries to resolve a token into its corresponding metadata object, by the runtime calling
the RuntimeResolve () method on the builder object.
* [SRE] Remove dead code.
* [SRE] Remove the MonoGenericMethod/MonoGenericCMethod classes, they have not needed.
* [SRE] Delay the creation of MonoClass-es for MonoGenericClass/GenericTypeParameterBuilder/SymbolType until its needed.
* [SRE] Small code cleanup.
* [SRE] Remove the TypeBuilder.IsGenericParameter () icall, it should return false.
* [SRE] Unify the calling of the various RuntimeResolve () methods by adding a RuntimeResolve () method to ModuleBuilder, and calling that from native code.
* [SRE] Remove unused TypeBuilder::get_event_info () icall.
* [SRE] Remove more unused/empty icalls.
The F_RDAHEAD define seems to be introduced in BSD, being the equivalent of POSIX_FADV_SEQUENTIAL.
This should improve sequential scanning speed by having the read ahead buffer doubled.
* [Mono.Security]: Remove Mono.Security.Interface.IMonoTlsContext.
This interface is not actually used anywhere anymore, so we can also
just get rid of it.
* [System]: Removed unused private TLS classes.
* [Mono.Security]: Cleanup the MonoTlsProvider's certificate validation code.
Each TLS Provider now has its own certificate validator and there is no
automatic fallback anymore. We only have three different TLS Providers,
"legacy", "appletls" and "btls" - and legacy is the only one which used
the managed validator. Both AppleTls and BTLS provider their own validator,
which invokes some native API.
All of the following were internal APIs.
* MonoTlsProvider.HasCustomSystemCertificateValidator has been removed.
* MonoTlsProvider.InvokeSystemCertificateValidator() has been renamed
into ValidateCertificate() and is now abstract.
(cherry picked from commit 63c0803b2b)
* I got confused between [TestFixtureSetup] and [Setup], so fix tests whose
[Setup] methods were changed/removed to properly clean up after each test
(using a [TearDown] method) so that the next time the on-demand creation of
objects works as expected (i.e. objects created in the [Setup] method should
be created on-demand once for each method instead of once for each class).
* Also fix SocketAcceptAsyncTest, the change to properly catch exceptions on
background threads was incorrect.
LegacyTlsProvider now lives in the 'Mono.Net.Security' namespace
(previously 'Mono.Net.Security.Private') and derives directly from
the public 'Mono.Security.Interface.MonoTlsProvider'.
This allows it to be used by products, for instance replacing
xamarin-macios/src/Security/Tls/OldTlsProvider.cs.
The idea is to have all 'MonoTlsProvider' implementations inside
System.dll and not access any of the private APIs from outside of it.
(cherry picked from commit 9437553e54)
When adding an image property, check that the value belongs to the same image.
Ensure that we don't leak the values when the property hashtables are destroyed.
In current eglib test framework there is no mechanism to specify where
the include file describing all tests is located. Current implementation also assumes it is the main
entry point of the process since it defines the main symbol. There are several scenarios
where it could make sense to reuse eglib test framework and its driver in other native unit test projects
unit testing native code. In those scenarios it would be nice to include existing driver.c
from eglib/test (no copy) and use toolchain capabilities to include needed header with test descriptions
and change main symbol name, since main will most likely be defined elsewhere.
This can be achieved by two simple defines that can be set when embedding eglib test framwork in other
native binaries. By default these defines will not be set and current behavior will be preserved.
When running with async suspend (ie, not coop), a user thread might be
suspended while its manipulating the coop handle stack. In that case,
we want to present a consitent view to mono_handle_stack_scan () by
adding memory fences to code that updates the stack chunks. In
particular we want to ensure that the chunk size is increased after
the new slot has a valid (null) value. Also when creating new chunks
make sure their size is initialized before the chunk stack is updated.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43921 (at least the
one stack trace observed in [comment 1](https://bugzilla.xamarin.com/show_bug.cgi?id=43921#c1)).
The "global" TLS Provider (returned by MonoTlsProviderFactory.GetProvider())
may only be modified at application startup (before any of the TLS / Certificate
code has been used).
* MonoTlsProviderFactory.HasProvider has been removed.
This property used to initialize the TLS Subsystem without throwing any
exceptions. However, properties with side-effects is a bad design principle.
* Add MonoTlsProviderFactory.IsInitialized.
Does not have any side-effects.
* Add MonoTlsProviderFactory.Initialize() and Initialize(string).
May only be called at application startup and explicitly initializes the
TLS Subsystem.
* Rename MonoTlsProviderFactory.GetDefaultProvider() into GetProvider()
and removed MonoTlsProviderFactory.GetCurrentProvider().
We do not distinguish between a "default" and a "current" provider anymore;
there is only one "global" provider.
* Add MonoTlsProviderFactory.IsProviderSupported(string).
Checks whether a specific TLS Provider is supported, without having side-effects.
* Make the old APIs [Obsolete] until products have been updated.
* Add some documentation to MonoTlsProviderFactory.
(cherry picked from commit 7c3ae83b31)
llc has some performance problems with large basic blocks so we have to break them up into smaller ones. Use some hacks to prevent opt/llc from merging them back again.
When there is an abstract class in the middle of an inheritance
hierarchy that doesn't override a method, get_base_methods needs to search
the parent class instead aborting early.
Example:
```
abstract class Root {
public abstract void Foo ();
}
abstract class Abs : Root { }
class Derived : Abs {
public override void Foo () { }
}
```
If we ask for the base method of Derived.Foo we used to get Derived.Foo
back because Abs did not provide an override. Instead we should skip
abs and look in Root.
Introduction of the structured trace logger accidentally broke Android
logcat logging. The reason for this is that the default logging handler
defined in eglib (in goutput.c) for Android was never called, instead it
was superseeded by the log file logger defined in mono-logger.c
The net effect was that Mono tried to write the messages to some file on
Android leaving logcat devoid of any trace of life :)
This commit fixes the issue by introducing a set of structured logging
functions for Android.
As a side note - file logging on Android is not that useful. Writing to
a file on external storage medium requires app permissions and writing
to a location on internal storage medium, while allowed, might be
subject to space limitations and should not be used for possibly
voluminous data. It's therefore not very practical on Android.
* [System] Fix line endings for a few files.
Best reviewed by not showing whitespace changes (should be empty diff in that case).
* [System] Fix potential crash in CookieParserTests.
Socket.EndAccept can throw an exception, which will crash the process if it
happens on a threadpool. So handle any exceptions when calling
Socket.EndAccept, and propagate those exceptions out of any threadpool code.
* [System.Net.Http] Throw a PlatformNotSupported exception when using HttpClientHandler on watchOS.
* [System.Net.Http] Tweak tests after watchOS API change.
Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.
* [System] Extract the HttpListenerResponseHelper class to a separate file.
Extract the HttpListenerResponseHelper class to a separate file so that it's
easier to replace the HttpListenerResponse implementation by using a different
file.
* [System] Throw a PlatformNotSupported exception when using the networking stack on watchOS.
* [System] Tweak tests after watchOS API changes.
Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.
* [System] Fix potential crash in SocketAcceptAsyncTest.
Fix potential crash in SocketAcceptAsyncTest by catching any exceptions in
code executed on the threadpool so that we never end up with unhandled
exceptions (which may terminate the process).
* [System] Avoid logic in SetUp attributes in tests.
Any type of exception in [SetUp] attributes causes all tests to fail with that
exception.
This even happens for tests that do not need the logic in the [SetUp]
attribute.
So rewrite tests a bit to not use [SetUp] when we can reasonably avoid it, and
instead instantiate class-level variables on first use. This ensures that any
exceptions that occur when initializing those variables are attributed to the
corresponding test, and not all of them.
* [System] Make exception handler (for test) catch more exceptions to avoid unhandled exceptions causing process termination.
* [System] Remove Obsolete attribute on API that throws PNSE.
This API is provided to be used by libraries providing crash reporting, so
that those libraries can install signal handlers and at the same time not
interfere with Mono's signals.
The intended pattern is this:
Mono.Runtime.RemoveSignalHandlers ();
InstallThirdPartySignalHandlers ();
Mono.Runtime.InstallSignalHandlers ();
This ensures that Mono is always notified first of any signals, and will then
chain to the third-party signal handlers if the signal did not originate in
managed code.
Mono's signals must first be removed, so that if third-party signal handler
does signal chaining, we don't end up in Mono's signal handler again.
Mailing-list thread: http://lists.dot.net/pipermail/macios-devel/2016-September/000016.html [Signal-chaining & crash reporters]
Example usage: https://github.com/rolfbjarne/HockeySDK-Xamarin/commit/862721199f1adec210bfc7b1943f975ffb8048a9
* CertificateValidationHelper.GetDefaultValidator(): rename this internal method into
GetInternalValidator() (keeping the old as [Obsolete] until products have been updated).
* CertificateValidationHelper.GetValidator(): remove the 'provider' argument.
This is part of a set of cleanups and simplifications for the upcoming BTLS integration.
Initial work to build eglib under none desktop Windows API family. Classic
Windows API have been split into families and partitions in order to support
different subsets on different Windows platforms. In order to build against
other Windows targets/platforms Mono needs to follow these families/partitions
in order to successfully build where API’s have been removed/replaced. Since most
Mono platforms uses the Windows API signatures a new defined has been added to all
platforms, HAVE_CLASSIC_WINAPI_SUPPORT, used to decide what implementation to include.
On none Windows platforms this is always defined and on Windows platforms it follows the
winapifamily.h. In order to keep down regressions, the existing API’s are kept for HAVE_CLASSIC_WINAPI_SUPPORT
even if there are more modern replacements available.
For now, concurrent mark runs concurrently with bridge during minors. Since bridge processing might tag object vtables, make sure we don't crash when we scan such objects.
After recent header size change in 883e0a2d89, we had some slot sizes unaligned which was leading to unaligned memory allocation and therefore SIGBUS-es on some ARMs.
We used to have all allocators use 16k blocks and slot sizes optimized for this. After we switched to allocating in 4k, 8k and 16k blocks the slot sizes were not optimized for the new format.
This commit fixes unaligned problems, at the same time optimizing the size of allocator slots.
We now have our own set of Windows bots on our Jenkins CI for building and testing Mono on Windows.
Special thanks to AppVeyor for providing us with build capacity over the last two years <3
It is possible for SSLHandshake() to return SslStatus.Success while we're still
having a pending write (AsyncOperationStatus.WantWrite).
This is because our managed write callback must never return 'WouldBlock', so
SSLHandshake() things that all data have been sent while we still have them in
our write queue.
When this happens, we currently flush the write queue then call SSLHandshake()
again via AsyncOperationStatus.WantWrite -> AsyncOperationStatus.Continue.
This returns SslStatus.Protocol on iOS 10.
Fix outstanding failures in "metadata" checked build mode
Fix two problems with the checked build metadata mode which were causing spurious failures, one a bug introduced by my last commit, one of which has been present since the start:
- Check assemblies in `references[]` are non-NULL before looking up their images
- A "from" imageset only needs to reference every image in the "to" imageset, it does not need to actually contain every image.
Also added support for a checked build jenkins lane.
This is important as platform unregister is where we signal the thread handle, and that should be done as late as possible, but still before we switch the thread state to DETACHED and remove it from the thread list.
The fact that we do under the suspend lock shouldn't be an issue as we shouldn't call in any other code than w32handle code.
An imageset can reference another imageset if every image in the "to"
imageset is referenced by some image in the "from" imageset.
Previously the checked build code was requiring the stricter criteria
of every image in the "to" imageset being present in the "from"
imageset, which was not only inconsistent with image->imageset and
imageset->image reference checking, but lead to spurious failures.
An example of a scenario where the previous check logic would fail is:
Assembly A:
class ClassA<T>
Assembly B:
class ClassB<T> extends ClassA<T>, ClassB2
Attempting to run the constructor for ClassB<ClassB2> would result in
a pointer to memory in imageset [A,B] being written into a structure
located in imageset [B]. This is valid since B references A, however
the MONO_CHECK_MODE=metadata checker would flag it as an error.
* In the .NET implementation of TcpServerChannel, if IPv4 is supported, the address for the host will use the first IPv4 address.
* Even if the first address is an IPv6 address, it should be skipped, as the server side will expect and IPv4 address.
* Change this implementation to look for an IPv4 address first, then fall back to whatever the first address is (IPv4 or IPv6) if things don't work out.
* [mkbundle] add support for bundling native libraries
* [glib] add g_mkdtemp
* mono: Load the various library payloads for bundled executables
* [msvc] Export mono_dl_open and mono_loader_register_module
* Remove Mono.Security.Providers.NewSystemSource and Mono.Security.Providers.NewTls.
* Remove InternalVisible for "Xamarin.BoringTls".
* Remove Mono.Security.Providers.OldTls and Mono.Security.Providers.DotNet.
(cherry picked from commit 7b7b7c9b64)
* gacutil should use System.Reflection.Assembly.ReflectionOnlyLoadFrom() since it doesn't need to run the assemblies;
* but in fact, it could also use a managed reflection library. So in this PR we change it to use IKVM.Reflection
* [w32handle] Fix race condition
* [w32mutex] Improve logging
* [w32mutex] Only add to owned mutex when we own it for the first time
* [w32mutex] Move own/disown code to w32mutex-unix.c
The read-only nature of Win32IPAddressCollection is handled by
the base class IPAddressCollection. Therefor removing the read-only
handling in this class and use InternalAdd from base class instead.
This race condition has been introduced with 348d793ebb. This is because we would wait on the cleanup_semaphore outside of the threadpool->domains_lock lock.
By using a cond variable instead of a semaphore, we avoid a potential deadlock.
- mono_assembly_load_module was not following MONO_RT_EXTERNAL_ONLY
rules
- New _checked methods were not following init rules
- module[] load code was botched
Right now, we use a special token in mono/config which replaces $mono_libdir with the runtime-detected assemblies lib dir - e.g. /usr/lib
Unfortunately, this does not handle cases where a --libdir= value is passed to configure, such as on Red Hat where they use --libdir=/usr/lib64 on AMD64
We already have a variable from configure - reloc_libdir - so introduce some helpers to use it in the $mono_libdir replacement.
This assumes the value of --libdir is a subdirectory of --prefix, but I doubt we have ever worked at all when that is not the case.
Fixes: #41953
* [threads] Use mono_thread_detach_internal to factor code
* [threads] Make sure we detach the thread before exiting
* [threads] Add mono_thread_internal_current_is_attached
* [threads] Ensure we detach the thread on Boehm
When registering profile counters on optimized Windows build you will get the following logging twice:
"you are registering twice the same counter address"
This happens since the optimizer will collapse cpu_load_1min, cpu_load_5min and cpu_load15min into
the same function on optimized Windows builds and that is not expected by register_internal.
By preventing inlining of cpu_load we can keep the different callback methods unique and optimizer
won't fold them into one single representation in the final binary.
This test is sensitive to the line ending mode used by git. When LF is used by
git (which is what Cygwin's git defaults to) this test fails on Windows since
CRLF will be used as line ending in the serialized XML. This patch changes the
test to use Environment.NewLine explicitly in the expected string.
This is something I noticed while following up on an issue with
mcs/tests/test-418.exe. The ECMA-335 spec contains the text:
"Usually, a module belongs only to one assembly, but it is
possible to share it across assemblies. When assembly A is loaded at
runtime, an instance of M3 will be loaded for it. When assembly B is
loaded into the same application domain, possibly simultaneously with
assembly A, M3 will be shared for both assemblies. Both assemblies
also reference F2, for which similar rules apply."
What happens in Mono when two assemblies both load the same module? We
never planned for that possibility in our architecture. Looking at our
current code, when an assembly image loads a module image into its
modules[] or files[] array, it immediately sets the "assembly" field
of that module to its own MonoAssembly. This field is a plain C
pointer with no safety on it whatsoever, and is references in various
places including by icalls. Consider the following scenario:
- Assembly A is loaded, references module M3, sets M3->assembly to
A->assembly.
- Assembly B is loaded, references module M3, sets M3->assembly to
b->assembly.
- Assembly B is unloaded.
At this point the image for B is unloaded, but M3 is still alive
because A keeps it alive, and its image contains a C pointer to freed
memory. There is likely some way to trigger a crash from this point.
Because the above scenario is fairly exotic, I dealt with it by just
causing the module loader to detect when multiple assemblies are
referencing the same module and throwing an exception in this case. I
also added a test to verify the exception is thrown. Allowing the
module load to raise an exception required adding _checked versions of
several functions.
Test mcs/tests/test-418.exe was failing when running a checked build
with MONO_CHECK_MODE=metadata. I audited how images track their
modules and fixed the following issues:
1. The checked build metadata "reference audit" was following
references stored in the "modules" field, but not the "files" field. I
changed the audit code to follow both.
2. Loading a module into the "modules[]" field was causing a leak
because mono_image_addref() was being called after
mono_image_open_full(), even though mono_image_open_full itself
returns the module +1. I removed the addref.
3. Loading a module into the "files[]" field was causing a leak
because we were opening the module with mono_image_open_full and then
never attempting to close it. I modified our image close to do the
same thing to "files[]" we do to "modules[]".
In order for 1 and 3 to work, I modified MonoImages to track the size
of the "files[]" field.
Mono.Cecil.Mdb is not installed with mono.
Instead of reference Mono.Cecil.Mdb we now add its sources directly.
Mono.Cecil internals are visible to Mono.Cecil.Mdb, but not to
mono-symbolicate so we add Mono.Cecil source too.
Fixes mono-symbolicate not working with installed mono.
Windows to launch the child mono process
The 'mono' shell script generated by the Cygwin make file system doesn't work
when running the soft debugger tests against an MSVC built mono executable.
This patch first tries with the main module of the current process when
running on Windows (and mono is built using MSVC). If it looks like a mono
executable the tests will use it before falling back to the shell script.
Satellite assemblies are special in that they all share the same file
name, but they live in separate directories named after the locale the
satellite assemblies pack. mkbundle currently doesn't support "clashing"
assembly filenames and will not be able to store the satellite
assemblies in the bundle for that reason.
This patch adds support for storing satellite assemblies with their
culture path prefix (e.g. en-US/MyAssembly.resources.dll) in the bundle
and also special code in the assembly loader to support such filenames
in the code which loads assemblies from the bundle.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=27061
Administrator
This test fails when running as Administrator since Administrator CAN set the
owner to Everyone. This patch ignores the test when running as Administrator.
The check has to be done after the File.SetAccessControl() call that is
expected to fail since when we aren't running as Administrator the IsInRole()
check will trigger UAC which we need to prevent when possible.
This was keeping around potentially many unused gray queue sections, or even constantly leaking in the case of many majors since every time we start a concurrent major we redirect some additional gray queue sections from main to worker thread gray queues, leading to unbounded growth. The gc thread always trims its gray queues at the end of the collection.
On graph8 this reduces memory usage by 5%. Fixes mem leak from #41995
A few tests are currently ignored when running on a system where the default
culture isn't "en" or "en-US". This patch changes Culture attributes to
SetCulture attributes instead to make those tests run on all system and make
NUnit set the culture to the required one during the test run.
Also found and fixed a test failure in one of these methods,
DateTimeTest.ToUniversalTime_TimeZoneOffsetShouldNotOverflow(), which assumed
the minimum year is 0 while it's actually 1. Confirmed that this is the case
on .NET as well.
The _notifyResetEvent could be closed and nulled and the
NotifyEventThread would still try to read from the event log.
Also multiple calls to EnableNotification would cause issues.
With this fix, we make sure only one notify event thread is
running and that we thread safe the disabling of notifications.
When a thread owning a mutex doesn't release it before it exits and a second
thread tries to take it using e.g. Mutex.WaitOne() an AbandonedMutexException
should be thrown. This is what .NET and Mono on Windows does.
This commit builds on the work done in PR #2267, which modifies the Win32
emulation of WaitForSingleObjectEx(), SignalObjectAndWait() and
WaitForMultipleObjectsEx() to return WAIT_ABANDONED_0 when expected, and
updates it to the current HEAD. It also adds a few test methods to
WaitHandleTest that test that WaitHandle.WaitAny() and WaitHandle.WaitAll()
follows the .NET behaviour.
When a thread owning a mutex doesn't release it before it exits and a second
thread tries to take it using e.g. Mutex.WaitOne() an AbandonedMutexException
should be thrown. This is what .NET and Mono on Windows does.
This commit adds the infrastructure needed in the Win32 emulation layer to
coomunicate that a mutex has been abandoned. It builds on the work done in
PR #2267 and updates it to the current HEAD.
TimeZoneInfo.GetDaylightChanges() didn't work as expected when run against the
time zone data available in Windows.
This patch also enables most of the time zone related tests that were
previously ignored when not run on Unix platforms. Time zone ids will now be
mapped from tz db time zone names to Windows time zone names when needed so
that most of the tests can be run on Mono on Windows as well.
This code path has not been used for a while now, as mono_os_(mutex|cond)_destroy return -1 in case of error, and not EBUSY.
This is also the only code path that would check the return value, so we can simply remove the returned value, and assert on the error.
The generic setter receives the element by reference which means we will never emit the write barrier since a reference to a reference is not a reference (mini_type_is_reference). Check the actual value instead. Fixes#42903.
Previously the tests were written so that some failures might occur on the
threadpool in methods that did not catch exceptions. In that case the process
would terminate due to an unhandled exception. So rewrite the tests to catch
exceptions in any code that doesn't run on the main thread, and forward those
exceptions to the main thread.
Also wait for async operations to complete on the main thread, and remove
asserts that are not supposed to be hit.
behaviour when passed times within the lost period at DST start
When passed a time within this period .NET's IsDaylightSavingTime() returns
true while GetUtcOffset() returns the BaseUtcOffset without the DST delta
added. This patch changes the behaviour in Mono to do what .NET does.
* [mono-threads] Remove MonoThreadParm.creation_flags
* [mono-threads] Remove MonoThreadParm.priority and set to MONO_THREAD_PRIORITY_NORMAL by default
* [threads] Wrap use of mono_thread_info_(get|set)_priority
* [threads] Store priority on MonoInternalThread
* [threads] Import mono_thread_info_set_priority
* [mono-threads] Remove MonoThreadParm
[arm64] fixes around icache flushing
This fixes https://bugzilla.xamarin.com/show_bug.cgi?id=39859
The problem in `emit_thunk` and the workarounds for the Cortex A53 errata are unrelated to the bug above, but they don't hurt either.
The basic problem that we see is that the Exynos 8890 SoC (shipped for example in the world edition of the Samsung Galaxy S7) is a big.LITTLE architecture with two different CPUs, four of each. `__clear_cache` of GCC [1], the built-in that we use to flush the instruction cache, correctly reads the cache line sizes for data- and instruction cache from the CPU and then caches that result. However, the two CPUs on the Exynos 8890 have two different cache line sizes for the instruction cache (128 bytes vs. 64 bytes): If we happen to initialize the cache line sizes with the larger one, we only flush every other cache line if the code runs on the second CPU model.
Neither V8 [2] and LLVM [3] do caching of the cache line sizes, but just read it every time from the register. We have a slightly different solution, where we cache _and_ read the value every time and try to determine a global minimum across CPUs, in case we get scheduled to a different CPU by the kernel during the flushing loop.
[1] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.9/libgcc/config/aarch64/sync-cache.c#33
[2] https://github.com/v8/v8/commit/fec99c689b8587b863df4a5c4793c601772ef663
[3] https://github.com/llvm-mirror/compiler-rt/blob/ff75f2a0260b1940436a483413091c5770427c04/lib/builtins/clear_cache.c#L146
After sweep, depending on the computed allowance, we are freeing empty blocks so that we still keep around enough blocks to fill that allowance (to avoid repeated vmaps).
On both collectors this had the problem that the allowance also accounts for LOS space, which we shouldn't account for in major section heuristics (which means that in LOS intensive benchmarks we only free major sections after the LOS shrinks).
On the concurrent collector, where we have a negative allowance adjustment depending on the duration of the concurrent mark (in order to mimic serial memory usage), we can have very small allowances at the end of a major collection, even 0. This means that we would reserve no empty blocks for later use.
We solve these issues by reserving empty blocks relative to the amount of current alive blocks, which is also the basis of how we compute the allowance in the first place.
This reverts commit 2f88b8eb5a.
There is a subtle problem with turning the monitor thread into a simple
MonoThreadInfo: It creates worker threads via mono_thread_create_internal (),
which allocates the thread object from the GC. No thread can allocate from
the GC unless it's actually attached, which the worker thread is not when
created with just mono_threads_create ().
mono_thread_info_get_stack_bounds has been updated to correctly report
the stack reserved base address quite some time ago.
Remove a couple of checks that still assume the old behavior of
reporting the committed base address.
This handle should have a total of maximum 3 copies:
- in MonoThreadInfo->handle
- in the return value of mono_threads_create_thread
- in MonoInternalThread->handle (if it's a managed thread)
Before, there would always be 2 references (in MonoThreadInfo->handle and another another for MonoInternalThread->handle), even if it would be referenced at one place only (MonoThreadInfo->handle), which would lead to a handle leak.
We also need to duplicate the returned handle, to avoid having a use-after-free of the handle (in case the thread exits before we access that handle)
If you abort a thread that is doing a Monitor:Enter, if the syscall abort lands before
the target thread start waiting it will block in a non aletable way.
To address that, we start by waiting in an alertable way and if interrupted we
decide to continue or not based on whether an abort can start.
Additionally, when alertable, we CAS the thread state to catch early Thread:Abort
calls that set the state by did not managed to init it.
This fixes a rare deadlock on tests/monitor-abort.exe.
* [threads] Allocate StartInfo in create_thread
* [threads] Put start_notify semaphore in StartInfo
* [threads] Factor common attach code in mono_thread_attach_internal
* [threads] Use same registered mechanism as mono-threads
The tests that fail like this actually work just fine on Mono on Windows.
Added the NotDotNet category to the CurrentThread_Domains() test since it
fails on .NET.
* Avoid race condition between domain unload and threadpool.
Previous logic only ensured that domain->threadpool_jobs was 0.
There was a race condition as follows:
* worker jobs are queued into ThreadPoolDomain outstanding_request's
* domain unload starts
* domain->threadpool_jobs is 0 so unload proceeds
* queued jobs are processed from the ThreadPoolDomain outstanding_request's
* the domain can be set/entered by worker threads since
mono_domain_set only fails for domains with state of MONO_APPDOMAIN_UNLOADED,
while our domain is in the MONO_APPDOMAIN_UNLOADING state
* jobs are now being unexpectedly run in domain that is being shutdown
* Fix a hang when unloading the domain.
This change applies the diff from ludovic-henry to correct the hang.
https://gist.github.com/ludovic-henry/6c8a4bc8951091c0ef36df2e52d5e32e
For some reason preamble length was asumed to be 3 when cp 65001
instead of always looking att the preamble length of the encoding.
This resulted in responses cropped by 3 chars on windows.
* When doing async connect on windows, connect returns `WSAEINPROGRESS`
which needs to be returned to managed code for correct handling. However
on Windows, last error gets reset before `WSAGetLastError` is called.
This fix moves all `WSAGetLastError` calls up closer to the socket
operation to make sure correct error code is returned to the managed code.
* Making sure `TcpNoDelay` is set to false for IPv4 by default and
that `DualMode` is default for IPv6.
* Making sure option value is set to 0 before calling getsockopt
because on Windows, a `BOOL` option value (eg TcpNoDelay) is returned
as a one byte value and the other bytes are left untouched which resulted
in TcpNoDelay always seemed to be true.
* Fixed so `TF_REUSE_SOCKET` is set only if `reuse` parameter is set
when disconnecting a socket.
Extracting mono, mcs, vbnc, al and gac path lookup to a common class.
On windows we now also check the running process to try to determine
the mono.exe.
* [threads] Remove use of CREATE_SUSPENDED for domain unload thread
* [threads] Remove use of CREATE_SUSPENDED for managed thread
* [threads] Remove CREATE_SUSPENDED
If the sweeping mechanism has been triggered by a major collection, then the iteration will wait for the general sweeping to finish and also for the sweeping of all the blocks. If this isn't the case (we are doing a major collection) we will iterate over the current state of the heap, some objects being bound to die during the collection, and the callback must account for this.
It doesn't make much sense to explicitly attempt to iterate without trying to sweep blocks that can be swept.
We never enter this case since we never iterate over the major objects without requiring to sweep, while a sweep is running. Even if we would be in this case, we directly access the mark bits which can be cleared at the same time by another thread sweeping the block, so we could miss live objects.
It doesn't make sense to check the remset during a major since majors dont use the cardtable and we clear it at the start. So we will obviously have missing remsets. For the debugging concurrent case, we should use the mod union consistency checks instead.
We would need to deal with scanning forwarded objects and dead objects which is not worth it. Only verify the heap at the start of a collection, as indicated by the name of the flag.
When verifying the heap we need to have the set of pinned objects otherwise we can observe missing remsets if suspended between the store and the write barrier. If we don't have the set of pinned objects, allow missing remsets.
After https://github.com/mono/mono/pull/3452 was merged, the LinkSdkRegressionTest.SecurityDeclaration
test in XI started failing:
```
[FAIL] LinkSdkRegressionTest.SecurityDeclaration : FileIOPermissionAccess
Expected: null
But was: <System.Security.Permissions.FileIOPermissionAccess>
at LinkSdk.LinkSdkRegressionTest.SecurityDeclaration () [0x00033] in /Users/builder/data/lanes/1411/2a96404f/source/xamarin-macios/tests/linker-ios/link sdk/LinkSdkRegressionTest.cs:990
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) [0x00038] in /Users/builder/data/lanes/1411/2a96404f/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
```
Due to the added call in the PR the linker preserved FileIOPermissionAccess enum,
which is apparently something we want to avoid.
Since according to https://github.com/mono/mono/pull/3452#discussion_r76384945 the only point of calling the
FileIOPermission is validating that the path doesn't contain invalid characters (mostly an issue on Windows),
I decided to just copy those checks as it's way cleaner.
Reference source of WindowsIdentity is using `MAXIMUM_ALLOWED`
as desired level by default when getting current token.
Changing to same behaviour to enable duplicate and impersonation
to be made on the token retrieved by GetCurrentToken.
* This improves the marshaling for packed classes and class involved in an inheritance hierarchy.
* Similar changes were made in the Unity fork of mono across a number of commits.
* The tests here have been taken from the repo and converted to work as NUnit tests in Mono.
Refcatored Win32RegistryApi.SetValue() to accept uint/byte/etc values for
DWord registry values.
Added handling of ERROR_CHILD_MUST_BE_VOLATILE errors to GenerateException().
Centralized MarkedForDeletion error handling to GenerateException().
Fixed tests which create volatile subkeys in RegistryKeyTest which used the
same key names but didn't clean up properly.
On Windows the TearDown() cannot delete the temp folder since it contains
loaded assemblies. The next time the test is run it will create a temp folder
inside the previous folder. After a number of runs the temp folder path will
approach the ~260 max path supported on Windows and some of the methods will
start failing.
This patch changes the way the temp folder is created and reduces the depth in
the same way as AssemblyTest was patched to fix a similar issue in
b90617e7b7.
Removed the differing code paths in FixtureSetUp() when running on non-Windows
platforms vs when running Mono on Windows or on .NET. The path previously
taken only on non-Windows platforms has been verified to work as expected on
both Mono on Windows and on .NET.
It failed a couple of times according to the babysitter logs with the following error:
```
MESSAGE:
Expected and actual are both <System.Int32[10]>
Values differ at index [1]
Expected: -1
But was: 0
```
Bump timeouts a little bit to see if this helps.
environment variables
Relying on the HOMEDRIVE/HOMEPATH environment variables is fragile as those
variables don't always have to be set. One such scenario is when running on a
Jenkins slave. When not set g_get_home_dir() in eglib would return NULL which
led to a crash in ves_icall_System_Environment_InternalGetHome().
This patch changes g_get_home_dir() to first try to call
SHGetKnownFolderPath() to get the current user's profile directory (i.e. home
dir). If that fails it falls back to the USERPROFILE environment variable. If
that isn't available the function will fallback to the original behavior and
try with HOMEDRIVE/HOMEPATH.
Creating new sockets between each connect instead of
trying to reuse the client socket. The original tests
was not working in the MS .NET runtime and socket reuse
is not recommended to use unless in very special cases.
On Windows the test used URLs like `file://C:\tmp\foo` which the
Mono.Security.Uri class was incapable of parsing. System.Uri from
referencesource parses such URLs just fine. This patch fixes the Uri class to
be able to parse such URLs. It also changes the Zone class to not throw an
exception if the Zone.CreateFromUrl() method is passed an invalid URL. Instead
the zone is set to NoZone. This seems to be how Zone in .NET behaves.
There are a few places in the runtime that should not be aborted as it would render it unusable.
cctor execution was the initial trigger for this changeset, but then edge triggering of TAE turned out
to expose this issue on other places.
This patch introduces those regions and apply them to the following places:
ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke: Not delivering the completed CB
screws up any completion logic the user setup up.
mono_unhandled_exception: Protect delivery of the unhandled exception. Can't fail during it or we'll
effectively double fault and abort.
A thread abort must not start if the thread is running a .cctor.
OTOH, if the cctor self aborts, it should start.
Threads now track how many cctors they are running in the cctor_exec_depth variable.
The abort machinery (in async_abort_critical) checks that flag and bail from
starting the abort.
The cctor code (in mono_runtime_class_init_full) ensures that cctor_exec_depth is bumped
around execution of the cctor itself. Additionally, error handling was cleaned up as it was pretty
inconsistent.
This callback allows the runtime to query mini on whether there's a block guard in play.
It allows for the runtime to correctly decide when to start an abort.
Call g_log_set_default_handler in mono_trace_set_log_handler and mono_trace_set_log_handler_internal to ensure that g_ logging is properly routed.
Additionally, change the internal logging callback to take the log message as a single string to simplify things.
The patch of mono/metadata/marshal.c makes sure that
Marshal.StringToHGlobalAnsi() allocates a memory area for the returned C
string which is at least as large as the length of the string object. This is
the behavior on non-Windows platforms. Without this patch the
MarshalTest.StringToHGlobalAnsiWithNullValues() test wrote outside of a memory
area and corrupted the heap which later on caused a heap corruption crash when
running the corlib test suite on Windows.
The patch of mono/metadata/mono-security.c fixes the freeing of the memory
returned by GetNamedSecurityInfoW(). When GetNamedSecurityInfoW() is used to
request a DACL one must also pass an argument for the ppSecurityDescriptor
parameter and this is the one that should be freed later on, not the pointer
to the DACL as the original code used to free. Before this patch
DSACryptoServiceProviderTest.UseMachineKeyStore() crashed because of a heap
corruption.
In defer mode, the debugger thread is started as soon as possible before
any clients are attached, but the debugger is_attached flag was being set
immediately. This would cause the runtime (and the System.Diagnostics.Debugger
class) to wrongly report a client as being attached.
Originally fixed in the Unity fork here: https://github.com/Unity-Technologies/mono/commit/797a210e0f2416d779c448bb9e03bb16933e261f
In defer mode, the debugger thread is started as soon as possible before
any clients are attached, but the debugger is_attached flag was being set
immediately. This would cause the runtime (and the System.Diagnostics.Debugger
class) to wrongly report a client as being attached.
Originally fixed in the Unity fork here: https://github.com/Unity-Technologies/mono/commit/797a210e0f2416d779c448bb9e03bb16933e261f
All ia64 compilers have intrinsics that we use. Also, this ia64 code was very
out of date (missing many functions we use now) so it wouldn't compile anyway.
When encoding a UTF-16 C# string into bytes using "latin-1"/"iso-8859-1" encoding we were
not properly taking surrogate pairs into account. MSDN[1] provides a good introduction about the topic.
For example, this string would fail to encode and throw an IndexOutOfRangeException: "\ud83d\ude0a "
However, this string would not: "\ud83d\ude0a" (note missing space at the end). More on that later.
In https://bugzilla.xamarin.com/show_bug.cgi?id=42887 it was noted that encoding the string
didn't cause the exception on Mono 2.10.8.1 and 3.2.8. Indeed, it doesn't happen until Mono 4.0
where we switched most of the string code to referencesources.
While looking at the output of `Encoding.GetEncoding("latin1").GetBytes("\ud83d\ude0a ")` on the
"working" Mono verions I noticed that they essentially returned wrong results, e.g.:
```
csharp> Encoding.GetEncoding("latin1").GetBytes("\ud83d\ude0a ")
{ 63, 32, 0 }
```
This is wrong, because a) there's only one 63 (i.e. the '?' question mark char which is used as
a replacement char whenever the target encoding doesn't support a specific char,
and b) there is a trailing '\0' which should not be there.
Checking on .NET confirms the expected result: { 63, 63, 32 } i.e. '?? '
Back to the IndexOutOfRangeException in Mono 4.0+: digging into Latin1Encoding.InternalGetBytes() it
turns out that when we detect a surrogate pair we were incrementing charIndex, but we didn't decrement count.
This means that after the fallback characters (the two '?') were added we would still try to encode one more
char in the loop even though we're already at the end of the string, resulting in the exception.
For the "\ud83d\ude0a" example we would not hit the `count > 1` code path which made it work in this case.
Adding the decrement fixes the bug and makes the code consistent with MonoEncoding.cs[2].
The reason why it "worked" in earlier Mono versions was that we had a very simple EncoderReplacementFallbackBuffer
implementation[3] which only output a single '?' for the surrogate pair:
```
csharp> var buf = Encoding.GetEncoding("latin1").EncoderFallback.CreateFallbackBuffer()
csharp> buf.Fallback((char)0xD800, (char)0xDC00, 0)
true
csharp> buf.GetNextChar()
'?'
csharp> buf.GetNextChar()
'\x0
csharp> buf.Fallback((char)0xD800, (char)0xDC00, 0)
true
csharp> buf.GetNextChar()
'?'
csharp> buf.GetNextChar()
'?'
csharp> buf.GetNextChar()
'\x0'
```
This means that for the "\ud83d\ude0a " example from above we would only add one '?' character
for the surrogate pair to the result buffer, then the space and then we'd be done, leaving the
uninitialized array value 0 in the buffer on index 2.
I added tests for Latin1Encoding, mostly copied from ASCIIEncoding with additions for these
specific cases.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42887
[1] https://msdn.microsoft.com/en-us/library/ms404377(v=vs.110).aspx
[2] https://github.com/mono/mono/blob/5b69e839e12b3d3512f310aa5a0e873346d7e50e/mcs/class/I18N/Common/MonoEncoding.cs#L62-L66
[3] https://github.com/mono/mono/blob/mono-3.12.0-branch/mcs/class/corlib/System.Text/EncoderReplacementFallbackBuffer.cs
Previously, we would try to satisfy the heapshot request every single time
process_requests () was invoked, but since heap_walk () would never unset
heapshot_requested, we'd end up doing GCs over and over, causing massive
overhead.
All events now come with a time field right after the event byte, and it is
encoded in the same way for all events (based on LogBuffer.time_base).
This allows readers to queue up events until a sync point event, then sort all
of those events by time, and process them in the order they were actually
written in.
Maintaining it for every format version is getting unwieldy and most readers
likely won't care about ancient format versions. Further, we haven't really
stabilized the format yet, so documenting every iteration of it doesn't make
a whole lot of sense. Finally, if somebody does care about older versions,
they can simply look in decode.c to see how mprof-report deals with them.
* Methods in backtraces are now properly encoded based on the method_base
rather than the ptr_base.
* The unused IL and native offset fields in TYPE_SAMPLE_HIT's backtrace frame
format have been removed.
* The unused flags fields in the backtrace format and in metadata events have
been removed.
* Changed a number of fields to be encoded as a single byte instead of LEB128.
These events basically establish points in the event stream where all previous
events can be processed and a complete view of the profiling state can be
formed. For instance, if an allocation event for object A of type T was seen
before a sync point, then it's guaranteed that the class load event for T also
came before that sync point (although it may have arrived after the allocation
event for A).
Other than timely arrival, there was never really a need to force buffers to be
flushed at these arbitrary points. Now that we flush all buffers periodically,
that reason is no longer relevant.
Heapshots have nothing to do with call depth, so they should be processed in
any case.
Also flush the local buffer in all enter/leave callbacks if needed.
This ensures that even for low-activity threads, it won't take ages before the
events from it arrive. We do this flush every 1sec (as with sampling of perf
counters).
The problem is this: Given an allocation of object O on address A1 in thread T1
and a subsequent GC move of O from A1 to A2 in T2, if T2's event buffer is
flushed before T1's buffer, the reader of the log file will a seemingly
nonexistent object being moved, and then see the actual allocation of that
object later. This makes it extremely difficult to keep track of the managed
heap.
The way we solve this is by flushing all thread-local buffers when the GC stops
the world. This way, we know that all prior allocations in the program have
been committed to the log file before any moves that are about to follow as
part of the collection. Similarly, we flush the GC thread's buffer before
restarting the world to ensure that all moves are committed before allocations
that may happen later (which could use some of the addresses freed up for use
due to the moves).
This is reasonably easy now that we have a global LLS of threads which are
attached to the profiler. However, we have to use some kind of lock to ensure
that buffers aren't being written to while we're trying to flush them, or that
a suspended thread was in the middle of modifying its buffer. For this, we use
a reader/writer spin lock of sorts, somewhat similar to the lock used by the
SGen binary protocol. When threads are modifying their own buffer (whether it
be writing to it or flushing it), they take the reader lock. This means that
many different threads can be operating on their own buffers without any lock
contention (which would kinda defeat the purpose of the thread-local buffers).
Now, when a thread -- such as the thread that initiated a GC -- wants to access
the buffers of other threads, it takes the writer lock. In doing so, all other
threads are prevented from modifying their own buffers. This gives the thread
holding the writer lock an opportunity to flush the buffers of other threads.
* Actual thread-local state is now stored in a MonoProfilerThread struct which
is stored in a single TLS slot per thread. This avoids storing things like
call_depth in LogBuffer. The current LogBuffer of a thread is also stored in
the MonoProfilerThread.
* All MonoProfilerThread structs are stored in a global linked list set. This
LLS is used to manually clean up the thread-local state of threads that, for
whatever reason, don't have the thread_end () callback invoked.
* Lifetime management of thread-local buffers is now much more straightforward.
* The thread-local list of referenced methods is now only allocated if needed.
* Fixed a MethodInfo memory leak in handle_writer_queue_entry ().
* Fixed some class load events that could be lost in the writer thread when
fetching the full name of a method.
* TLS slots are now actually freed on shutdown.
Make GC bridge perform well in the "double fan" scenario
The GC bridge currently performs VERY poorly when the object graph has a "double fan" shape. If M Java objects point to 1 C# object which points to N Java objects, the graph exported to Monodroid will currently drop the C# object node and replace it with (M\*N) edges. It is easy to write code where (M\*N) grows ludicrously big.
In testing on device, this patch solves that problem while leaving other cases unaffected. In testing on device, I found:
* All performance tests except double fan: No discernible performance difference after patch
* Double fan test with M=N=1000: Before the patch this took between three and seven seconds. After the patch this took between 0.2 and 0.3 seconds.
* Double fan test with M=N=4000: Before the patch this took anywhere from one to two minutes. After the patch, this took about 1.2 seconds.
* Double fan test with M=N=6000: Before the patch, this took so long I was not able to get it to ever complete. After the patch, this took about 1.3 seconds.
* Double fan test with M=N=20000: I did not attempt this test pre-patch. After the patch, it took about 5.6 seconds.
The commit messages describe the changes in some detail but the short version is:
* Add a mechanism for exporting non-bridged SCCs to the bridge client
* Turn that mechanism on whenever the product fanin*fanout grows too large
* Make the merge cache more aggressive
To function, this patch requires a corresponding change to monodroid. See https://github.com/xamarin/xamarin-android/pull/154
When running msbuild on mono against an architecture-specific
project that also defines satellite assemblies, the /platform
switch will be passed to al.exe. Mono's implementation of al.exe
does not support this switch, which results in a failed build.
This commit adds the /platform switch, which also required
changing the implementation from System.Reflection to
IKVM.Reflection because Mono's implementation of AssemblyBuilder
does not support the necessary options.
While testing this change, I also noticed a few attributes that
the MS version of al.exe will copy from "template" assemblies,
so I added support for those, as well.
SetUp() already sets up a temp folder for the test methods and TearDown()
handles cleaning up and taking into account that on Windows, loaded assemblies
cannot be deleted. However, some of the tests created temp files outside of
this folder and had their own cleanup code which didn't expect temp files to
be undeletable on Windows.
This patch removes any custom temp file creation/cleanup from individual test
methods. It also slightly changes the way SetUp() created the temp folder for
each test, now the paths will be shallower.
When AppDomain.Unload() is called a new thread is created and attached. When
this thread is done the thread handle is immediately closed using
CloseHandle() but the same handle is also passed to CloseHandle() later on by
the InternalThread destructor. On the second CloseHandle() call Windows will
abort the process with an "Invalid handle" error.
This patch removes the CloseHandle() calls in mono_domain_try_unload() which
is called by AppDomain.Unload(). The patch also wires up some more functions
in mono/utils/mono-threads-windows.c to set the MonoThreadInfo.handle field to
NULL when a thread has exited.
* Get rid of the arch-specific headers.
* Do verbose printing in one place.
* Simplify the cross compilation case to avoid repetition.
* Define all variables with a macro in a single header.
* Print detected hwcap info via g_print () so it's visible on mobile.
* Expose plain bool variables in the s390x implementation.
It doesn't work on nunitlite e.g. on XA:
```
src/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs(268,11): error CS0117: `NUnit.Framework.Assert' does not contain a definition for `Less'
```
Previously every time we add a new runtime setting for the bridge
processor we have added a new callback for it. Because this is getting
unweildy, and also because some of these settings might have been
broken by recent init order changes, I created a new set_config
callback and merged the existing set_dump_prefix and enable_processing
with it.
hash_perturb was being mixed in in the wrong place. Fix that, also
make the hash function take some input from high bits on 64-bit
systems, also make the types around the hash more reasonable.
The names were fixed only for the subset of methods that are included in netstandard,
and in cases where netstandard differs from Desktop .NET we match with .NET.
* [runtime] Remove most of the contents of MonoDynamicGenericClass, the elements of the 'fields' array are not used anywhere, making all the other fields unneccesary too.
* [runtime] Remove the MonoDynamicGenericClass structure, merge it into MonoGenericClass. Add some comments.
On Windows we should check the path for invalid characters. Also expand
relative paths set using file:// URLs like .NET does. This patch also removes
the code which prepends "//" on Windows when a file:// URL is given as .NET
doesn't seem to do that in more recent versions.
When having a float variable in memory, we should always access its contents through the fload_r4/fstore_r4 funcs, which do the conversion between float and double and different memsize vs var size. It is common case, to have a temp float, have its address loaded with ldaddr and later do a load_r4_membase on that address to access the contents. If alias analyis lowers this load_r4_membase to an op_fmove directly on the register pair, this would in turn be decomposed into 2 simple int op_moves on soft float, which is wrong if these op_moves are converted to memory accesses.
Even though we register emulations for these opcodes, the native function doesn't not map to the opcode logic, being used instead as part of the opcode decomposition along with other instructions. Make sure we don't try to emulate these opcodes through the general emulation pass.
Add missing source file, sgen-os-coop.c to project.
Add source files and headers into correct filters (Header/Source Files).
Eliminated Visual Studio linker warning LNK4221 for libmonoruntime project generated
by empty source files under certain configurations, boehm-gc.c, lock-tracer.c,
null-gc.c and sgen-os-coop.c
If we happen to have the debugger or the log profiler enabled, we would run into a use before initialization case for the w32handle. The debugger or profiler would call `mono_gc_base_init` which would attach the current thread, and that would crash in `mono_w32handle_new` at w32handle.c:437 with `scan_mutex` being an invalid value (EINVAL).
FileNotFoundException on Mono on Windows and on .NET when target doesn't exist
FileInfoTest.MoveTo_DestFileName_DirectoryDoesNotExist() expects
FileNotFoundException to be thrown but on Windows a DirectoryNotFoundException
is thrown instead.
This patch changes MoveFile() in mono/io-layer/io.c to set the last error to
ERROR_PATH_NOT_FOUND rather than ERROR_FILE_NOT_FOUND when the destination
path doesn't exist. This results in a DirectoryNotFoundException being thrown
in managed code rather than FileNotFoundException. This is the behaviour
observed in .NET.
Also updated FileInfoTest.MoveTo_DestFileName_DirectoryDoesNotExist() to check
for DirectoryNotFoundException rather than FileNotFoundException.
The methods are already available in our implementations of those types so we can just forward the calls
to the "real" types instead of throwing NotImplementedException.
I audited all code in mcs/class/Facades and the only places where we still throw NotImplementedException
are ones where we really need to add a custom implementation.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43695
It's unlikely the ServiceController APIs will be supported on mobile since they don't really make sense there,
they were initially designed for controlling Windows Services.
If the declaring type of a nested type marked by an xml descriptor
is not otherwise marked, the members of the nested type will not
be preserved, because the linker will not process the nested type
(since the parent type isn't marked, MarkStep:InitializeAssembly
will skip it, and thus skip akk its nested types as well).
https://bugzilla.xamarin.com/show_bug.cgi?id=43658
If sub == 0, i.e. there are no repeated separators, this method just returns
the input string. On Windows, where DirectorySeparatorChar (\) is different
from AltDirectorySeparatorChar (/), this means that the call
Path.GetDirectoryName ("foo/bar/dingus")
won't return "foo\bar" as .NET would but rather returns "foo/bar".
This patch makes sure the '/' -> '\' conversion is run when
AltDirectorySeparatorChar characters have been seen in the input string, even
if sub == 0.
PathTest.GetDirectoryName() triggered this bug.
When a FileStream is opened with the FileOptions.Asynchronous flag set the
code in file-io.c will pass FILE_FLAG_OVERLAPPED to the CreateFile() function.
On Windows this means the file will be in asynchronous mode and when
ReadFile()/WriteFile() are called an OVERLAPPED struct has to be passed. Mono
doesn't do this which means that when reading/writing asynchronous FileStreams
Windows returns an ERROR_INVALID_PARAMETER and an exception is raised in
managed code.
This patch simply removes the code which passes the FILE_FLAG_OVERLAPPED to
CreateFile(). This will work since asynchronous I/O is handled in managed code
anyway, using threads. On the OS level the I/O is still synchronous. The patch
won't affect other platforms since the implementation of
ReadFile()/WriteFile()/etc in mono/io-layer/, which is used on non-Windows, is
always synchronous and ignores the FILE_FLAG_OVERLAPPED.
This bug was triggered by the
MonoTests.System.IO.BinaryWriterTest.AsynchronousModeWrites test.
This test assumes that `new DirectoryInfo (@"c:").Name == "C:\"` when run on
Windows but the actual value depends on the current directory. If current dir
is C:\temp the Name property will return "temp". Similar problem in the
FullName() and Parent() tests.
This patch sets the current directory to C:\ explicitly before running the
failing tests on Windows. The current dir is reset in TearDown().
In an effort to cut down on the number of different scripts we have that try to output NUnit xml.
It also fixes a bug in emitnunit.pl where it would not output anything when one of the tests crashes
the process, because then the final "Overall results: tests: 22425, 100% pass, opt combinations: 25"
line isn't printed and emitnunit.pl just exits. This happens on Alpine.
DoubleTest.Parse() expects "3 5" to be unparseable in the current culture and
expects an exception to be thrown. In sv-SE however "3 5" parses to 35 and
this test fails.
This patch sets the current culture to en-US when the DoubleTest.Parse() test
is run.
When running DirectoryInfo.EnumerateFileSystemInfos() on an empty directory
MonoIO.FindFirst() will return null and the method returns without closing the
handle which is opened by FindFirst(). This patch makes sure the finally block
which closes the handle is run even when FindFirst() returns null.
Also added a call to FindClose() and some more cleanup in the native
implementation of MonoIO.FindFirst() when an allocation fails.
This bug caused an exception in DirectyoryInfoTest.TearDown() and several
other TearDown() methods in the MonoTests.System.IO tests on Windows due to
RemoveDirectory() failing on an empty directory which still had an open handle
associated with it.
The targets depended on a feature that doesn't exist in
xbuild (https://bugzilla.xamarin.com/show_bug.cgi?id=43645)
and as a consequence would fail to add the generated file to
the build when the GenerateTargetFrameworkMonikerAttribute
target was up to date.
With the .NET 4.6.2 merge in https://github.com/mono/mono/commit/b6a30059db8319348ebb454cc303633dfabd6a29#diff-799d44d25450b5b84906cbe7095708a0L86
the RSAPKCS1SignatureDescription class switched from using SHA1CryptoServiceProvider as the DigestAlgorithm to SHA1Cng.
This uncovered an issue when running SignatureDescriptionTest in FullAOT, as we were missing an entry for SHA1Cng
in CryptoConfig.fullaot.cs and so we didn't find the algorithm.
Additionally, 4.6.2 added new variants of the SignatureDescription class using SHA256, SHA384 and 512 which
had to be added alongside the corresponding digest/signature URLs defined by https://msdn.microsoft.com/en-us/library/windows/desktop/dd979768(v=vs.85).aspx
Note that on mobile/FullAOT we're falling back to the *Managed variants of the SHA algorithms as the *Cng/*CryptoServiceProvider variants
aren't exposed there (except for SHA1CryptoServiceProvider since it was in the framework from the beginning) so we need to special case these in the tests.
They were all using the same .cs source files so just including the generic monotouch .sources
makes it easier to reason about and reduces the risk of forgetting to update one of the lists.
SetUp() calls uname() in libc to check whether the test is running on OS X. On
Windows this fails since libc isn't available.
This patch removes the call to uname() completely since the result wasn't used
by the test anyway.
* Fixing linker warning when building libmono DLL.
After splitting mono runtime into a static library used when building libmono
DLL, we got a linker warning since there were no object files left in the
libmono project. There was also a sematic issue with the current organization
of DllMain since it is located in driver.c that will be compiled into the static
library and then consumed by the linker building the DLL. In cases where the
static library was consumed directly it would still include DllMain entry point.
By splitting the DllMain method implementation into a separate specific windows file
we can both resolve the linker warning and remove the DllMain method implementation from the static
library and only include it when building the libmono DLL.
* Visual Studio projects support to optimally link mono applications using static libmono library.
Added a new property, MONO_USE_STATIC_LIBMONO that can be used to link some
mono applications, for example mono(-sgen).exe, towards static version of libmono.
This gives us the option to build a binary without dependencies on other runtime binaries
minimizing what’s needs to be deployed in order to run mono. This in combination with static linked c-runtime
(another option available through a VS property) will produce a mono runtime binary without
addition dependencies except .NET assemblies deployed by mono runtime users.
The default is still using the dynamic version of libmono as before.
* Visual Studio project to test/debug testdriver tests from within Visual Studio.
Added an additional Visual Studio project preconfigured to run testdriver related tests
directly from within Visual Studio.
Commit also includes an additional configuration script that can be used test projects in order
to setup a mono config file. The testdriver project uses this to create a unique configuration
files pointing to the build libtest.dll for running configuration. The configuration file will then
be used when the tests are executed to make sure the correct libtest.dll for current build configuration
gets used when running test different tests from within the Visual Studio debugger.
The project comes with a number of user macros as well that can be used in order to tailor how the tests are run.
Most of the values are preconfigured and shouldn't need to be changed in order to use
current build. In order to change the test that is executed, use the following user macro
defined in mono-testdriver-test property sheet added to the project:
MONO_TESTDRIVER_RUN_TARGET
and point it to the assembly hosting the tests to execute from within Visual Studio.
* Visual Studio project to test/debug nunit tests from within Visual Studio.
Added an additional Visual Studio project preconfigured to run nunit related tests
directly from within Visual Studio.
The project comes with a number of user macros as well that can be used in order to tailor how the tests are run.
Most of the values are preconfigured and shouldn't need to be changed in order to use
current build. In order to change the test that is executed, use the following user macro
defined in mono-nunit-test property sheet added to the project:
MONO_NUNIT_RUN_TARGET
and point it to the assembly hosting the tests to execute from within Visual Studio.
There is also an additional user macro defined:
MONO_NUNIT_FIXTURE
This can be used to limit the number of nunit test run within a test suite.
The merge_cache previously, if it encountered an SCC ("color") with
many outgoing links, would not attempt to merge that SCC with existing
SCCs and instead would just create a new color. Because unbridged SCCs
are now reported to the bridge client, the cost of creating extra
colors has increased. To mitigate this the merge cache now attempts to
merge objects of all sizes, and has been changed to be able to do this
performantly.
The biggest change is that in the case of a hash collision, SCCs will
sometimes be merged without fully checking if they are exactly equal.
This is considered okay because false merges will be infrequent and
nothing worse will happen than short-term failure to reclaim memory.
The bridge-pathologies double fan test has been amended to verify
large-object merging works.
Augments each tarjan-bridge SCC ("color") with a count of how many
SCCs are pointing to it. The mechanism for exporting non-bridged SCCs
uses this count to only export those SCCs where the "double fan"
scenario appears to be occurring. In testing this eliminates the
performance overhead imposed by the previous commit.
Also renamed/moved some variable declarations because namespace bugs
were creeping in.
Introduces a mechanism for non-bridged SCCs which lay between bridged
SCCs in the SCC forest to be reported to the bridge client. In this
version, such non-bridged SCCs are always reported. The result is that
most GCs get a little slower but GCs in which the "double fan" shape
appears (many bridged objects link to one C# object which links to
many bridged objects) become massively faster.
Because before clients were allowed to assume exported SCCs were
always bridged, SGEN_BRIDGE_VERSION has been incremented.
Windows
The error (ERROR_DIRECTORY) wasn't recognized in MonoIO so the error message
became "Win32 IO returned 267. Path: C:\foo\bar" which includes the path. The
test tests that the path isn't include in the message in the thrown
IOException.
Previously we were wrongly trying to achieve this by doing a load-acq followed by a store-rel. Assuming we have memory access on address A (before) and C (after) while the atomic operation happens on address B, the order of the instructions would look like this :
[A], [B]load, load-acq, store-rel, [B]store, [C]
In this case a reordering of memory accesses like the following is possible, which clearly breaks the desired constraints :
[B]load, load-acq, [C], [A], store-rel, [B]store
In order to provide the sequential memory constraint we could emit the barriers like this instead :
[A], membar, [B]load, [B]store, membar, [C]
We can additionally save an instruction and emit the barriers like this instead (this is also what gcc does) :
[A], [B]load, store-rel, [B]store, membar, [C]
In this case we only need to worry about the relation between memory accesses on A and the loading of B. We need to consider what happens if B is loaded before the access on A is fulfilled. This only matters if we load an older value for B (rather than the one visible by other threads) before A. In that case the erroneous store will fail due to using exclusive stores. At the retry the value read from B will be the right one.
Loads with acquire semantics guarantee that following memory accesses are not reordered with the load. Add full membar before it to ensure full sequencing.
Stores with release semantics guarantee that previous memory accesses are not reordered with the store. Add a full membar after it to ensure full sequencing.
NET_2_1 is also defined whenever we define MOBILE, so they have the same effect. Silverlight was 2.1 but it's been dead for a while now, and we do not even support it.
On Win64 Mono doesn't (yet) implement fast JIT TLS (mono_get_jit_tls_offset()
returns -1). This means that the code in
mono_arch_create_handler_block_trampoline() takes the code path in the "else"
which is the same code path taken when AOT compiling. The code generated in
this code path manipulates the stack pointer to ensure it's aligned properly
according to the ABI (RSP-8 is 16-byte aligned on function entry) for the AOT
case where the mono_handler_block_guard_trampoline() C function is called
directly from the handler_block_trampoline.
This patch unifies the JIT and AOT generated code to be as similar as possible
and gets rid of the fast path. There's no need for this code to be fast. The
handler_block_trampoline will after this patch call
mono_handler_block_guard_trampoline() directly, both in JIT and in AOT mode,
and then jump back to the saved return address itself rather than let the
MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD generic trampoline do this.
The tests mono/tests/finally_block_ending_in_dead_bb.exe and
mono/tests/block_guard_restore_aligment_on_exit.exe trigger this bug.
Split up reflection.c into three separate files:
1. reflection-query.c: This contains System.Type and the interrogative System.Reflection APIs.
2. reflection.c: This contains the System.Reflection.Emit APIs
3. reflection-custom-attrs.c: All about dealing with custom attributes.
Simplify code by always accessing tlab information and inside_critial_region through the SgenThreadInfo pointer. This also fixes potential failure to detect that we are in a critical region within the managed allocator.
MONO_THREAD_VAR_OFFSET definitions don't work when loading mono as a dynamic library. This means that we need to be conservative and don't aot code that contains these tls chunks.
In the future, we should remove HAVE_KW_THREAD altogether and use only pthread since it simplifies the code alot.
Added a couple of new/updated test/debug Visual Studio utility projects.
These projects can be used to quicker get up to speed when there is a need
to run/test/debug mono runtime tests inside Visual Studio debugger.
Added utility projects can be used to run mini regression tests using JIT as
well as compile/run full AOT:ed versions of mini regression tests or other assemblies.
The different .prop files are also organized so they can be reused when adding additional
run/test/debug projects going forward.
The code in mono_arch_create_handler_block_trampoline() in tramp-amd64.c emits
a relative CALL which calls the mono_amd64_handler_block_trampoline_helper()
functions via:
amd64_call_code (code, mono_amd64_handler_block_trampoline_helper)
This macro however only works properly for offsets less than 32-bits. For
64-bit offsets it truncates the offset to a 32-bit number. On Win64 the offset
in this case is always a number larger than 2^32. The emitted CALL will jump
to an illegal address causing a crash.
This patch changes the emitted code sequence to load the address of
mono_amd64_handler_block_trampoline_helper() to RAX and then calls the address
in RAX.
The test mono/tests/finally_block_ending_in_dead_bb.exe triggered this bug.
After this patch the test still crashes but in a new way related to another
bug.
* [corlib] Regression test for non-visible custom attributes.
See https://bugzilla.xamarin.com/show_bug.cgi?id=43291
* [reflection] Don't crash when building dynamic custom attributes on dynamic types (Fixes#43291)
1. Don't dereference a NULL custom attribute ctor, throw a type load
exception.
2. When building MonoCustomAttrInfo from an array of
MonoReflectinoCustomAttr*, compute the number of
non-visible (non-public) attributes correctly, and make sure to
iterate over all the attributes when populating the result array.
Fixes [#43291](https://bugzilla.xamarin.com/show_bug.cgi?id=43291)
* [reflection] Marginally better TLE for custom attrs
At least include a message about what went wrong when trying to
construct a custom attribute from a type that isn't finished yet.
I accidentally added this in 3c3ef17376 because I missed that on
full .NET this class inherits from NameValueCollection which provides `this[string name]` already
(the diff tool showed it as missing because it didn't take this into account).
The test fails due an ArgumentException being thrown when the catch handler in
the test's Run() method tries to write to the console. The ArgumentException
is thrown in EncodingTable.GetCodePageFromName(string) since the encoding name
passed to it is null. Normally this exception would be caught and the default
encoding would fall back to UTF8. However, since the thread is aborted the
ThreadAbortException will be rethrown and terminates the test with an uncaught
exception. I have verified that the same behavior is seen on OS X if I mock up
the default encoding code to throw the same ArgumentException.
This patch adds a call to Thread.ResetAbort() just before the call to
Console.WriteLine() in the catch handler. This removes the abort status of the
thread and avoids the rethrow of the ThreadAbortException.
We need a valid MonoThreadInfo in the TLS key while we run
unregister_thread because we may need to block the thread when it tries
to take the sgen GC mutex.
Fixes [#43099](https://bugzilla.xamarin.com/show_bug.cgi?id=43099)
The mono_threads_platform_get_priority()/mono_threads_platform_set_priority()
functions in mono-threads-windows.c assume the "handle" member has been set in
the MonoThreadInfo struct passed to it but it's always NULL. This patch
implements mono_threads_suspend_register() in the same file which sets the
"handle" member at thread registration time, like it's done in
mono-threads-posix.c.
This patch also makes sure the priority of a new thread is set as expected
when the Thread.Priority property has been changed prior to the thread being
started.
Also added a test method to mono/tests/priority.cs which tests that the
priority of the main thread is Normal by default and that it can be changed as
expected.
The changes in this patch fixes the failures in mono/tests/priority.exe on
Windows i386 and x64.
typeof (int).GetType ().GetType ().Name is now RuntimeType since https://github.com/mono/mono/pull/3045.
We did not notice this since most of our bots don't run with en-US locale set which this test requires.
We don't use svn anymore since a very long time and some diff implementations (e.g. in Alpine) don't support --exclude.
Removing the argument is an easy fix.
Previous implementation laid out the BSTR structure
in directly memory in C# code. This layout was not correct
for windows.
Furthermore memory was allocated using AllocCoTaskMem but later freed
using SysFreeString which on windows are different memory areas.
Third issue is that SecureString asumes big-endian when copying the chars
to its internal byte buffer. So on little-endian environments,
a swap of bytes is needed before the buffer is sent to native side
for BSTR conversion. This should probably be handled internally in
SecureString instead.
In the past there were wars between constified and unconstified
second parameter.. NetBSD went with constifying it. POSIX went without
const and most other OSes standarized. NetBSD is still having
incompatible function prototype.
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <iconv.h>
size_t
iconv(iconv_t cd, const char ** restrict src, size_t * restrict srcleft,
char ** restrict dst, size_t * restrict dstleft);
iteritems() was removed in py3, we can just use items() instead since we're iterating
over the list anyway so we don't need the lazy evaluation behavior of iteritems().
TODO: there's a gratuitous call to mono_lookup_internal_call_full().
Should really cache the uses_handle info along with the addr since the
lookup by name is rather involved.
Since UNICODE is defined when Mono is compiled under Windows the
GetLocaleInfo() macro will expand to GetLocaleInfoW() which returns the
current locale identifier in g_win32_getlocale() in 16-bit Unicode.
g_win32_getlocale() however expects an 8-bit encoding. By using
GetLocaleInfoA() explicitly we'll get the identifier back as an ordinary 8-bit
C string.
This patch fixes the mono/tests/threadpool-exceptions5.exe test.
MVID and AOTID metadata is no longer displayed at the end of the stack
trace.
Now, every stack frame contains a MVID and AOTID inlined.
An IL offset stackframe looks like:
at StackTraceDumper.Main () [0x00000] in <a3ec873a838c42c29f4eba7cab7d1dfb>:0
A native offset stack frame looks like:
at StackTraceDumper.<Main>m__0 () <0x100e15d50 + 0x00029> in <a3ec873a838c42c29f4eba7cab7d1dfb#b37a9d11247b811ffffdaff8090d8a59>:0
The crash would come from a use-after-free of stack memory: in coop_cond_timedwait_alertable, we would allocate the struct we pass to the mono_thread_info_install_interrupt function on the stack. But there is no guarantee as to when break_coop_alertable_wait is run. The fix is to allocate the data passed to mono_thread_info_install_interrupt on the heap, and free it in the callback, or if it hasn't been interrupted.
the stack.
Windows uses a guard page before the committed stack memory pages to detect
when the stack needs to be grown. If we suspend a thread just after a function
prolog has decremented the stack pointer to point into the guard page but
before the thread has been able to read or write to that page, starting the
stack scan at the thread's ESP/RSP will raise a STATUS_GUARD_PAGE_VIOLATION and
the process will crash.
This patch uses VirtualQuery() to determine whether the thread's stack_start
value points into the guard page. If it does the stack scan will instead be
started at the following, non-guard page.
Windows x64 only has 1 MB of stack per thread which is less than other x86
64-bit OSes. Using 10000 for "depth" in this test causes a stack overflow on
Windows x64. This patch changes "depth" to 5000 only on Windows x64. 5000 will
fit within the default stack size.
This is the recent behavior in .NET/MSBuild as well [1]:
> Starting in Visual Studio 2013, the MSBuild Toolset version is the same
> as the Visual Studio version number. MSBuild defaults to this Toolset
> within Visual Studio and on the command line, regardless of the
> toolset version specified in project file.
With this change xbuild will always use its own version instead
of the one specified in the project, unlessa ToolsVersion is forced
via the /tv switch on the command line.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42938
[1] https://msdn.microsoft.com/en-us/library/bb383796.aspx#Anchor_1
For test harnesses which don't support the full babysitter protocol,
the test harness can now report back paths to NUnit-format XML files
containing test results, or the paths to those XML files can be given
by whoever invoked the babysitter script. Failures listed in the XMLs
are included in the babysitter log.
test-runner.cs has been modified to report its XMLs, so we should now
see mono/tests failures in the babysitter log.
The Process.Exited event would be triggered too early, leading to crash in code using this event to access the process exit code. This is because in Process.ExitCode, we first check that the process has really exited.
ABI states that "All memory beyond the current address of RSP is considered
volatile".
On Windows the stack grows dynamically as the thread needs more stack space.
Windows places a guard page before the page at the top of stack and when this
guard page is accessed by the thread Windows will add a new page to the stack
and resume the thread.
Before this fix SGen on Win64 subtracted 128 from the stack pointer of a
suspended thread and started the stack scan from this address. In the case
when the stack pointer would be less than 128 from the start of the memory
page SGen would attempt to read from the previous page. If this happens to be
the guard page a STATUS_GUARD_PAGE_VIOLATION exception is raised and the
process crashes. The sgen-weakref-stress.exe triggered this bug on almost
every invocation.
We split mono-threads-{posix,windows,mach}.c functions in 2 categories:
- platform: depends on the host the runtime is compiled on (possible values: posix or windows)
- suspend: depends on the mono-threads suspend backend in use (possible values: posix, windows or mach)
On musl __GLIBC__ is not defined, so the conditional logic will
not produce correct result. Add a specific case to handle when
__GLIBC__ is not defined.
It showed the following error before:
```
In file included from wapi.h:23:0,
from wapi.c:2:
../../mono/io-layer/processes.h:218:31: error: unknown type name 'pid_t'
gchar* wapi_process_get_path (pid_t pid);
^
Makefile:603: recipe for target 'wapi.lo' failed
make[3]: *** [wapi.lo] Error 1
```
The NetBSD version of mremap takes additional argument "newp" to hint
new position of a mapped range.
void *
mremap(void *oldp, size_t oldsize, void *newp, size_t newsize,
int flags);
-- NetBSD's mremap(2)
While Linux by default sets old_address and fails if the resize
operation cannot be finished for the original address.
void *mremap(void *old_address, size_t old_size,
size_t new_size, int flags, ... /* void *new_address */);
-- Linux's mremap(2)
NetBSD offers inversed logic with the MAP_FIXED flag to Linux's MREMAP_MAYMOVE:
MAP_FIXED newp is tried and mremap() fails if that address can't
be used as new base address for the range. Otherwise,
oldp and newp are used as hints for the position,
factoring in the given alignment.
-- NetBSD's mremap(2)
MREMAP_MAYMOVE
By default, if there is not sufficient space to expand a mapping
at its current location, then mremap() fails. If this flag is
specified, then the kernel is permitted to relocate the
mapping to a new virtual address, if necessary. If the mapping
is relocated, then absolute pointers into the old mapping
location become invalid (offsets relative to the starting address
of the mapping should be employed).
-- Linux's mremap(2)
The thing that bothers is calling mremap(2) syntax from Linux "posix", but we
cannot do anything with it, for now just simulate the Linux behavior on NetBSD.
# The Sun Forte compiler complains about inline functions that access static variables
@@ -741,21 +783,51 @@ fi
AC_ARG_ENABLE(system-aot, [ --enable-system-aot Enable the Ahead-Of-Time compilation of system assemblies during the build (on by default on some platforms)], enable_system_aot=$enableval, enable_system_aot=default)
AC_ARG_WITH(csc, [ --with-csc=mcs,roslyn,default Configures the CSharp compiler to use],[
if test x$withval = xmcs; then
csc_compiler=mcs
elif test x$withval = xroslyn; then
csc_compiler=roslyn
elif test x$withval = xdefault; then
:
else
AC_MSG_ERROR([You must supply one of "mcs", "roslyn" or "default" to the --with-csc option])
fi
],[csc_compiler=default])
if test $csc_compiler = default; then
if test $endian = big; then
csc_compiler=mcs
elif test $endian = little; then
csc_compiler=roslyn
else
csc_compiler=mcs
fi
fi
AC_MSG_RESULT($csc_compiler)
#
# Set the build profiles and options before things which use them
#
AC_ARG_WITH(profile4_x, [ --with-profile4=yes,no If you want to install the 4.x FX (defaults to yes)], [], [with_profile4_x=default])
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=default])
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the Xamarin.iOS assemblies (defaults to no)], [], [with_monotouch=default])
AC_ARG_WITH(monotouch_watch, [ --with-monotouch_watch=yes,no If you want to build the Xamarin.WatchOS assemblies (defaults to no)],[], [with_monotouch_watch=default])
AC_ARG_WITH(monotouch_tv, [ --with-monotouch_tv=yes,no If you want to build the Xamarin.TVOS assemblies (defaults to no)], [], [with_monotouch_tv=default])
AC_ARG_WITH(bitcode, [ --with-bitcode=yes,no If bitcode is enabled (defaults to no)], [], [with_bitcode=default])
AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you want to build the Xamarin.Mac assemblies (defaults to no)], [], [with_xammac=default])
AC_ARG_WITH(mobile_static, [ --with-mobile_static=yes,no If you want to build the mobile_static assemblies (defaults to no)], [], [with_mobile_static=default])
AC_ARG_WITH(profile4_x, [ --with-profile4_x=yes,no If you want to install the 4.x FX (defaults to yes)], [], [with_profile4_x=default])
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=default])
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the Xamarin.iOS assemblies (defaults to no)], [], [with_monotouch=default])
AC_ARG_WITH(monotouch_watch, [ --with-monotouch_watch=yes,no If you want to build the Xamarin.WatchOS assemblies (defaults to no)],[], [with_monotouch_watch=default])
AC_ARG_WITH(monotouch_tv, [ --with-monotouch_tv=yes,no If you want to build the Xamarin.TVOS assemblies (defaults to no)], [], [with_monotouch_tv=default])
AC_ARG_WITH(bitcode, [ --with-bitcode=yes,no If bitcode is enabled (defaults to no)], [], [with_bitcode=default])
AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you want to build the Xamarin.Mac assemblies (defaults to no)], [], [with_xammac=default])
AC_ARG_WITH(testing_aot_hybrid, [ --with-testing_aot_hybrid=yes,no If you want to build the testing_aot_hybrid assemblies (defaults to no)], [], [with_testing_aot_hybrid=default])
AC_ARG_WITH(testing_aot_full, [ --with-testing_aot_full=yes,no If you want to build the testing_aot_full assemblies (defaults to no)], [], [with_testing_aot_full=default])
AC_ARG_WITH(winaot, [ --with-winaot=yes,no If you want to build the Windows friendly AOT assemblies (defaults to no)], [], [with_winaot=default])
AC_ARG_WITH(orbis, [ --with-orbis=yes,no If you want to build the Orbis assemblies (defaults to no)], [], [with_orbis=default])
AC_ARG_WITH(runtime_preset, [ --with-runtime_preset=net_4_x,all,mobile_static,bitcode_mobile_static Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
AC_ARG_WITH(runtime_preset, [ --with-runtime_preset=net_4_x,all,aot,hybridaot,fullaot,bitcode Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
AC_ARG_ENABLE(bcl-opt, [ --disable-bcl-opt BCL is compiled with no optimizations (allows accurate BCL debugging)], test_bcl_opt=$enableval, test_bcl_opt=yes)
AC_ARG_ENABLE(perf-events, [ --enable-perf-events Enable using `perf` for profiling on Linux], test_perf_events=$enableval, test_perf_events=no)
if test "x$test_perf_events" = "xyes"; then
AC_DEFINE(ENABLE_PERF_EVENTS, 1, [Enable using `perf` for profiling on Linux])
AC_SUBST(ENABLE_PERF_EVENTS)
fi
AC_MSG_CHECKING([if big-arrays are to be enabled])
AC_ARG_ENABLE(big-arrays, [ --enable-big-arrays Enable the allocation and indexing of arrays greater than Int32.MaxValue], enable_big_arrays=$enableval, enable_big_arrays=no)
if test "x$enable_big_arrays" = "xyes" ; then
@@ -2856,13 +2961,12 @@ if test "x$enable_llvm" = "xyes"; then
# avoid AR calling ranlib, libtool calls it anyway. suppress no symbols warning.
AR_FLAGS="Scru"
RANLIB="$RANLIB -no_warning_for_no_symbols"
AC_MSG_RESULT([yes])
]
)
fi
case "x$libgc" in
xincluded)
# Pass CPPFLAGS to libgc configure
@@ -3873,6 +4059,90 @@ else
fi
AC_SUBST(LIBMONO_LA)
dnl **************
dnl *** Btls ***
dnl **************
AC_ARG_ENABLE(btls, [ --disable-btls Disable the BoringTls provider], enable_btls=$enableval, enable_btls=$BTLS_SUPPORTED)
AC_ARG_WITH(btls_android_ndk, [ --with-btls-android-ndk Android NDK for BoringTls])
AC_ARG_ENABLE(dynamic-btls, [ --enable-dynamic-btls Place the BTLS provider into a separate shared library/archive.], enable_dynamic_btls=$enableval, enable_dynamic_btls=no)
mono \- Mono's ECMA-CLI native code generator (Just-in-Time and Ahead-of-Time)
.SHSYNOPSIS
@@ -104,11 +104,6 @@ than one can be specified:
.RS
.ne8
.TP
.Iautoreg
The AOT compiler will emit a (ELF only) library initializer to automatically
register the aot compiled module with the runtime. This is only useful in static
mode
.TP
.Iasmonly
Instructs the AOT compiler to output assembly code instead of an
object file.
@@ -118,11 +113,6 @@ object file.
If specified, forces the generated AOT files to be bound to the
runtime version of the compiling Mono. This will prevent the AOT
files from being consumed by a different Mono runtime.
.Ifull
.Sp
This is currently an experimental feature as it is not complete.
This instructs Mono to precompile code that has historically not been
precompiled with AOT.
.TP
.Idata-outfile=FILE.dll.aotdata
.Sp
@@ -134,10 +124,59 @@ on demand by using the
.Imono_install_load_aot_data_hook
method.
.TP
.Idirect-icalls
.Sp
When this option is specified, icalls (internal calls made from the
standard library into the mono runtime code) are invoked directly
instead of going through the operating system symbol lookup operation.
This requires use of the
.Istatic
option.
.TP
.Idirect-pinvoke
.Sp
When this option is specified, P/Invoke methods are invoked directly
instead of going through the operating system symbol lookup operation.
This requires use of the
.Istatic
option.
.TP
.Idwarfdebug
Instructs the AOT compiler to emit DWARF debugging information. When
used together with the nodebug option, only DWARF debugging
information is emitted, but not the information that can be used at
runtime.
.TP
.Ifull
.Sp
This creates binaries which can be used with the --full-aot option.
.TP
.Ihybrid
.Sp
This creates binaries which can be used with the --hybrid-aot option.
.TP
.Illvm
AOT will be performed with the LLVM backend instead of the Mono backend where possible. This will be slower to compile but most likely result in a performance improvement.
.TP
.Illvmonly
AOT will be performed with the LLVM backend exclusively and the Mono backend will not be used. The only output in this mode will be the bitcode file normally specified with the
.Illvm-outfile
option. Use of
.Illvmonly
automatically enables the
.Ifull
and
.Illvm
options. This feature is experimental.
.TP
.Illvm-outfile=[filename]
Gives the path for the temporary LLVM bitcode file created during AOT.
.TP
.Iinfo
Print the architecture the AOT in this copy of Mono targets and quit.
.TP
.Ild-flags
Additional flags to pass to the C linker (if the current AOT mode calls for invoking it).
.TP
.Illvm-path=<PREFIX>
Same for the llvm tools 'opt' and 'llc'.
@@ -156,7 +195,12 @@ llc compiler.
.Inimt-trampolines=[number]
When compiling in full aot mode, the IMT trampolines must be precreated
in the AOT image. You can add additional method trampolines with this argument.
Defaults to 128.
Defaults to 512.
.TP
.Ingsharedvt-trampolines=[number]
When compiling in full aot mode, the value type generic sharing trampolines must be precreated
in the AOT image. You can add additional method trampolines with this argument.
Defaults to 512.
.TP
.Inodebug
Instructs the AOT compiler to not output any debugging information.
@@ -166,23 +210,22 @@ This prevents the AOT compiler from generating a direct calls to a
method. The AOT compiler usually generates direct calls for certain
methods that do not require going through the PLT (for example,
methods that are known to not require a hook like a static
constructor) or call into simple internal calls.
.TP
.Idwarfdebug
Instructs the AOT compiler to emit DWARF debugging information. When
used together with the nodebug option, only DWARF debugging
information is emitted, but not the information that can be used at
runtime.
constructor) or call into simple internal calls.
.TP
.Inrgctx-trampolines=[number]
When compiling in full aot mode, the generic sharing trampolines must be precreated
in the AOT image. You can add additional method trampolines with this argument.
Defaults to 1024.
Defaults to 4096.
.TP
.Inrgctx-fetch-trampolines=[number]
When compiling in full aot mode, the generic sharing fetch trampolines must be precreated
in the AOT image. You can add additional method trampolines with this argument.
Defaults to 128.
.TP
.Intrampolines=[number]
When compiling in full aot mode, the method trampolines must be precreated
in the AOT image. You can add additional method trampolines with this argument.
Defaults to 1024.
Defaults to 4096.
.TP
.Ioutfile=[filename]
Instructs the AOT compiler to save the output to the specified file.
@@ -191,6 +234,16 @@ Instructs the AOT compiler to save the output to the specified file.
If the AOT compiler cannot compile a method for any reason, enabling this flag
will output the skipped methods to the console.
.TP
.Iprofile=[file]
Specify a file to use for profile-guided optimization. See the "AOT PROFILING" section. To specify multiple files, include the
.Iprofile
option multiple times.
.TP
.Iprofile-only
AOT *only* the methods described in the files specified with the
Loaded 100 of 4734 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.