This involves a few steps.
First define MonoAssemblyName in RuntimeStructs.cs
Then add some helped to decode blob arrays and handle hex digits.
Finally, move the actual implementation from native to managed.
And call it consistently in thread start functions when the managed
thread start function returns with an exception.
(If coop is not enabled, the exception handler unwinds the thread and
when there's no handler invokes the unhandled exception hook via
jit_tls->abort_func, so this is just for the coop case.)
Fixes mono/tests/unhandled-exception-1.cs for coop and bitcode.
Allows safe allocation of native utf8 char* strings from managed
strings.
using (var h = new SafeStringMarshal (str)) {
/* use h.Value IntPtr */
} // g_free'd by h.Dispose ()
This is necessary on weird devices where the hwcap code might fail to detect
the ARM version it's running on (usually caused by differences in /proc/cpuinfo
output).
Some Android devices for some reason have a 'model name' line instead of a
'Processor' line. On such devices, we would fail to detect the architecture
version at all, and end up thinking that it's ARMv4 (even if the runtime
was compiled for ARMv7).
When we shutdown we set suspend_finalizers flag in metadata so we no longer run any finalizers. After recent changes, we avoid traversing gc hashes for finalizer enqueuing when this flag is set. The counterpart, popping the queues empty (even without running the finalizers) can still take some time, especially since we lock for each entry. Exit early from this loop if we no longer need to run finalizers.
Achieve this by setting a new flag inside sgen, instead of passing the address of suspend_finalizers all the time to the sgen api.
By asserting on error, we ensure that we return from these functions only when successfull, or when it makes sense to return an error (for example, timedwait return -1 only on timeout or interrupt).
By asserting on error, we ensure that we return from these functions only when successfull, or when it makes sense to return an error (for example, timedwait return -1 only on timeout).
The following scenario might happen:
- thread A: returns from tpdomain D1, then parks
- thread B: returns from tpdomain D1, D1 is unloading so it's removed with `domain_remove`
- thread A: unparks, calls `domain_get_next` with tpdomain D1
- domain_get_next asserts as it can't find tpdomain D1 in the list of domains
To fix that, we simply set the previous_tpdomain to NULL when unparking.
This was from when we did a nursery collection as part of the
finishing collection pause. Now that we don't do that anymore, we
underaccount major collection times.
The store/store fence incurs quite a high cost, so we only want it to
run when absolutely necessary. The most efficient way is to
separately compile nursery object operations for when the concurrent
collector is running, so there has to be no dynamic check.
In the future we might want to try batching updates of references to
moved objects so we have to do only one fence per batch.
The missing remset check uses the binary protocol to log missing
remsets it found. Debugging is easier if we don't have to manually
flush the binary protocol.
If a thread is interrupted after a reference write but before the corresponding
write barrier, the remset will be missing, but the object will be pinned.
After the latest code changes, we may land here with `errors == SslPolicyErrors.None`,
so we need to make sure that we actually set it to `RemoteCertificateChainErrors` if
the system validator returns an error.
(cherry picked from commit b4304354b1)
Alternative implementation to 8f092147bb.
In CI we explicitly pass EMIT_NUNIT=1 and check-seq-points to generate the nunit xml and run the tests,
locally those are omitted. This avoids needing to sniff for Jenkins/Wrench variables.
Same for a9eec21d62, but we already pass V=1 in Jenkins.
When doing the first phase of sweeping we tag the block pointer within the block list with a CAS, after which we own the block and we are free to update the state and do sweep computations on the block. When we finish this phase we directly write the untagged block pointer back in the list, making the block available to inspect by other threads. We need a write barrier before writting the untagged pointer back because, when another thread might acquire the block, it might encounter an invalid block state.
I noticed this while looking at why Mono.CSharp is registered as "crashed" in the the new
fullaot PR job on Jenkins. It turns out all tests were excluded in mobile_static which means
no NUnit xml was produced and that is exactly what the script then interprets as a crash.
I saw that ASTVisitorTest.cs was not included in the net_4_x tests as well, likely inadvertently.
It got bitrotten over the years so I had to fix it up a bit, now it compiles/runs on mobile_static as well.
Since acceptance-tests/Makefile (and llvm/Makefile) include scripts/submodules/versions.mk which evals versions.py which looks
for a SUBMODULES.json file in the current working directory we got confusing error messages if the build directory is not the src dir:
```
Traceback (most recent call last):
File "../../mono/scripts/submodules/versions.py", line 22, in <module>
submodules = json.load(open(CONFIG_FILE))
IOError: [Errno 2] No such file or directory: 'SUBMODULES.json'
```
Instead we now pass the path to SUBMODULES.json as a variable to versions.py and set it based on $(top_srcdir) so it works
even for out-of-tree builds.
In order for our exception handling to work on linux, we need the
unwind-dw2-fde-dip implementation in libgcc to work with our
.o file. This requires that `--eh-frame-hdr` be passed by the linker.
By using clang++ as the linker, we will get this and other flags
necessary for correct interop with c++ libraries.
Fixes issues where ResponseStream.Close would throw an exception when
peer had already closed the connection and ResponseStream.Close would
still try to communicating to peer that it was closing.
The issue was brought to our attention by failures on:
- MonoTests.System.Net.WebRequestTest.TestReceiveCancelation
- MonoTests.System.Net.HttpWebRequestTest.TestLargeDataReading
A common pattern that we use across the test suite is to create objects on a new thread, join the thread, collect then expect certain objects to be dead/finalized since we assumed that thread to be no longer a source of pinning. This is not always the case since, after joining, the thread might still be alive and running unmanaged code related to the thread shutdown, which can reuse the stack that previously contained the managed references.
The workaround is to still allocate objects far down the stack, even if we are on a separate thread.
At the moment the helper can be used in tests which run under the TestDriver (since it's included in TestDriver.dll) and can also be included as a helper source for test bcl classes that need it.
This reverts commit cf94a6fcd4.
It seems this causes something that prevents the chroot from unmounting in the Linux builds on Jenkins,
resulting in an endless "can't unmount" loop and stuck builds. Reverting to see if this fixes it.
For objects that die at the same time, normal finalizers should be run before critical finalizers. When we were unloading a domain we were running finalizers for all objects in that domain without checking whether the finalizer is critical or not. Now we enqueue the objects first in the finalization queues so we can run all the normal finalizers before the critical ones.
Fix for the following failing pinvoke tests in runtime tests suite on win x64:
* pinvoke11.exe
* winx64structs.exe
* pinvoke_ppcs.exe
* pinvoke_ppcc.exe
- Microsoft.WebApplication.targets was inadvertently removed.
- The new Microsoft.NuGet.Build.Tasks assembly sources were not getting dist'ed. Adding to DIST_ONLY_SUBDIRS fixes this for now,
though we can maybe add it to SUBDIRS instead (but neither me nor Marek know for what exactly that's used)
ILASM.exe has features which a mobile_static runtime will not support.
It is invoked with an external mono when used in the runtime.
We skip it here because otherwise it will fail to verify.
Wrapper stack frames don't have MVID or IL associated.
ex: (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
This fixes an inconsistency where xbuild would add System.Core
references to all builds, and MSBuild would only add them for
.NETFramework.
This change could break user XA/XI/XM projects on Mac if the user has
manually removed the explicit System.Core reference from the project,
however such projects would already be broken on Windows.
This is required for interoperating with project.json-based NuGet package configuration files
(not to be confused with DNX or AspNet Core which use it as a project file too) from MSBuild/xbuild.
The task hooks into the build process, resolves assembly references from the nuget package cache
and injects them into the compilation project so the csproj doesn't need to be modified when
adding new references/packages.
It is the first step on our road to PCL5/NuGet3.
Also add Mono.RuntimePropertyHandle struct representing a native MonoProperty pointer.
Also add ves_icall_System_Reflection_PropertyInfo_internal_from_handle_type icall
that wraps mono_property_get_object_checked.
Add new Mono.RuntimeEventHandle struct wrapping a pointer to a native MonoEvent
Add new icall
ves_icall_System_Reflection_EventInfo_internal_from_handle_type that's
mostly a wrapper around mono_event_get_object_checked.
This happens because current implementation is doing a direct call to Win32
GetLastError in order to get the value before it get clobbered by the icall
setting the last error value in mono. When running AOT all constructs that tries
to call a method using a direct address will be dropped since that will not work
in full AOT. This results in incomplete compiled libraries causing runtime exceptions
in full AOT.
The fix on Windows x64 is to introduce a new OP code, GET_LAST_ERROR that will
retrieve the last error without clobbering it in the process. This is done by
emitting code reading the value directly from the TEB (thread environment block)
and will be lowered to just a move from the segment register holding the TEB data
structure on Windows x64. This is how GetLastError is doing this as well, but since
we won’t be able to call the method in a “safe” way in full AOT, using the segment
register directly will solve the issue. We use the segment register for accessing TLS,
so we already relying on the TEB structure.
NOTE, this will only be applied to Windows x64, full AOT for now.
be detected at runtime. Since the process crash, lot of valuable information was never
written out to the console (like the managed stack trace) needed to effectively resolve
the issue.
Current implementation used different value type ABI’s depending on if call
was a managed->native, native->managed or managed->managed call. The implementation
was also overcomplicated since it was a tweaked copy from System V x64 value type
ABI with scenarios and conditions that wouldn’t apply to the Windows x64 value
type ABI. Having a uniform value type ABI when possible regardless of managed->native,
native->managed or managed->managed calls simplifies scenarios and reduce complexity.
While all the above are legitimate reasons the primary driving factor behind
the rewrite was a different issue. There are .NET wrapper libraries around DirectX API
used by game engines and other libraries that uses a pattern using a call into a stub
managed method that gets patched directly in the MSIL to a calli that will end up in a
native DirectX vtable method. In current ABI we can’t detect scenario like this, so arguments
are passed as if the call was a managed->managed call causing issues for value types. Since DirectX
uses value types a lot (vectors, matrixes etc.), this was a blocker getting these technologies
running on Windows using DirectX at all. Another approach could be to change the behavior of the
library, but this would require a major redesign of the library and since several of these libraries
are mature, that wasn’t a realistic option, especially since MS .NET runtime handles the libraries as is
without modifications.
The rewrite makes sure Windows x64 value type ABI follow the platform value type ABI in all scenarios.
Also:
1. MethodBase.GetMethodFromHandleInternalType_native icall
2. reimplemented the other MethodBase GetMethodFromHandleXXX methods
in terms of this new icall.
3. MonoError-ize mono_class_get_methods_by_name
The mutex on pending_bridge_callbacks was overkill because the init
model for the mono runtime already enforces the callbacks being set on
the init thread. Added a couple comments to formalize this.
If we have an invalid SP in the suspended thread, we don't set stack_start in the thread info, expecting it to be 0 in order to signal a resume and suspend retry to the suspender thread. If the thread was already restarted before (from a different reason like IP in critical section), it would have a nonzero stack_start from the previous suspend, leading to an assertion in the previously described case.
This is also what we do on mach.
On Windows, xbuild can fail with the somewhat obscure error message: "error : Error building target GetReferenceAssemblyPaths: UNC paths should be of the form \\server\share." This occurs because a call to Path.GetFullPath(@"\") returns the string "\" on Windows, when it should return a root path that includes the drive letter, like "C:\".
The code in xbuild tries to scan directories for files. Specifically, it looks for "\.*dll". If any .dll files exist in the root directory, each will be returned with the path "/\foo.dll". This path is used to create a FileInfo, and the exception about a UNC path occurs.
So if the path is "\" or "/" Path.GetFullPath should return the correct root path, including the drive letter, on Windows.
Here is the full call stack from xbuild:
Error building target GetReferenceAssemblyPaths: System.ArgumentException: UNC paths should be of the form \\server\share.
at System.IO.Path.InsecureGetFullPath (System.String path) <0x25343f0 + 0x003fb> in <filename unknown>:0
at System.IO.Path.GetFullPath (System.String path) <0x2534378 + 0x00013> in <filename unknown>:0
at System.IO.FileInfo..ctor (System.String fileName) <0x25fae20 + 0x00033> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.FileInfo:.ctor (string)
at System.IO.DirectoryInfo.GetFiles (System.String searchPattern) <0x25fa7c0 + 0x00087> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:GetFiles (string)
input, Int32 ptr, System.IO.DirectoryInfo directory, Boolean recursive) <0x25fa2b0 + 0x0016b> in <filename unknown>:0
input, Int32 ptr, System.IO.DirectoryInfo directory) <0x25fa270 + 0x0002f> in <filename unknown>:0
at Microsoft.Build.BuildEngine.DirectoryScanner.ProcessInclude (ITaskItem include_item, System.Collections.Generic.Dictionary`2 excludedItems, System.Collections.Generic.List`1 includedItems) <0x25d72d0 + 0x002ab> in <filename unknown>:0
at Microsoft.Build.BuildEngine.DirectoryScanner.Scan () <0x25d70e0 + 0x000ff> in <filename unknown>:0
at Microsoft.Build.BuildEngine.BuildItem.Evaluate (Microsoft.Build.BuildEngine.Project project, Boolean evaluatedTo) <0x25d5a50 + 0x005d3> in <filename unknown>:0
at Microsoft.Build.BuildEngine.BuildTaskItem.Execute () <0x25e5ad8 + 0x0002b> in <filename unknown>:0
at Microsoft.Build.BuildEngine.TaskBatchingImpl.Execute (IBuildTask buildTask, TaskExecutionMode taskExecutionMode) <0x25e3698 + 0x0004a> in <filename unknown>:0
at Microsoft.Build. BuildEngine.TaskBatchingImpl.Run (IBuildTask buildTask, TaskExecutionMode taskExecutionMode, System.Boolean& executeOnErrors) <0x25e50e0 + 0x0004f> in <filename unknown>:0
at Microsoft.Build.BuildEngine.TaskBatchingImpl.Build (IBuildTask buildTask, TaskExecutionMode taskExecutionMode, System.Boolean& executeOnErrors) <0x25e21b0 + 0x00097> in <filename unknown>:0
at Microsoft.Build.BuildEngine.TargetBatchingImpl.RunTargetWithBucket (System.Collections.Generic.Dictionary`2 bucket, Microsoft.Build.BuildEngine.Target target, System.Boolean& executeOnErrors) <0x25e14b8 + 0x00213> in <filename unknown>:0
at Microsoft.Build.BuildEngine.TargetBatchingImpl.Run (Microsoft.Build.BuildEngine.Target target, System.Boolean& executeOnErrors) <0x25e1360 + 0x000f7> in <filename unknown>:0
at Microsoft.Build.BuildEngine.TargetBatchingImpl.Build (Microsoft.Build.BuildEngine.Target target, System.Boolean& executeOnErrors) <0x25dfee0 + 0x00053> in <filename unknown>:0
at Microsoft.Build.BuildEngine.Target.DoBuild (System.Boolean& executeOnErrors) <0x25dfcf0 + 0x0004f> in <filename unknown>:0
Enable compact seq points by default so that the stack trace have IL
offsets instead os native ones.
This changes will allow any stacktrace generated from now on to be
symbolicated using mono-symbolicate.
Deprecates options gen-compact-seq-points.
This is cleanup to the previous emergency fix for bug 42469. The goal of that fix was to defer bridge processor initialization until after sgen init, but it introduced a requirement mono_gc_register_bridge_callback be called before sgen init. This breaks Xamarin Designer, which sets up callbacks late.
This patch introduces an sgen_init_bridge () which is called both at startup and after callbacks are set, and performs the initialization once all pieces are in place. Additional concurrency and style issues are also addressed.
* [corlib] Rewrite RuntimeType.GetGenericParameterConstraints
using managed code for managed object manipulation by surfacing the
native MonoGenericParamInfo struct to managed code as Mono.RuntimeStructs.GenericParamInfo
* [corlib] RuntimeType::GetGenericParameterAttributes can be managed code now.
* [corlib] Fix x86 breakage
RuntimeTypeHandle.GetGenericParameterInfo returns a pointer
Not a struct that's the same size as a pointer. On the x86 Linux
calling convention they behave differently.
mono_gc_register_bridge_callbacks is a function which the android implementation calls before initializing the runtime. One of the things this function previously did was initialize the default bridge processor if none has been initialized yet. However, because the function gets called before initializing the runtime, a bridge processor was never initialized. This lead to two bad effects:
- If a bridge processor was ever manually specified, the bridge processor would get initialized twice
- Tarjan crashes if initialized before sgen, so when Tarjan became the default bridge processor Android always crashed on launch
The default bridge processor is now initialized at the end of sgen_gc_init.
MVID and AOTID stacktrace metadata no longer displays guids with '-'.
Metadata is now also using lowercase instead of uppercase.
Changed mono-symbolicate and mono --aot to use the minimalistic GUIDs.
Replaced static constructor with delayed initialization.
Fixed possible undeterministic order of dumped MVIDs.
Used AppendFormat when possible.
Added comment to StackTrace.AddMetadataHandler explaining that it can be
used with reflection by outside code, to avoid removing it or changing
its signature.
Added StringComparer.Ordinal to dictionary.
Extracted Symbolicate.Process stacktrace dump logic into DumpStackTrace
method. Which can also be used to dump the last stack trace after the
process loop.
mono-symbolicate can now be called:
symbolicate store-symbols <msym dir> [<dir>]+
This will store in <msym dir> all the managed symbols found in the
provided directories.
mono-symbolicate now parses stack traces with metadata at their end.
All the stack trace and metada are read, so that symbolicate can use
MVID and AOTID to retrieve the symbols from the msym directory..
The MVID metadata handler displays multiple MVID(s) followed by the
comma separated list of StackFrame lines whose method belongs to the
module with the displayed MVID.
Added a reflectable static method that can be used to customize data
displayed after a stack trace.
Added metadata handler that display the AOTID of the executing assembly.
AOTID is a GUID generated by the AOT compiler and stored along with the
native code.
The AOTID uniquely identifies the generated native assembly.
The AOTID is required when we want to map native offsets to IL offsets
and the sequence points mapping those values need to be determined.
Previously handles were pointer-sized structs. Unfortunately not all
calling conventions treat pointer-sized structs as pointers, so if we
wanted to interact with handles from wrappers, we would have to do
something complicated.
With the new design, `TYPED_HANDLE_DECL(MonoFoo)` will expand to:
```c
typedef struct {
MonoFoo *__obj;
} MonoFooHandlePayload;
typedef MonoFooHandlePayload *MonoFooHandle;
```
- A single dll can be mapped to different targets based on function name.
- The dllentry target can be omitted if it is the same as the source.
This change is released under the MIT license.
Exceptions.exe regression test started to fail on win x64 release builds.
Turns out that the Visual Studio C compiler picked a different optimization
for release builds (due to a change of library type that uses a different default optimization level)
using RSI register in native code calling into JIT:ed code. If the JIT:ed code used reflection
and exceptions, that triggers InternalInvoke and lmf_filter, the code only
stored System V x64 non-volatile registers in the unwind information. On Windows,
RSI is also a non-volatile register (RDI as well) that needs to be preserved and
since the code didn’t include those in the unwind information, the correct RSI value
was not restored during the unwind. Once the control was handled back to the native
code it dereferenced RSI (that was set to 0) and crashed.
The fix is to make sure we store all non-volatile registers on x64 Windows
when we save an lmf so the unwind code can restore them when unwinding through
the lmf.
* Making sure ownerThread is not nulled unless lockCount is zero.
* Fixed so Locked property checks lockCount when determining if locked
instead of _locked field which was never set.
* Added test for setting Locked property.
* Added test capturing the original issue.
I saw this failing occasionally on iOS on Wrench:
```
[FAIL] TimerTest.AutoResetEventFalseStopsFiringElapsed : #2 wrong elapsedCount
Expected: 1
But was: 0
at MonoTests.System.Timers.TimerTest.AutoResetEventFalseStopsFiringElapsed () [0x00091] in /Users/builder/data/lanes/1411/b07703ed/source/xamarin-macios/external/mono/mcs/class/System/Test/System.Timers/TimerTest.cs:327
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/b07703ed/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
```
* Fix for non GCC win x86 calling convention when passing empty structs over pinvoke.
Port of https://github.com/mono/mono/pull/3085 to Winwdows x86 fixing failures
in pinvoke2 tests:
test_0_marshal_empty_struct
* Fix for incorrect implementation of small struct (single float/double) on Windows x86.
Failure in pinvoke3 test_0_marshal_small_struct_delegate9 is caused by incorrect
implemented small struct ABI on Windows x86.
Windows x86 ABI for returning structs of size 4 or 8 bytes (regardless of type)
dictates that values are passed in EDX:EAX register pairs,
https://msdn.microsoft.com/en-us/library/984x0h58.aspx.
This is different compared to for example float or double return types
(not in struct) that will be returned in ST(0),
https://msdn.microsoft.com/en-us/library/ha59cbfz.aspx.
Fix disables the alternative to do special handling of structs with 1 float or double
and make sure same logic is always applied to all small structs regardless type
as dictated by Windows x86 ABI.
* mono_test_marshal_delegate_ref_delegate uses incorrect calling convention.
mono_test_marshal_delegate_ref_delegate called by pinvoke3::test_55_marshal_delegate_ref_delegate
uses incorrect calling convention. Mono assumes delegates to be stdcall but
current definitions will be cdecl, this will cause an incorrect stack pointer
on architectures where cdecl and stdcall are different (Windows x86). Test fails
with "corrupt" stack pointer on Windows x86.
* Smaller adjustment based on feedback.
* Changed boolean struct member to bit field (on both x86 and x64)
* Changed compare code style from 0 == x to x == 0 to comply with coding standard.
libmono will use static library when building its dynamic library. This gives
the option to build binaries that could link the static version of mono runtime
or use the dynamic version of the same library. The default build binaries still
link against the dynamic version of the runtime.
The conflict happens when a type is declared like this:
.class value private auto ansi serializable sealed foo extends [mscorlib]System.Enum
The value keyword would make it a value type and ignore the parent declaration.
.net ilasm favors the later, which makes more sense.
I addressed the issue mentioned in the comments of mono_method_can_access_method:
* FIXME:
* with generics calls to explicit interface implementations can be expressed
* directly: the method is private, but we must allow it. This may be opening
* a hole or the generics code should handle this differently.
* Maybe just ensure the interface type is public.
The way to do it is to check access between gmds
Covers #41564
When multiple methods shared soap header a duplicate key exception would
be thrown.
This issue only occurs on XAMMAC and MOBILE where the non reference
source serializer is still used.
.NET supports this, from MSDN: "If an entry with the specified path and name already exists in the archive, a second entry is created with the same path and name.".
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=42219.
* [remoting] Convert mono_load_remote_field_new_checked to managed code.
* [corlib] Expose runtime struct MonoRemoteClass and MonoClass to managed
Also expose mono_class_get_type to managed code.
* [corlib] Add Mono.RuntimeClassHandle to encapsulate MonoClass*
and Mono.RuntimeRemoteClassHandle to encapsulate MonoRemoteClass*
* [runtime] mono_marshal_get_ldfld_remote_wrapper invoke the managed TransparentProxy.LoadRemoteFieldNew method directly
Don't bother going through a native call and back out to managed.
* [runtime] Get rid of MONO_WRAPPER_LDFLD_REMOTE
When the MONO_WRAPPER_LDFLD is operating on a proxy, it always invokes
the TransparentProxy::LoadRemoteFieldNew managed method
* [runtime] Remove dead mono_load_remote_field_new_icall
* [mini] Bump AOT file format version
Because we removed the LDFLD_REMOTE wrapper type so all the
MonoWrapperType enum values shifted.
[utils] Fix retiring of live block for the lock free allocator
Freeing a block descriptor (along with the block) can happen either when freeing a pointer in the block (we do this in order to prevent situations where we need to wait for the next alloc in order to free a block), either when we acquire an empty block while allocating. Either way, in order to free a block descriptor, we need to acquire it first.
When freeing a slot in a block, we are checking if the block is now empty in which case we acquire the block descriptor in order to free it (along with the block). While doing so, we were failing to account for the case where, by the time we make the block descriptor empty and the time we acquire it, another thread would try to allocate from the same descriptor, see that it's empty, free it, allocate a new descriptor (which would happen to have the same address as the retired one) to fulfill the allocation and then set it as the active descriptor for the allocator. When the first thread finally acquires the descriptor, we need to double check that it is still empty since it might be logically a different descriptor than the one we actually freed from. In the unlikely case it's not empty, we need to put it back in the allocator's data structures.
Fixes#41616
ConnectAsyncCallback now throws an exception when called a second time.
ConnectAsync reuses SocketAsyncEventArgs in BeginConnect which
already updates its state and calls ConnectAsyncCallback.
The changes make sure that ConnectAsyncCallback no longer called on
ConnectAsync catch block, while the state is still updated with the
exception.
Covers #41616
Our console runner is currently swallowing this test unhandled
exceptions.
To make it test show the failure I had to set legacyUnhandledExceptionPolicy
to 0 in mcs/class/lib/net_4_x/nunit-console.exe.config
Then running we can observe the crash by running:
make -C mcs/class/System check TESTNAME=System.Net.Sockets.SocketTest.ConnectAsyncUnhandledEx
Other tests appear to crash with legacyUEP set to 0, while the runner
shows no errors.
When we cleanup the gc at shutdown, we no longer care about running the remaining finalizers so we set the suspend_finalizers flag. This flag skipped running the finalizers but we would still traverse and modify the sgen finalizer hashes (on an arm box this could take even longer than 1s and lead to finalizer_thread_exited assertion failure since it's over the 100ms limit).
Avoid traversing sgen finalization hashes as soon as we see that we are shutting down.
libmonosgen-2.0.dll and breaks the build of monograph.exe which links against
it.
Also adds -O2 to CFLAGS on all platforms to align with how releases are built.
This should make it easier to programmatically check for errors, since it will remove the need to test the output string, which is an unreliable way of doing things.
Freeing a block descriptor (along with the block) can happen either when freeing a pointer in the block (we do this in order to prevent situations where we need to wait for the next alloc in order to free a block), either when we acquire an empty block while allocating. Either way, in order to free a block descriptor, we need to acquire it first.
When freeing a slot in a block, we are checking if the block is now empty in which case we acquire the block descriptor in order to free it (along with the block). While doing so, we were failing to account for the case where, by the time we make the block descriptor empty and the time we acquire it, another thread would try to allocate from the same descriptor, see that it's empty, free it, allocate a new descriptor (which would happen to have the same address as the retired one) to fulfill the allocation and then set it as the active descriptor for the allocator. When the first thread finally acquires the descriptor, we need to double check that it is still empty since it might be logically a different descriptor than the one we actually freed from. In the unlikely case it's not empty, we need to put it back in the allocator's data structures.
As described in https://bugzilla.xamarin.com/show_bug.cgi?id=34883 at
least Samsung SG3 doesn't allow access to the local network
interface (in fact, even ifconfig doesn't work on the device). Therefore
the test needs to be disabled on those devices. This is the first part
of the fix, the second one will be implemented in Xamarin.Android test
suite which will provide the AndroidShouldPingWork method which will
check the device id against list of those that do not work for this
test.
Part #1 of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=34883
MXR is not coming back (see https://bugzilla.mozilla.org/show_bug.cgi?id=1279952 and https://github.com/SuaveIO/mono-script-buildpack/issues/9#issuecomment-226749314)
and this broke everyone who still relied on mozroots. Fix by using the version from the hg repository instead.
Starting from Mono 3.12 we've been shipping cert-sync to import CA certificates from the local computer trust store to Mono's trust store,
we strongly encourage everyone to move to that instead. Added a deprecation warning to mozroots to further strengthen this message.
Note that when fetching the CA list over the new https URL we need to skip cert validation errors, as the common use case for mozroots is when
no certs are present on the system (bootstrapping). This enables MITM but we don't really have any other options. Another reason why cert-sync is superior.
In some cases the "git log -1 <remote>" check fails even though the remote is configured
and an unnecessary fetch is done. Adding the branch to the check fixes this.
* An enhancement to the thread priority work added earlier. This will support starting a thread with a specified priority. Currently, the thread will start with the priority of the creator. The semantics of threads allow you to specify the priority of a thread before it has started. Therefore, we take note of this value at thread creation time.
* Missed committing this file the first time
* Correct typo
* Fix creation_flags reference
* MonoThreadParm really should not be in objects-internal
* Place priority in MonoInternalThread where it can be accessed by GetThreadPriority(). This enablses the priority to be set/retrieved before the thread is started. It also ensures that new threads default to a priority of THREAD_PRIORITY_NORMAL rather than inheriting the parent thread's priority.
* Revert changes to MonoInternalThread/Thread.cs. Properly use the handle for thread lookup. Initialize priority at thread creation time. Use stored value of priority if thread has not been started.
* Add code to handle retrieving the thread priority from a started thread that had been set before thread had started. This is necessary as before the thread is started the priority value can be manipulated. This value is stored in the MonoThread structure. Before the thread is started the value can be interrogated so we return this value rather than invoking the GetThreadPriority() API. When a thread is started this value is used to set the threads priority (if scheduling policy is SCHED_FIFO or SCHED_RR). For POSIX threads, after the thread is started we now keep the priority in the _Wapi_thread structure which is located via the thread handle. This structure doesn't exist until after the thread is started so we can't store the value there but after we can cache the priority value there and return it for non-SCHED_[RR|FIFO] threads. This way the expected value will always be set and returned by ThreadPriority property (currently for these threads it will simply return Normal). A test case has been added to the mono/tests directory.
* Use a copy of creation_flags so local modifications aren't propagated
* Use pthread_setschedparam as OSX doesn't support pthread_setschedprio
This fixes the bug where form authentication tickets do not expire until 50 years later.
I bumped into this bug after upgrading mono from 4.2.2 to 4.4.0
Firstly, the authentication ticket's expiry must always equal to the timeout attribute on the <forms/> element. It doesn't matter whether persistent or session cookies are used.
Secondly, if the cookie is persistent, then it's expiry should be set to the same as that of the authentication ticket.
Reference: https://blogs.msdn.microsoft.com/dansellers/2006/02/15/change-to-asp-net-2-0-forms-authentication-persistent-cookies/
This should fix some problem with Nuget archives created by Mono.
No test case for this one because it would involve writing a mini-ZIP file parser to make sure the value is written correctly (or hardcore the value offset in the generated file, which could lead to a very flakey test).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=41775.
Updated Visual Studio build uses a different default build location of modules
compared to previous version. The tests config file includes a relative
path to libtest used for by all pinvoke tests. Since the module is now
placed at a different location the load failed during the test.
naming for intermediate pdb files for exe/dll's.
All artifacts will now have the same name of their final pdb file as
the library/dll/exe target file name.
The problem with the naming turns out to be a problem in Visual Studio
when a exe/dll use the same name of its intermediate pdb files and final
pdb file. In that case the final pdb file produced by the linker will be
incorrect and not usable by the debugger. This was the reason for the initial
change, giving intermediate pdb files a different name. Moving back to the
default naming for intermediate pdb files for exe/dll's will give the same
effect (a different name) and since libraries are not affected by this
problem, libraries can use the target name for their pdb files as well.
Also added support to not always replace config.h/version.h since that triggers
unnecessary rebuilds during development. New script will check if there is
an actual difference in the config.h/version.h file before doing the copy.
* Added regression test running mono/mini --regression [regression_tests]
* Added regression test running mono/mini --aot [regression_tests]
* Added default debugging options to run regression tests from within visual studio debugger.
* On new build system, setting up include folder if not availalble.
All changes applies to debug/release 32/64 bit.
* Added support for user macros in order to set build/install/sgen.
* Added support for more arguments to bat files + support for quoted paths.
* Added support for verbose/quite output in bat files.
* Moved libmono xcopy post build step into separate bat file.
* Cleaned some sgen configs still left in vcxprojs.
* Enabled build target suffix in order to lable a build (primarly for sgen).
* Enabled separate build tree.
* Dropped all sgen configurations, replaced by properties and target suffix.
* Fixed pdb naming of intermediate pdb files.
* Upgraded all projects to new vs2015 tool chain.
* Used mono.props through property manager instead of import.
* Fixed dependencies to be more explicitly in additional dependecies.
* Fixed error in mono.props, switched $ to % when referencing internal variables.
* Added property variables for includes and libraries, defined in mono.props.
The reason why mkbundle is not working is that for some reason
this constant expression is producing different code than the
-24 that it is supposed to.
What is odd is that the return value from the lseek system
call is the same, but yet, read fails with an end-of-file with
this value, and otherwise it passes.
With this call:
lseek (fd, -(16+sizeof(uint64_t)), SEEK_END)
strace displays:
lseek(0x3, 0xFFFFFFE8, 0x2) = 19375512 0
With this call:
lseek (fd, -24, SEEK_END)
strace displays:
lseek(0x3, 0xFFFFFFFFFFFFFFE8, 0x2) = 19375512 0
Now, while both results from lseek are the same, a subsequent read
with 24 bytes to read returns zero on the former case, and 24 on
the latter case.
When building a mobile_static build, we need to pass a lot of flags
which disable features. These make the net_4_x profile not build
correctly when using the official jenkins script. This helps.
on Windows. Updates the tests-config.in file with Windows specific <dllmap>
elements that map 'libtest' to the MSVC built libtest.dll for the current
architecture. test-runner.cs has been modified to accept a --config option to
be able to use a specific config file. Makefile.am now configures test-
runner.exe to use the tests-config config when running the tests.
Parsing ```default-allowance-ratio``` in ```MONO_GC_PARAMS``` is completely broken and accepts only one value - 1.0, while it should accept range of 1.0-10.0. We can clearly notice that when setting ```default-allowance-ratio``` to e.g. ```2.0``` and trying to run any program through Mono runtime:
```
Warning: In environment variable `MONO_GC_PARAMS': `default-allowance-ratio` must be between 1.00 - 1.00. - Using default value.
```
Therefore, correct this for using proper 1.0-10.0 range.
The do_try_exec_main function is always called in contexts where any
exception from doing the invoke is going to be stored in the exc outarg.
That means any MonoError will be handled locally by do_try_exec_main.
So we don't need a MonoError argument, we just need an inner_error.
We're seeing it randomly fail on Wrench with durations of 1550 - 1800ms.
Talked to Zoltan, this might be normal so bumping the timeout to reduce the failure rate.
The llvmonly backend will use `mono_aot_init_gshared_method_this`
and other initializers to initialize methods. These will transitively call
`mono_icall_get_wrapper_full` when icall wrappers are needed.
The init functions will set the
initialized flag after initialization. They set it in a non-atomic manner. This means that
in a multithreaded environment, it's possible to call the functions
twice.
When `mono_icall_get_wrapper_full` is called without this patch, the
pointers to wrappers it gets from `mono_marshal_get_icall_wrapper`
will not have the same addresses. They will hash to the same value
though.
This will lead to them not being found or inserted by
`find_aot_method_in_amodule`.
The fact that we already have a value with this hash means that
the new wrapper doesn't get inserted. The fact that the pointers differ
mean that we don't say that we've found our desired wrapper.
This leads to an assertion in `mono_icall_get_wrapper_full`
crashing the runtime.
Since we intend to have the semantics of a wrapper for each icall,
this change uses a cache to ensure uniqueness. The observed crashes
do not happen when this change is applied.
MONO_EXECUTABLE env variable to test-runner.exe using the --runtime command
line parameter. Defaults to 'mono' which is also the defult in test- runner.cs
if no --runtime argument is given.
* [runtime] Move 'pedump' to tools/pedump, build tools by default.
* Add missing file.
* [runtime] Mark mono_opcodes[] with MONO_API.
* [runtime] Build monograph when sgen is supported instead of boehm.
* [runtime] Link monograph against the static runtime libraries.
* [runtime] Use the same SUBDIRS/DIST_SUBDIRS for the CROSS_COMPILING case.
We're seeing the following exception on devices in CI:
```
[FAIL] HttpListenerRequestTest.HttpRequestIsLocal : System.Net.Sockets.SocketException : Could not resolve host 'XQA-AppleTV-1'
at System.Net.Dns.Error_11001 (System.String hostName) [0x00000] in /Users/builder/data/lanes/1381/d8287824/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/Dns.cs:292
at System.Net.Dns.GetHostByName (System.String hostName) [0x00024] in /Users/builder/data/lanes/1381/d8287824/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/Dns.cs:419
at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00061] in /Users/builder/data/lanes/1381/d8287824/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/Dns.cs:380
at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00065] in /Users/builder/data/lanes/1381/d8287824/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/Dns.cs:406
at MonoTests.System.Net.HttpListenerRequestTest.HttpRequestIsLocal () [0x00006] in /Users/xamarinqa/QABot/data/lanes/2441/d8287824/source/xamarin-macios/external/mono/mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs:197
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/1381/d8287824/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
```
From looking at the code, resolving the hostname to IP addresses via DNS fails so the test doesn't even run.
We don't care where the local IPs come from so we can use an alternative way of getting them - via querying the network interfaces.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=41671
PS: fixed a hardcoded port while I was touching the code
[mini] lower typechecks later
lower typecheck instructions later in the compilation, so we've a chance to do high-level optimization after `method-to-ir`
Rewriite `MonoMethodMessage::InitMessage` in managed code
Change icall
`System.Runtime.Remoting.Messaging/MonoMethodMessage::InitMessage` to
managed code.
Also update `mono_message_init()` to invoke `InitMessage`.
Using mono_marshal_free n mono_string_builder_to_utf8
`mono_string_builder_to_utf16` is allocating using `mono_marshal_alloc` which, on windows, allocates memory using `CoTaskMemAlloc`. This buffer was then released in `mono_string_builder_to_utf8` using `g_free` which resulted in a crash since that's a different memory on windows. The fix in this PR makes sure `mono_marshal_free` is called instead which has the correct behaviour and results in a `CoTaskMemFree` on windows.
[System] Make ServicePointTest.DnsRefreshTimeout test more reliable
We are still seeing quite rare failures of this test:
```
HostEntry should result in the same IPHostEntry object.
Expected: same as <System.Net.IPHostEntry>
But was: <System.Net.IPHostEntry>
+++++++++++++++++++
STACK TRACE:
at MonoTests.System.Net.ServicePointTest.DnsRefreshTimeout () [0x00045] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/System/Test/System.Net/ServicePointTest.cs:228
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/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
```
Since the test is only checking if expiring of the cached DNS lookup works, we don't really need to use an external domain name for this as "localhost" works just fine as well and typically doesn't trigger a DNS query which makes the test more reliable against network issues.
@monojenkins merge
We are still seeing quite rare failures of this test:
```
HostEntry should result in the same IPHostEntry object.
Expected: same as <System.Net.IPHostEntry>
But was: <System.Net.IPHostEntry>
+++++++++++++++++++
STACK TRACE:
at MonoTests.System.Net.ServicePointTest.DnsRefreshTimeout () [0x00045] in /Users/builder/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/System/Test/System.Net/ServicePointTest.cs:228
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/jenkins/workspace/test-mono-mainline/label/osx-i386/mcs/class/corlib/System.Reflection/MonoMethod.cs:309
```
Since the test is only checking if expiring of the cached DNS lookup works, we don't really need to use an external domain name for this
as "localhost" works just fine as well and typically doesn't trigger a DNS query which makes the test more reliable against network issues.
We were not exiting the critical section on this code path. This was leading to hangs at stw since the native code would take locks when compiling the code.
We were seeing intermittent failures on devices like:
```
[FAIL] TimerTest.EnabledInElapsed : #1 loss of events
Expected: True
But was: False
at MonoTests.System.Timers.TimerTest.EnabledInElapsed () <0x33b168 + 0x0014f> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object , BindingFlags , System.Reflection.Binder , System.Object[] , System.Globalization.CultureInfo ) <0x66d400 + 0x000b7> in <filename unknown>:0
```
Since OS scheduling and GCs can influence the exact timing of the timer intervals sleeping for 200ms is likely just too short.
Instead of bumping the timeout, I decided to rewrite the test to not rely on Thread.Sleep ().
I also added another test which verifies setting AutoResetEvent=false stops the timer event from firing after the first one,
which was implicitly tested before by the other test.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=41530
Without doing this, the check would consider a valid option name like
IpTimeToLive to be the same as ReuseAddress, as they share the same enum
value.
Fixes SocketTest.TtlChange and SocketTest.UdpMulticasTimeToLive on Android and
other platforms that don't support ReuseAddress.
* Move the versions.mk infrastructure to scripts/submodules so it can be used elsewhere too.
* Add a conditional submodule for llvm.
* Fix commit messages emitted by the bump- targets.
* Use a anonymous git url for llvm.
Before closing a socket we try to interrupt and wait for all socket
pending system calls to return. For that we set the socket as non
blocking which makes the system calls to return with EAGAIN\EWOULDBLOCK.
This issue was caught by System.Net.Sockets.SocketTest.SendAsyncFile
that was intermittently failing, we were only able to reproduce it while
running multiple test suites in parallel. We now can say that it only failed when
the the socket was closed and the sendfile was waiting for the OS to
allocate enough resources to send the file.
This was fixed by changing wapi_sendfile to return on EAGAIN.
Stack traces of blocked threads are now displayed on the exception.
The threads stacktraces are only stored when MONO_TESTS_IN_PROGRESS env
var is set to yes.
When we allocate the complex descriptor for a new type we might have the concurrent marker scan objects. While the concurrent marker scans the bitmap for a complex object, which resides in the complex_descriptor array, another thread might allocate a new complex descriptor, thus reallocate the complex_descriptor array, which would lead to corruption of the bitmap used by the concurrent marker.
We reuse the SgenArrayList which never reallocates, using instead a list of exponentially increasing arrays.
This is the initial code drop of a new handles implementation.
It differs from the previous one is a few ways:
- It keeps a separate stack of handles which is shared by all "arenas".
This eliminates malloc in the majority of the cases without the need for any tuning
- Custom gc scanning code for the handles stack.
The original implementation registered the chunks as a GC roots. Which is a terribly
slow operation as it takes the GC lock.
Instead of allocating a new handle arena for each icall, we compute a stack mark,
which is the position in the handles stack at icall entry. On exit, we simply restore that
position, which is just a couple of stores.
Since the stack is implemented using arraylets, addressed are stable in the face of
expansion.
Only the typed handles function/macros are in as having both typed and untyped handles
adds extra complexity for no clear value.
The macros only handle what was needed to port a sizeable chunk of locales.c.
This commit just sets the stage for the feature, there's quite some work left
before we can start using it, as it can be seen in the big TODO in handle.c
We were seeing an issue where attempts to create the MonoClass for an
exception in a no-exec context was causing failure. No-exec will forbid
the constructor call. Our solution was to realize that there was no
need to allocate an exception, as MonoError could already encode the
errors.
Fixes a bug in exiting modal runloop that caused not really exiting it
(not calling XplatUI.SetModal(..., false).
It caused issues with menu, for example, if you first ran a modal
dialog (a wizard), and then you started the application.
This would lead to a crash when unregistering the thread from the currnt MonoThreadInfo* destructor, as `mono_thread_info_current_unchecked` would return NULL. This would trigger an infinite loop in `mono_threads_enter_gc_safe_region_unbalanced_with_info`.
unregister_thread is the destructor for the current MonoThreadInfo* TLS key, meaning that when in this function, calling mono_thread_info_current_unchecked will always return NULL.
On Unix, errno value might change between the native call and the call to mono_marshal_set_last_error, if we exit the gc safe region. We need to ensure that it's done right after the native call.
[gc] Register a critical region when executing managed allocators.
Previously, if we stopped a thread and it had a stack looking like this:
...
profiler_signal_handler
<signal handler called>
managed_allocator
...
We would fail to identify the fact that we've just interrupted a thread that's
in a managed allocator (uninterruptible code) because we only look at the very
latest instruction pointer of the thread, which will be pointing into
profiler_signal_handler or some other function called by it. So we would
happily continue along with the STW process and proceed to doing the actual GC,
where we would see a broken heap.
We could solve this by unwinding the stack and checking all frames, but that's
complicated and error-prone. Instead, register a critical region while the
managed allocator runs. This way, if we don't identify it by instruction pointer, we
will identify it by the fact that the thread is in a critical region.
This fixes a regression introduced in 123aaa5db0.
We would sometimes see an ObjectDisposedException when calling AcceptAsync ()
because that patch removed the try-catch around it.
Xamarin.Android internal test suite takes advantage of the BCL tests
in Mono, so far their inclusion was a manual process and this commit
fixes it. A set of source inclusion and exclusion lists is added
and a handful of code fixes to make them compile on Xamarin.Android
[System] Fixes socket async exception.
SendAsyncFile uses StartSocketServer to start a server and at the same
time begins to accept a client socket. The issue is that when
the accept callback is called SendAsyncFile already closed the socket.
Fixed race condition by moving StartSocketServer and ReceiveCallback
logic into SendAsyncFile, and by using a new MRE to ensure that the
client receives all the data before the server is closed.
Fixes [#41264](https://bugzilla.xamarin.com/show_bug.cgi?id=41264)
SendAsyncFile uses StartSocketServer to start a server and at the same
time begins to accept a client socket. The issue is that when
the accept callback is called SendAsyncFile already closed the socket.
Fixed race condition by moving StartSocketServer and ReceiveCallback
logic into SendAsyncFile, and by using a new MRE to ensure that the
client receives all the data before the server is closed.
Fixes#41264
Standard C and C++ doesn't allow empty structs, empty structs will always have a
size of 1 byte. GCC have an extension to allow empty structs,
https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html. This cause a
little dilemma since runtime build using none GCC compiler will not be
compatible with GCC build C libraries and the other way around. On platforms
where empty structs has size of 1 byte it must be represented in call and cannot
be dropped.
Libraries build using for example MSVC failed pinvoke call when empty
structs where used in pinvoke2.cs tests. The problem was that current
implementation dropped value types of size 0, eliminating them from the
call. Since MSVC implements C/C++ standard regarding empty structs (no extension used),
the function expected the parameter to be present, even if was not used.
This became a problem if the empty struct ended up in one of the 4 first
parameters (backed by registers) since if excluded, wrong parameter gets
into wrong registers (the same will apply to stack slots as well). For example,
a C signature like this, (int a, EmptyStruct es, int b) will get lowered to the
following on MSVC win x64, a -> rcx, es -> rdx and b -> r8, but since caller
eliminated es from the call, the register assignment from the caller was
a -> rcx and b -> rdx causing a violation of the calling convention and
error in callee.
The fix is to make sure that empty structs are still represented on none GCC
compilers on windows x64 (MSVC), since they must be represented in the call
to pinvoked methods. Fix will also use a const value of 0 to represent the value
passed as the struct instead of loading a value from stack into register/stack slot,
this is inline with the value the .NET runtime passes to pinvoked method. The reason
why we use a 0 instead of loading from stack is because a struct of size 0 is not explicitly
represented on stack and will have garbage data if loaded. Since it’s an empty struct value
type there is no need to load anything, just represent it as 0 in the register/stack slot passed
to caller.
There is also a case when returning an empty struct from a pinvoked method. Result will be returned
as 0 in RAX by MSVC compiled libraries (or whatever value stored in the 1 byte representation).
Since we have similar issues as above with empty structs of size 0 not explicitly represented on the
stack, the store will be eliminated and not written back to stack by caller since an empty struct doesn’t
represent any unique data.
Calling convention for managed->managed code is kept intact since it is working as expected
handling the case with empty structs as input and return values.
With fix all pinvoke2.cs tests now pass running on Windows x64 JIT.
This appears to serve no purpose as tlab_next is a thread-local variable. It's
only ever accessed by other threads in order to write to it, not read it. We
also don't do this memory barrier in the native allocation functions.
Previously, if we stopped a thread and it had a stack looking like this:
...
profiler_signal_handler
<signal handler called>
managed_allocator
...
We would fail to identify the fact that we've just interrupted a thread that's
in a managed allocator (uninterruptible code) because we only look at the very
latest instruction pointer of the thread, which will be pointing into
profiler_signal_handler or some other function called by it. So we would
happily continue along with the STW process and proceed to doing the actual GC,
where we would see a broken heap.
We could solve this by unwinding the stack and checking all frames, but that's
complicated and error-prone. Instead, register a critical region while the
managed allocator. This way, if we don't identify it by instruction pointer, we
will identify it by the fact that the thread is in a critical region.
Made breakpoint uniqueness test switch to a hash after 8th item added,
consolidated the code that handles the uniqueness test and makes the
breakpoint in one function, fixed style issues.
* Add TODO list
* Use -useSourcePath when building resources, so we do not need to add the explicit extra path
* More updates, now battling resource generation across the board
* Use newlines in the Unix commands to avoid generating things like cs-parser.cs^M
The tests added during the initial development of the -multiassembly argument failed to test the presence of extension methods;
the result was a crash that occurred when there were extension methods present in multiple assemblies.
This patch addresses the issue by putting a guard clause around the code that adds the extension method to the index.
Tests have been modified accordingly to verify this bug and include extension methods
Additionally, the -multiassembly parameter was removed entirely. This behavior is now triggered by the presence of -apistyle,
which is where support for "multiple assemblies" was meant to work anyways. To review, this is to support cross-platform
development, where you have multiple -- *different* -- assemblies for each platform. These assemblies will share a certain
cross-section of APIs that will be *exactly* the same in each assembly (as opposed to multiple versions of literally the same assembly).
As a result, every member will now contain an individual `AssemblyInfo` tag that also contains the name of the assembly.
The date/time struct in zip.h defines the month value as
uInt tm_mon; /* months since January - [0,11] */
.NET's DateTime object in turn stores months from 1-12. We didn't
take this into account when passing the values from managed->native
so the month ended up being off by one.
We didn't use this codepath before https://github.com/mono/mono/pull/3036
that's why it didn't show up until now.
The test assembly used *.dll.excludes before while the library uses *.dll.exclude.sources.
Make this consistent to reduce confusion.
Also remove corlib_cmp.dll.excludes which is from a profile that no longer exists.
We were seeing timeouts in the runtime step if two builds happen to be scheduled
at the exact same time on the ARM workers on Jenkins, causing increased load and
longer test times. They aborted the runtime step right before it'd finish.
Bump the timeout a bit to avoid this.
When we scan a block we need to have it checked for sweeping. Instead of waiting for all the blocks to be checked for sweeping, we traverse all the blocks (even though they might not have live objects), and do the sweeping check only for blocks that have dirty cards associated with them, without waiting for sweeping to end.
Allocating a major block needs addition to the allocated_blocks array, operation that needs sweep to be finished because sweep moves elements and changes the size when compacting the array. Do this operation in the sweep start instead, when we are not racing.
Support for GSHAREDVT added for Windows x64. Changes needed
(ones gsharedvt concept was understood, crashes debugged and adjustments located)
where quite small. Primarily around shadow stack used by windows + incorrect handling
of none volatile registers on windows when going over the gsharedvt trampolines.
All GSHAREDVT tests, gshared.exe and aot.tests.exe pass in full AOT builds with above adjustments.
Support for DYNCALL added/enabled for Windows x64. Current AMD64 support was working
for basic scenarios but not enabled on Windows. Identified a problem on AMD64
when structs are passed as input parameters or returned by methods for DYNCALL scenarios
in full AOT:ed builds. This scenario doesn't seem to work for any AMD64 platform for
full AOT and the tests in aot-test.exe handling these scenarios are not run on AMD64.
Adjusted categories on test in aot-tests.exe to reflect what’s really needed by the tests
to run correctly. Also added a new category to some DYNCALL tests that uses struct support
currently not implemented on AMD64, !FULLAOT-AMD64, so at least some of the DYNCALL tests
can be run on AMD64 platforms in full AOT:ed builds.
Testing with the debugger showed multiple failures around recursive
functions:
1. Step-out breakpoints can trigger on inner frames.
Solution: Extend existing inner-frame test from step-over to step out
also.
2. "Same source line, continuing" test triggers even on wrong frame
(affects both step over and step out)
Solution: Check frame as part of this test
3. When step breakpoints pick next sequence points, they can register
multiple breakpoints at the same place if a recursive call happens to
exit there. (Possibly harmless but may have resulted in duplicate
debugger events being generated in one test.)
Solution: Check for duplicates in step-request breakpoint list before
adding new breakpoints
4. Mono.Debugging.Soft in the debugger-libs repo sometimes resumes
after breakpoints if it decides Mono.Debugger.Soft has not stepped
far enough, but the check to trigger this was not recursion-aware.
Solution: This one is not addressed in this commit, but a fix was
checked in to debugger-libs. Any code using this commit therefore
needs to be run in conjunction with debugger-libs dfbf6d8b13.
Tests were also added for issues 1-3 above.
- Add logfile and syslog capability. For Windows, the latter is simulated by writing to a file. Adding Eventlog support is for a future effort. The choice of logging mode is made via MONO_LOG_DEST environment variable.
- Add timestamps and pid to the trace messages to make them more useful
- Add timestamps to SGEN_LOG
- Related to tracing: when tracing and using something like Valgrind the system may be slowed so much that the sleep abort limit may be exceeded for threads. This fix adds an environment variable lookup of "MONO_SLEEP_ABORT_LIMIT" which is a value greater than 40, which defines the number of milliseconds to wait for threads to complete pending operations. If not set, the valus is 200.
2016-03-08 14:54:11 -05:00
1031 changed files with 24642 additions and 21698 deletions
# 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(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(large-heap, [ --with-large-heap=yes,no Enable support for GC heaps larger than 3GB (defaults to no)], [large_heap=$withval], [large_heap=no])
AC_ARG_WITH(large-heap, [ --with-large-heap=yes,no Enable support for GC heaps larger than 3GB (defaults to no)], [large_heap=$withval], [large_heap=no])
if test "x$large_heap" = "xyes"; then
CPPFLAGS="$CPPFLAGS -DLARGE_CONFIG"
fi
AC_SUBST(LIBGC_CPPFLAGS)
AC_SUBST(LIBGC_LIBS)
AC_SUBST(LIBGC_STATIC_LIBS)
AC_SUBST(libgc_dir)
AC_SUBST(BOEHM_DEFINES)
dnl
dnl End of Boehm GC Configuration
dnl
@@ -2572,13 +2788,17 @@ dnl **************
dnl *** LLVM ***
dnl **************
AC_ARG_ENABLE(llvm,[ --enable-llvm Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
AC_ARG_ENABLE(llvm,[ --enable-llvm Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=default)
AC_ARG_ENABLE(llvm-version-check,[ --enable-llvm-version-check Check that the LLVM matches the version expected by mono], enable_llvm_version_check=$enableval, enable_llvm_version_check=no)
AC_ARG_ENABLE(llvm-runtime,[ --enable-llvm-runtime Enable runtime support for llvmonly code], enable_llvm_runtime=$enableval, enable_llvm_runtime=no)
AC_ARG_WITH(llvm, [ --with-llvm=<llvm prefix> Enable the LLVM back-end], enable_llvm=yes,)
if test "x$enable_llvm" = "xdefault"; then
enable_llvm=$enable_llvm_default
fi
if test "x$enable_llvm" = "xyes"; then
if test "x$with_llvm" != "x"; then
LLVM_CONFIG=$with_llvm/bin/llvm-config
@@ -3559,15 +3779,6 @@ case "x$libgc" in
;;
esac
AC_ARG_WITH(profile4_x, [ --with-profile4=yes,no If you want to install the 4.6 FX (defaults to yes)], [], [with_profile4_x=yes])
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=no])
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the Xamarin.iOS assemblies (defaults to no)], [], [with_monotouch=no])
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=no])
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=no])
AC_ARG_WITH(bitcode, [ --with-bitcode=yes,no If bitcode is enabled (defaults to no)], [], [with_bitcode=no])
AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you want to build the Xamarin.Mac assemblies (defaults to no)], [], [with_xammac=no])
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=no])
MALLOC_MEMPOOLS=no
AC_ARG_WITH(malloc_mempools,[ --with-malloc-mempools=yes,no Use malloc for each single mempool allocation (only for runtime debugging, defaults to no)],[
if test x$with_malloc_mempools = xyes; then
@@ -3577,15 +3788,18 @@ AC_ARG_WITH(malloc_mempools,[ --with-malloc-mempools=yes,no Use malloc for eac
])
DISABLE_MCS_DOCS=no
DISABLE_MCS_DOCS=default
AC_ARG_WITH(mcs_docs,[ --with-mcs-docs=yes,no If you want to build the documentation under mcs (defaults to yes)],[
if test x$with_mcs_docs != xyes; then
DISABLE_MCS_DOCS=yes
fi
])
if test x$with_profile4_x != xyes; then
if test -n "$INSTALL_4_x_TRUE"; then :
DISABLE_MCS_DOCS=yes
fi
if test "x$DISABLE_MCS_DOCS" = "xdefault"; then
DISABLE_MCS_DOCS=$DISABLE_MCS_DOCS_default
fi
AC_ARG_WITH(lazy_gc_thread_creation, [ --with-lazy-gc-thread-creation=yes|no Enable lazy runtime thread creation, embedding host must do it explicitly (defaults to no)],[
if test x$with_lazy_gc_thread_creation != xno ; then
@@ -35,3 +35,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyFileVersion ("4.0.0.0")]
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../../msfinal.pub")]
[assembly: ReferenceAssembly]
Loaded 100 of 1031 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.