Instead of using fragile lockless code in the sigchld signal handler, wake up the finalizer thread and make it call back
into the process code to signal finished processes.
The previous build used an outdated path in the lane config for uploading msbuild logs, causing the build to be orange.
Let's try getting a green build.
- Create a unique temporary directory for each test in TypeBuilderTest and delete
it on TearDown.
- Change tests to use tempDir instead of Path.GetTempPath ()
- Change IsSerializable () test to how it was 11 years ago and have it write to a
file with a simple name (but now in a directory where noone else is writing)
- Change FieldsWithSameName (), FieldsWithSameNameAndType () and
MethodsWithSameNameAndSig () to use the default temp assembly (now in a
unique tempDir) instead of using the CreateTempAssembly ()
- Remove CreateTempAssembly function. It is dead code.
Suppose we have two versions of an assembly: AsmA 1.0.0.0 and AsmA 2.0.0.0 that
we want to load into the same domain at the same time (for example we want to
load AsmB and AsmC that statically reference the two versions, respectively, or
maybe we used reflection). Suppose version 1 got loaded first (and we found it
on our MONO_PATH in "somepathdir/AsmA.dll"). Now we want to load version 2.
The problem is that if version 1 is on MONO_PATH first, we'll find a filename
that matches ("somepathdir/AsmA.dll") and try to open that image. Then we'll
end up here in mono_assembly_open_predicate() after the mono_image_open_a_lot()
call hits the image cache. So we get back an image and image->assembly is
version 1.
The old behavior would just return any non-NULL image->assembly. The new
behavior is to check the predicate and reject opening the propose file if the
predicate doesn't match. (If we're not using the strict loader, or if there's
no predicate set, return the existing image->assembly as before).
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=57222
Although methods aren't affected by this bug, I added a regression test for
this case anyway in case the implementation changes.
Currently MethodBuilder.RuntimeResolve() goes through a different codepath - it
calls RuntimeType.GetMethod (MethodInfo) which calls into an icall which looks
for a method with a matching token rather than a matching name.
RuntimeType:GetField (FieldInfo) looks up the field by name and attributes,
which doesn't work for SRE because it is legal to create multiple fields with
the same name and type and attributes. So lookup using the
RuntimeFieldHandle (aka MonoClassField*) instead.
When creating a bundle on Windows to run on Android, macOS/iOS or Linux we need
to use the target system's path separator when storing satellite assemblies in
the bundle instead of the host system's one. Failing to do so will embed (on
Windows) the satellite assemblies with paths like
fr_FR\myassembly.resources.dll
while at runtime Mono will try to look up the assembly by
fr_FR/myassembly.resources.dll
and fail to find it, obviously. The `--style` parameter is now consulted to see
what path separator character should be used.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=55603
we got a couple of bug reports, all with the same failure:
https://bugzilla.xamarin.com/show_bug.cgi?id=44907https://bugzilla.xamarin.com/show_bug.cgi?id=46482https://bugzilla.xamarin.com/show_bug.cgi?id=51791
The bugs are private, therefore here what I wrote:
```
Thank you Matthias, this was very helpful.
>>> 09-30 12:24:50.347: A/DEBUG(6211): pid: 6191, tid: 6209, name: Thread-4 >>> com.distech.x50.ui.droid <<<
>>> 09-30 12:24:50.347: A/DEBUG(6211): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
>>> 09-30 12:24:50.347: A/DEBUG(6211): r0 d6b58728 r1 00004001 r2 00000000 r3 d6b58738
>>> 09-30 12:24:50.347: A/DEBUG(6211): r4 00000008 r5 ea97427c r6 00001f3c r7 00000015
>>> 09-30 12:24:50.347: A/DEBUG(6211): r8 00001f38 r9 00000015 sl d6b58728 fp d67fed90
>>> 09-30 12:24:50.347: A/DEBUG(6211): ip ea9742c0 sp d67fed60 lr ea7a4504 pc ea716a58 cpsr 800e0010
The crash happens on this assignment:
https://github.com/mono/mono/blob/de1865dad5c0350f391fedcaa08f02f610530d3f/mono/mini/mini-generic-sharing.c#L418
Here the according disassembly:
https://gist.github.com/lewurm/b1094749027c9e5ea19fdc4fac7905a7
The crash happens in the last loop iteration (`r9=i`, `r7=slot`). Looking
at the machine code it just _cannot_ happen, which is confirmed by the C
code as well: `*oti` successfully happens in the if check, but after
returning from `alloc_oti()`, `oti` doesn't contain a valid address anymore.
I suspect some weird hardware issue that fails to restore all registers
properly from the stack.
```
[...]
```
Thanks again Matthias. Unfortunately, I'm out of ideas, and I can't
blame anything but the hardware. The situation we see is too weird. We
segfault at offset `0xdda60: str sl, [r4]`, but really we should
already segfault at offset `0xdda2c: ldrge sl, [r4, #8]!"`. So I
suspect two things why this could happen:
(1) The instruction at `dda2c` fails to do the post-increment correctly
for *whatever* reason.
(2) Something along the execution path corrupts the stackslot, where
`r4` is saved, in such a way that it *exactly* masks it with `0xf`.
Everything else on the stack looks fine, so this is sort of very
unlikely to be honest.
This only happens on a very specific device: The Nexus 9 is the only
device that was ever shipped with the Tegra K1 T132. I suspect an issue
in the binary translation layer of `armv7` instruction set to the internal
micro-ops of the CPU. I tried to stress test the instruction in
question (see https://github.com/lewurm/ldrinsntest), however I was not
able to trigger a crash. So either, I'm missing some context in order
to trigger the bug or I'm on a completely wrong track.
That said, even if we could proof that it is indeed a hardware issue,
the workaround is also non-trivial (it would then either need a fix in
gcc or require a microcode update by the chip vendor).
```
And then we saw:
https://github.com/golang/go/issues/19809#issuecomment-290804472
Another hint that this device is buggy.
After looking at https://github.com/mono/mono/pull/4949 I did a
quick pass through the other config sections and found two more
cases where we missed adding to the properties list.
(cherry picked from commit cbd180afe6)
Otherwise, while we are clearing the domain, another domain might be created that has the same id as the current one. This would lead to crashes due to releasing of data from the newly created domain (ex gchandles).
* [S.R.I.RuntimeInformation] Fix FrameworkDescription on Android
It turns out using `DllImport ["__Internal"]` doesn't work on
XA (and other cases where Mono is embedded) because it searches
for the method in the host which embeds Mono and doesn't find it,
resulting in an EntryPointNotFoundException.
We need to switch to an icall instead. However there's already
an existing icall+BCL wrapper: Mono.Runtime.GetDisplayName().
Added IVT from corlib to S.R.I.RuntimeInformation so we can call it.
* Update API snapshot
(cherry picked from commit 37fe83f6ea)
replace it by its canonical open instantiation.
If we have
```
class Foo<A,B,C> { ... }
class Bar<T,U> { ... }
```
Then if someone tries to construct `Bar<Foo, int>` (or more precisely, the
MonoGenericInst corresponding to `<Foo, int>` instead return `Bar< Foo<A,B,C>, int >`.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=54485
The canonical instantiation of a generic type definition is the open
instantiation where the GTD is applied to its own generic parameters in order.
Suppose we have `class T<A,B> { ... }` then the canonical instantiation is just "T<A,B>".
When an AssemblyLoad event fires in a domain, a System.Reflection.Assembly
object is created in that domain for the assembly being loaded. The bug left
this object alive after the domain was unloaded, which lead to a GC crash.
The thread_state indicates whether we have a pending exception that needs to be consumed (be it sync or async). Normally we check the state before calling mono_thread_execute_interruption, but make sure we don't consume an exception if the thread_state doesn't allow us to (we can have an abort requested but mono_thread_clear_interruption_requested can return FALSE if we are inside an abort protected block and shouldn't process it)
Thread.Yield doesn't guarantee that the thread doing GCs won't do it excessively, leading to significant variances in test run time.
Decrease number of iterations since these tests can take around 1 min.
Bring in the change that makes building the "tool" subdirectory
in BTLS off by default - we don't need it in Mono and it fails
to build on some platforms with older C++ compiler.
(cherry picked from commit ab514a67ee)
Follow-up to https://github.com/mono/mono/pull/4899. I audited
all the places in BCL where we made use of Cecil's AssemblyDefinition
and made sure we're properly disposing them and not keeping files
unnecessarily open.
I used InMemory=true in cases where tracking the lifetime would
be complicated. There are also some tests in mcs/tests which I
didn't bother to fix.
(cherry picked from commit 3637f8cddf)
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
(cherry picked from commit 5077205a44)
It was #ifdef'ed to only be available on monotouch before,
but the testing_aot_full profile in CI runs into this test failure:
```
MESSAGE:
System.ExecutionEngineException : Attempting to JIT compile method '(wrapper native-to-managed) Mono.Btls.MonoBtlsSslCtx:NativeVerifyCallback (intptr,int,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
+++++++++++++++++++
STACK TRACE:
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_thread_interruption_checkpoint ()
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:GetFunctionPointerForDelegateInternal (System.Delegate)
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate[TDelegate] (TDelegate d) [0x00013] in <fa55a8c31ba0490383239e5850d81686>:0
at Mono.Btls.MonoBtlsSslCtx..ctor (Mono.Btls.MonoBtlsSslCtx+BoringSslCtxHandle handle) [0x00059] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Btls.MonoBtlsSslCtx..ctor () [0x0000b] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Btls.MonoBtlsContext.InitializeConnection () [0x00000] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Btls.MonoBtlsContext.StartHandshake () [0x00000] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncProtocolRequest asyncRequest, Mono.Net.Security.AsyncOperationStatus status) [0x00004] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (Mono.Net.Security.AsyncOperationStatus status) [0x0006b] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation () [0x0000d] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.AsyncProtocolRequest.StartOperation () [0x0003c] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.AsyncProtocolRequest.StartOperation (Mono.Net.Security.AsyncOperation operation) [0x00024] in <18810f39bffc41dcb0263eb2043cc10e>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Net.LazyAsyncResult lazyResult) [0x00057] in <18810f39bffc41dcb0263eb2043cc10e>:0
```
The attribute itself is already conditional on MONOTOUCH and
FULL_AOT_RUNTIME so simply removing the ifdef should fix the issue.
(cherry picked from commit f4ce23e0b7)
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.
When [Xamarin.Android attempts to build with mono/2017-04][0], the
build breaks when cross-linking Windows code via MXE due to the
presence of an undefined `inline`d function:
./.libs/libmini.a(libmini_la-tramp-amd64.o):…/xamarin-android/external/mono/mono/mini/tramp-amd64.c:746:
undefined reference to `mono_arch_unwindinfo_get_size'
Turn `mono_arch_unwindinfo_find_pc_rt_func_in_table()` and
`mono_arch_unwindinfo_get_size()` into `static inline` functions so
that they don't cause "undefined reference" linker errors.
Additionally, audit the rest of `mono` to ensure there aren't any
other `inline` functions that aren't `static`:
$ git grep '\<inline\>' mono | grep -v static | grep -E '(\.c|\.h):'
# ~50 matches, all of which are in comments or otherwise not relevant.
[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/388/
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.
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.
* [jit] Fix CPBLK for large sizes.
* [amd64] Fix the byref->byval passing of small arguments from gsharedvt methods, we were loading loading them as pointers, which meant the upper bits might contain garbage. Fixes#56247.
It is accessed with a 64bits atomic operation, so it needs to be 64bits aligned, even on a 32bits platform. A CPU exception EXC_ARM_DA_ALIGN triggers on armv7 32bits.
Fix https://bugzilla.xamarin.com/show_bug.cgi?id=56202
Use 'ObjCRuntimeInternal' as the namespace instead of 'ObjCRuntime' to avoid
these compiler-warnings when building xamarin-macios assemblies (which defines
the same types in the ObjCRuntime namespace, and to whom System.dll has an
InternalsVisibleTo attribute):
> xamarin-macios/src/build/watch/watch/Foundation/NSExtensionRequestHandling.g.cs(28,49): warning CS0436: The type `ObjCRuntime.INativeObject' conflicts with the imported type of same name'. Ignoring the imported type definition
> xamarin-macios/src/ObjCRuntime/INativeObject.cs(6,19): (Location of the symbol related to previous warning)
> xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.WatchOS/repl/System.dll (Location of the symbol related to previous warning)
If a remote invoke in another domain throws an exception, the xdomain-dispatch wrapper will serialize the exception and pass it over to the calling domain so that it can be rethrown there. Serializing the exception object can itself throw an exception which we didn't properly catch, leading to unwinding to the caller domain without changing the domain state back and wreaking havoc.
If the serialization of the original exception throws a new exception, this new exception takes its place, being passed instead to the caller domain.
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)
I noticed this when I cleaned my Mono repo and reran autogen.sh.
I suddenly got a popup from XQuartz about "Unrecognized option: =".
Turns out this was introduced in 9e967f00b3,
the second half of the if is missing `test`, so it actually runs
`x = xyes` which starts XQuartz :D
Also cleaned up the USE_NLS checking since that ran immediately
before this and just printed "no" before which confused me.
(cherry picked from commit 12d5afd75f)
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.
monodroid used to build its own version of mkbundle since it
requires slightly different code than the desktop. This
logic was protected in a #if block. Now that monodroid is
trying to make use of the shipped mkbundle rather than use
its own we need to turn this logic on at runtime.
A new parameter has been added
--bundled-header
When this option is passed, the code which skips including
mono/metadata/mono-config.h
will be skipped in favour of defining the required structures
and entry points directly.
(cherry picked from commit 59737b2a47)
If mono is compiled without DISABLE_STRICT_STRONG_NAMES, but someone passes
--assembly-loader=legacy at runtime, give them the lax strong name
checking behavior (a candidate assembly is good as long as the name is right, but ignoring
the public key token and version).
When strict strong name checking is enabled, Mono will check public key tokens
and versions match between a requested assembly reference and a candidate found
via its usual loading directories.
amend
errors are correctly dealt with.
Some network errors in iOS are exposed as Stream errors, specially those
related with the lost of the connection. This patch ensures that if such
an issue happens an exception is raised in the async read task.
Fixes bug https://bugzilla.xamarin.com/show_bug.cgi?id=53792
* Check strong names on a couple more codepaths during assembly loading. Fixes [bugzilla #580](https://bugzilla.xamarin.com/show_bug.cgi?id=580) and [bugzilla #55436](https://bugzilla.xamarin.com/show_bug.cgi?id=55436)
* Add `--apply-bindings=FILE` option. Allows us to specify a configuration file for assembly binding redirections when AOTing.
* Use the above flag when AOTing `System.ReflectionMetadata.dll` to pick up `csc.exe.config`
* Add all the Facades to the `framework_assemblies` list in the runtime. Facade and non-Facade framework assemblies behave differently:
* for Facades, don't do any version remapping, and any version is okay.
* for non-Facades, consult the version map to remap depdending on the --runtime used.
Previous it was just the desktop runtime, but now that we have special handling
for framework facade assemblies in the loader, we should do it on other
runtimes, too.
As long as the name and public key token matches.
This is different from the non-facade framework assemblies for which the
name and version must match but the public key token is ignored.
Apply bindings from configuration file FILE when running the AOT compiler.
This is useful if you need to AOT a module bar.dll that is loaded when the main
assembly foo.exe has a configuration file foo.exe.config that specifies
assembly bindings that bar.dll should respect.
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.
The TrimSpecial() method and Windows-specific code was removed from
xammac 4.5 so reflection can't find it anymore, handle this case.
Also add a workaround for SqlParameterCollectionTest.CopyToTest()
which fails on watchos since the SqlCommand would throw a PNSE.
It's a workaround because it just makes the test ignored since we don't
set the env var that ConnectionManager.Instance.Sql reads in XI tests,
but it makes the test consistent with the other tests in the suite.
We should fix this properly later on.
(cherry picked from commit ceabda8a54)
When ConnectionManager.Instance.Sql.ConnectionString throws in
SetUp() we'd still call SqlConnection.ClearAllPools() in the TearDown()
which happens for example when the connection string environment
variable is not set.
This is a problem on WatchOS since SqlConnection.ClearAllPools()
throws PlatformNotSupportedException there, making the tests fail.
Instead we now check whether the connectionString is set and only
call the method in that case.
(cherry picked from commit f11c25c426)
* [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).
(cherry picked from commit b9b2d23f1a)
When framework assemblies are compiled for the mobile runtime, they are
generally signed with a different key than the normal desktop one.
Unfortunately each assembly has different logic for which key is
used (typically silverlight.pub or corefx.pub in place of ecma.pub), and short
of hardcoding a table in the runtime, there's no good way to know.
Added a new EXTERNAL_FACADE_DRAWING_REFERENCE variable which
specifies the path to an assembly that contains drawing types,
e.g. in the monotouch/monodroid case System.Drawing is built
inside the XI/XA repos.
Also update netstandard typeforwards to the latest version
from the dotnet/standard repo.
(cherry picked from commit a0d6c26a04)
resgen.exe used to load WinForms via reflection which is a pretty
large dependency. Instead we can just embed the few types that
are used for reading/writing resx files directly into the app.
Add System.Drawing.dll to the "build" profile so we can put
resgen there as well and allow us to no longer rely on system
resgen for mobile profiles like monotouch/monodroid.
(cherry picked from commit 9635b9cea0)
Also remove Mono.Simd as we don't it on new platforms.
Cleanup monotouch_dirs to not depend on testing_aot_full_dirs since
it should be separate (even though it contains the same right now).
(cherry picked from commit 13f5db4888)
Loading modules for other processes can fail under some linux sandboxing rules but that doesn't mean
we should not be able to compute the process name. So when module == NULL, we make module loading non-fatal.
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)
* [runtime] Add support for the simplest case of default interfaces, where the default method is used.
* [runtime] Implement overriding of default interface methods in interfaces.
* [jit] Fix gshared support for default interface methods, they require an mrgctx since the this argument doesn't point to the implementing class, not the interface.
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.
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.
* [interp] Fix a few problems exposed by the iltests.exe test suite.
The ENDFINALLY opcode should empty the stack. The INITBLK opcode is two bytes.
* [interp] Store the MonoMethod->RuntimeMethod mapping in a separate hash in MonoJitDomainInfo instead of using MonoDomain.jit_code_hash, the latter contains MonoMethod->MonoJitInfo mappings. Also avoid holding the domain lock while creating the RuntimeMethod structure.
* [interp] Add a mono_jit_compile_method_jit_only () function which always compiles its argument using the JIT/AOT.
* [interp] Print a warning when --interpreter is used with a runtime compiled without ENABLE_INTERPRETER.
* [interp] Fix the size of the icall enter trampoline on amd64. Fix some formatting issues.
* [interp] Add support for calling JITted code from the interpreter. This uses the gsharedvt_out wrappers used by bitcode to reduce the number of possible calling conventions since all arguments and the return value are passed/returned by value. Not enabled yet.
* [interp] Add a --interp= argument which allows passing of options to the interpreter. Add a 'jit=' option which is used to control the set of types whose methods will be called by exiting the interpreter.
* [interp] Add tests for mixed mode execution.
* [interp] Add support for calling interpreter code from JITted code.
* [interp] add mixedmode target to CI
* Revert a debug change.
* [runtime] Fix the locking in the gsharedvt/interp wrapper creation functions.
* [interp] Implement support for interp->jit calls with more than 8 arguments.
This remove the possibility to execute different callbacks on the threadpool, but this allows us to remove the work_items_lock, which is called on the hot path of the ThreadPool.
- 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"
issues found with
`MONO_GC_DEBUG=3,collect-before-allocs,check-remset-consistency ../mini/mono-sgen --interpreter /Users/bernhardu/work/mono/b/lib/mono/4.5/mcs.exe hello.cs`
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
Doxygen treats '@code' as the start of a '@code'...'@endcode' block, so
it raised spurious "reached end of file while inside code block" errors
when '@code' was used to denote a parameter. Change these instances to
'\param code' (declaration) and '\p code' (mention).
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.
* [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.
Test that HttpWebRequest.AutomaticDecompression actually performs the
decompression and that it removes the Content-Encoding header. Also fix
the value of Content-Encoding for other tests to follow the HTTP
specification.
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 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.
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.
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).
When building mono solution from Visual Studio it correctly handles incremental
builds just rebuilding what's needed. When doing the same from msbuild it rebuilds
to much. This happens due to two different issues.
First, a change in winconfig.h setting up a define for corlib version was not
included in our compare config file script, so diff was detected as a change in
config file causing a replace of config.h triggering a complete rebuild.
Second, once above was fixed there was still a rebuild of mini-amd64.c when not needed.
This was due to a difference in how post build events are handled in Visual Studio
and msbuild. Visual Studio will detect that the complete project won't need to be
rebuild and then it doesn't trigger any of the events. msbuild on the other hand
will trigger events even if nothing needs to be rebuild and that triggered creation of cpu-amd64.h
that in turn will trigger rebuild of mini-amd64.c. Switching from post build event
to a custom build step with proper input/output files will work as expected in both
Visual Studio and msbuild.
Commit also disables the build of test projects that are part of solution
but won't provide any build output. These projects are mainly there to make launching of test
configurations easier and doesn't need to be included in solution build.
* [System.Web] Fix standalone-runner to return non-zero exit code on failure
We didn't notice that test runs with standalone-runner.exe failed
because it still exited with 0 in those cases.
Fixed that and the standalone tests that showed up as failed in
System.Web.Extensions (some differences likely from referencesource
code import).
* Fix replacement logic for Consts.cs.in to use Windows paths
TrustStatus and X509SelectionFlag are missing from .NET Core (https://github.com/dotnet/corefx/issues/17194), hence TrustStatus was taken from .NET Framework and X509SelectionFlag was left untouched.
* less allocation in Socket
avoid allocate `System.Threading.QueueUserWorkItemCallback` in `SocketAsyncResult.Complete`
avoid allocate `Task` and anonymous function in `Socket.QueueIOSelectorJob`
* update: fix race and use replace static field with in line lambda
* cleanup code
* QueueIOSelectorJob keep async, and provie a fastpath
* SocketAsyncResult: simplify callback code
* add missing line `IOSelect.Add(handle, job)` :(
* fix typo
* fix compile error
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.
These tests place strong named assemblies on the MONO_PATH and into
MONO_GAC_PREFIX in various configurations and check that when a strong assembly
name is specified: mono will ignore non-strong named assemblies that come
earlier in the search paths; mono will ignore strong named assemblies that have
the right filename and come earlier in the search path but have an incorrect
strong name.
DefineDefaultConstructor_Parent_DefaultCtorInaccessible:
On Mobile, due to the Silverlight CoreCLR sandboxing, MethodInvoke doesn't wrap MethodAccessException in TargetInvocationException.
Instead of fixing the mobile difference, we adjust the test.
LoadWithPartialName:
Stop hardcoding the test assembly name otherwise this test will break on every new profile we add.
ReflectionOnlyLoadFrom:
Don't assume that the test suite was loaded from $CWD.
GetRuntimeDirectory:
Not all monodroid targets embed assemblies in the same way. So make a reasonable assumption instead.
Currently mono_arch_unwindinfo_install_tramp_unwind_info can only be called on
JIT:ed code since it assumes place for unwind info has been allocated behind
code block. When called by AOT:ed code the complete this is have not done and
the unwind info should not be registered with OS for AOT:ed code
(should be part of the image).
1. Don't re-add the domain assemblies to the hashtable on every recursive
call - they are already in there (we're holding the assemblies_lock, noone
else can add anything to domain->domain_assemblies); just add them once when
the hash table is created.
2. When iterating over the referenced assemblies, don't stop at the first NULL.
a NULL means that referenced assembly hasn't been demanded by anyone yet,
but there's no reason to assume some other referenced assembly that happens
to come later in the table hadn't been resolved. Iterate upto assembly->nreferences.
* bug-30085 test
mscrorlib pubKeyToken depends on what we're testing
* bug-17537 test
AOT the helper assembly so it can be loaded by fullaot runtime
* bug-3903 test
explicit paths to corlib and System.Core reference assemblies
If an assembly references another with a strong name, the loader will require
that the strongly named assembly match exactly the requested name (name, version, culture, public
key token).
For assemblies without a strong name, continue Mono's existing behavior.
Actually create a new mono_assembly_load_from_predicate () and call that from
the old mono_assembly_load_from_full ().
This function is responsible for creating brand new MonoAssembly* values and
then committing them by calling mono_assembly_invoke_load_hook(). So if we
would like to have a chance to reject a candidate assembly from loading for
some reason, this is the only place we can do it:
* anywhere before the call to mono_assembly_load_from_predicate there is no
MonoAssembly* yet.
* anywhere after mono_assembly_load_from_predicate returns, the load hook was
already called (in a plain vanilla Mono, there's an installed load hook
called mono_domain_fire_assembly_load () which caches the MonoAssembly* in
the domain that requested the load - after that point we cannot possibly
consider another MonoImage* for the same MonoAssemblyName - the appdomain
will always return the cached one).
The next commit will use this predicate to reject some strongly named
assemblies when the candidate assembly doesn't exactly match the wanted
MonoAssemblyName. (Note that load_from doesn't have the MonoAssemblyName that
was requested, so we'd have to thread /something/ down here - might as well be
a predicate function.)
This is an extension of mono_assembly_open_full with a user-supplied predicate
that gets a chance to interrogate the candidate MonoAssembly before it is
consider successfully loaded.
`mono_domain_alloc` does that for us. also, use proper locking around
JIT code hashtable. the interpreter repurpose the JITs hashtable, so
let's use the existing locks.
Otherwise mono-api-info crashes on System.Windows.Forms.dll with a NotImplementedException.
This is the only place in the codebase where we used `BindableSupport.Yes` instead of `true`.
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
This was initially done so we didn't get orange builds
when ppc64el was in the same job as our other archs.
ppc64el was since moved into a separate job so we can
stop skipping the test suites.
Also fixed badges in README.md for ppc64el and s390x
For timeouts of 0 milliseconds, WaitOne may produce incorrect results. In case of timeout, the result of WaitAny denotes the amount of milliseconds that have timed out. WaitOne relies on WaitAny and interprets the result falsely as the index of the completed handle. This change introduces a check on the timeout and returns `IsSet` when the handle is not allowed to block.
This is in accordance to Microsofts [documentation of WaitOne](https://msdn.microsoft.com/de-de/library/cc189983(v=vs.110).aspx) which states "If millisecondsTimeout is zero, the method does not block. It tests the state of the wait handles and returns immediately.".
[Here](https://github.com/StephenCleary/AsyncEx.Interop.WaitHandles/blob/master/src/Nito.AsyncEx.Interop.WaitHandles/WaitHandleInterop.cs#L51) is an example of some code relying on correct output of `WaitOne(0)` that is effectively broken by the current behaviour.
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.
due to the way basic block handling is done in the interpreter, it can
happen that we have one additional element on the stack (as opposed to
what metadata tells us)
unbox is supposed to push a managed pointer on the stack and ldobj does
the actual value copy. unbox_any is basically unbox+ldobj according to
the spec.
fixes random crashes in test_0_regress_80622:iltests.il
This should hopefully "fix" the mass fails in the WinForms
tests we sometimes see in CI.
We're using the simplest WinForms code that invokes the XplatUI
and causes the X connection to be established, if this fails
then something is seriously wrong and we skip the WinForms tests.
Apparently Roslyn looks in -lib directories only if it doesn't find the needed
assembly in MONO_PATH first. On the other hand, using a full path with -r will
take priority over the assemblies in system directories.
Mono.Options.CommandSet allows easily having separate commands and
associated command options, allowing creation of a *suite* along the
lines of **git**(1), **svn**(1), etc.
CommandSet allows intermixing plain text strings for `--help` output,
Option values -- as supported by OptionSet -- and Command instances,
which have a name, optional help text, and an optional OptionSet.
var suite = new CommandSet ("suite-name") {
// Use strings and option values, as with OptionSet
"usage: suite-name COMMAND [OPTIONS]+",
{ "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 },
// Commands may also be specified
new Command ("command-name", "command help") {
Options = new OptionSet {/*...*/},
Run = args => { /*...*/},
},
new MyCommandSubclass (),
};
suite.Run (new string[]{...});
CommandSet provides a `help` command, and forwards `help COMMAND`
to the registered Command instance by invoking Command.Invoke()
with `--help` as an option.
There are now 4 kinds of arguments to icalls:
1. Plain old values like 'int', 'bool', etc. Passed from the wrapper to the
icall as is.
2. Objects in the managed heap. Passed using coop handles.
3. 'out' objects in the managed heap. A NULL coop handle is passed in
and its final value is written back out to the caller's out argument.
4. Value types passed by 'ref' or 'out'. An "interior" coop handle is created which has
the effect of pinning the object into which the ref points (if it points
to the stack, nothign happens). The argument is passed to the icall as a
raw reference (MonoFoo*, not MonoFooHandle). The ref will be unpinned
when the icall wrapper returns.
- Call mono_handle_stack_scan for both the precise and the imprecise gc scans.
- For now assert during scan that all handles are to the beginning of an
object.
- Add TYPED_VALUE_HANDLE_DECL Macro to declare valuetype handles:
TYPED_VALUE_HANDLE_DECL (MonoMethodInfo);
/* Declare MonoMethodInfoValueHandle and MonoMethodInfoValueHandleOut */
- Add MONO_HANDLE_NEW_GET_VALPTR (h, type, field) macro to create a new handle that
points to "field" (of type "type") in the object "h".
valgrind said this on `mcs --version`:
```
==807== Thread 1:
==807== Source and destination overlap in memcpy(0x413f050, 0x413f050,
8)
==807== at 0x4C32513: memcpy@@GLIBC_2.14 (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==807== by 0x7FB6DD: sgen_qsort_rec (sgen-qsort.c:76)
==807== by 0x7FB8CC: sgen_qsort (sgen-qsort.c:118)
==807== by 0x7ED834: major_free_swept_blocks (sgen-marksweep.c:2136)
==807== by 0x7F0590: sgen_memgov_calculate_minor_collection_allowance
(sgen-memory-governor.c:114)
==807== by 0x7F0D2E: sgen_memgov_major_collection_end
(sgen-memory-governor.c:278)
==807== by 0x7A6C71: major_finish_collection (sgen-gc.c:2116)
==807== by 0x7A6E23: major_do_collection (sgen-gc.c:2158)
==807== by 0x7A7464: sgen_perform_collection (sgen-gc.c:2355)
==807== by 0x7A85AF: sgen_gc_collect (sgen-gc.c:2854)
==807== by 0x77C022: mono_gc_collect (sgen-mono.c:2574)
==807== by 0x726A18: mono_domain_finalize (gc.c:439)
==807==
==807== Source and destination overlap in memcpy(0x413f078, 0x413f078,
8)
==807== at 0x4C32513: memcpy@@GLIBC_2.14 (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==807== by 0x7FB6DD: sgen_qsort_rec (sgen-qsort.c:76)
==807== by 0x7FB798: sgen_qsort_rec (sgen-qsort.c:92)
==807== by 0x7FB8CC: sgen_qsort (sgen-qsort.c:118)
==807== by 0x7ED834: major_free_swept_blocks (sgen-marksweep.c:2136)
==807== by 0x7F0590: sgen_memgov_calculate_minor_collection_allowance
(sgen-memory-governor.c:114)
==807== by 0x7F0D2E: sgen_memgov_major_collection_end
(sgen-memory-governor.c:278)
==807== by 0x7A6C71: major_finish_collection (sgen-gc.c:2116)
==807== by 0x7A6E23: major_do_collection (sgen-gc.c:2158)
==807== by 0x7A7464: sgen_perform_collection (sgen-gc.c:2355)
==807== by 0x7A85AF: sgen_gc_collect (sgen-gc.c:2854)
==807== by 0x77C022: mono_gc_collect (sgen-mono.c:2574)
==807==
==807== Source and destination overlap in memcpy(0x413f088, 0x413f088,
8)
==807== at 0x4C32513: memcpy@@GLIBC_2.14 (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==807== by 0x7FB6DD: sgen_qsort_rec (sgen-qsort.c:76)
==807== by 0x7FB798: sgen_qsort_rec (sgen-qsort.c:92)
==807== by 0x7FB798: sgen_qsort_rec (sgen-qsort.c:92)
==807== by 0x7FB8CC: sgen_qsort (sgen-qsort.c:118)
==807== by 0x7ED834: major_free_swept_blocks (sgen-marksweep.c:2136)
==807== by 0x7F0590: sgen_memgov_calculate_minor_collection_allowance
(sgen-memory-governor.c:114)
==807== by 0x7F0D2E: sgen_memgov_major_collection_end
(sgen-memory-governor.c:278)
==807== by 0x7A6C71: major_finish_collection (sgen-gc.c:2116)
==807== by 0x7A6E23: major_do_collection (sgen-gc.c:2158)
==807== by 0x7A7464: sgen_perform_collection (sgen-gc.c:2355)
==807== by 0x7A85AF: sgen_gc_collect (sgen-gc.c:2854)
```
* Finalize the implementation of SignedXml.ComputeSignature().
The implementation was taken from Reference Source, which makes the behaviour of this method the same as in .NET Framework, as well as makes it possible to use custom signature descriptions.
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.
For the profiles where we compile the BCL with -d:MOBILE, (where the
`[assembly: AssemblyVersion (Consts.FxVersion)]` attribute ends up pointing to
the mobile version) make sure we AOT and run the tests using the mobile
runtime. This ensures that for the framework assemblies the version number in
the assembly matches the version number that the internal runtime remapping (
`mono/metadata/assembly.c` `framework_assemblies` array)
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.
Current mono build on (at least Windows) fails if build with disabled JIT
since the .def file used when building libmono, mono-2.0-sgen.dll, exports
a couple of symbols missing when DISABLE_JIT is defined.
Turns out that these methods have been incorrectly exported and should not
be part of the public API surface. This commit removes MONO_API for the
methods incorrectly marked:
mono_emit_native_call
mono_inst_name
mono_replace_ins
It also removes them from the .def files so they won't be exported in the
mono runtime DLL on Windows.
For mono_set_break_policy an empty stub will be added since it is considered
being a public API.
The above support is primarily used on none desktop Windows platforms
when building mono runtime module without JIT support.
This commit also fix a problem introduced in tramp-amd64.c by commit
https://github.com/mono/mono/commit/4281399ba4b7c44a30fa2c2a314a470260bb3eb1
causing it to get duplicated definitions of mono_arch_get_enter_icall_trampoline
when DISABLE_JIT has been defined.
This allows centralized configuration of library paths. For instance,
previously setting path to libgtk-x11-2.0 won't make all parts of Mono use
provided library.
Wait functions for Mutex, Semaphore and Condition (like pthread_cond_timedwait) for 'task' synchronisation in Linux uses CLOCK_REALTIME by default,
this creates many problems where a process changes time. e.g. Command line utility < date -s "desired date and time" >
A thread may be blocked for a more\less time depending upon time change. It is always desirable to use clock source immune to such changes
However, it is not possible to change clock source for mutex and semaphore wait functions in Linux. So changing it for condition only
This can be seen by a simple application if you make a simple timer using System.Timers.Timer and print time stamp every regular interval say 2 seconds, now if time shifts in the system for whatever reason ( you can do this in Linux by <sudo date -s "Wed Oct 26 20:25:24 IST 2016"> put desired time in quotes), this print stops coming for the offset time duration.
The reason behind this is the call to 'pthread_cond_timedwait' function, by Timer class which uses it to sleep for timeout duration. Now this function uses CLOCK_REALTIME which can be changed, so if you change this clock, a thread will be blocked for the unexpected time. So using CLOCK_MONOTONIC removes the error.
There are many embedded systems which do not have RTC and rely upon the external time like systems using GPS or set top box. So this fix is inevitable for them, at least for condition variable wait.
This is the sample code
using System;
using System.Timers;
public class Example
{
private static System.Timers.Timer aTimer;
public static void Main()
{
SetTimer();
Console.WriteLine("\nPress the Enter key to exit the application...\n");
Console.WriteLine("The application started at {0:HH:mm:ss.fff}", DateTime.Now);
Console.ReadLine();
aTimer.Stop();
aTimer.Dispose();
Console.WriteLine("Terminating the application...");
}
private static void SetTimer()
{
// Create a timer with a two second interval.
aTimer = new System.Timers.Timer(2000);
// Hook up the Elapsed event for the timer.
//((System.ComponentModel.ISupportInitialize)(aTimer)).BeginInit();
aTimer.Elapsed += OnTimedEvent;
//((System.ComponentModel.ISupportInitialize)(aTimer)).EndInit();
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
Console.WriteLine("__The Elapsed event was raised at {0:HH:mm:ss.fff}",
e.SignalTime);
}
}
This updates and merge https://github.com/mono/mono/pull/3828
This commit improves the unwind support on Windows x64 by implementing a number
of missing features. It also adds support for out of proc function table callback
module on older OS versions and switch to different function table methods
(growable function tables) on Win8/Win2012Server and later OS versions.
Commit aligns more to the windows x64 prolog/epilog ABI, but since mono
uses negative offsets from frame pointer while x64 windows uses positive, it is
not possible to do a 100% "correct" representation in the prolog, but if we don’t
give the OS unwinder the full unwind metadata in the frame pointer use case,
we can trick unwinder to do the right thing presenting correct callstacks in
debuggers.
Commit includes representation of windows unwind info in mono's unwind data
using extensions to better integrate windows specific unwind info in
areas currently not supported (like trampolines). It will also be easier to implement
unwind info in full AOT objects in the future, if windows specific unwind data is
included in mono’s unwind data structures.
On Win8/Win2012Server and later OS versions, all function table data is registered
using growable function tables giving full support for callstacks on live debug targets
and crash dumps. On previous OS versions function table callbacks are used together
with an out of proc module. This works for live debugging in WinDBG and Visual Studio
(if right permissions are given to the debuggers to load out of proc unwind module).
Crash dumps works as expected in WinDBG but currently not in Visual Studio for older OS
versions using callback support. If that use case needs to be supported it needs to be
solved in a separate PR, but since we support crash dumps in Visual Studio on later OS
versions and in WinDBG on earlier, it is still possible to analyze crash dumps by picking
the right tool.
Debuggers needs some additional information to work with function table callbacks out of proc
modules (NOTE, this is NOT needed on Win8/Win2012Server and later).
WinDBG:
To just do live debugging, it is possible to run the following command in WinDBG,
settings set EngineInitialization.VerifyFunctionTableCallbacks=false
To do crash dump analysis the following registry key needs to be set,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\KnownFunctionTableDlls
Add the full path to mono-2.0-dac-sgen.dll matching the mono-2.0-sgen.dll as a 32-bit REG_DWORD.
NOTE, adding the registry key removes the need to set the setting.
Visual Studio:
To do live debugging, set the same registry key as WinDBG use case.
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).
Volatile variables should be ignored by AA as, by design, we can't
properly tell whether removing indirection is safe or not.
This shows up when handling the LMF var in some cases.
* Set boehm to disabled
* Set threading to use pthreads, not __thread
(causes static TLS issues)
* Add the library needs for locale
(FIXME: does this apply to eglib?)
* proclib: Adapted Andreas' code to the refactored proclib.
Allocates ahead of time.
* threads: pthread_setschedparam is semantically different on Haiku,
because it returns positive numbers on success. Handle this
difference.
With these changes, Mono can now get to the point Roslyn runs, and
fails immediately due to lack of stack walking.
Much of the code was bitrotting as refactors were done. With this,
mono-sgen can be compiled. Code in support/ is still broken,
however. The compiled binary hasn't been tested yet as a result.
Run configure as: LIBS=-ltextencoding ./configure --disable-boehm
boehm looks to be a mess to port and diverged from upstream making
integration of Haiku support difficult. For now, SGen should be OK.
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.
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.
=================================================================
```
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
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
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.
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.
In some hashtables we add multiple elements with the same hash. If we use only the address for hashing they would cluster since they are likely to have close addresses.
We mark cards when storing in hashtables. During minors, instead of scanning the entire tables, we only scan the sections for the dirty cards. In order to simplify the implementation we split into separate key/value tables.
To achieve this, instead of using an user descriptor for the hashtable structure, we directly register the tables and we create a new type of root descriptor for it to teach sgen how to find pointers in it. In addition to the precise scan of the root, which is done during majors, we also support a remset scan for it. We expect all roots registered as ROOT_TYPE_WBARRIER, to use this new descriptor (ROOT_DESC_VECTOR). In order for a root descriptor to be in the ROOT_TYPE_WBARRIER category, it has to have a defined remset scan mode.
* [threadpool] Let the runtime abort and wait for threads on shutdown
We would previously have the threadpool abort and wait for its threads during runtime shutdown, but it would tend to be buggy or leaky. The runtime already takes care of aborting and waiting all the other threads, so we simply also let it take care of the threadpool threads.
* [threadpool] Wake up all parked threads on shutdown
This fixes a hang at shutdown, where one or more threadpool threads might not be unparked and only exit after the timeout, delaying runtime shutdown.
`/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.
not quite sure yet what the requirements are, but this works now for
executing a simple hello world :-) in metadata/gc.c we use this
interface to call the Finalize method on objects.
console_close triggered a MONO_REQ_GC_SAFE_MODE assert in checked mode on
because the console handles were unref'd which caused them to close.
Until w32handle is coop-aware, just transition to GC unsafe mode (a noop if
it's already in unsafe) in these callbacks.
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.
When building on Android with BTLS support, the '--with-btls-android-ndk' argument
is required to teach the underlying cmake the NDK location. Fixes#52511.
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.
Followup to last commit (f238640c9f).
We need to transition to unsafe to call file_share_release and the _wapi_
functions, and then back to safe to call close(2).
* [w32file] Push coop transitions into functions, closer to syscalls
Previous the coop transitions happened in the icalls and high level
platform-independent functions. Now they surround syscalls and platform API
calls, instead.
(Among other benefits, this fixes a problem where MoveFile on unix was
implemented in some circumstances in terms of CopyFile which resulted in an
illegal coop transition from blocking to blocking.)
* There is a FIXME with `mono_w32handle_new_fd` and `mono_w32handle_close`: the w32handle API is not coop-friendly yet, so we have to switch to gc safe mode around calls to `w32handle_new_fd` and `w32handle_close`. In the case of `w32handle_close`, it calls back into the w32file functions `pipe_close`, `console_close` and `file_close`. So the calls to `close(2)` inside those functions are not surrounded by transitions to GC safe mode - instead they require that we're already in safe mode (as is the case when they're called from w32handle).
* During the ambiguous hour .NET will return the DST version of the time whereas mono is returning the base time. Rather than use the transitions array we look up the Adjustment rules (which are created from the transition rules in the first place).
In addition, CurrentTimeToUtc() also has problems around the transition time.
Added test and fixed another.
Fixes#43805.
* Despite the tutorial on msdn about daylight saving time, .NET interprets the 'ambiguous' hour of DST as being DST rather than standard time which is what mono did.
The disabled tests assume perfect scheduling and non-coalescing system timers. Neither exists
on OSX Sierra, iOS or Android. This tests fail there regularly.
* * [exceptions] When encountering a filter (when) clause, don't setup the stack trace before we know if the filter is going to work. Otherwise, any exception that isn't blocked by the when clause will have its stack trace cut at the point of the parent of the function containing the when clause
* Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=46661
* + Added test case for bug 46661
Previously pasting of Unicode text, e.g. from LibreOffice, resulted in
question marks being displayed.
This fixes Xamarin-7359.
Change-Id: I78ec4cb1bbbd0e14da91d06a6fc517bc5c91e135
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
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
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.
* When 'settings != null' and 'settings.CertificateSearchPaths == null',
then we add the default paths, including the 'settings.TrustAnchors'.
This applies to all platforms, including Android.
* In MonoBtlsContext, we can now simply call
MonoTlsProvider.SetupCertificateStore(MonoTlsSettings,bool) instead of
having a custom version of it.
Waiting for the threadpool threads to exit on shutdown triggers a hand. The simplest solution is to not wait for them, and let the OS clean them up.
This is not an ideal solution, but this is to fix a months-long chase for this bug, and to release a less-buggy monthly release.
mono_arch_code_chunk_new()/mono_arch_code_chunk_destroy() are not compiled in
on Windows when DISABLED_JIT is defined.
code_manager_chunk_new()/code_manager_chunk_destroy() in mini-runtime.c, which
use these functions, will however be compiled in on Windows regardless of
whether DISABLED_JIT is defined or not. This causes linking failures due to
missing mono_arch_code_chunk_new()/mono_arch_code_chunk_destroy() symbols when
building on Windows and DISABLE_JIT is defined.
* [btls]: Add option to specify the certificate search paths.
* MonoTlsSettings.CertificateSearchPaths: new property.
Valid values are
- @default - add default search paths
- @user - add default user search path
- @machine - add default machine search path
- @trust - add 'MonoTlsSettings.TrustedRoots'
- @pem:<directory> - custom directory containing certificates in PEM format
- @der:<directory> - same, in DER format
* Make it internal for the moment.
* Cosmetic; use "?.".
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.
# make dist will collect files in .sources files from all profiles
dist-local: dist-default
subs=' ' ; \
for f in `$(topdir)/tools/removecomments.sh $(filter-out $(wildcard *_test.dll.sources) $(wildcard *exclude.sources),$(wildcard *.sources))` $(TEST_FILES) ; do \
for f in `$(topdir)/tools/removecomments.sh $(filter-out $(wildcard *_test.dll.sources) $(wildcard *_xtest.dll.sources) $(wildcard *exclude.sources),$(wildcard *.sources))` $(TEST_FILES) ; do \
Loaded 100 of 1763 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.