[2018-08] [arm64] Correct exception filter stack frame size
Fixes: https://github.com/mono/mono/issues/14170
Fixes: https://github.com/xamarin/xamarin-android/issues/3112
The `call_filter()` function generated by `mono_arch_get_call_filter()`
was overwriting a part of the previous stack frame because it was not
creating a large enough new stack frame for itself. This had been
working by luck before the switch to building the runtime with Android
NDK r19.
I used a local build of [xamarin/xamarin-android/d16-1@87a80b][0] to
verify that this change resolved both of the issues linked above. I
also confirmed that I was able to reintroduce the issues in my local
environment by removing the change and rebuilding.
After this change, the generated `call_filter()` function now starts by
reserving sufficient space on the stack to hold a 64-bit value at the
`ctx_offset` location. The 64-bit `ctx` value is saved to the
`ctx_offset` location (offset 344 in the new stack frame) shortly
afterwards:
stp x29, x30, [sp,#-352]!
mov x29, sp
str x0, [x29,#344]
As expected, the invocation of `call_filter()` now no longer modifies
the top of the previous stack frame.
Top of the stack before `call_filter()`:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
Top of the stack after `call_filter()` (unchanged):
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
<details>
<summary>Additional background information</summary>
### The original lucky, "good" behavior for [mono/mono/2018-08@725ba2a built with Android NDK r14][1]
1. The `resume` parameter for `mono_handle_exception_internal()` is
held in register `w23`.
2. That register is saved into the current stack frame at offset 20 by
a `str` instruction:
0x00000000000bc1bc <+3012>: str w23, [sp,#20]
3. `handle_exception_first_pass()` invokes `call_filter()` via a `blr`
instruction:
2279 filtered = call_filter (ctx, ei->data.filter);
0x00000000000bc60c <+4116>: add x9, x22, x24, lsl #6
0x00000000000bc610 <+4120>: ldr x8, [x8,#3120]
0x00000000000bc614 <+4124>: ldr x1, [x9,#112]
0x00000000000bc618 <+4128>: add x0, sp, #0x110
0x00000000000bc61c <+4132>: blr x8
Before the `blr` instruction, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x0a8b31d8 0x00000071
0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071
4. `call_filter()` runs. This function is generated by
`mono_arch_get_call_filter()` and starts with:
stp x29, x30, [sp,#-336]!
mov x29, sp
str x0, [x29,#344]
Note in particular how the first line subtracts 336 from `sp` to
start a new stack frame, but the third line writes to a position
that is 344 bytes beyond that, back within the *previous* stack
frame.
5. After the invocations of `call_filter()` and
`handle_exception_first_pass()`, `w23` is restored from the stack:
0x00000000000bc820 <+4648>: ldr w23, [sp,#20]
At this step, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071
Notice how `call_filter()` has overwritten bytes 8 through 15 of the
stack frame. In this original lucky scenario, this does not affect
the value restored into register `w23` because that value starts at
byte 20.
6. `mono_handle_exception_internal()` tests the value of `w23` to
decide how to set the `ji` local variable:
2574 if (resume) {
0x00000000000bb960 <+872>: cbz w23, 0xbb9c4 <mono_handle_exception_internal+972>
Since `w23` is `0`, `mono_handle_exception_internal()` correctly
continues into the `else` branch.
### The bad behavior for [mono/mono/2018-08@725ba2a built with Android NDK r19][2] works slightly differently
1. As before, the local `resume` parameter starts in register `w23`.
2. This time, the register is saved into the stack frame at offset 12
(instead of 20):
0x00000000000bed7c <+3200>: str w23, [sp,#12]
3. As before, `handle_exception_first_pass()` invokes `call_filter()`
via a `blr` instruction.
At this step, the top of the stack looks like this:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
4. `call_filter()` runs as before. And the first few instructions of
that function are the same as before:
stp x29, x30, [sp,#-336]!
mov x29, sp
str x0, [x29,#344]
5. `w23` is again restored from the stack, but this time from offset 12:
0x00000000000bf2c0 <+4548>: ldr w23, [sp,#12]
The problem is that `call_filter()` has again overwritten bytes 8
through 15 of the stack frame:
(gdb) x/8x $sp
0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071
So after the `ldr` instruction, `w23` has an incorrect value of
`0x7f` rather than the correct value `0`.
6. As before, `mono_handle_exception_internal()` tests the value of `w23` to
decide how to set the `ji` local variable:
2574 if (resume) {
0x00000000000be430 <+820>: cbz w23, 0xbe834 <mono_handle_exception_internal+1848>
But this time because `w23` is *not* zero, execution continues
*incorrectly* into the `if` branch rather than the `else` branch.
The result is that `ji` is set to `0` rather than a valid
`(MonoJitInfo *)` value. This incorrect value for `ji` leads to a
null pointer dereference, as seen in the bug reports.
[0]: https://github.com/xamarin/xamarin-android/tree/xamarin-android-9.3.0.22
[1]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1432/Azure/
[2]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1436/Azure/
</details>
Backport of #14757.
/cc @lambdageek @brendanzagaeski
TypeTest.MakeGenericType_BadUserType
TypeTest.MakeGenericType_NestedUserDefinedType
TypeTest.MakeGenericType_UserDefinedType
TypeTest.TestMakeGenericType_UserDefinedType_DotNet20SP1
These tests pass when run with the interpreter on xamarin-macios.
They were disabled on master with https://github.com/mono/mono/commit/dc9bc9e0e6462739872117afc59e46fbc780d981
Bump to get the msbuild 16 update
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
The thread_stopped profiler event can be raised by the thread_info_key_dtor tls
key destructor when the thread is already doesn't have a domain set. In that
case, don't call process_profiler_event since it cannot handle a thread with
null TLS values.
Addresses https://github.com/xamarin/xamarin-android/issues/2920
with the following stack trace
```
* thread #20, name = 'Filter', stop reason = signal SIGSEGV: invalid address (fault address: 0xbc)
* frame #0: libmonosgen-2.0.so`mono_class_vtable_checked(domain=0x0000000000000000, klass=0x0000007200230648, error=0x00000071e92f9178) at object.c:1890
frame #1: libmonosgen-2.0.so`get_current_thread_ptr_for_domain(domain=0x0000000000000000, thread=0x00000071ebfec508) at threads.c:595
frame #2: libmonosgen-2.0.so`mono_thread_current at threads.c:1939
frame #3: libmonosgen-2.0.so`process_event(event=<unavailable>, arg=<unavailable>, il_offset=<unavailable>, ctx=<unavailable>, events=<unavailable>, suspend_policy=<unavailable>) at debugger-agent.c:3715
frame #4: libmonosgen-2.0.so`thread_end [inlined] process_profiler_event(event=EVENT_KIND_THREAD_DEATH, arg=0x00000071ebfec508) at debugger-agent.c:3875
frame #5: libmonosgen-2.0.so`thread_end(prof=<unavailable>, tid=<unavailable>) at debugger-agent.c:3991
frame #6: libmonosgen-2.0.so`mono_profiler_raise_thread_stopped(tid=<unavailable>) at profiler-events.h:105
frame #7: libmonosgen-2.0.so`mono_thread_detach_internal(thread=<unavailable>) at threads.c:979
frame #8: libmonosgen-2.0.so`thread_detach(info=0x00000071e949a000) at threads.c:3215
frame #9: libmonosgen-2.0.so`unregister_thread(arg=<unavailable>) at mono-threads.c:544
frame #10: libmonosgen-2.0.so`thread_info_key_dtor(arg=0x00000071e949a000) at mono-threads.c:774
frame #11: 0x00000072899c58e8 libc.so`pthread_key_clean_all() + 124
frame #12: 0x00000072899c5374 libc.so`pthread_exit + 76
frame #13: 0x00000072899c5264 libc.so`__pthread_start(void*) + 44
frame #14: 0x000000728996617c libc.so`__start_thread + 72
```
I'm not sure about the correctness of this workaround but it works on macOS for the repro from https://github.com/mono/mono/issues/9664#issuecomment-472260968
Transition bounds used by time zone info represent some local date-time but actually they are of Unspecified date-time kind.
When we try to get transition offset we compare some current date-time converted to UTC with appropriate transition bounds.
The fix is to use UTC for both current date-time and transition bounds during comparing.
Fixes https://github.com/mono/mono/issues/9664
-> Doing stepping into in VSM in some situation the frame saved in TLS is not synchronised with what is really been executed in the main thread. This makes the debugger-agent crashes because it tries to get variable info in some memory that is not available anymore.
-> To fix it I forced the update of stack when CMD_THREAD_GET_FRAME_INFO is called.
-> Doing step over in Visual Studio for Windows, if you have the threads debugger window enabled, VSW calls frame_commands for each thread that is showed, and if the thread is not really_suspended it tries to get variable info from a memory that is not available anymore because the thread is not suspended yet.
-> To fix it I don't send variable info of a frame if the thread is not really_suspended and doesn't have an async_state valid.
#Fixes 12843
Concurrent request completions could cause following exception:
FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException:
Index was out of range. Must be non-negative and less than
the size of the collection.
Parameter name: index
at System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) [0x00009] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Collections.Generic.List`1[T].Remove (T item) [0x0000c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.Cleanup () [0x00011] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.set_IsCompleted (System.Boolean value) [0x00034] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.Complete (System.Exception ex) [0x0001a] in <28c4695205ef47378f5370502b066592>:0
at System.ServiceModel.Channels.HttpRequestChannel+<>c__DisplayClass7_1.<BeginProcessRequest>b__0 (System.IAsyncResult r) [0x000bd] in <28c4695205ef47378f5370502b066592>:0
This stack was captured after some changes in AwaitTaskContinuation.RunOrScheduleAction.
Unfortunately the current implementation of AwaitTaskContinuation.RunOrScheduleAction re-throws the above
exception with a wrong stack:
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00052] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageTwo () [0x000a1] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00003] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.TrySetException (System.Object exceptionObject) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00029] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__241`1[T].MoveNext () [0x000e0] in <3e9b3e26c4694baab3f689687ad40612>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00024] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action action, System.Boolean allowInlining, System.Threading.Tasks.Task& currentTask) [0x00023] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishContinuations () [0x00052] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x0004f] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetResult (TResult result) [0x0003d] in <4a8a0eaa024f41829d3435c07e5c7edb>:0
at System.Net.ServicePointScheduler+<WaitAsync>d__45.MoveNext () [0x000f7] in <3e9b3e26c4694baab3f689687ad40612>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <4a8a0
On an Android Xamarin installation this causes an app crash. Since no user code is active the exception cannot be caught.
* [crash] Add more detailed reporting for exceptions
This bumps the crash reporting file format to version 0.0.3.
* [crash] Fix exception stack walker to consider captured_traces
Previously we were missing these frames from the captured_traces fields
of MonoException and MonoStackTrace.
* [interp] Add method to seq_points table after we finish registering it
When adding a breakpoint (mono_de_set_breakpoint) we search in this table for seq_point information for the method. If we find the information we expect that the method is already compiled and has the metadata initialized when actually adding the breakpoint (set_bp_in_method). We were crashing if the jinfo field of the interp method was not yet initialized.
Fixes https://github.com/xamarin/xamarin-macios/issues/5381
* [interp] Move profiler callback when we are actually done
Just in case.
What was happening was that this was building with a Mono.Cecil from
the build profile, but was trying to load the system Mono.Cecil.
Those versions mismatch when building 2018-08 with a nightly mono that is 5.23.0.
Rather than messing with the MONO_PATH and risking shadowing something
important there, I chose to copy the Mono.Cecil files into this
"lib/build/tmp" directory that we are using for the emitted executable.
It is loaded by the system Mono as the correct Mono.Cecil to use.
This fixes the build.
* [crash] Support extra merp params
* [runtime] Make infrastructure for merp tests
* [runtime] Fix dumping when crash happens without sigctx
* [runtime] Disable crashy (886/1000 runs) stacktrace walker
* [crash] Remove usage of allocating build/os info functions
* [crash] Remove often-crashing g_free on native crash path
* [crash] Add crash_reporter checked build
We add a checked build mode that asserts when mono mallocs inside of
the crash reporter. It makes risky allocations into assertions. It's
useful for automated testing because the double-abort often represents
itself as an indefinite hang. If it happens before the thread dumping
supervisor process is started, or after it ends, the crash reporter
hangs.
* [crash] Remove reliance on nested SIGABRT/double-fault (broken on OSX)
* [crash] Fix top-level handling of double faults/assertions
* [runtime] Make fatal unwinding errors return into handled error paths
* [crash] Change dumper logging for better info
* [runtime] Fix handling of segfault on sgen thread
Threads without domains that get segfaults will end up in
this handler. It's not safe to call this function with a NULL domain.
See crash below:
```
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10eff40f8)
* frame #0: 0x000000010e1510d9 mono-sgen`mono_threads_summarize_execute(ctx=0x0000000000000000, out=0x0000001000000000, hashes=0x0000100000100000, silent=4096, mem="", provided_size=2199023296512) at threads.c:6414
frame #1: 0x000000010e152092 mono-sgen`mono_threads_summarize(ctx=0x000000010effda00, out=0x000000010effdba0, hashes=0x000000010effdb90, silent=0, signal_handler_controller=1, mem=0x0000000000000000, provided_size=0) at threads.c:6508
frame #2: 0x000000010df7c69f mono-sgen`dump_native_stacktrace(signal="SIGSEGV", ctx=0x000000010effef48) at mini-posix.c:1026
frame #3: 0x000000010df7c37f mono-sgen`mono_dump_native_crash_info(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-posix.c:1147
frame #4: 0x000000010de720a9 mono-sgen`mono_handle_native_crash(signal="SIGSEGV", ctx=0x000000010effef48, info=0x000000010effeee0) at mini-exceptions.c:3227
frame #5: 0x000000010dd6ac0d mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48, debug_fault_addr=0xffffffffffffffff) at mini-runtime.c:3574
frame #6: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000000010effeee0, context=0x000000010effef48) at mini-runtime.c:3612
frame #7: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
frame #8: 0x0000000110bb81c1
frame #9: 0x000000011085ffe1
frame #10: 0x000000010dd6d4f3 mono-sgen`mono_jit_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x00007ffee1ea9f08, error=0x00007ffee1eaa250) at mini-runtime.c:3215
frame #11: 0x000000010e11509d mono-sgen`do_runtime_invoke(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, exc=0x0000000000000000, error=0x00007ffee1eaa250) at object.c:2977
frame #12: 0x000000010e10d961 mono-sgen`mono_runtime_invoke_checked(method=0x00007faae4f01fe8, obj=0x0000000000000000, params=0x00007ffee1eaa180, error=0x00007ffee1eaa250) at object.c:3145
frame #13: 0x000000010e11aa58 mono-sgen`do_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5042
frame #14: 0x000000010e118803 mono-sgen`mono_runtime_exec_main_checked(method=0x00007faae4f01fe8, args=0x000000010f0003e8, error=0x00007ffee1eaa250) at object.c:5138
frame #15: 0x000000010e118856 mono-sgen`mono_runtime_run_main_checked(method=0x00007faae4f01fe8, argc=2, argv=0x00007ffee1eaa760, error=0x00007ffee1eaa250) at object.c:4599
frame #16: 0x000000010de1db2f mono-sgen`mono_jit_exec_internal(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1298
frame #17: 0x000000010de1d95d mono-sgen`mono_jit_exec(domain=0x00007faae4f00860, assembly=0x00007faae4c02ab0, argc=2, argv=0x00007ffee1eaa760) at driver.c:1257
frame #18: 0x000000010de2257f mono-sgen`main_thread_handler(user_data=0x00007ffee1eaa6a0) at driver.c:1375
frame #19: 0x000000010de20852 mono-sgen`mono_main(argc=3, argv=0x00007ffee1eaa758) at driver.c:2551
frame #20: 0x000000010dd56d7e mono-sgen`mono_main_with_options(argc=3, argv=0x00007ffee1eaa758) at main.c:50
frame #21: 0x000000010dd5638d mono-sgen`main(argc=3, argv=0x00007ffee1eaa758) at main.c:406
frame #22: 0x00007fff73aaf015 libdyld.dylib`start + 1
frame #23: 0x00007fff73aaf015 libdyld.dylib`start + 1
thread #2, name = 'SGen worker'
frame #0: 0x000000010e2afd77 mono-sgen`mono_get_hazardous_pointer(pp=0x0000000000000178, hp=0x000000010ef87618, hazard_index=0) at hazard-pointer.c:208
frame #1: 0x000000010e0b28e1 mono-sgen`mono_jit_info_table_find_internal(domain=0x0000000000000000, addr=0x00007fff73bffa16, try_aot=1, allow_trampolines=1) at jit-info.c:304
frame #2: 0x000000010dd6aa5f mono-sgen`mono_sigsegv_signal_handler_debug(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0, debug_fault_addr=0x000000010e28fb20) at mini-runtime.c:3540
frame #3: 0x000000010dd6a8d3 mono-sgen`mono_sigsegv_signal_handler(_dummy=11, _info=0x000070000fb81c58, context=0x000070000fb81cc0) at mini-runtime.c:3612
frame #4: 0x00007fff73dbdf5a libsystem_platform.dylib`_sigtramp + 26
frame #5: 0x00007fff73bffa17 libsystem_kernel.dylib`__psynch_cvwait + 11
frame #6: 0x00007fff73dc8589 libsystem_pthread.dylib`_pthread_cond_wait + 732
frame #7: 0x000000010e28d76d mono-sgen`mono_os_cond_wait(cond=0x000000010e44c9d8, mutex=0x000000010e44c998) at mono-os-mutex.h:168
frame #8: 0x000000010e28df4f mono-sgen`get_work(worker_index=0, work_context=0x000070000fb81ee0, do_idle=0x000070000fb81ed4, job=0x000070000fb81ec8) at sgen-thread-pool.c:165
frame #9: 0x000000010e28d2cb mono-sgen`thread_func(data=0x0000000000000000) at sgen-thread-pool.c:196
frame #10: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
frame #11: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
frame #12: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
thread #3, name = 'Finalizer'
frame #0: 0x00007fff73bf6246 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x000000010e1d9c0a mono-sgen`mono_os_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-os-semaphore.h:84
frame #2: 0x000000010e1d832d mono-sgen`mono_coop_sem_wait(sem=0x000000010e43e400, flags=MONO_SEM_FLAGS_ALERTABLE) at mono-coop-semaphore.h:41
frame #3: 0x000000010e1da787 mono-sgen`finalizer_thread(unused=0x0000000000000000) at gc.c:920
frame #4: 0x000000010e152919 mono-sgen`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=0x000070000fd85000) at threads.c:1178
frame #5: 0x000000010e1525b6 mono-sgen`start_wrapper(data=0x00007faae4f31bd0) at threads.c:1238
frame #6: 0x00007fff73dc7661 libsystem_pthread.dylib`_pthread_body + 340
frame #7: 0x00007fff73dc750d libsystem_pthread.dylib`_pthread_start + 377
frame #8: 0x00007fff73dc6bf9 libsystem_pthread.dylib`thread_start + 13
thread #4
frame #0: 0x00007fff73c0028a libsystem_kernel.dylib`__workq_kernreturn + 10
frame #1: 0x00007fff73dc7009 libsystem_pthread.dylib`_pthread_wqthread + 1035
frame #2: 0x00007fff73dc6be9 libsystem_pthread.dylib`start_wqthread + 13
(lldb)
```
* [crash] Add signal-safe mmap/file "allocator"
* [crash] Remove use of static memory from dumper
* [runtime] Reduce print buffer size for lockless printer.
Each frame that prints ends up increased by the size of buff.
In practice, clang often fails to deduplicate some of these buffers,
leading to 30k-big stackframes.
It was noticed by a series of hard-to-diagnose segfaults on stacks that
looked otherwise fine during the crash reporting stress test.
This change fixes this, making stacks a 1/10th of the size. It doesn't
seem to break the crash reporter messages anywhere (may need to shrink
other "max name length" fields), and it's not mission-critical anywhere
else.
* [crash] Use async-safe file memory for dumper internals
* [crash] Add memory barriers around merp configuration
* [crash] Use signal-safe printers on all native crash paths
* [crash] Move gdb/lldb lookup to startup
* [runtime] Move MOSTLY_ASYNC_SAFE_FPRINTF to eglib
* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_PRINTF
* [runtime] Fix all callsites of MOSTLY_ASYNC_SAFE_FPRINTF
* [crash] Switch to signal-safe exit function
* [crash] Make dumper enum in managed
* [runtime] Add more information to managed frame
* [crash] Make async_safe printers inlined
* [runtime] Move basic pe_file functionality into proclib
* [crash] Fix handling of thread attributes
* [crash] Place hashes into the json file for all threads
* [crash] Fix 2018-08 CI, disable test
After .NET 4.5 .NET Framework has changed the System.ComponentModel.Composition ReflectionModelServices.IsExportFactoryImportDefinition to not throw.
Updating this to match the .NET Framework behavior.
Backport of: https://github.com/mono/mono/commit/eebe4b52857140ba9dea872c6249960273d222f2 from https://github.com/mono/mono/pull/12454
The latest Android NDK releases no longer ship with per-platform C headers.
Instead they ship with a set of unified headers and require the presence of the
`__ANDROID_API__` macro in order to select the target platform.
The AOT offset dumper doesn't support this new layout and this commit changes
that by adding support for the unified headers (without removing support for the
older NDKs) thus fixing the following error when trying to dump the offsets with
newer NDK:
Processing triple: aarch64-v8a-linux-android
Error parsing '[...]/mono/mono/metadata/metadata-cross-helpers.c'
[...]/mono/mono/metadata/metadata-cross-helpers.c(5,10): fatal: 'stdio.h' file not found
Error parsing '[...]/mono/mono/mini/mini-cross-helpers.c'
[...]/mono/mono/mini/mini-cross-helpers.c(7,10): fatal: 'stdio.h' file not found
* [Debugger] Fix crash when there is a generic struct with a field that is an enumerator. (#12368)
* [Debugger] Debugger crashes when inside a class, there is an internal struct, with a field that is an enumerator.
files.myBucket.GetEnumerator().get_Current().Key
Fixes#10735
* [Debugger] Debugger crashes when there is a generic struct with a field that is an enumerator.
Example: files.get_Current().Key
A unit test that reproduces this crash was added too.
Fixes#10735
* Removing the extra space.
* Merging changes from dtest-app.cs
* Adding extra line.
On some platforms (e.g. AppleTV) SigContext is available, but isn't as
precise as we would like to have it. For example, it doesn't save
callee-saved registers and thus aren't restored properly.
Unfortunately, this also means we can't use the fastpath for
interp2native, so we disable it on those platforms.
Xamarin.Android is looking to switch to using the latest Android NDK, r18.
However, there are a few build issues in Mono and BTLS which need to be
addressed before that happens.
* BTLS fails to build some ARM assembly sources with NDK r18's clang.
https://github.com/mono/boringssl/pull/12 fixes this issue
* BTLS uses obsolete Android cmake toolchain file.
Add a configure option to set alternative toolchain file.
* NDK r18 minimu supported API level is 16.
This commit makes the API level configurable and sets the minimum platform
to API 16
* NDK r18 makes changes to declaration of `mmap` which break Mono build.
Detect NDK version in `mono-compiler.h` and act accordingly (do not
redeclare `mmap`)
* NDK r18 doesn't have `cpp` and SDKs build assumes it's present.
Detect whether `cpp` is present and, if not, use `compiler -E` instead.
* NDK r18 uses unified headers exclusively and requires __ANDROID_API__ to be
set in order to present the correct set of native APIs.
SDKs now define the macro when the `ANDROID_NEW_NDK` Make variable is set to
anything else than `no`.
* [Network] Fix CVE 2018-8292 on Mac OS X.
This commit ensures that CVE 2018-8292 is fixed by not setting
auto-redirect in the first request done by CFNetwork. CFNetwork has the
same bug, but we can work around it by performing the first request,
checking the response and, if it is a rediret, follow it without the
Authorization headers.
* No need to close the obc, it can be reused.
* Small typo.
* Fix error while chaging the request :/
* Minor style changes.
There are two identical sounding functions:
mono_string_handle_to_utf8:
What we usually use. Sounds reasonable. Usually is reasonable.
Allocates with malloc.
mono_string_to_utf8str_handle:
What should be used here. Allocates with CoTaskMemAlloc.
So it can be freed with marshal_free => CoTaskMemFree.
i.e. The allocator and the freeer need to agree.
[2018-08] [mini] use AOT trampolines in interp mixed mode
Fixes this on mscorlib/mixed mode on Xamarin.iOS:
```
[FAIL] NonExceptional.Serialization_Deserialization : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] NonExceptional.Serialize_Deserialize_FixedDateRule : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] NonExceptional.Serialize_Deserialize_FloatingDateRule : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] SerializationTests.Serialization_Deserialization : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
[FAIL] TimeZoneTest.CurrentTimeZone_SerializationRoundtrip : System.Runtime.Serialization.SerializationException : An error occurred while deserializing the object. The serialized data is corrupt.Â
```
Backport of #11767.
/cc @lewurm
[2018-08] [interp] attempt to intrinsify again after a method is resolved regarding generics
discovered when running https://github.com/Clancey/gMusic
Backport of #11712.
/cc @luhenry @lewurm
This pull request fixes starting a process with an empty environment variable collection in `ProcessStartInfo`. As per the issue it fixes a regression that it used to work but currently an empty environment variable collection works like it was never touched.
I also made a minor fix to remove the `StringBuilder` because a simple `string.Concat` does the job without the `StringBuilder` allocation and overhead.
I've included unit tests. Please let me know if you'd like any changes.
Fixes#8766
Backport of #11630.
Otherwise it might have left-over files from previous builds since it
uses our custom submodule system which isn't catched by Jenkins cleaning.
(cherry picked from commit 49a5af74f7)
(cherry picked from commit b429e290e8)
[2018-08] [ios] remove DISABLE_POLICY_EVIDENCE
Originally it was introduced with db3591b
It seems like only the icall definitions were disabled for device
runtimes (which aren't shipped there anyway), however the icalls
themselves are _included_ in the device runtime. Not sure what the
rationale was behind this. Since the original change is very old, I
think it just happened to be like that today. When running with the
interpreter we need the definitions at runtime too (via the optional
icall table that is linked in, so no additional cost for the fullAOT
runtime due to this change).
Backport of https://github.com/mono/mono/pull/11565
/cc @lewurm
[2018-08] [bcl] avoid false pinning in GCTest
Backport of #11521.
/cc @luhenry @lewurm
Description:
needed for mscorlibtests on Xamarin.iOS with interpreter
Backport of #11435.
/cc @alexanderkyte
Description:
The change which made the handler return (rather than crashing the
runtime) did not consider this control flow path that causes the sigterm
signal handler to trigger the merp dumper if we return.
We now always return.
This was previously so that a random sigterm could be used to trigger a
dump. This isn't really used, and won't work right now anyways
(we don't register it until right before we dump). My fix is to remove
it, and to make the signal handler only work as part of the dumper
machinery.
@monojenkins skip
Earlier in the 2018-08 branch, Mono on desktop Linux, OSX and Windows would
default to hybrid suspend. Turn that off for now (revert to preemptive suspend
by default).
Continue hybrid suspend work on 2018-10 and master.
[2018-08] [interp] enable more BCL tests
Backport of #11381.
/cc @lewurm
Description:
probably won't pass on all configurations, I wanna find out on which.
Mono doesn't use libxml2 and neither do the LLVM bits used by Mono when building
the AOT cross-compilers. Presence of `-lxml2` on the command line breaks 32-bit
builds on 64-bit Linux hosts:
libtool: link: cc -shared -fPIC -DPIC -Wl,--whole-archive ./.libs/libmini.a ./.libs/libmono-ee-interp.a ./.libs/libmono-dbg.a ../../mono/metadata/.libs/libmonoruntimesgen.a ../../mono/sgen/.libs/libmonosgen.a ../../mono/utils/.libs/libmonoutils.a ../../mono/eglib/.libs/libeglib.a -Wl,--no-whole-archive -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -L$HOME/xamarin-android/external/mono/sdks/out/llvm-llvm32/lib -lz -ltinfo -lxml2 -lstdc++ -lm -lrt -ldl -lpthread -O0 -ggdb3 -m32 -g -mno-tls-direct-seg-refs -Wl,-export-dynamic -Wl,-soname -Wl,libmonosgen-2.0.so.1 -o .libs/libmonosgen-2.0.so.1.0.0
mv -f .deps/libmini_la-aot-runtime-wasm.Tpo .deps/libmini_la-aot-runtime-wasm.Plo
/usr/bin/ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libxml2.so when searching for -lxml2
/usr/bin/ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libxml2.a when searching for -lxml2
/usr/bin/ld: cannot find -lxml2
collect2: error: ld returned 1 exit status
make[7]: *** [Makefile:1495: libmonosgen-2.0.la] Error 1
Installation of `libxml2-dev` (on Ubuntu/Debian + friends) for the x86
architecture (or x86_64 architecture on 32-bit host) would be possible but then
it would break the 64-bit build because the 64-bit version of the library would
be absent. It would be a problem if Mono+LLVM actually used xml2, but since it
doesn't we can just disable the feature completely.
(cherry picked from commit 0d68ffd1ce)
[2018-08] [tests] lower recursion depth of PerformNoPinAction
Backport of #11065.
/cc @lewurm
Description:
so it doesn't overflow the stack when running on macOS with `clang -O0`.
* [threads] Make mono_add_internal_call external only
The runtime should use mono_add_internal_call_internal or
mono_add_internal_call_with_flags.
The thread suspend mechanism needs to know if an icall is added via the legacy
mono_add_internal_call API (which is not coop-aware, and so the registered
icalls must run in GC Safe mode), or if it is added by the runtime or by a
cooperative client (currently either the profiler or the System.Native PAL)
which knows to add GC transitions and safepoints and not to block indefinitely.
* [marshal] Factor out GCSafeTransitionBuilder
Make a local builder for creating the GC Safe transition calls for a method wraper.
* [sgen] Add coop GC transitions in mono_gc_toggleref_add
Also mark it external only. It's not used inside the runtime.
* [marshal] Emit GC Safe transitions around foreign icalls.
A foreign icall is added using mono_add_internal_call and that is not coop GC
aware. (The runtime uses mono_add_internal_call_with_flags or
mono_add_internal_call_internal)
Under hybrid suspend, foreign icalls will run in GC Safe mode and transition to
GC Unsafe only when the call back into the runtime or invoke managed code.
Fixes https://github.com/mono/mono/issues/11138
* [runtime] Add new API call mono_dangerous_add_raw_internal_call
Under hybrid suspend, this adds an icall that is assumed to run in GC Unsafe
mode. As such it has additional requirements for correct operation: it must
not run loops without periodically polling the runtime, and it must not perform
blocking operations such as blocking I/O or taking locks without manually
switching to GC Safe mode.
[2018-08] [aot] Reenable recursion checking when initing shared got entries
Backport of #11258.
/cc @BrzVlad
Description:
Broken in https://github.com/mono/mono/pull/11190
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
* [arm64] Remove the limitation on the number of nullable arguments for dyncalls.
Fixes https://github.com/xamarin/xamarin-macios/issues/4984.
* [amd64] Remove the limitation on the number of nullable arguments for dyncalls.
* [jit] Add tests for dyncalls with lots of nullable arguments.
* fix merge conflict
* [llvm] Make sure OP_LSHL_IMM is transformed to a 64 bit shift even if the input is 32 bit, which can happen because the JIT IR is not regular. Fixes bug-17590.exe on arm64+fullaot+llvm.
* [llvm] Fix a crash when trying to pass a vtype of size 0 on arm64. Fixes generic-constrained.2.exe.
Flags to DrawText never reached MeasureText therefore strings with '&' were measured incorrect when drawn with flag TextFormatFlags.NoPrefix.
Fixes#6352
They require the additional files:
- mono/eglib/eglib-config.h: that's to build `libmonodroid`
- mcs/build/Consts.cs: that's to build `Mono.Posix` and `Mono.Data.Sqlite`
* [interp] Avoid unnecessary allocations when pinvoke void functions
* [amd64] Refactor interp pinvoke context computation
* [amd64] Interp trampoline for interpreter entry
* [aot] Don't include interp_in_wrapper when we use entry trampoline
These wrappers take a lot of space in the image.
* [runtime] Add icall to format crashes to disk in uniform way
* [crash] More gentle error handling around stack walking
* [crash] Make self-summarizier not need managed thread state
* [crash] Remove reliance on sgen/gchandles
* [crash] Refactor dumper mechanism
* [crash] Make threads not die during thread dump
* [crash] Add support for registering/dumping native libraries
* [crash] Add silent option to dumper
* [crash] Print error when unable to dump thread
* [crash] Add icalls to directly trigger telemetry-style walks
* [crash] Increase maximum frame depth
* [crash] Add managed method names when privacy disabled
* [crash] Add tests for concurrent dumping
* [crash] Add support for concurrent global dump requests
* [crash] Switch from CAS+Sleep to semaphore for dumper
Locks and GC-Safe regions are both unsafe in a signal handler
context. CAS primitives and the sleep syscall was used before.
Semaphores appear to be safe, enabling the following cleanup.
* [runtime] Make find_method use stack memory for dumper-facing entry point
* [crash] Enable install_state_summarizer on all platforms
* [crash] Dump managed stacks from controlling thread
* [crash] Don't use allocating method name formatter
* [crash] Copy safer strings with crash privacy disabled
* [crash] Fix string races with DumpTotal icall
* [crash] Fix space in crash file name
* [crash] Fix lifetime and size checks on mono-state memory
* [crash] Fix icall declarations for new style
* [runtime] Make sequence point lookup lockless
* [crash] Fix managed exception dumper icall format
* [crash] Print half-completed dump when space runs out
* [crash] Bump static memory for crash string to 500k
Note:
- This memory isn't accessed until we're crashing
- On any modern machine, unused static memory is lazily allocated. When
we access it, the fault will trigger the MMU to map memory for us.
- This is guaranteed to be reentrant and safe. mmap (the alternative) is
surely fairly stable on many systems, but this is not guaranteed. The
documentation pages for mmap specifically claim it as not safe in these async
contexts.
* [crash] Make whitelist lookup lockless
* [crash] Split unmanaged ptrs into method ip + offset
* [System]: Reenable native Apple Certificate support on WatchOS. (#11173)
During the code refactoring this summer, support for native apple certificates
has been dropped on watchOS.
* add `apple-certificates.sources` and move all certificate-related code from
`appletls.sources`.
* move non-network related code from `MacProxy` into a new `AppleTypes`.
* add the `MONO_FEATURE_APPLE_X509` magic to `System/Makefile` where it was missing from.
(cherry picked from commit b61a3ffb02)
* [csproj] Update project files
* [sdks] Remove redundant --enable-cxx
* [sdks] Shorten `-m32`/`-m64` parameters detection for runtimes
* [sdks] Build BCL profiles without configure flags
* [sdks] Add BclTemplate to build BCL profiles
This is to avoid building all the profiles in a single `sdks/out/bcl` directory which will be shared between android, ios and wasm.
* [sdks] Add download/pack capabilities for LLVM
* [sdks] Create archive targets for pre-building on CI
* [sdks] Use archive-{android,ios,wasm} on CI
* [sdks] Run archive-llvm-llvm{,win}{32,64} on CI
* [sdks] Ensure LLVM is cloned before trying to download
* [sdks] Simplify call to BclTemplate
* [mcs] Make directory dependency as order-only
We would otherwise always rebuild the target since the directory is updated whenever something is added to the directory. This is a common Makefile technique.
* [sdks] Build tests for BCL targets
* [jit] Fix a constant propagation problem on 32 bit with iconst+conv.i8, we would be setting inst_imm even for long opcodes.
* [llvm] Fix the special casing of OP_LCOMPARE_IMM, its not needed.
* Use TARGET_SIZEOF_VOID_P.
`HttpWebRequest.RunWithTimeoutWorker()` needs to observe the worker task's exception
on timeout to prevent it from being thrown via the `TaskScheduler.UnobservedTaskException`
event. Fixes#10488.
* [interp] fix op_implicit/op_explicit conversions for native types
Conversion operators have been mostly broken in the interpreter, for
example conversion from nint to float didn't work. While some
conversions are easy to intrinsify (like nint -> I8), there are harder
cases like nint -> decimal. The JIT actually falls back to the managed
implementation, so let's do this in the interpreter as well.
However the managed implementation expects a pointer to the value type,
i.e. the container type System.nfloat instead of float/double primitives.
In such cases the value is going to be stored in a local and then the
address of its storage is pushed on the stack before invoking the
managed implementation of the conversion.
Added test cases for scenarios observed in Xamarin.iOS.
* [interp] support ntype.CompareTo ()
* [interp] support ntype.Equals ()
* [interp] support nfloat.*Infinity
* [interp] support ntype.ToString ()
* [interp] introduce float R4 stack type
Before we only did this for PR builds but it turns out it's needed for
normal master/branch builds too.
In situations where there are two Mac builds at roughly the same time
the downstream Windows builds would otherwise both refer to the same/latest
commit since they just checkout the latest ref on the branch.
Now we reset the Windows build to the sha1 which is passed to it.
(cherry picked from commit b13145bb12)
Right now if anything goes wrong in the security stack you get a message like this:
```
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
```
This is confusing since SSPI is a Windows-only thing and is not used on Mono.
We inherited this error message string from referencesource.
Change the string to something more generic which also aligns us with CoreFX:
https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.Net.Security/src/Resources/Strings.resx#L210-L212
(cherry picked from commit 42e347ee47)
xamarin-macios currently builds zlib-helper.o using mono's source code.
It would be preferrable to use a version built by mono, and since
zlib-helper.o is a byproduct of building libMonoPosixHelper, we need to build
libMonoPosixHelper (we already build it for simulator architectures), even
though we don't need/use libMonoPosixHelper itself.
So they are next to their NUnit counterparts.
Move xunit remote executor app to tests dir too and compile it when
compiling the test assembly instead of doing it before running the test.
We need to use an absolute path for the xunit remote executor and it
needs to be in Windows format on Windows since we pass it as an env var
to the xunit tests.
[2018-08] [runtime] Disable stack guard for main thread on osx
Backport of #10899.
/cc @luhenry @BrzVlad
Description of #10899:
On macOS Mojave, it seems that changing the mapping of stack pages for main thread can lead to corruption bugs.
https://github.com/mono/mono/issues/10802
<!--
Thank you for your Pull Request!
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->
If another thread locked at least one of the other handles, and there is a
cooperative GC STW happening, this function will loop forever.
Add GC Safe transitions around the call to sleep to give this thread a chance
to suspend.
Fixes https://github.com/mono/mono/issues/10863
The `X509Certificate(byte[])` constructor should call `CertificateProvider.Import(byte[])`
to use the native apple implementation if possible.
(cherry picked from commit 8b3ca0dbbe0af1436d33d74bb2ca00b3cbfc28b8)
It turns out some Debian versions identify themselves as `Debian GNU/Linux`, add
this string to the list of distributions which have mingw. This *should* fix the
PR builds (fingers crossed)
Debian and its derivatives include full mingw chain (both 64 and 32-bit) and so
they don't need to build the toolchain at all. However, the current detection of
Linux flavor takes into account only Ubuntu and all other distros are configured
to *require* MXE but they do *not* build them.
This commit fixes detection of distros which provide the mingw toolchain in a
way that makes it easy to extend the set of compatible distributions as needed.
In order to mark a distribution as one with MinGW one has to add the `:Distro:`
string to the `LINUX_WITH_MINGW` make variable in `mxe.mk`. The `Distro` string
is whatever the `determine-linux-flavor.sh` script returns.
When building 32-bit binaries on a 64-bit system and vice versa, it is necessary
to pass the `-m32` or `-m64` compiler flags, respectively. Failure to do so will
result not only in linking problems (different binary architecture) but also in
problems when using some system headers which are sensitive to the architecture.
For instance, `ucontext.h` contains register set definitions for different
architectures and building Mono runtime with a 64-bit compiler targetting 32-bit
architecture results in this error:
.../mono/mono/utils/mono-sigcontext.h:173:74: error: ‘REG_EIP’ undeclared (first use in this function); did you mean ‘REG_RIP’?
#define UCONTEXT_REG_EIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.gregs [REG_EIP])
The issue here is that the compiler defines the `__x86_64__` macro which causes
`ucontext.h` to choose declarations for amd64 (which does not use `REG_EIP` but
has `REG_RIP` instead) while Mono runtime assumes its building for a 32-bit host
and uses 32-bit register names. Passing `-m32` to the compiler will fix the
issue as now the compiler will define the `__i386__` macro and all parties will
agree where they are and what they want.
This commit uses a rather baroque statement when constructing compiler flags to
build the Mono runtime to check whether the host triple targets 32 or 64-bit
host and adds the appropriate flag.
mono_aot_get_unbox_trampoline: amd64 hardcode unbox trampoline size to 5 at compile-time.
This fixes: MonoTests.System.Linq.ParallelEnumerableTests.TestGroupBy frequently crashing on FullAOT/LLVM/Linux/amd64 CI.
https://github.com/mono/mono/issues/10441https://github.com/mono/mono/issues/9554https://github.com/mono/mono/issues/9046
The actual size varies between 6 and 9 but we can just pretend the last instruction has size 1 (it is 2 or 5; calling it 5 can be fatal, calling it 2 is no better than 1).
Otherwise, a trampoline can overlap the next function, jit info lookup of the next function can fail, then gsharedvt wrapper omited, and crash.
The afflicted function in this case was
System_Linq_Parallel_WrapperEqualityComparer_1_T_GSHAREDVT_GetHashCode_System_Linq_Parallel_Wrapper_1_T_GSHAREDVT.
You can see it with debugprint: https://github.com/mono/mono/pull/10582.
There are many other possible fixes.
Such as runtime disassembly, hardcode in runtime instead of compiler, produce static trampinfo, omit trampinfo entirely, compute minimum size.
See https://github.com/mono/mono/commit/d589f3b64fca77c5c8bb5a8582eea5c0670312d7.
We want to attach a thread before any TLS operation is done by the
interpreter. In the JIT this happens inside the native-to-managed
wrapper via `mono_threads_attach_coop ()`. Unfortunately, this is too
late for the interpreter as it already requires a working TLS before
even calling into the wrapper.
Also, fixup naming of locals in the native-to-managed wrapper.
* [metadata] Hack - get mono_use_interpreter from metadata
Don't use this, it's a mistake. The granularity is all wrong, for one: in the
future the interpreter may not be an all-or-nothing deal.
* [marshal] Don't emit CEE_MONO_JIT_ATTACH except for interpreter
Always use the mono_threads_coop_attach/mono_threads_coop_detach pair.
* [aot] Drop MONO_PATCH_INFO_JIT_THREAD_ATTACH
We always emit the mono_threads_attach_coop icalls now.
Bump MONO_AOT_FILE_VERSION
* [mini] mark mono_jit_thread_attach external only
It's used by Xamarin.Mac and possibly other embedders.
Interpreter still used mono_jit_thread_attach_interp until it's fixed to work
with coop.
There shouldn't be any other callers.
* [interp] Add a thread attach EE callback
Use it to set the interpreter thread context on the JIT tls value
* [marshal] Always emit mono_threads_attach_coop instead of CEE_MONO_JIT_ATTACH
Use the coop icall for the interpreter, too.
* [interp] Drop MINT_MONO_JIT_ATTACH and detach opcodes
* [metadata] Drop CEE_MONO_JIT_ATTACH and detach opcodes
* Revert "[metadata] Hack - get mono_use_interpreter from metadata"
This reverts commit c3d2f488b824dcdfa261f8292013c805740f353f.
* [mini] Drop unused mini_jit_thread_attach_interp
It was a temporary workaround for the interpreter; no longer needed.
* [coop] Switch to GC Safe in mono_jit_thread_attach.
It's an external-only function that's not called by the runtime on any
threads. So the only calls are explicit uses by Mono API clients. Leave the
thread in GC Safe mode and leave it to the n2m invoke wrappers or MONO_API
entry points to switch to GC Unsafe.
* [interp] Add MINT_MONO_THREADS_ATTACH_COOP opcode
Because this icall can be called from detached threads, don't go through
do_icall () which needs initialized tls keys
* fixup for c++ build
* fixup indentation and comments
* fixup C++ a bit more
* [mini] Bump MONO_EE_API_VERSION
* Revert "[interp] Add a thread attach EE callback"
This reverts commit 8a343d6ce15f0475a62936f28264f638ebf0344f.
* [interp] sync jittls context before entering EH machinery
* [interp] get context refactor (#10561)
* [interp] Add declaration for set_context (#10575)
* Fix Mono Windows cross compiler using mono LLVM release_60 branch.
For scenario where llvm-config.exe can't be run (none WSL/CygWin build target)
Build will fallback to hard coded libraries not working with mono LLVM release_60
branch.
Added an exact mirror of what llvm-config.exe is returning for different components
on mono LLVM master and mono LLVM release_60 branch.
The selected codegen libraries (passed in as extra_libs) was not handled in any cases
so added them into the build script as well.
* Split parameter between lvm codegen libs and llvm extra libs.
Need to explicit pass -lz in case where configure have detected zlib availability
and llvm-config.exe can't be executed. In cases where zlib is not available, default
in mingw installs, this check make sure link step won't fail due to missing library.
* Fix inversion of aarch64codegen libs.
* Enable package-android-cross-{arm,arm64,x86,x86_64}-win builds on CI.
We can't decrement the size on removal as we use tombstones.
When using tombstones, the invariant to keep is on the number of null entries as those
are used as search stop-marks.
Without this change, it's possible that a long series of add/remove operations could leave the array with no null entries,
just tombstones and filled entries. In that case, search would degenerate into a linear search that would look into all array elements.
This change fixes worst-case perf of not-found searches to be bound to the load factor.
Additionally, clear the array to null entries, otherwise we fall into the above trap even more easily.
0dbcdd5 added CFLAGS etc in front of the command but that's not something the TESTCMD can execute.
We shouldn't pass CFLAGS etc at all for this since that is handled by bockbuild.
* Ensure the finalization of SafeHandle and GCHandle in DeflateStreamNative is performed in the correct order.
* Do not access BaseStream from finalizer.
* [exceptions] ftnptr_eh_callback test that stresses n2m transitions
on Xamarin.iOS it happens that the ftnptr_eh_callback calls into managed
code, that is yet another native-to-managed transition.
* [coop] Use unbalanced transition to GC Unsafe in mono_raise_exception
Since `mono_raise_exception_deprecated` never returns, the transition won't be
balanced. This fixes a cookie-counting problem (assert on mono shutdown) in
coop and hybrid checked builds using the new test case:
MONO_THREADS_SUSPEND=coop MONO_CHECK_MODE=thread,gc mono mono/tests/install_eh_callback.exe
Backport of #9843.
* Truncate MachineName (and UserDomainName) at first period
Unix machines often put their FQDN as the host name, and domain
name is used for things such as yp. As such, truncate the FQDN to
just the hostname, as other Unix utilities seem to do.
Matches the .NET Core and .NET Framework behaviour, and MS seems to
require this for a future project. Fixes#9839.
* Add a unit test for bug
* Formatting tweaks
* [sdks] Add CrossRuntimeTemplate
* [sdks] Add cross-{arm,arm64,x86,x86_64}{,-win} runtimes for XA
* [sdks] Factor various variables for RuntimeTemplate
* [sdks] Use CrossRuntimeTemplate for iOS
* [sdks] Unify provisioning of LLVM for both Android and iOS.
A global CFLAGS would be set in `run-jenkins.sh`, and that would screw up with LLVM. The global CFLAGS makes sense as long as we are only building Mono, but that's not the case with LLVM anymore.
* [sdks] Use MonoRuntime template for desktop-x86_64
* [sdks] Remove android-armeabi, it's been removed from XA already and the target has been deprecated in the NDK
The llvm/llvm_config.mk makefile fragment just includes make (not automake)
variable definitions. So there is no need to regenerate the mini/Makefile.am
file if the fragment updates - the include will pick it up.
In order to allow managed crash reporting using the existing telemetry
format, I have added initial support for converting a MonoException into
a json blob for telemetry.
When we execute the certificate verification callback we just don't test for success and set status11. Now we get the error (if any) and map the error code to those defined by ChainStatusFlags and add it to a list of X509ChainStatus objects for that chain. Now when get_ChainStatus is called we convert that list to an array of X509ChainStatus and return it.
* [threads] Add enums for suspend phases and for begin-suspend results
* [coop] Two phase suspend
If we're using hybrid suspend, initially request suspension for threads, but
don't preemptively suspend blocking threads. In the mop-up phase, peek at the
state and if they are still blocking_suspend_requested, preemptively suspend
them.
In full coop and in full preemptive, just use a single phase.
This should fix hybrid suspension deadlocks due to preemptively-suspending
threads taking locks that prevent cooperatively-suspending threads from
reaching a safepoint by leaving all threads running until all
cooperatively-suspending threads come to a safepoint. At that point we can
preemptively suspend the remaining threads.
Fixes https://github.com/mono/mono/issues/9921
* [tests] renable flaky hybrid suspend tests on PRs
* [coop] Thread state machine helper peek_blocking_suspend_requested
* [coop] Check async suspend status in ReqSuspendInitSuspendBlocking case
So the issue is that calling begin_suspend_for_blocking_thread under hybrid
suspend will perform a preemptive suspension of the victim thread.
The preemptive suspend doesn't always succeed.
In particular, thread_state_init_from_sigctx or thread_state_init_from_handle
could return FALSE and into->suspend_can_continue will be set to FALSE.
When the thread_state_init_* functions return FALSE, they also set the
MonoThreadUnwindState:valid to FALSE.
So it is important to check the value of MonoThreadInfo:suspend_can_continue
before proceeding with a suspension.
As a result in suspend_sync in the ReqSuspendInitSuspendRunning case we call
check_async_suspend which checks (for preemptively suspended threads) whethere
suspend_can_continue is true. If it isn't, we resume the victim thread and
loop once more in suspend_sync_nolock and try again.
We didn't have a check_async_suspend call in the ReqSuspendInitSuspendBlocking
case, so a thread could be considered suspended even if we couldn't capture a
valid MonoThreadUnwindState for it.
That breaks the assertion the call to mono_thread_info_get_last_managed in
async_suspend_critical which needs a valid MonoThreadUnwindState.
Fixes https://github.com/mono/mono/issues/10031
* fixup - remove coop assertion in check_async_suspend
result for coop could be iether BeginSuspendOkCooperative or
BeginSuspendOkNoWait depending on whether the thread was running (Ok) or
blocking (OkNoWait)
* [coop] suspend_can_continue if async raced with self-suspend (osx + win32)
Companion to 006d6ce097 from earlier this year
which applied this fix for POSIX signal based suspend. This is the
corresponding OSX and Win32 fix.
In hybrid suspend, in the case where a suspend initiator needs to preemptively
suspend a thread, but the thread self-suspended while after the suspend
initiator put it into the blocking_suspend_requested state, we want to allow
the suspend to continue. We do have to call the syscall to undo the native
async suspend, but after that, we can leave the victim to continue waiting for
a resume.
This should not have any effect on full cooperative or full preemptive suspend
- in the full coop case we never call async suspend, in the full preemptive
case the thread never self-suspends in blocking.
This https://github.com/mono/mono/issues/10143 and fix is from there.
I considered nulling the array elements as I go, and then the tail,
to help the GC, but does it help actually? I suspect not.
macOS 10.14 introduces a Network framework, which means Xamarin.Mac now has a Network namespace.
This conflicts with 'using Network = System.Net':
> mono/mcs/class/System.Xml.Linq/Test/System.Xml.Schema/ExtensionsTest.cs(97,27): error CS0576: Namespace '<global namespace>' contains a definition conflicting with alias 'Network'
so just remove the using and use the full 'System.Net' namespace instead.
* [reflection] Assembly.LoadFile should throw ArgumentException for relative paths
Fixes https://github.com/mono/mono/issues/9943
* [mcs/tests] Use full path in the compiler-tester
Otherwise the call to LoadFile will fail
* [mono/tests] Use full path in LoadFile in test-multi-netmodule-4-exe
* [mono/tests] Use the test runner for a couple of tests
* [fullaot] Disable test-multi-netmodule-4-exe and custom-attr-errors.exe
* [tests] Use Path.GetFullPath and Path.Combine in AssemblyTest
Fix windows test failures
If an AOT library is loaded that was compiled with safepoints, but currently
we're running with preemptive suspend (e.g. MONO_THREADS_SUSPEND=preemptive is
set), don't assert. `mono_polling_required` will always be false, so the
safepoint will be ignored.
Fixes https://github.com/mono/mono/issues/9947
* [threads] switch to GC Safe around pthread calls in mono_thread_internal_set_priority
Observed pthread_getschedparam taking a lock on OSX
* [win32] Capture GetLastError before MONO_EXIT_GC_SAFE
The LoadFrom assembly loading context and the individual assembly loading
context (aka LoadFile aka "no context") behave differently when requesting a
referenced assembly - for LoadFile we expect the runtime to probe the appdomain
base, the GAC + MONO_PATH but not the basedir of the requesting assembly. For
LoadFrom the basedir of the requesting assembly _is_ included. So the tests
here try all the possible variations.
1. If an assembly filename is in the GAC, always open the assembly in default
context.
2. If an assembly filename is in the appdomain search path (base directory or
private bin path) always open the assembly in default context.
3. If an assembly filename is in the base dir of the requesting assembly and
the requesting assembly was in LoadFrom context, always open the assembly in
LoadFrom context.
Fixes https://github.com/mono/mono/issues/9753
and Fixes https://github.com/mono/mono/issues/9542
Add a hook that can be used to check whether a given path belongs to some
assembly load context.
For example if a given path is in the application base of the current
appdomain, an appdomain hook would set out_asmctx to MONO_ASMCTX_DEFAULT and
return TRUE.
If an assembly was loaded with LoadFile, it can reference assemblies from the
application base, the GAC or MONO_PATH.
Fixes https://github.com/mono/mono/issues/8575
if an assembly in LoadFrom context calls Assembly.Load, the given assembly name
should be tried in the basedir of the executing assembly, and the resulting
loaded assembly should be in LoadFrom context.
AC_ARG_WITH(crash-privacy, [ --with-crash_privacy=yes,no If you want your crashes to not include names of symbols present in the binary. ], [], [with_crash_privacy=no])
AC_ARG_WITH(structured-crashes, [ --with-structured_crashes=yes,no If you want your unmanaged crashes to result in a small crash dump file. ], [], [with_structured_crashes=yes])
AC_MSG_ERROR([LLVM for Windows only supported using Visual Studio build mono runtime, see http://www.mono-project.com/docs/advanced/mono-llvm/ for more details.])
fi # win32
LLVM_CODEGEN_LIBS="x86codegen"
case "$target" in
arm*)
LLVM_CODEGEN_LIBS="armcodegen"
;;
aarch64*)
LLVM_CODEGEN_LIBS="aarch64codegen"
;;
powerpc*)
LLVM_CODEGEN_LIBS="powerpccodegen"
;;
esac
if test "x$host" != "x$target"; then
# No need for jit libs
LLVM_CODEGEN_LIBS=
fi
AC_SUBST(LLVM_CODEGEN_LIBS)
AC_SUBST(EXTERNAL_LLVM_CONFIG)
AC_DEFINE(ENABLE_LLVM, 1, [Enable the LLVM back end])
fi # ENABLE_LLVM
@@ -4539,6 +4555,7 @@ AC_DEFINE(HAVE_UWP_WINAPI_SUPPORT, 0, [Don't use UWP Windows API support])
AC_ARG_WITH([overridable-allocators], [ --with-overridable-allocators allow g_*alloc/g_free to call custom allocators set via g_mem_set_vtable])
@@ -4562,8 +4579,6 @@ elif test x$target_ios = xno; then
AC_CHECK_FUNCS(strndup getpwuid_r)
fi
AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)
AC_SEARCH_LIBS(sqrtf, m)
# nanosleep may not be part of libc, also search it in other libraries
@@ -5011,11 +5026,12 @@ if test x$enable_cooperative_suspend_default != xyes; then
X86 | AMD64)
dnl Some host/target confusion, there's no host_osx (and
dnl host_darwin would be true on iOS not just macOS).
if test x$target_osx = xyes; then
enable_hybrid_suspend_default=yes
elif test x$host_linux = xyes -o x$host_win32 = xyes; then
enable_hybrid_suspend_default=yes
fi
dnl if test x$target_osx = xyes; then
dnl enable_hybrid_suspend_default=yes
dnl elif test x$host_linux = xyes -o x$host_win32 = xyes; then
dnl enable_hybrid_suspend_default=yes
dnl fi
true
;;
esac
fi
@@ -5061,7 +5077,7 @@ dnl **********************
dnl *** checked builds ***
dnl **********************
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread, private_types],[
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread, private_types, crash_reporting],[
AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)
AC_CHECK_HEADER([malloc.h],
[AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1],
[Define to 1 if you have /usr/include/malloc.h.])],,)
@@ -5128,6 +5155,26 @@ dnl **************
AC_ARG_ENABLE(btls, [ --disable-btls Disable the BoringTls provider], enable_btls=$enableval, enable_btls=$BTLS_SUPPORTED)
AC_ARG_ENABLE(btls-lib, [ --disable-btls-lib Disable building the BTLS native library], enable_btls_lib=$enableval, enable_btls_lib=$BTLS_SUPPORTED)
AC_ARG_WITH(btls_android_ndk, [ --with-btls-android-ndk Android NDK for BoringTls])
AC_ARG_WITH(btls_android_api, [ --with-btls-android-api Android NDK API level for BTLS build])
AC_ARG_WITH(btls_android_cmake_toolchain, [ --with-btls-android-cmake-toolchain Path to the cmake toolchain file for Android])
AC_ARG_WITH(btls_android_ndk_asm_workaround, [ --with-btls-android-ndk-asm-workaround Work around a problem with NDK r18+ clang compiler when compiling some AES assembly for ARM])
if test "x$with_btls_android_api" = "x" ; then
case "$BTLS_PLATFORM" in
android-armv5)
with_btls_android_api=16" ;;
android-armv6)
with_btls_android_api=16" ;;
android-armv7)
with_btls_android_api=16 ;;
android-v8a)
with_btls_android_api=21 ;;
android-x86)
with_btls_android_api=16 ;;
android-x64)
with_btls_android_api=21 ;;
esac
fi
if test "x$enable_btls" = "xno"; then
enable_btls_lib=no
@@ -5185,30 +5232,38 @@ if test "x$enable_btls" = "xyes"; then
# FIXME: URL should be http://xamjenkinsartifact.blob.core.windows.net/build-package-osx-llvm-$(NEEDED_LLVM_BRANCH)/llvm-osx64-$(NEEDED_LLVM_VERSION).tar.gz
# FIXME: URL should be http://xamjenkinsartifact.blob.core.windows.net/build-package-osx-llvm-$(NEEDED_LLVM_BRANCH)/llvm-osx64-$(NEEDED_LLVM_VERSION).tar.gz
.PHONY:download-llvm
download-llvm:
wget --no-verbose -O - http://xamjenkinsartifact.blob.core.windows.net/build-package-osx-llvm-release60/llvm-osx64-$(NEEDED_LLVM_VERSION).tar.gz| tar xzf -
.PHONY:download-llvm36
download-llvm36:
wget --no-verbose -O - http://xamjenkinsartifact.blob.core.windows.net/build-package-osx-llvm/llvm-osx64-$(NEEDED_LLVM36_VERSION).tar.gz | tar xzf -
<!-- WARNING: this file is autogenerated, don't modify it. Edit the .sources file of the corresponding assembly instead if you want to add/remove C# source files. -->
<!-- WARNING: this file is autogenerated, don't modify it. Edit the .sources file of the corresponding assembly instead if you want to add/remove C# source files. -->
Loaded 100 of 407 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.