Compare commits

...
94 Commits
Author SHA1 Message Date
monojenkinsandImran Hameed 620cf53820 [2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin. (#20297)
* Avoid following invalid pointers in mono_w32process_get_modules on Darwin.

`_dyld_get_image_name` and `_dyld_get_image_header` can return pointers
to data that will be freed or unmapped by concurrent calls to `dlclose`.
Avoid this by using `_dyld_register_func_for_add_image` and
`_dyld_register_func_for_remove_image` to install callbacks that
maintain a runtime-internal set of loaded dynamic libraries.

Some notes:

- dyld doesn't provide a public "app store friendly" API (like
`dl_iterate_phdr`) to traverse a snapshot of all loaded dynamic
libraries in a process. There are two alternative private APIs that do
this: one uses `_dyld_process_info_create` and friends and is present in
macOS 10.12 and above, and the other depends on
`_dyld_get_all_image_infos`, which is documented by Apple (... in a WWDC
video) to "go away" at some point in dyld3.

- `dladdr` linearly scans the dyld loaded image array (and each image's
segment set) for a matching address, so `image_added` will get slower as
more dynamic libraries are loaded in the process. But dyld3's
implementation of dlopen already scales linearly in time with the number
of loaded libraries. The use of `dladdr` can be avoided by using
`_dyld_register_for_image_loads` or
`_dyld_register_for_bulk_image_loads`, but those are both private APIs.

- The callbacks registered with `_dyld_register_func_for_add_image` and
`_dyld_register_func_for_remove_image` can never be unregistered, so
this is yet another thing that makes it impossible to safely unload an
embedded mono.

- `MonoW32ProcessModule::inode` only seems to be used to avoid dupicates
in other implementations of w32process; sorting the returned module list
in `mono_w32process_get_modules` wouldn't be necessary if the
`mono_dyld_image_info`s were also kept in an intrusive circular doubly
linked list.

- It looks like `mono_w32process_get_modules` in `w32process-unix-bsd.c`
has a similar race condition.

Also see: https://github.com/mono/mono/issues/20107

* Formatting.

* Make `image_added` and `image_removed` non-blocking.

It is theoretically possible for `mono_w32process_get_modules` to cause
a deadlock if either `image_added` or `image_removed` is waiting for the
image table mutex to be released and if `g_new0`, `g_strdup`,
`g_hash_table_iter_next`, or any of the symbols they depend on are
lazily bound and haven't already been resolved.

Only one thread may iterate over the image table and only one thread may
add/remove entries to/from the image table.

The writer thread attemps to lock a mutex to block readers from
iterating over the table. If the writer successfully acquires this lock,
then no readers are concurrently iterating over the image table and it
is safe to eagerly free stale data.

If the writer doesn't successfully acquire this lock, then the reader
thread is running concurrently with the writer; if this happens, the
writer pushes stale data into a limbo list. Readers opportunistically
clear this list.

Use `mono_mutex_t` instead of `MonoCoopMutex`. Hand-roll the necessary
GC state transitions inside `mono_w32process_get_modules`.

Add `mono_conc_hashtable_foreach_snapshot` to mono-conc-hashtable.{h,c}.

`MonoConcurrentHashTable` depends on the hazard pointer table
(`hazard_table` inside hazard-pointer.c), which is initialized lazily on
the first call to `mono_thread_small_id_alloc`. Perhaps this should be
explicitly initialized early during `mono_init_internal`.

* Revert "Make `image_added` and `image_removed` non-blocking."

This reverts commit a22a4440df5f0f13da29b1b90e80a3420223c2b9.

* Use mono_mutex_t instead of MonoCoopMutex

* Explicitly load symbols not used by `image_added` before `mono_w32process_get_modules` runs

Co-authored-by: Imran Hameed <[email protected]>
2020-08-25 10:02:57 -07:00
Alexander Köplinger 41494af55d Bump corefx to disable DateTime test
See https://github.com/mono/mono/issues/16623

(cherry picked from commit e88d9ced3b)
2020-08-25 13:12:55 +02:00
monojenkinsandZoltan Varga 66e2b84002 [aot] Fix an assert which is hit for generic instances with a lot of arguments. (#20239)
The c# compiler generates these for anonymous types.

Fixes https://github.com/xamarin/xamarin-macios/issues/9289.

Co-authored-by: Zoltan Varga <[email protected]>
2020-08-13 12:34:37 -04:00
Alexander Köplinger d3daacdaa8 Bump msbuild to latest commit
Includes https://github.com/mono/msbuild/pull/429
2020-07-30 21:12:24 +02:00
Cody Russell e59c1cd70f Fix Cairo issue on macOS Big Sur (#20154)
Bumps bockbuild to get the changes from https://github.com/mono/bockbuild/pull/162

BigSur's CoreGraphics seems to need a copy of the data to stick around longer than the surface,
so we provide it a copy of the data instead.
2020-07-24 13:44:47 +02:00
monojenkinsandZoltan Varga 648655b86d [aot] Avoid a crash in generic sharing for invalid generic instances. (#20158)
Fixes https://github.com/mono/mono/issues/20138.

Co-authored-by: Zoltan Varga <[email protected]>
2020-07-24 11:26:03 +02:00
Alexander Köplingerandmathieubourgeois ec71e8a7ae [2020-02] Reapply "Emit DWARF debug_abbrev offset for compile units as a label instead of 0" (#20046)
* Revert "Revert "Emit DWARF debug_abbrev offset for compile units as a label instead of 0 (#19794)" (#20013)"

This reverts commit 83105ba224.

* Bring back previous debug_abbrev offset behavior on Apple platforms (#20031)

https://github.com/mono/mono/pull/19794 broke on iOS. Analyzing the result showed that, while the assembly was generated as expected, the linked result was different. Analyzing the LLVM code (which triggered the original fix) seems to imply that, on Apple platforms, they will not generate a label for it, only doing the 0-offset as we were doing before. Therefore, match the LLVM behavior by bringing back our previous logic when targetting Mach, otherwise use the new way of doing things.

Fixes https://github.com/mono/mono/issues/8806 (again)

(cherry picked from commit 51dfcfe5c0)

Co-authored-by: mathieubourgeois <[email protected]>
2020-07-24 11:06:00 +02:00
monojenkinsandlambdageek 20bb4f9a6d [mono][mini] Do a non-virtual call for bound delegates (#20039)
When we call a delegate that was bound to a specific function, don't do a virtual call.

Fixes mono/mono#19964

Co-authored-by: lambdageek <[email protected]>
2020-06-30 08:49:17 -04:00
monojenkinsandAlexis Christoforides 9ca6fa646a [merp] Remove dead code (#20043)
Entry to crash reporting is now more properly handled by mono_dump_start()

Co-authored-by: Alexis Christoforides <[email protected]>
2020-06-30 07:18:36 -04:00
Alexis Christoforides 2ff424be29 [crashing] Improve crash chaining (#20018)
With this change, `mono_post_native_crash_handler` chains the crashing signal directly, instead of that having to happen after `mono_handle_native_crash` returns (which created a fragile repetitive code pattern). Finally, this way `mono_post_native_crash_handler` can also re-raise the signal right after chaining it. Since we remove our crashing signal handlers in `mono_handle_native_crash`, this should allow the OS to handle the signal as the final action.

Fixes https://github.com/mono/mono/issues/19860
2020-06-25 15:50:45 -04:00
Alexander Köplinger 83105ba224 Revert "Emit DWARF debug_abbrev offset for compile units as a label instead of 0 (#19794)" (#20013)
This reverts commit 87ef555701.

It breaks on iOS: https://github.com/mono/mono/issues/8806#issuecomment-648286417
2020-06-23 21:06:54 +02:00
Zoltan Varga 109b4b6f44 [jit] Fix the Activator.CreateInstance () intrinsic for primitive types. (#19989) (#19994)
Fixes https://github.com/xamarin/xamarin-android/issues/4817.
2020-06-20 10:17:34 -04:00
monojenkinsandThays Grazia 15782aa740 If there is a crash and the debugger is attached, we call mini_get_dbg_callbacks ()->send_crash(). That call ends up in mono_debugger_agent_send_crash which does all kinds of questionable stuff like trying to take the loader lock. Eventually it ends up calling socket_transport_send which tries to do a transition to GC Safe mode. I inserted a MONO_ENTER_GC_UNSAFE in mono_debugger_agent_send_crash function and this fixes the assert. (#19992)
Fixes #18794

Co-authored-by: Thays Grazia <[email protected]>
2020-06-19 22:58:21 -04:00
monojenkinsandAlexis Christoforides 6ea4cbcee0 [2020-02] [merp] Add API methods for getting hashcode/reason of last crash (#19978)
* [merp] Add API methods for getting hashcode/reason of last crash

* Add test

* Review feedback and cleanup

Co-authored-by: Alexis Christoforides <[email protected]>
2020-06-17 17:46:44 -04:00
Alexis Christoforides d45ff3af75 [merp] Add tests for crashing via POSIX signal (#19977) 2020-06-16 21:01:51 -04:00
monojenkinsandAlexis Christoforides bc1dd071a7 [merp] Add a test for Mono.Runtime.SendExceptionToTelemetry() (#19966)
Co-authored-by: Alexis Christoforides <[email protected]>
2020-06-15 18:09:15 -04:00
monojenkinsandMathieu Bourgeois 87ef555701 Emit DWARF debug_abbrev offset for compile units as a label instead of 0 (#19794)
When outputting DWARF code to start a compilation unit in .debug_info, the standard expect a 4-byte offset from the .debug_abbrev code. Mono has always output an offset of 0.

However, this doesn't work in every cases. When we have linux+fullaot, we link two object files (one from Mono, one from LLVM). Both have their .debug_abbrev section. If we use 0 as an offset, it seems possible that the linker will keep thinking that our offset is 0, no matter the circumstances. Since the offset is always 0, it can be using the wrong abbreviation table (i.e. the one from the LLVM assembly instead of the one from the Mono assembly). The consequence of this is that the linked file is not valid DWARF (dwarfdump and objdump will complain about invalid offsets). At best, some tools will be able to work with a part of what we have, but any program requiring entirely valid DWARF will fail.

To fix this, we generate a label for the start of our debug_abbrev section and we instead generate it by generating a long with that label. This matches existing behavior seen in the LLVM generated code, and makes dwarfdump and objdump react properly to the linked product.

Fixes https://github.com/mono/mono/issues/8806

Co-authored-by: Mathieu Bourgeois <[email protected]>
2020-05-26 18:44:37 +02:00
monojenkinsandMarek Habersack 8c085a99b3 [reflection] Check whether a pointer is valid before dereferencing (#19842)
`Xamarin.Android` native runtime calls `mono_reflection_type_from_name`
and passes `NULL` as the `image` parameter.  The parameter is then
propagated all the way to `_mono_reflection_get_type_from_info` where,
in case the assembly isn't loaded yet, it is used to obtain base
directory of the assembly.  However, since the `image` parameter is
`NULL` in our case, attempt to dereference it causes a segfault:

    libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
    crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
    /system/bin/tombstoned: received crash request for pid 11029
    crash_dump64: performing dump of process 11029 (target tid = 11029)
    DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
    DEBUG   : Revision: '0'
    DEBUG   : ABI: 'x86_64'
    DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
    DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
    DEBUG   : uid: 10134
    DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
    DEBUG   : Cause: null pointer dereference
    DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
    DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
    DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
    DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
    DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
    DEBUG   :
    DEBUG   : backtrace:
    DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
    DEBUG   :       #01 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
    DEBUG   :       #02 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
    DEBUG   :       #03 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       #04 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
    DEBUG   :       #05 pc 0000000000069532  <anonymous:5ad25000>

Even though this happens in `Xamarin.Android`, the error may occur for
any embedding application which passes `NULL` for the `image` parameter
in situation when the assembly isn't in memory yet.

Co-authored-by: Marek Habersack <[email protected]>
2020-05-26 09:25:48 -04:00
monojenkins 89d772a3ab Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
As-is, a tarball created in Roslyn mode is missing the file charinfo.nlp, which mcs needs to build the classlib.

Backport of #19807.
2020-05-25 12:40:13 +02:00
Alexander Köplinger e9d3af508e Bump bockbuild to get https://github.com/mono/bockbuild/pull/159 2020-05-15 14:33:13 +02:00
Ankit Jain d6f0c25d34 [2020-02] Bump msbuild to track mono-2019-12 (#19661)
- Updates roslyn to `3.6.0-4.20224.5` to match msbuild
- This bump includes `NuGet.Build.Tasks` update to `5.6.0-rtm.6591`
2020-04-30 10:32:20 +02:00
monojenkins 075c3f0619 Fix if already send error to http client, do not callback. (#19668)
Fixed #10435 

HttpListener already closes the Response object, closes the HTTP Client connection, and then sets the value of Response.StatusCode again. If so, an ObjectDisposedException is thrown.

```
Unhandled Exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
  at System.Net.HttpListenerResponse.set_ContentLength64 (System.Int64 value) [0x00013] in <b4473693dd3c4d45883c574a53529fbe>:0
  at MonoConsoleApp1.Program.Main (System.String[] args) [0x000f8] in <a66f6d7d417445dc9f89c691941ca70b>:0
  at MonoConsoleApp1.Program.<Main> (System.String[] args) [0x0000c] in <a66f6d7d417445dc9f89c691941ca70b>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListenerResponse'.
  at System.Net.HttpListenerResponse.set_ContentLength64 (System.Int64 value) [0x00013] in <b4473693dd3c4d45883c574a53529fbe>:0
  at MonoConsoleApp1.Program.Main (System.String[] args) [0x000f8] in <a66f6d7d417445dc9f89c691941ca70b>:0
  at MonoConsoleApp1.Program.<Main> (System.String[] args) [0x0000c] in <a66f6d7d417445dc9f89c691941ca70b>:0
```

If an error is sent to the HTTP client while processing a request, it is patched so that the next process is not executed anymore.

Backport of #19664.
2020-04-28 20:22:51 +02:00
monojenkins 35cc82cc6c [2020-02] [debugger] Remove assert when the DebuggerTypeProxy cannot be instantiated (#19632)
Remove the assert because we don't need to stop the debug if we cannot create the object when calling the constructor using invoke_method, if it's a DebuggerTypeProxy, we are not able to show the value of the DebuggerTypeProxy, but we still can show the Raw View, if it's not the case of DebuggerTypeProxy, we just cannot evaluate this expression, but we can continue the debug session.

Fix #19492 

Backport of #19542.
2020-04-28 13:25:47 +02:00
monojenkins 00ae178a04 Bump corefx (#19656)
Bump CoreFX submodule to get https://github.com/mono/corefx/pull/399.

Backport of #19646.
2020-04-27 17:59:37 +02:00
Ankit Jain c23ad4f5b3 [2020-02] Bump msbuild to track mono-2019-12 (#19623) 2020-04-27 14:33:16 +02:00
monojenkins 83558de96b [System.Runtime.Serialization] Work around specified cast is not valid error (#19640)
Backport of #19620.
2020-04-24 10:56:03 +02:00
monojenkinsandMartin Baulig 051408e0be Bump CoreFX to pickup https://github.com/mono/corefx/pull/398. (#19566)
Fixes https://github.com/mono/mono/issues/19451.

Backport of #19564.

Co-authored-by: Martin Baulig <[email protected]>
2020-04-17 11:07:42 +02:00
monojenkinsandMartin Baulig 58b04da0d7 Bump CoreFX to pickup https://github.com/mono/corefx/pull/397. (#19548)
Co-authored-by: Martin Baulig <[email protected]>
2020-04-15 23:56:58 +02:00
Thays Grazia f51cb7ad85 [2020-02][debugger] Bump protocol for multi threaded single step implementation (#19437) (#19477)
As suggested by jbevain we should bump the protocol to implement this. (#19437)

Backport https://github.com/mono/mono/pull/19437/
2020-04-09 16:41:11 +02:00
monojenkinsandFilip Navara 62414d588b [2020-02] Add BeginRead/BeginWrite/EndRead/EndWrite overloads back to SslStream (#19476)
* Add BeginRead/BeginWrite/EndRead/EndWrite overloads back to SslStream and underlying implementation. Unlike the default implementation in Stream it allows parallel read along with parallel write using the standard TaskToApm pattern (https://github.com/dotnet/runtime/issues/33447). This reverts part of https://github.com/mono/mono/pull/17393 which could lead to deadlocks as reported in https://github.com/mono/mono/issues/18865.

* Move the TaskToApm pattern from MobileAuthenticatedStream to SslStream

* Bump API snapshot submodule

Co-authored-by: Filip Navara <[email protected]>
2020-04-09 01:55:40 +02:00
Thays Grazia 259ec2ef65 [2020-02][debugger] Bump protocol for this commit https://github.com/mono/mono/pull/19248 (#19318) (#19473)
* Bump protocol for this commit https://github.com/mono/mono/pull/19248 as suggested by @vargaz.

* Fix coding convention.
2020-04-08 16:35:29 -03:00
Thays Graziaandmonojenkins 165f4b0341 [2020-02][debugger] Fix NOT_IMPLEMENTED while debugging. (#19450)
* Backporting this, and after this I will backport the bump protocol for this PR.

* Bump API snapshot submodule

Co-authored-by: monojenkins <[email protected]>
2020-04-08 09:57:01 -03:00
monojenkinsandMitchell Hwang b04dc7e6a4 Bump corefx to get https://github.com/mono/corefx/pull/395 (#19426)
Co-authored-by: Mitchell Hwang <[email protected]>
2020-04-03 19:40:04 +02:00
Zoltan Varga ecde08600b [runtime] Allocate the memory for gshared gparams from image sets. (#19361) (#19419)
Fixes https://github.com/mono/mono/issues/18127.
2020-04-03 00:36:36 +02:00
monojenkinsandCoffeeFlux 8fb9301292 [meta] Add mono_type_get_name_full to public API (#19415)
This is needed by Xamarin.Android to be able to round-trip with names fetched via reflection, as the only public API for this (`mono_type_get_name`) uses the IL format instead.

Fixes https://github.com/mono/mono/issues/19377

Co-authored-by: CoffeeFlux <[email protected]>
2020-04-02 12:46:06 -04:00
Alexander Köplinger 7bfb441fb4 Fix Windows .msi build using newer xar
The old version didn't compile anymore with OpenSSL 1.1

(cherry picked from commit 9485a66d20)
2020-04-01 16:32:07 +02:00
Alexander Köplinger e77cea1910 Fix Windows .msi build with recent cygwin updates
Cygwin now ships libssl 1.1 which removed OpenSSL_add_all_ciphers so the xar configure fails.
Replace the configure check with another existing function to fix it.

(cherry picked from commit e10990125d)
2020-04-01 12:37:03 +02:00
monojenkinsandThays Grazia fda73998f9 Adding static to ss_req_acquire and ss_req_count (#19391)
Fixes #19389

Backport of #19390.

Co-authored-by: Thays Grazia <[email protected]>
2020-03-31 20:55:35 +02:00
monojenkinsandCoffeeFlux beccf5ba43 [2020-02] Use GArray instead of GList when getting custom attributes from an image (#19102)
* Use GArray instead of GList when getting custom attributes from an image

Xamarin.Forms calls this _constantly_ during startup, to the point where the malloc calls were actually showing up in the profile. This should help with that, and gives us some ms back during startup.

There are also a bunch of calls that return empty arrays, which in theory could be created in managed for a perf boost. However, it seems the Xamarin.Android team has mostly gotten rid of those calls and that optimization would complicate the code and require changes to our managed CustomAttribute implemented for both legacy and netcore, so I've opted to not check it in for now. If the empty calls continue to show up down the line, I can dig the code back up from my local branch and PR it separately.

If this is producing huge arrays and malloc continues to show up in the profile, consider https://github.com/dotnet/runtime/issues/32972. Even without that, this is a substantial improvement.

* [metadata] Fix leak in custom attribute lookup (#19279)

https://github.com/dotnet/runtime/commit/9dec6ae2ea81d46884bf49d2df8b26cc1e28eb12#r37604565

Co-authored-by: CoffeeFlux <[email protected]>
(cherry picked from commit 9f390a7d8a)

Co-authored-by: CoffeeFlux <[email protected]>
2020-03-28 00:38:33 +01:00
monojenkinsandZoltan Varga 5bea89d861 [llvm] Disable running the llvm verifier by default, it was enabled by mistake, and it takes a long time. (#19332)
Co-authored-by: Zoltan Varga <[email protected]>
2020-03-27 16:21:00 +01:00
Thays Graziaandmonojenkins 4b0424cd68 [2020- 02][debugger] Implementing step through multithreaded code. (#19343)
* [debugger] Implementing step through multithreaded code.
Backport #19103

* Bump API snapshot submodule

Co-authored-by: monojenkins <[email protected]>
2020-03-27 16:00:06 +01:00
2444b38b3c [2020-02] [dim] Class overriding interface method that was already override by another interface (#19121)
* The problem was a parent class overriding an interface that was already override by another interface. Fix #18917

* Adding test to cmake.

* Fixing test.

* Fixing test.

* Trying to refactor mono_class_setup_vtable_general.

* Changing what was suggested by @lambdageek.

* Update mono/metadata/class-init.c

Co-Authored-By: Aleksey Kliger (λgeek) <[email protected]>

* Update mono/metadata/class-init.c

Co-Authored-By: Aleksey Kliger (λgeek) <[email protected]>

Co-authored-by: Thays Grazia <[email protected]>
Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
2020-03-26 19:56:33 -03:00
Thays Grazia 93a2f4ea39 Fix suspend_policy that will be sent to debugger-libs, because on debugger-libs we want to resume the VM only when it's suspended, but we were sending the wrong suspend_policy in the case of EVENT_KIND_VM_START and mono is started with suspend=y. (#19330)
With this fix we can do this PR again: https://github.com/mono/debugger-libs/pull/264/

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/999375/
2020-03-26 19:04:09 -03:00
monojenkinsandJonathan Chambers 0565f6e2c0 Do not access unloading domains in debugger (case 1013579) (#19322)
There was a race where a domain was being unloaded while debugger would access it. A domain was only removed from the 'appdomains_list' as a very last step. The domain was already invalid to access at this point (locks freed for example).

Worse, images would be unloaded if only referenced by that domain. All places the debugger iterates domains hold the loader lock. The loader lock is acquired by the domain unloading process, so as long as a domain is not unloading when we access it inside of the loader lock we are safe.

include domain unloading check in collect_domain_bp

Co-authored-by: Jonathan Chambers <[email protected]>
2020-03-26 16:38:26 -04:00
Vlad Brezae b7196c45e8 [jit] Initialize correct class for tls fields (#19300) (#19313)
Initialize the klass containing the field to be accessed, rather than the class of the method from where we are accessing.
2020-03-26 16:34:03 -04:00
monojenkinsandAlexis Christoforides 88c1989895 [2020-02] [merp] Add breadcrumb for StackHash (#19242)
* [merp] Add breadcrumb for StackHash

Contributes to https://github.com/mono/mono/issues/18715

Co-authored-by: Alexis Christoforides <[email protected]>
2020-03-26 16:33:15 -04:00
monojenkinsandAleksey Kliger d2be7389b1 [2020-02] [corlib] Suppress finalization of underlying console FileStreams (#19164)
* [corlib] Suppress finalization of underlying console FileStreams

We already suppress the finalization of the CStreamReader and CStreamWriter,
but during shutdown, the underlying FileStream may be finalized which
invalidates its access field which can lead to a crash.

The issue is that during shutdown, the CStreamWriter and its underlying
FileStream might be finalized in arbitrary order, so if the FileStream is
finalized first, even though it doesn't own the safeHandle, the access check in
Write(byte[], int, int) will fail, despite the fact that the underlying call to
MonoIO.Write could have succeeded.

Addresses https://github.com/mono/mono/issues/19005

Co-authored-by: Aleksey Kliger <[email protected]>
2020-03-26 16:32:18 -04:00
Alexander Köplinger a7e29665d2 Bump nunitlite to get https://github.com/mono/NUnitLite/pull/26
(cherry picked from commit 81939f45c4)
2020-03-24 11:18:05 +01:00
Alexander Köplinger c51a2eba84 Bump boringssl submodule 2020-03-20 11:55:36 +01:00
monojenkinsandlambdageek f0784b26dd [mono] Enter GC Unsafe mode in some string allocation functions (#19262)
All these functions are MONO_RT_EXTERNAL_ONLY and they all allocate managed
objects.

Fixes a deadlock if an embedder calls the function and it needs to take the GC
lock to do a collection.

Co-authored-by: lambdageek <[email protected]>
2020-03-19 23:57:43 -04:00
monojenkinsandAleksey Kliger d90665a422 [2020-02] [corlib] Capture the ExceptionDispatchInfo when rethrowing from TaskContinuation (#19209)
* [corlib] Capture the ExceptionDispatchInfo when rethrowing from TaskContinuation

In `task.GetAwaiter().OnCompleted(action)` if `action` throws, the
`TaskContinuation.RunOrScheduleAction method will catch the exception and then
call `RuntimeAugments.ReportUnhandledException`.  We must not simply throw the
exception again - in that case we will lose all the frames leading up to the
`catch` in `RunOrScheduleAction`.  Instead use ExceptionDispatchInfo to
caputure the original throw.

Addresses https://github.com/mono/mono/issues/19166

* [test] Add regression test

For annoying reasons we can't run this as a simple NUnit test because the
exception is unhandled on some arbitrary threadpool worker thread, and those
don't show up within an NUnit setup.

Additionally because the unhandled exception in the root domain would normally
terminate the application, we need to run this in a new appdomain.

Co-authored-by: Aleksey Kliger <[email protected]>
2020-03-13 10:04:42 -04:00
Ankit Jain 74bf77a59c [2020-02] Bump msbuild to track xplat-master (#19206) 2020-03-12 23:38:45 +01:00
monojenkinsandAlexis Christoforides f0ce5105d4 [merp] Remove unnecessary call to msync in mono_state_free_mem (#19170)
Closes https://github.com/mono/mono/issues/19136

Co-authored-by: Alexis Christoforides <[email protected]>
2020-03-12 06:51:44 -04:00
monojenkinsandZoltan Varga 4ca7d77e34 [2020-02] Avoid passing /features:peverify-compat to csc, it generates very inefficient code in some cases. (#19145)
* Avoid passing /features:peverify-compat to csc, it generates very inefficient code in some cases.

See https://github.com/mono/mono/issues/18572#issuecomment-595924767.

Fixes https://github.com/mono/mono/issues/18572.

* Disable the IL verifier for now, it can't handle code compiled without /features:peverify-compat.

Co-authored-by: Zoltan Varga <[email protected]>
2020-03-12 01:20:48 +01:00
monojenkinsandImran Hameed 338349925c [arm] Fix branch island disassembly for arm64 and thumb. (#19189)
Followup to https://github.com/mono/mono/pull/19126 and
https://github.com/mono/mono/pull/19169.

Bring arm64 `mono_arch_get_call_target` in line with other platforms by
returning NULL on failure instead of asserting. Bits 30-26 in an arm64
unconditional branch are exactly 0b00101, so 0x1f (0b11111) is used as a
mask to determine if the branch uses an immediate target--0x7 (0b111)
would incorrectly match against branches using register targets. The
extracted immediate is now sign extended in a branch-free way.

Avoid following blx entries in the method address table; ld64 can emit 4
different instruction sequences for islands involving thumb, and I'd
rather not implement support for them all now because 32-bit iOS is old
and large unlinked assemblies seem rare.

Co-authored-by: Imran Hameed <[email protected]>
2020-03-11 10:37:50 -07:00
imhameed 3a4122f14f [2020-02][arm][ios] Follow branch islands when determining method entry addresses. (#19169)
[2020-02][arm][ios] Follow branch islands when determining method entry addresses.

Fixes https://github.com/mono/mono/issues/18612; `aot_code_low_addr` and
`aot_code_high_addr` were set to a range that included only first-level
branch islands, so `find_aot_module` would fail early when passed a
genuine function address.

This change only affects monotouch for now.

Why not use relative offsets stored in a read-only section? One reason
is that llvm-as cannot handle a `.long` directive containing a
subtraction expression involving externally-defined symbols. The AOT
method address table and AOT LLVM-generated code are currently emitted
in separate object files, so the method address table would include
expressions with undefined symbols.

Related: https://xamarin.github.io/bugzilla-archives/70/707/bug.html

Backport of #19126.
2020-03-09 19:36:16 -04:00
monojenkinsandAlexis Christoforides 6134b2fdc9 [merp] Create a 'reason' breadcrumb for the crash dump process (#19120)
For example, the system name of a signal ('segv') or 'MANAGED_EXCEPTION' are typical arguments.

Co-authored-by: Alexis Christoforides <[email protected]>
2020-03-09 13:45:58 -04:00
monojenkinsandMarek Safar 8cac8ee9c3 Bump linker (#19152)
Co-authored-by: Marek Safar <[email protected]>
2020-03-09 13:28:43 +01:00
Marek Safar 8c184a19d1 [2020-02] Switch to linker on mono-2020-02 branch 2020-03-04 14:02:54 +01:00
Ankit Jain 72c8e7c7ff [2020-02] Bump msbuild to track xplat-master (#19079) 2020-03-02 20:49:23 +01:00
Alexis Christoforides 544930719e [2020-02][runtime] Improve handling crashing signals (#19019)
* [runtime] Improve handling crashing signals

The default handlers for SIGTRAP, SIGSYS on macOS and Linux crash the process, so we now have Mono report this.

This patch also changes how the name of the signal is acquired for passing on to the crash reporting functions, allowing code reuse on crashing signals.

* [mono] Remove SIGTRAP handler, as it interferes with debugging

See https://github.com/mono/mono/pull/18243#issuecomment-586013427

* Fix lack of cleanup for SIGSYS
2020-02-28 21:10:14 -05:00
Alexander Köplinger 69d8e50279 Update mono-extensions 2020-02-28 19:58:33 +01:00
Alexander Köplinger 017cd6e606 Update mono-extensions 2020-02-28 19:06:08 +01:00
Alexander Köplinger 79f94d9960 Bump mono-extensions 2020-02-28 15:23:07 +01:00
monojenkins 2aa8108972 [aot] Avoid mono_defaults when creating trampolines. (#19062)
[2020-02] [aot] Avoid `mono_defaults` when creating trampolines.

Fixes https://github.com/mono/mono/issues/19009.

https://github.com/mono/mono/pull/18505 made PLT initialization occur at
image load time. When initializing the PLT for mscorlib,
`mono_defaults.corlib` is not yet initialized.

This change works around this by using `mscorlib_aot_module`--which is
initialized relatively early--instead of `mono_defaults.corlib`. PLT
initialization is also moved slightly later: it now happens after
`use_page_trampolines` has been initialized. The `USE_PAGE_TRAMPOLINES`
macro has also been changed to dereference `mscorlib_aot_module`.

This commit also removes an unused parameter from
`mono_aot_create_specific_trampoline`.

Backport of #19055.

/cc @lewurm @imhameed
2020-02-27 11:16:08 -05:00
Thays Grazia 2b7e10ebda [2020-02][debugger] Enable reading embedded ppdb (#19049)
Backport https://github.com/mono/mono/pull/18895
2020-02-27 11:41:14 +01:00
Alexander Köplinger 23b4f40e1b Bump bockbuild for Pango nil check fix
Pango nil check fix: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1069059/

Brings in https://github.com/mono/bockbuild/pull/153

Backport of https://github.com/mono/mono/pull/18936
2020-02-24 19:49:21 +01:00
monojenkinsandAlexis Christoforides 4cc5d1bdd3 [merp] Produce hashes for unmanaged thread stacks also (#18963)
Before, this was only done for managed stacks.

Addresses https://github.com/mono/mono/issues/18941

Co-authored-by: Alexis Christoforides <[email protected]>
2020-02-24 13:02:07 -05:00
monojenkinsandAlexis Christoforides 86f2aad309 [merp] Increase buffer size for state dump (#18837)
Addresses https://github.com/mono/mono/issues/18796

Co-authored-by: Alexis Christoforides <[email protected]>
2020-02-24 10:21:37 -05:00
Ankit Jain de18868297 [2020-02] Bump msbuild to track xplat-master (#18988) 2020-02-24 15:50:47 +01:00
monojenkinsandNathan Ricci 9a18f06a45 Added some parenthesis and a cast to control order of operations. (#18983)
This fixes https://github.com/mono/mono/issues/17140; intermittent incorrect results from GetTotalBytesAllocated for current thread. uint64_t and a pointer difference are not the same type/width on all architectures, so incorrect results can happen with out the parenthesis.

Co-authored-by: Nathan Ricci <[email protected]>
2020-02-21 21:35:18 -05:00
monojenkinsandFan Yang e40d66b687 Revert linker change of 5a65a97 (#18993)
This is needed because  the required='false' field in
```
<type fullname="System.Reflection.Emit.TypeBuilder" required='false' preserve="fields" feature="sre">
			<method name="SetCharSet" feature="sre" />
			<!-- reflection.c mono_reflection_call_is_assignable_to () -->
			<method name="IsAssignableTo" feature="sre" />
```
Fails to preserve the IsAssignableTo method.

Co-authored-by: Fan Yang <[email protected]>
2020-02-22 01:26:40 +01:00
monojenkinsandVlad Brezae 86679ca35a [sgen] Disable managed allocator when using nursery-canaries (#18947)
The managed allocator included in a full aot image does not support canaries, leading to inconsistent object layout.

Fixes https://github.com/mono/mono/issues/18925

Co-authored-by: Vlad Brezae <[email protected]>
2020-02-20 14:00:50 +02:00
monojenkinsandEgor Bogatov fce530c0b0 Remove TestEnvVarSwitchForInnerHttpHandler test as it should be in XA/LinkerTests.cs instead (#18955)
Co-authored-by: Egor Bogatov <[email protected]>
2020-02-20 11:11:49 +01:00
Aleksey Kliger (λgeek) daf5d55df9 [2020-02][merp] Capture Environment.FailFast message in crash report (#18920)
* [merp] Capture Environment.FailFast message in crash report

* [test] merp-crash-test refactor crasher data; add optional validator

Switch from a Tuple<T1,T2> to a struct for the crash items.  Add a third
optional validator field which is an action to run on the json blob that we get
back.

Not updating existing tests to do any json validation, yet.

* [test] Add new MERP crash test for Environment.FailFast

Check that the resulting json blob includes the failfast message.
2020-02-19 21:32:13 +01:00
monojenkinsandAlexander Köplinger ab4049e219 [tests] Disable bug-10127.exe runtime test on Windows x64 (#18939)
It hangs: https://github.com/mono/mono/issues/18827

Co-authored-by: Alexander Köplinger <[email protected]>
2020-02-19 21:31:36 +01:00
monojenkins 76126c14e9 [2020-02] [bcl] Default XmlSerializer stream serialize to UTF8 Encoding (#18907)
* [mcs] Default XmlSerializer stream serialize to UTF8 Encoding

* [bcl] Add XmlSerialize Test to preserve UTF chars in stream
2020-02-19 14:06:38 -05:00
Marius Ungureanu bfd182bd20 Bump bockbuild to bring in Gtk# regression fix (#18910)
Backport of https://github.com/mono/mono/pull/18909
2020-02-18 19:45:58 +01:00
monojenkinsandEgor Bogatov 5070e45d54 [2020-02] Make MonoWebRequestHandler linker friendly (#18834)
* Make MonoWebRequestHandler linker friendly

* Make MonoWebRequestHandler's ctor public (to be able to use in Activator.CreateInstance without binding flags)

* Remove Console.WriteLine from system.net.http

Co-authored-by: Egor Bogatov <[email protected]>
2020-02-18 15:54:54 +03:00
monojenkinsandEgor Bogatov 8f348378ec Move HttpClientHandlerTests.Android.cs to nunit (#18890)
Co-authored-by: Egor Bogatov <[email protected]>
2020-02-18 15:54:44 +03:00
monojenkins 124300cac1 [sdks] add anroid-interpreter-{arm64-v8a,armeabi-v7a,x86,x86_64} targets (#18855)
[2020-02] [sdks] add anroid-interpreter-{arm64-v8a,armeabi-v7a,x86,x86_64} targets

The Xamarin.Android team prefers that we ship two different `libmonosgen-2.0.so` for each target, e.g. for arm64 we will have with this PR:

* `./sdks/out/android-arm64-v8a-release/lib/libmonosgen-2.0.so`
* `./sdks/out/android-interpreter-arm64-v8a-release/lib/libmonosgen-2.0.so`

As the names indicate one has the interpreter enabled.

This is contrary to what we do for Xamarin.iOS. There, `--enable-minimal=interpreter` has the side-effect that the build will produce a `libmono-ee-interp.dylib` that can be linked next to `libmonosgen-2.0.dylib`. We _could_ do the same for Android, but that would require us to

* Add `--disable-visibility-hidden` to the Android Mono runtime builds. There are concerns however that this will slow down `dlopen (libmonosgen-2.0.so)` on the Xamarin.Android side.
* Do some changes to the interpreter infrastructure, because `--disable-minimal=interpreter` is designed to be used with a cross compiler in mind. For example, we would need a different solution for this: https://github.com/mono/mono/blob/d7e6fcbda82639fd5afe106b0e7a65a2a72a4f63/mono/mini/tramp-arm64.c#L631-L634

/cc @grendello 

Backport of #18814.

/cc @lewurm
2020-02-17 12:06:05 -05:00
monojenkinsandAlexander Köplinger ecc716b89e Bump linker submodule (#18885)
Contains fix for -out argument.

Co-authored-by: Alexander Köplinger <[email protected]>
2020-02-17 14:55:02 +01:00
f460694bac [2020-02] Bump linker submodule (#18845)
* Bump linker submodule

* Use -o instead of -out for linker output

The arguments changed in linker.

Co-authored-by: Fan Yang <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
2020-02-14 12:20:01 +01:00
monojenkinsandAlexander Köplinger 778878e336 Move offsets-tool into mono/tools (#18829)
Backporting this since we see errors during `pip install` on the Android Mono SDKs build on Linux and with this we're removing the call to pip (it wasn't needed).

Backport of #18783.

Co-authored-by: Alexander Köplinger <[email protected]>
2020-02-13 14:16:45 +01:00
Ankit Jain 4fcb57e73b [2020-02] Bump msbuild to track xplat-master (#18806)
* [2020-02] Bump msbuild to track xplat-master

* Bump roslyn to 3.5.0-beta3-20111-03

* * Update nuget.exe to match msbuild

- the closest version available right now, to `5.5.0-rtm.6422` is
`5.5.0-preview2`, so using that for now.
2020-02-12 20:56:35 +01:00
monojenkins 879f6699bb [2020-02] Allow users to switch to MonoWebRequestHandler on Android via UI (#18785)
* Bring back old HttpHandler for Android
Co-authored-by: Egor Bogatov <[email protected]>
2020-02-12 16:24:23 +03:00
monojenkinsandAlex Soto 688a178aa4 [iOS] Replace removed dsymutil -t switch with -num-threads (#18742)
Apple removed `-t` switch from dsymutil in favor of `-num-threads`

Co-authored-by: Alex Soto <[email protected]>
2020-02-07 11:14:17 +01:00
monojenkinsandAlexis Christoforides 5be9a0f156 [merp] Add an exception type for managed exceptions (#18721)
Addresses https://github.com/mono/mono/issues/18681

Co-authored-by: Alexis Christoforides <[email protected]>
2020-02-06 17:27:41 -05:00
Alexander Köplinger a503f98e06 Skip WebAssembly build in sdks archive build on non-master branches
WebAssembly doesn't use our usual release branches yet.

(cherry picked from commit a40e1ae681)
2020-02-06 22:37:04 +01:00
monojenkinsandManuel de la Pena 9af77d0093 [NUnitLite] Bump nunitlite submodule. (#18732)
Update the nunitlite submodule to pick up some fixes in the NUnit v3
outputwriter that are needed by xamarin-macios.

Co-authored-by: Manuel de la Pena <[email protected]>
2020-02-06 15:58:20 +01:00
Matt Sylvia 75a7ff235a Update deprecated query parameter to header (#18705)
Use of `access_token` is now deprecated, switching to HTTP header

```
Please use the Authorization HTTP header instead, as using the `access_token` query parameter is deprecated.
```

(cherry picked from commit 2f74ab393f)
2020-02-04 22:59:10 +01:00
Alexander Köplinger 05dc198dfc Treat 2020-02 as a valid release branch name too
This should give us breathing room until 2100-02 :)

(cherry picked from commit 44fe895ab0)
2020-02-04 19:28:39 +01:00
Alexander Köplinger 950644e9de Bump bockbuild 2020-02-04 16:37:33 +01:00
Jo Shields cd8a898912 Bump version to 6.12 (#18698) 2020-02-04 16:37:00 +01:00
120 changed files with 2013 additions and 681 deletions

No files matched your search

+2 -1
View File
@@ -116,6 +116,8 @@
/mono/sgen @BrzVlad @lambdageek
/mono/tools/offsets-tool @lewurm @rolfbjarne
/mono/utils @vargaz @lewurm @lambdageek
/mono/utils/atomic* @lewurm @vargaz
/mono/utils/mono-hwcap* @lewurm @vargaz
@@ -156,6 +158,5 @@
/tools @lambdageek @vargaz
/tools/locale-builder @marek-safar @egorbo
/tools/nuget-hash-extractor @marek-safar @radical @akoeplinger
/tools/offsets-tool @lewurm @rolfbjarne
/tools/pedump @lambdageek @lewurm
/tools/sgen @brzvlad @vargaz @naricc
-2
View File
@@ -139,8 +139,6 @@ llvm/usr/
sdks/builds/llvm-*/
sdks/builds/android-*/
mcs/build/compiler-server.log
tools/offsets-tool-py/offtool/
tools/offsets-tool-py/clang/__pycache__
##############################################################################
# Arcade output directories
+21 -3
View File
@@ -4,7 +4,7 @@
# This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
# It should remain in the format they expect.
#
AC_INIT(mono, [6.11.0],
AC_INIT(mono, [6.12.0],
[https://github.com/mono/mono/issues/new])
AC_CONFIG_SRCDIR([Makefile.am])
@@ -1208,6 +1208,7 @@ if test x$enable_monotouch = xyes; then
fi
AC_ARG_ENABLE(cxx, [ --enable-cxx compile some code as C++])
AM_CONDITIONAL(ENABLE_CXX, test x$enable_cxx = xyes)
# mono/corefx/native has a lot of invalid C++98 in its headers
# dotnet/corefx/native looks a lot better, i.e. 44e5bdafb8d989a220c9cf1b94f31a64a6e4f052
@@ -2936,6 +2937,23 @@ if test x$host_win32 = xno; then
])
fi
dnl ********************************
dnl *** Checks for sys_signame ***
dnl ********************************
AC_MSG_CHECKING(for sys_signame)
AC_TRY_LINK([
#include <signal.h>
], [
const char *signame = sys_signame[0];
], [
# Yes, we have it...
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SYSSIGNAME, 1, [Have sys_signame])
], [
AC_MSG_RESULT(no)
])
dnl ********************************
dnl *** Checks for semaphore lib ***
dnl ********************************
@@ -6080,8 +6098,8 @@ fi
AC_SUBST(mono_runtime)
AC_SUBST(mono_runtime_wrapper)
CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.5.0/csc.exe
VBCS_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.5.0/VBCSCompiler.exe
CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.6.0/csc.exe
VBCS_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.6.0/VBCSCompiler.exe
if test $csc_compiler = mcs; then
CSC=$mcs_topdir/class/lib/build/mcs.exe
+1 -1
+1 -1
+7 -1
View File
@@ -1498,6 +1498,9 @@ scanning is available.
\fBno-managed-allocator\fR
Disables the managed allocator.
.TP
\fBmanaged-allocator\fR
Enables the managed allocator.
.TP
\fBcheck-scan-starts\fR
If set, does a plausibility check on the scan_starts before and after each collection
.TP
@@ -1523,7 +1526,10 @@ sgen-gc.c. You can then use this command to explore the output
\fBnursery-canaries\fR
If set, objects allocated in the nursery are suffixed with a canary (guard)
word, which is checked on each minor collection. Can be used to detect/debug
heap corruption issues.
heap corruption issues. This disables the usage of the managed allocator,
because allocation from full aot code is inconsistent with this option. If
the application is guaranteed not to use aot code, the managed allocator can
be enabled back with managed-allocator option.
.TP
\fBdo-not-finalize(=\fIclasses\fB)\fR
+1 -2
View File
@@ -19,8 +19,7 @@ endif
TEST_HARNESS = $(topdir)/class/lib/$(PROFILE_DIRECTORY)/$(PARENT_PROFILE)nunit-lite-console.exe
PLATFORM_DEBUG_FLAGS = /debug:portable
# Workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=59967
MCS_FLAGS = /features:peverify-compat /langversion:latest
MCS_FLAGS = /langversion:latest
LIBRARY_FLAGS =
ifndef CFLAGS
CFLAGS = -g -O2
@@ -409,6 +409,9 @@ namespace Mono.Debugger.Soft
public ErrorCode ErrorCode {
get; set;
}
public string ErrorMessage {
get; set;
}
}
/*
@@ -436,7 +439,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
internal const int MINOR_VERSION = 54;
internal const int MINOR_VERSION = 57;
enum WPSuspendPolicy {
NONE = 0,
@@ -792,10 +795,12 @@ namespace Mono.Debugger.Soft
// For reply packets
offset = 0;
ReadInt (); // length
var len = ReadInt (); // length
ReadInt (); // id
ReadByte (); // flags
ErrorCode = ReadShort ();
if (ErrorCode == (int)Mono.Debugger.Soft.ErrorCode.INVALID_ARGUMENT && connection.Version.AtLeast (2, 56) && len > offset)
ErrorMsg = ReadString ();
}
public CommandSet CommandSet {
@@ -810,6 +815,10 @@ namespace Mono.Debugger.Soft
get; set;
}
public string ErrorMsg {
get; internal set;
}
public int Offset {
get {
return offset;
@@ -1792,7 +1801,7 @@ namespace Mono.Debugger.Soft
LogPacket (packetId, encoded_packet, reply, command_set, command, watch);
if (r.ErrorCode != 0) {
if (ErrorHandler != null)
ErrorHandler (this, new ErrorHandlerEventArgs () { ErrorCode = (ErrorCode)r.ErrorCode });
ErrorHandler (this, new ErrorHandlerEventArgs () { ErrorCode = (ErrorCode)r.ErrorCode, ErrorMessage = r.ErrorMsg});
throw new NotImplementedException ("No error handler set.");
} else {
return r;
@@ -34,6 +34,11 @@ namespace Mono.Debugger.Soft
}
}
public int GetId()
{
return id;
}
public EventType EventType {
get {
return etype;
@@ -371,7 +371,7 @@ namespace Mono.Debugger.Soft
case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET:
throw new ArgumentException ("Cannot set breakpoint on the specified IL offset.");
default:
throw new CommandException (args.ErrorCode);
throw new CommandException (args.ErrorCode, args.ErrorMessage);
}
}
@@ -657,7 +657,9 @@ namespace Mono.Debugger.Soft
internal EventRequest GetRequest (int id) {
lock (requests_lock) {
return requests [id];
EventRequest obj;
requests.TryGetValue (id, out obj);
return obj;
}
}
@@ -885,13 +887,18 @@ namespace Mono.Debugger.Soft
public class CommandException : Exception {
internal CommandException (ErrorCode error_code) : base ("Debuggee returned error code " + error_code + ".") {
internal CommandException (ErrorCode error_code, string error_message) : base ("Debuggee returned error code " + error_code + (error_message == null || error_message.Length == 0 ? "." : " - " + error_message + ".")) {
ErrorCode = error_code;
ErrorMessage = error_message;
}
public ErrorCode ErrorCode {
get; set;
}
public string ErrorMessage {
get; internal set;
}
}
public class VMNotSuspendedException : InvalidOperationException
@@ -613,6 +613,11 @@ public class Tests : TestsBase, ITest2
pointers2 ();
return 0;
}
if (args.Length >0 && args [0] == "ss_multi_thread") {
ss_multi_thread ();
return 0;
}
test_invalid_argument_assembly_get_type ();
return 3;
}
@@ -641,6 +646,10 @@ public class Tests : TestsBase, ITest2
LocalReflectClass.RunMe ();
}
public static void test_invalid_argument_assembly_get_type () {
}
public static void breakpoints () {
/* Call these early so it is JITted by the time a breakpoint is placed on it */
bp3 ();
@@ -861,6 +870,24 @@ public class Tests : TestsBase, ITest2
n.Buffer2 = new char4('a', 'b', 'c', 'd');
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_multi_thread () {
for (int i = 0; i < 5; i++)
{
var t = new Thread(mt_ss);
t.Name = "Thread_" + i;
t.Start();
}
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
static void mt_ss()
{
int a = 12;
int b = 13;
int c = 13;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void test_new_exception_filter () {
test_new_exception_filter1();
+93 -1
View File
@@ -470,7 +470,6 @@ public class DebuggerTests
var pdbFromMemory = assemblyMirror.GetPdbBlob ();
if (!File.Exists (pdbPath)) {
Assert.IsFalse (assemblyMirror.HasPdb);
Assert.IsTrue (assemblyMirror.HasFetchedPdb);
continue;
}
@@ -5198,8 +5197,101 @@ public class DebuggerTests
Assert.IsInstanceOfType (typeof (ArgumentException), ex);
}
}
[Test]
public void InvalidArgumentAssemblyGetType () {
Event e = run_until ("test_invalid_argument_assembly_get_type");
var assembly = entry_point.DeclaringType.Assembly;
try {
var type = assembly.GetType ("System.Collections.Generic.Dictionary<double, float>.Main");
}
catch (CommandException ex) {
Assert.AreEqual(ex.ErrorMessage, "Unexpected assembly-qualified type \"System.Collections.Generic.Dictionary<double, float>.Main\" was provided");
}
}
[Test]
public void CheckSuspendPolicySentWhenLaunchSuspendYes () {
vm.Exit (0);
var port = GetFreePort ();
// Launch the app using server=y,suspend=y
var pi = CreateStartInfo (dtest_app_path, "attach", $"--debugger-agent=transport=dt_socket,address=127.0.0.1:{port},server=y,suspend=y");
pi.UseShellExecute = false;
var process = Diag.Process.Start (pi);
string failMessage = null;
try {
vm = ConnectToPort (port);
vm.EnableEvents (EventType.AssemblyLoad, EventType.ThreadStart);
var es = vm.GetNextEventSet ();
Assert.AreEqual (es.SuspendPolicy, SuspendPolicy.All);
Assert.AreEqual (EventType.VMStart, es[0].EventType);
}
catch (Exception ex) {
failMessage = ex.Message;
}
finally {
vm.Exit (0);
vm = null;
}
if (failMessage != null)
Assert.Fail (failMessage);
}
[Test]
public void InvokeSingleStepMultiThread () {
vm.Detach ();
Start (dtest_app_path, "ss_multi_thread");
MethodMirror m = entry_point.DeclaringType.GetMethod ("mt_ss");
int firstLineFound = m.Locations [0].LineNumber + 1;
int line_first_counter = 5;
int line_second_counter = 5;
int line_third_counter = 3;
Event e = run_until ("ss_multi_thread");
EventRequest req = create_step (e);
req.Disable ();
ReusableBreakpoint breakpoint = new ReusableBreakpoint (this, "mt_ss");
breakpoint.Continue ();
e = breakpoint.lastEvent;
req = create_step (e);
while (line_first_counter > 0 || line_second_counter > 0 || line_third_counter > 0) {
var thread = e.Thread;
var l = thread.GetFrames ()[0].Location;
var frame = thread.GetFrames()[0];
if (l.LineNumber == firstLineFound)
line_first_counter--;
if (l.LineNumber == firstLineFound + 1)
line_second_counter--;
if (l.LineNumber == firstLineFound + 2)
line_third_counter--;
if (req.GetId() != breakpoint.req.GetId())
req.Disable ();
req = create_step (e);
((StepEventRequest)req).Size = StepSize.Line;
try {
if ((e.Thread.GetFrames ()[0].Location.LineNumber == firstLineFound + 1 && (e.Thread.Name.Equals("Thread_0") || e.Thread.Name.Equals("Thread_1"))) || l.LineNumber == firstLineFound + 2) {
vm.Resume ();
e = GetNextEvent ();
}
else
e = step_over_or_breakpoint ();
req = e.Request;
}
catch (Exception z){
//expected vmdeath
break;
}
}
Assert.AreEqual(0, line_first_counter);
Assert.AreEqual(0, line_second_counter);
Assert.AreEqual(0, line_third_counter);
vm = null;
}
#endif
} // class DebuggerTests
@@ -0,0 +1,27 @@
using System.Reflection;
namespace System.Net.Http
{
partial class HttpClientHandler : HttpMessageHandler
{
static IMonoHttpClientHandler CreateDefaultHandler ()
{
string envvar = Environment.GetEnvironmentVariable ("XA_HTTP_CLIENT_HANDLER_TYPE")?.Trim ();
if (envvar?.StartsWith("System.Net.Http.MonoWebRequestHandler", StringComparison.InvariantCulture) == true)
{
Type monoWrhType = Type.GetType (envvar, false);
if (monoWrhType != null)
return (IMonoHttpClientHandler) Activator.CreateInstance (monoWrhType);
}
// Ignore other types of handlers here (e.g. AndroidHttpHandler) to keep the old behavior
// and always create SocketsHttpHandler for code like this if MonoWebRequestHandler was not specified:
//
// var handler = new HttpClientHandler { Credentials = ... };
// var httpClient = new HttpClient (handler);
//
// AndroidHttpHandler is used only when we use the parameterless ctor of HttpClient
return new SocketsHttpHandler ();
}
}
}
@@ -70,7 +70,7 @@ namespace System.Net.Http
TimeSpan? timeout;
bool disposed;
internal MonoWebRequestHandler ()
public MonoWebRequestHandler ()
{
allowAutoRedirect = true;
maxAutomaticRedirections = 50;
@@ -1328,7 +1328,7 @@
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StreamContent.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StreamToStreamCopy.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Http\src\System\Net\Http\StringContent.cs" />
<Compile Include="HttpClientHandler.SocketsHandler.cs" />
<Compile Include="HttpClientHandler.SocketsHandler.Android.cs" />
<Compile Include="HttpClientHandler.cs" />
<Compile Include="HttpRequestMessage.Mono.cs" />
<Compile Include="IMonoHttpClientHandler.cs" />
@@ -8,27 +8,34 @@ namespace System.Net.Http {
static HttpMessageHandler CreateDefaultHandler ()
{
Type type = Type.GetType("Android.Runtime.AndroidEnvironment, Mono.Android");
if (type == null)
return GetFallback ("Invalid Mono.Android assembly? Cannot find Android.Runtime.AndroidEnvironment");
string envvar = Environment.GetEnvironmentVariable ("XA_HTTP_CLIENT_HANDLER_TYPE")?.Trim ();
MethodInfo method = type.GetMethod ("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
if (method == null)
return GetFallback ("Your Xamarin.Android version does not support obtaining of the custom HttpClientHandler");
if (string.IsNullOrEmpty (envvar))
return new HttpClientHandler ();
object ret = method.Invoke (null, null);
if (ret == null)
return GetFallback ("Xamarin.Android returned no custom HttpClientHandler");
if (envvar?.StartsWith ("System.Net.Http.MonoWebRequestHandler", StringComparison.InvariantCulture) == true)
{
Type monoWrhType = Type.GetType (envvar, false);
if (monoWrhType != null)
return new HttpClientHandler ((IMonoHttpClientHandler) Activator.CreateInstance (monoWrhType));
var handler = ret as HttpMessageHandler;
if (handler == null)
return GetFallback ($"{ret?.GetType()} is not a valid HttpMessageHandler");
return handler;
}
return new HttpClientHandler ();
}
Type handlerType = Type.GetType (envvar, false);
if (handlerType == null && !envvar.Contains (", "))
{
// if assembly was not specified - look for it in Mono.Android too
// (e.g. AndroidHttpHandler is there)
handlerType = Type.GetType (envvar + ", Mono.Android", false);
}
if (handlerType == null)
return new HttpClientHandler ();
if (Activator.CreateInstance (handlerType) is HttpMessageHandler msgHandler)
return msgHandler;
static HttpMessageHandler GetFallback (string message)
{
Console.WriteLine (message + ". Defaulting to System.Net.Http.HttpClientHandler");
return new HttpClientHandler ();
}
}
@@ -1 +1,2 @@
HttpClient.DefaultHandler.cs
HttpClientHandler.SocketsHandler.cs
@@ -1,2 +1,3 @@
#include socketshandler.sources
System.Net.Http/HttpClient.android.cs
HttpClientHandler.SocketsHandler.Android.cs
@@ -423,8 +423,10 @@ namespace System.Runtime.Serialization.Json
XmlDictionaryString namespaceLocal = null;
if (nameLocal != null && nameLocal is string)
writer.WriteStartElement ((string) name, null);
else
else if (name is XmlDictionaryString)
writer.WriteStartElement ((XmlDictionaryString) name, null);
else
writer.WriteStartElement (name.ToString(), null);
}
void WriteEndElement ()
@@ -429,13 +429,9 @@ namespace System.Xml.Serialization
}
}
static Encoding DefaultEncoding = Encoding.Default;
public void Serialize (Stream stream, object o)
{
XmlTextWriter xmlWriter = new XmlTextWriter (stream, DefaultEncoding);
xmlWriter.Formatting = Formatting.Indented;
Serialize (xmlWriter, o, null);
Serialize (stream, o, null);
}
public void Serialize (TextWriter textWriter, object o)
@@ -452,7 +448,7 @@ namespace System.Xml.Serialization
public void Serialize (Stream stream, object o, XmlSerializerNamespaces namespaces)
{
XmlTextWriter xmlWriter = new XmlTextWriter (stream, DefaultEncoding);
XmlTextWriter xmlWriter = new XmlTextWriter (stream, Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
Serialize (xmlWriter, o, namespaces);
}
@@ -2676,6 +2676,19 @@ namespace MonoTests.System.XmlSerialization
Assert.AreEqual ("<:GenComplexStructOfInt32String http://www.w3.org/2000/xmlns/:xsd='http://www.w3.org/2001/XMLSchema' http://www.w3.org/2000/xmlns/:xsi='http://www.w3.org/2001/XMLSchema-instance'><:something>123</><:simpleclass><:something>456</></><:simplestruct><:something>789</></><:listclass><:somelist><:int>100</><:int>200</></></><:arrayclass><:arr><:int>11</><:int>22</><:int>33</></></><:twoclass><:something1>10</><:something2>Ten</></><:derivedclass><:something1>two</><:something2>2</><:another1>1</><:another2>one</></><:derived2><:something1>4</><:something2>four</><:another1>3</><:another2>three</></><:nestedouter><:outer>5</></><:nestedinner><:inner>six</><:something>6</></></>", WriterText);
}
[Test]
public void TestSerializeStreamPreserveUTFChars () {
string foo = "BÄR";
XmlSerializer serializer = new XmlSerializer (typeof (string));
MemoryStream stream = new MemoryStream ();
serializer.Serialize (stream, foo);
stream.Position = 0;
foo = (string) serializer.Deserialize (stream);
Assert.AreEqual("BÄR", foo);
}
[Test] // bug #80759
public void HasNullableField ()
{
@@ -488,6 +488,26 @@ namespace System.Net.Security
return Impl.WriteAsync (buffer, offset, count, cancellationToken);
}
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return TaskToApm.Begin (Impl.ReadAsync (buffer, offset, count), callback, state);
}
public override int EndRead (IAsyncResult asyncResult)
{
return TaskToApm.End<int> (asyncResult);
}
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return TaskToApm.Begin (Impl.WriteAsync (buffer, offset, count), callback, state);
}
public override void EndWrite (IAsyncResult asyncResult)
{
TaskToApm.End (asyncResult);
}
#else // !SECURITY_DEP
const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
@@ -237,8 +237,12 @@ namespace System.Net {
}
if (ProcessInput (ms)) {
if (!context.HaveError)
context.Request.FinishInitialization ();
if (!context.HaveError) {
if (!context.Request.FinishInitialization()) {
Close (true);
return;
}
}
if (context.HaveError) {
SendError ();
@@ -192,12 +192,12 @@ namespace System.Net {
return false;
}
internal void FinishInitialization ()
internal bool FinishInitialization ()
{
string host = UserHostName;
if (version > HttpVersion.Version10 && (host == null || host.Length == 0)) {
context.ErrorMessage = "Invalid host name";
return;
return true;
}
string path;
@@ -223,7 +223,7 @@ namespace System.Net {
if (!Uri.TryCreate (base_uri + path, UriKind.Absolute, out url)){
context.ErrorMessage = WebUtility.HtmlEncode ("Invalid url: " + base_uri + path);
return;
return true;
}
CreateQueryString (url.Query);
@@ -239,7 +239,7 @@ namespace System.Net {
// 'identity' is not valid!
if (t_encoding != null && !is_chunked) {
context.Connection.SendError (null, 501);
return;
return false;
}
}
@@ -247,7 +247,7 @@ namespace System.Net {
if (String.Compare (method, "POST", StringComparison.OrdinalIgnoreCase) == 0 ||
String.Compare (method, "PUT", StringComparison.OrdinalIgnoreCase) == 0) {
context.Connection.SendError (null, 411);
return;
return false;
}
}
@@ -255,6 +255,8 @@ namespace System.Net {
ResponseStream output = context.Connection.GetResponseStream ();
output.InternalWrite (_100continue, 0, _100continue.Length);
}
return true;
}
internal static string Unquote (String str) {
+23 -23
View File
@@ -630,28 +630,28 @@
<method signature="System.Void .ctor(System.String)" />
</type>
<type fullname="System.Reflection.Emit.AssemblyBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ConstructorBuilder" preserve="fields" required="false" feature="sre"/>
<type fullname="System.Reflection.Emit.DynamicMethod" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.AssemblyBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ConstructorBuilder" preserve="fields" feature="sre"/>
<type fullname="System.Reflection.Emit.DynamicMethod" preserve="fields" feature="sre" />
<!-- mono_dynamic_image_register_token -->
<type fullname="System.Reflection.Emit.EnumBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.EventBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.FieldBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.EnumBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.EventBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.FieldBuilder" preserve="fields" feature="sre" />
<type
fullname="System.Reflection.Emit.GenericTypeParameterBuilder" preserve="fields" required="false" feature="sre" />
fullname="System.Reflection.Emit.GenericTypeParameterBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ILExceptionBlock" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ILExceptionInfo" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ILGenerator" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.LocalBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.MethodBuilder" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ModuleBuilder" preserve="fields" required="false" feature="sre">
<type fullname="System.Reflection.Emit.ILGenerator" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.LocalBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MethodBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ModuleBuilder" preserve="fields" feature="sre">
</type>
<type fullname="System.Reflection.Emit.MonoResource" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.MonoWin32Resource" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ParameterBuilder" preserve="nothing" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.PropertyBuilder" preserve="nothing" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.SignatureHelper" preserve="nothing" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.TypeBuilder" preserve="fields" required="false" feature="sre">
<type fullname="System.Reflection.Emit.MonoResource" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MonoWin32Resource" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ParameterBuilder" preserve="nothing" feature="sre" />
<type fullname="System.Reflection.Emit.PropertyBuilder" preserve="nothing" feature="sre" />
<type fullname="System.Reflection.Emit.SignatureHelper" preserve="nothing" feature="sre" />
<type fullname="System.Reflection.Emit.TypeBuilder" preserve="fields" feature="sre">
<method name="SetCharSet" feature="sre" />
<!-- reflection.c mono_reflection_call_is_assignable_to () -->
<method name="IsAssignableTo" feature="sre" />
@@ -660,12 +660,12 @@
<method name="DefineCustom" feature="sre" />
<method name="DefineLPArrayInternal" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.ArrayType" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ByRefType" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.PointerType" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.FieldOnTypeBuilderInst" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.MethodOnTypeBuilderInst" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ConstructorOnTypeBuilderInst" preserve="fields" required="false" feature="sre" />
<type fullname="System.Reflection.Emit.ArrayType" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ByRefType" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.PointerType" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.FieldOnTypeBuilderInst" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MethodOnTypeBuilderInst" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ConstructorOnTypeBuilderInst" preserve="fields" feature="sre" />
<!-- exception.c: mono_get_exception_runtime_wrapped () -->
<type fullname="System.Runtime.CompilerServices.RuntimeWrappedException">
+2 -2
View File
@@ -6,7 +6,7 @@ export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
LIBRARY = corlib.dll
LIBRARY_NAME = mscorlib.dll
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%)
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%) $(UNICODECHARINFO:%=-resource:%)
USE_XTEST_REMOTE_EXECUTOR = YES
LIBRARY_WARN_AS_ERROR = yes
@@ -95,7 +95,6 @@ else
endif
RESOURCE_FILES = \
$(UNICODECHARINFO) \
$(MANAGED_COLLATOR_RESOURCES_FILES) \
LinkerDescriptor/mscorlib.xml
@@ -207,6 +206,7 @@ EXTRA_DISTFILES = \
$(RESOURCE_FILES) \
$(TEST_RESOURCE_FILES) \
$(TEST_RESOURCES:.resources=.resx) \
resources/charinfo.nlp \
LinkerDescriptor/mscorlib_test.xml
TEST_RESOURCE_FILES = \
+38
View File
@@ -27,6 +27,7 @@
//
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -255,6 +256,43 @@ namespace Mono {
}
}
static string get_breadcrumb_value (string file_prefix, string directory_str, bool clear)
{
var allfiles = Directory.GetFiles (directory_str, $"{file_prefix}_*" );
if (allfiles.Length == 0)
return string.Empty;
if (allfiles.Length > 1) {
// it's impossible to tell which breadcrumb is the last one (let's not trust filesystem timestamps)
// delete the multiple files so at least next crash can make sense
try {
Array.ForEach (allfiles, f => File.Delete (f) );
} catch (Exception) { }
return string.Empty;
}
if (clear)
File.Delete (allfiles [0]);
var filename = Path.GetFileName (allfiles [0]);
return filename.Substring (file_prefix.Length + 1);
}
static long CheckCrashReportHash (string directory_str, bool clear)
{
var value = get_breadcrumb_value ("crash_hash", directory_str, clear);
if (value == string.Empty)
return 0;
else
return Convert.ToInt64 (value, 16);
}
static string CheckCrashReportReason (string directory_str, bool clear)
{
return get_breadcrumb_value ("crash_reason", directory_str, clear);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void AnnotateMicrosoftTelemetry_internal (IntPtr key, IntPtr val);
+5 -1
View File
@@ -186,7 +186,11 @@ namespace System
{
try {
// TODO: Should use __ConsoleStream from reference sources
return new FileStream (handle, access, false, bufferSize, false, true);
var stream = new FileStream (handle, access, false, bufferSize, false, true);
// Don't run the finalizer on the underlying stream so that System.WriteLine can be
// called inside a finalizer during shutdown or domain unload.
GC.SuppressFinalize (stream);
return stream;
} catch (IOException) {
return Stream.Null;
}
+4 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
using System.Runtime.ExceptionServices;
namespace Internal.Runtime.Augments {
partial class RuntimeAugments {
@@ -7,7 +8,8 @@ namespace Internal.Runtime.Augments {
public static void ReportUnhandledException (Exception exception)
{
throw exception;
var edi = ExceptionDispatchInfo.Capture (exception);
edi.Throw ();
}
internal static ReflectionExecutionDomainCallbacks Callbacks => s_reflectionExecutionDomainCallbacks;
@@ -19,4 +21,4 @@ namespace Internal.Runtime.Augments {
return new MissingMetadataException ();
}
}
}
}
+1 -1
View File
@@ -124,7 +124,7 @@ endif
LINKER_OUTPUT := illink-output-$(PROFILE_DIRECTORY)
PROFILE_PATH = $(topdir)/class/lib/$(PROFILE_DIRECTORY)
LINKER = MONO_PATH=$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE) $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/monolinker.exe -c link -out $(LINKER_OUTPUT) -b true -d $(PROFILE_PATH)
LINKER = MONO_PATH=$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE) $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/monolinker.exe -c link -o $(LINKER_OUTPUT) -b true -d $(PROFILE_PATH)
LINKER_DEFAULT = $(LINKER) -l none $(LINKER_PROFILE_OPTIONS)
TEST_EXEC = MONO_PATH=$(LINKER_OUTPUT) $(RUNTIME) $(RUNTIME_FLAGS) --debug -O=-aot
-2
View File
@@ -130,13 +130,11 @@ libmonoruntime_config_la_CPPFLAGS = $(AM_CPPFLAGS) -DMONO_BINDIR=\"$(bindir)/\"
#
# Support is a separate library because it is not valid C++.
#
if !ENABLE_NETCORE
support_libraries = libmonoruntime-support.la
libmonoruntime_support_la_SOURCES = support.c
libmonoruntime_support_la_LDFLAGS = $(Z_LIBS)
libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ZLIB_CFLAGS@
endif
#
# This library contains the icall tables if the runtime was configured with --disable-icall-tables
+106 -106
View File
@@ -2537,6 +2537,11 @@ apply_override (MonoClass *klass, MonoClass *override_class, MonoMethod **vtable
}
dslot += mono_class_interface_offset (klass, decl->klass);
//check if the override comes from an interface and the overrided method is from a class, if this is the case it shouldn't be changed
if (vtable [dslot] && vtable [dslot]->klass && MONO_CLASS_IS_INTERFACE_INTERNAL (override->klass) && !MONO_CLASS_IS_INTERFACE_INTERNAL (vtable [dslot]->klass))
return TRUE;
vtable [dslot] = override;
if (!MONO_CLASS_IS_INTERFACE_INTERNAL (override->klass)) {
/*
@@ -2856,6 +2861,102 @@ print_vtable_layout_result (MonoClass *klass, MonoMethod **vtable, int cur_slot)
}
}
/*
* LOCKING: this is supposed to be called with the loader lock held.
*/
static int
setup_class_vtsize (MonoClass *klass, GList *in_setup, int *cur_slot, int *stelemref_slot, MonoError *error)
{
GPtrArray *ifaces = NULL;
int i, max_vtsize = 0;
ifaces = mono_class_get_implemented_interfaces (klass, error);
if (!is_ok (error)) {
char *name = mono_type_get_full_name (klass);
mono_class_set_type_load_failure (klass, "Could not resolve %s interfaces due to %s", name, mono_error_get_message (error));
g_free (name);
mono_error_cleanup (error);
return -1;
} else if (ifaces) {
for (i = 0; i < ifaces->len; i++) {
MonoClass *ic = (MonoClass *)g_ptr_array_index (ifaces, i);
max_vtsize += mono_class_get_method_count (ic);
}
g_ptr_array_free (ifaces, TRUE);
ifaces = NULL;
}
if (klass->parent) {
mono_class_init_internal (klass->parent);
mono_class_setup_vtable_full (klass->parent, in_setup);
if (mono_class_set_type_load_failure_causedby_class (klass, klass->parent, "Parent class failed to load"))
return -1;
max_vtsize += klass->parent->vtable_size;
*cur_slot = klass->parent->vtable_size;
}
max_vtsize += mono_class_get_method_count (klass);
/*Array have a slot for stelemref*/
if (mono_class_need_stelemref_method (klass)) {
*stelemref_slot = *cur_slot;
++max_vtsize;
++*cur_slot;
}
return max_vtsize;
}
/*
* LOCKING: this is supposed to be called with the loader lock held.
*/
static void
mono_class_setup_vtable_ginst (MonoClass *klass, GList *in_setup)
{
ERROR_DECL (error);
int i;
MonoClass *gklass = mono_class_get_generic_class (klass)->container_class;
MonoMethod **tmp;
mono_class_setup_vtable_full (gklass, in_setup);
if (mono_class_set_type_load_failure_causedby_class (klass, gklass, "Could not load generic definition"))
return;
tmp = (MonoMethod **)mono_class_alloc0 (klass, sizeof (gpointer) * gklass->vtable_size);
klass->vtable_size = gklass->vtable_size;
for (i = 0; i < gklass->vtable_size; ++i)
if (gklass->vtable [i]) {
MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], klass, mono_class_get_context (klass), error);
if (!is_ok (error)) {
char *name = mono_type_get_full_name (klass);
mono_class_set_type_load_failure (klass, "VTable setup of type %s failed due to: %s", name, mono_error_get_message (error));
mono_error_cleanup (error);
g_free (name);
return;
}
tmp [i] = inflated;
tmp [i]->slot = gklass->vtable [i]->slot;
}
mono_memory_barrier ();
klass->vtable = tmp;
mono_loader_lock ();
klass->has_dim_conflicts = gklass->has_dim_conflicts;
mono_loader_unlock ();
/* Have to set method->slot for abstract virtual methods */
if (klass->methods && gklass->methods) {
int mcount = mono_class_get_method_count (klass);
for (i = 0; i < mcount; ++i)
if (klass->methods [i]->slot == -1)
klass->methods [i]->slot = gklass->methods [i]->slot;
}
if (mono_print_vtable)
print_vtable_layout_result (klass, klass->vtable, gklass->vtable_size);
}
/*
* LOCKING: this is supposed to be called with the loader lock held.
*/
@@ -2866,7 +2967,6 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
MonoClass *k, *ic;
MonoMethod **vtable = NULL;
int i, max_vtsize = 0, cur_slot = 0;
GPtrArray *ifaces = NULL;
GHashTable *override_map = NULL;
GHashTable *override_class_map = NULL;
GHashTable *conflict_map = NULL;
@@ -2883,44 +2983,10 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
if (overrides && !verify_class_overrides (klass, overrides, onum))
return;
ifaces = mono_class_get_implemented_interfaces (klass, error);
if (!is_ok (error)) {
char *name = mono_type_get_full_name (klass);
mono_class_set_type_load_failure (klass, "Could not resolve %s interfaces due to %s", name, mono_error_get_message (error));
g_free (name);
mono_error_cleanup (error);
max_vtsize = setup_class_vtsize (klass, in_setup, &cur_slot, &stelemref_slot, error);
if (max_vtsize == -1)
return;
} else if (ifaces) {
for (i = 0; i < ifaces->len; i++) {
MonoClass *ic = (MonoClass *)g_ptr_array_index (ifaces, i);
max_vtsize += mono_class_get_method_count (ic);
}
g_ptr_array_free (ifaces, TRUE);
ifaces = NULL;
}
if (klass->parent) {
mono_class_init_internal (klass->parent);
mono_class_setup_vtable_full (klass->parent, in_setup);
if (mono_class_set_type_load_failure_causedby_class (klass, klass->parent, "Parent class failed to load"))
return;
max_vtsize += klass->parent->vtable_size;
cur_slot = klass->parent->vtable_size;
}
max_vtsize += mono_class_get_method_count (klass);
/*Array have a slot for stelemref*/
if (mono_class_need_stelemref_method (klass)) {
stelemref_slot = cur_slot;
++max_vtsize;
++cur_slot;
}
/* printf ("METAINIT %s.%s\n", klass->name_space, klass->name); */
cur_slot = setup_interface_offsets (klass, cur_slot, TRUE);
if (cur_slot == -1) /*setup_interface_offsets fails the type.*/
return;
@@ -2929,80 +2995,14 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
/* Optimized version for generic instances */
if (mono_class_is_ginst (klass)) {
ERROR_DECL (error);
MonoClass *gklass = mono_class_get_generic_class (klass)->container_class;
MonoMethod **tmp;
mono_class_setup_vtable_full (gklass, in_setup);
if (mono_class_set_type_load_failure_causedby_class (klass, gklass, "Could not load generic definition"))
return;
tmp = (MonoMethod **)mono_class_alloc0 (klass, sizeof (gpointer) * gklass->vtable_size);
klass->vtable_size = gklass->vtable_size;
for (i = 0; i < gklass->vtable_size; ++i)
if (gklass->vtable [i]) {
MonoMethod *inflated = mono_class_inflate_generic_method_full_checked (gklass->vtable [i], klass, mono_class_get_context (klass), error);
goto_if_nok (error, fail);
tmp [i] = inflated;
tmp [i]->slot = gklass->vtable [i]->slot;
}
mono_memory_barrier ();
klass->vtable = tmp;
mono_loader_lock ();
klass->has_dim_conflicts = gklass->has_dim_conflicts;
mono_loader_unlock ();
/* Have to set method->slot for abstract virtual methods */
if (klass->methods && gklass->methods) {
int mcount = mono_class_get_method_count (klass);
for (i = 0; i < mcount; ++i)
if (klass->methods [i]->slot == -1)
klass->methods [i]->slot = gklass->methods [i]->slot;
}
if (mono_print_vtable)
print_vtable_layout_result (klass, klass->vtable, gklass->vtable_size);
mono_class_setup_vtable_ginst (klass, in_setup);
return;
}
vtable = (MonoMethod **)g_malloc0 (sizeof (gpointer) * max_vtsize);
if (klass->parent && klass->parent->vtable_size) {
MonoClass *parent = klass->parent;
int i;
memcpy (vtable, parent->vtable, sizeof (gpointer) * parent->vtable_size);
// Also inherit parent interface vtables, just as a starting point.
// This is needed otherwise bug-77127.exe fails when the property methods
// have different names in the iterface and the class, because for child
// classes the ".override" information is not used anymore.
for (i = 0; i < parent->interface_offsets_count; i++) {
MonoClass *parent_interface = parent->interfaces_packed [i];
int interface_offset = mono_class_interface_offset (klass, parent_interface);
/*FIXME this is now dead code as this condition will never hold true.
Since interface offsets are inherited then the offset of an interface implemented
by a parent will never be the out of it's vtable boundary.
*/
if (interface_offset >= parent->vtable_size) {
int parent_interface_offset = mono_class_interface_offset (parent, parent_interface);
int j;
mono_class_setup_methods (parent_interface); /*FIXME Just kill this whole chunk of dead code*/
TRACE_INTERFACE_VTABLE (printf (" +++ Inheriting interface %s.%s\n", parent_interface->name_space, parent_interface->name));
int mcount = mono_class_get_method_count (parent_interface);
for (j = 0; j < mcount && !mono_class_has_failure (klass); j++) {
vtable [interface_offset + j] = parent->vtable [parent_interface_offset + j];
TRACE_INTERFACE_VTABLE (printf (" --- Inheriting: [%03d][(%03d)+(%03d)] => [%03d][(%03d)+(%03d)]\n",
parent_interface_offset + j, parent_interface_offset, j,
interface_offset + j, interface_offset, j));
}
}
}
}
if (klass->parent && klass->parent->vtable_size)
memcpy (vtable, klass->parent->vtable, sizeof (gpointer) * klass->parent->vtable_size);
/*Array have a slot for stelemref*/
if (mono_class_need_stelemref_method (klass)) {
-10
View File
@@ -46,13 +46,6 @@ typedef enum {
MONO_WRAPPER_NUM
} MonoWrapperType;
typedef enum {
MONO_TYPE_NAME_FORMAT_IL,
MONO_TYPE_NAME_FORMAT_REFLECTION,
MONO_TYPE_NAME_FORMAT_FULL_NAME,
MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED
} MonoTypeNameFormat;
typedef enum {
MONO_REMOTING_TARGET_UNKNOWN,
MONO_REMOTING_TARGET_APPDOMAIN,
@@ -1150,9 +1143,6 @@ mono_class_get_exception_for_failure (MonoClass *klass);
char*
mono_identifier_escape_type_name_chars (const char* identifier);
char*
mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format);
char*
mono_type_get_full_name (MonoClass *klass);
+10
View File
@@ -18,6 +18,13 @@ typedef struct _MonoClassField MonoClassField;
typedef struct _MonoProperty MonoProperty;
typedef struct _MonoEvent MonoEvent;
typedef enum {
MONO_TYPE_NAME_FORMAT_IL,
MONO_TYPE_NAME_FORMAT_REFLECTION,
MONO_TYPE_NAME_FORMAT_FULL_NAME,
MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED
} MonoTypeNameFormat;
MONO_API MONO_RT_EXTERNAL_ONLY
MonoClass *
mono_class_get (MonoImage *image, uint32_t type_token);
@@ -130,6 +137,9 @@ MONO_API MONO_RT_EXTERNAL_ONLY
void*
mono_ldtoken (MonoImage *image, uint32_t token, MonoClass **retclass, MonoGenericContext *context);
MONO_API char *
mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format);
MONO_API char*
mono_type_get_name (MonoType *type);
+14 -10
View File
@@ -1606,7 +1606,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig
guint32 cols [MONO_CUSTOM_ATTR_SIZE];
MonoTableInfo *ca;
MonoCustomAttrInfo *ainfo;
GList *tmp, *list = NULL;
GArray *attr_array;
const char *data;
MonoCustomAttrEntry* attr;
@@ -1618,20 +1618,24 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig
if (!i)
return NULL;
i --;
// initial size chosen arbitrarily, but default is 16 which is rather small
attr_array = g_array_sized_new (TRUE, TRUE, sizeof (guint32), 128);
while (i < ca->rows) {
if (mono_metadata_decode_row_col (ca, i, MONO_CUSTOM_ATTR_PARENT) != idx)
break;
list = g_list_prepend (list, GUINT_TO_POINTER (i));
attr_array = g_array_append_val (attr_array, i);
++i;
}
len = g_list_length (list);
if (!len)
len = attr_array->len;
if (!len) {
g_array_free (attr_array, TRUE);
return NULL;
}
ainfo = (MonoCustomAttrInfo *)g_malloc0 (MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * len);
ainfo->num_attrs = len;
ainfo->image = image;
for (i = len, tmp = list; i != 0; --i, tmp = tmp->next) {
mono_metadata_decode_row (ca, GPOINTER_TO_UINT (tmp->data), cols, MONO_CUSTOM_ATTR_SIZE);
for (i = 0; i < len; ++i) {
mono_metadata_decode_row (ca, g_array_index (attr_array, guint32, i), cols, MONO_CUSTOM_ATTR_SIZE);
mtoken = cols [MONO_CUSTOM_ATTR_TYPE] >> MONO_CUSTOM_ATTR_TYPE_BITS;
switch (cols [MONO_CUSTOM_ATTR_TYPE] & MONO_CUSTOM_ATTR_TYPE_MASK) {
case MONO_CUSTOM_ATTR_TYPE_METHODDEF:
@@ -1644,7 +1648,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig
g_error ("Unknown table for custom attr type %08x", cols [MONO_CUSTOM_ATTR_TYPE]);
break;
}
attr = &ainfo->attrs [i - 1];
attr = &ainfo->attrs [i];
attr->ctor = mono_get_method_checked (image, mtoken, NULL, NULL, error);
if (!attr->ctor) {
g_warning ("Can't find custom attr constructor image: %s mtoken: 0x%08x due to: %s", image->name, mtoken, mono_error_get_message (error));
@@ -1652,14 +1656,14 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig
mono_error_cleanup (error);
error_init (error);
} else {
g_list_free (list);
g_array_free (attr_array, TRUE);
g_free (ainfo);
return NULL;
}
}
if (!mono_verifier_verify_cattr_blob (image, cols [MONO_CUSTOM_ATTR_VALUE], error)) {
g_list_free (list);
g_array_free (attr_array, TRUE);
g_free (ainfo);
return NULL;
}
@@ -1667,7 +1671,7 @@ mono_custom_attrs_from_index_checked (MonoImage *image, guint32 idx, gboolean ig
attr->data_size = mono_metadata_decode_value (data, &data);
attr->data = (guchar*)data;
}
g_list_free (list);
g_array_free (attr_array, TRUE);
return ainfo;
}
+3 -3
View File
@@ -172,8 +172,7 @@ mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
return NULL;
}
// Temporarily disabled to unblock Roslyn
#if HOST_WIN32 //|| HAVE_SYS_ZLIB
#if HOST_WIN32 || HAVE_SYS_ZLIB
if (ppdb_data) {
/* Embedded PPDB data */
/* ppdb_size is the uncompressed size */
@@ -436,7 +435,8 @@ mono_ppdb_lookup_location (MonoDebugMethodInfo *minfo, uint32_t offset)
}
location = g_new0 (MonoDebugSourceLocation, 1);
location->source_file = docname;
if (docname && docname [0])
location->source_file = docname;
location->row = start_line;
location->column = start_col;
location->il_offset = iloffset;
+9 -4
View File
@@ -118,6 +118,7 @@
#include "icall-decl.h"
#include "mono/utils/mono-threads-coop.h"
#include "mono/metadata/icall-signatures.h"
#include "mono/utils/mono-signal-handler.h"
//#define MONO_DEBUG_ICALLARRAY
@@ -6479,7 +6480,7 @@ ves_icall_Mono_Runtime_ExceptionToState (MonoExceptionHandle exc_handle, guint64
// FIXME: Push handles down into mini/mini-exceptions.c
MonoException *exc = MONO_HANDLE_RAW (exc_handle);
MonoThreadSummary out;
mono_summarize_timeline_start ();
mono_summarize_timeline_start ("ExceptionToState");
mono_summarize_timeline_phase_log (MonoSummarySuspendHandshake);
mono_summarize_timeline_phase_log (MonoSummaryUnmanagedStacks);
mono_get_eh_callbacks ()->mono_summarize_exception (exc, &out);
@@ -6524,8 +6525,7 @@ ves_icall_Mono_Runtime_SendMicrosoftTelemetry (const char *payload, guint64 port
hashes.offset_free_hash = portable_hash;
hashes.offset_rich_hash = unportable_hash;
// Tells mono that we want to send the HANG EXC_TYPE.
const char *signal = "SIGTERM";
const char *signal = "MANAGED_EXCEPTION";
gboolean success = mono_merp_invoke (crashed_pid, signal, payload, &hashes);
if (!success) {
@@ -6643,7 +6643,7 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab
mono_get_runtime_callbacks ()->install_state_summarizer ();
mono_summarize_timeline_start ();
mono_summarize_timeline_start ("DumpStateTotal");
gboolean success = mono_threads_summarize (ctx, &out, &hashes, TRUE, FALSE, scratch, MONO_MAX_SUMMARY_LEN_ICALL);
mono_summarize_timeline_phase_log (MonoSummaryCleanup);
@@ -7745,7 +7745,12 @@ ves_icall_System_Environment_FailFast (MonoStringHandle message, MonoExceptionHa
} else {
char *msg = mono_string_handle_to_utf8 (message, error);
g_warning ("CLR: Managed code called FailFast, saying \"%s\"", msg);
#ifndef DISABLE_CRASH_REPORTING
char *old_msg = mono_crash_save_failfast_msg (msg);
g_free (old_msg);
#else
g_free (msg);
#endif
}
if (!MONO_HANDLE_IS_NULL (exception)) {
-4
View File
@@ -2450,10 +2450,6 @@ mono_image_close_except_pools (MonoImage *image)
mono_wrapper_caches_free (&image->wrapper_caches);
for (i = 0; i < image->gshared_types_len; ++i)
free_hash (image->gshared_types [i]);
g_free (image->gshared_types);
/* The ownership of signatures is not well defined */
g_hash_table_destroy (image->memberref_signatures);
g_hash_table_destroy (image->method_signatures);
+11 -5
View File
@@ -567,11 +567,6 @@ struct _MonoImage {
GHashTable *pinvoke_scopes;
#endif
/* Indexed by MonoGenericParam pointers */
GHashTable **gshared_types;
/* The length of the above array */
int gshared_types_len;
/* The loader used to load this image */
MonoImageLoader *loader;
@@ -613,6 +608,11 @@ typedef struct {
GHashTable *aggregate_modifiers_cache;
/* Indexed by MonoGenericParam pointers */
GHashTable **gshared_types;
/* The length of the above array */
int gshared_types_len;
mono_mutex_t lock;
/*
@@ -897,6 +897,12 @@ mono_image_set_strdup (MonoImageSet *set, const char *s);
MonoImageSet *
mono_metadata_get_image_set_for_aggregate_modifiers (MonoAggregateModContainer *amods);
MonoImageSet *
mono_metadata_get_image_set_for_type (MonoType *type);
MonoImageSet *
mono_metadata_merge_image_sets (MonoImageSet *set1, MonoImageSet *set2);
#define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
gboolean
+37 -2
View File
@@ -2796,6 +2796,12 @@ delete_image_set (MonoImageSet *set)
g_hash_table_destroy (set->aggregate_modifiers_cache);
for (i = 0; i < set->gshared_types_len; ++i) {
if (set->gshared_types [i])
g_hash_table_destroy (set->gshared_types [i]);
}
g_free (set->gshared_types);
mono_wrapper_caches_free (&set->wrapper_caches);
image_sets_lock ();
@@ -3312,19 +3318,25 @@ mono_metadata_get_inflated_signature (MonoMethodSignature *sig, MonoGenericConte
}
MonoImageSet *
mono_metadata_get_image_set_for_class (MonoClass *klass)
mono_metadata_get_image_set_for_type (MonoType *type)
{
MonoImageSet *set;
CollectData image_set_data;
collect_data_init (&image_set_data);
collect_type_images (m_class_get_byval_arg (klass), &image_set_data);
collect_type_images (type, &image_set_data);
set = get_image_set (image_set_data.images, image_set_data.nimages);
collect_data_free (&image_set_data);
return set;
}
MonoImageSet *
mono_metadata_get_image_set_for_class (MonoClass *klass)
{
return mono_metadata_get_image_set_for_type (m_class_get_byval_arg (klass));
}
MonoImageSet *
mono_metadata_get_image_set_for_method (MonoMethodInflated *method)
{
@@ -3352,6 +3364,29 @@ mono_metadata_get_image_set_for_aggregate_modifiers (MonoAggregateModContainer *
return set;
}
MonoImageSet *
mono_metadata_merge_image_sets (MonoImageSet *set1, MonoImageSet *set2)
{
MonoImage **images = g_newa (MonoImage*, set1->nimages + set2->nimages);
/* Add images from set1 */
memcpy (images, set1->images, sizeof (MonoImage*) * set1->nimages);
int nimages = set1->nimages;
// FIXME: Quaratic
/* Add images from set2 */
for (int i = 0; i < set2->nimages; ++i) {
int j;
for (j = 0; j < set1->nimages; ++j) {
if (set2->images [i] == set1->images [j])
break;
}
if (j == set1->nimages)
images [nimages ++] = set2->images [i];
}
return get_image_set (images, nimages);
}
static gboolean
type_is_gtd (MonoType *type)
{
+11 -7
View File
@@ -6624,13 +6624,12 @@ mono_string_empty_handle (MonoDomain *domain)
MonoString *
mono_string_new_utf16 (MonoDomain *domain, const mono_unichar2 *text, gint32 len)
{
MONO_REQ_GC_UNSAFE_MODE;
ERROR_DECL (error);
MonoString *res = NULL;
MONO_ENTER_GC_UNSAFE;
ERROR_DECL (error);
res = mono_string_new_utf16_checked (domain, text, len, error);
mono_error_cleanup (error);
MONO_EXIT_GC_UNSAFE;
return res;
}
@@ -6727,10 +6726,12 @@ mono_string_new_utf32 (MonoDomain *domain, const mono_unichar4 *text, gint32 len
MonoString *
mono_string_new_size (MonoDomain *domain, gint32 len)
{
MonoString *str;
MONO_ENTER_GC_UNSAFE;
ERROR_DECL (error);
MonoString *str = mono_string_new_size_checked (domain, len, error);
str = mono_string_new_size_checked (domain, len, error);
mono_error_cleanup (error);
MONO_EXIT_GC_UNSAFE;
return str;
}
@@ -7563,9 +7564,12 @@ mono_string_intern (MonoString *str_raw)
MonoString*
mono_ldstr (MonoDomain *domain, MonoImage *image, guint32 idx)
{
MonoString *result;
MONO_ENTER_GC_UNSAFE;
ERROR_DECL (error);
MonoString *result = mono_ldstr_checked (domain, image, idx, error);
result = mono_ldstr_checked (domain, image, idx, error);
mono_error_cleanup (error);
MONO_EXIT_GC_UNSAFE;
return result;
}
+1 -1
View File
@@ -1958,7 +1958,7 @@ _mono_reflection_get_type_from_info (MonoAssemblyLoadContext *alc, MonoTypeNameP
MonoAssemblyByNameRequest req;
mono_assembly_request_prepare_byname (&req, MONO_ASMCTX_DEFAULT, alc);
req.requesting_assembly = NULL;
req.basedir = image->assembly->basedir;
req.basedir = image ? image->assembly->basedir : NULL;
assembly = mono_assembly_request_byname (&info->assembly, &req, NULL);
if (!assembly)
return NULL;
+8 -1
View File
@@ -2639,7 +2639,7 @@ mono_gc_get_allocated_bytes_for_current_thread (void)
info = mono_thread_info_current ();
/*There are some more allocated bytes in the current tlab that have not been recorded yet */
return info->total_bytes_allocated + info->tlab_next - info->tlab_start;
return info->total_bytes_allocated + (ptrdiff_t)(info->tlab_next - info->tlab_start);
}
guint64
@@ -3018,6 +3018,13 @@ sgen_client_handle_gc_debug (const char *opt)
mono_log_finalizers = TRUE;
} else if (!strcmp (opt, "no-managed-allocator")) {
sgen_set_use_managed_allocator (FALSE);
} else if (!strcmp (opt, "managed-allocator")) {
/*
* This option can be used to override the disabling of the managed allocator by
* the nursery canaries option. This can be used when knowing for sure that no
* aot code will be used by the application.
*/
sgen_set_use_managed_allocator (TRUE);
} else if (!sgen_bridge_handle_gc_debug (opt)) {
return FALSE;
}
+3
View File
@@ -6514,6 +6514,9 @@ summarizer_state_term (SummarizerGlobalState *state, gchar **out, gchar *mem, si
mono_get_eh_callbacks ()->mono_summarize_managed_stack (threads [i]);
}
/* The value of the breadcrumb should match the "StackHash" value written by `mono_merp_write_fingerprint_payload` */
mono_create_crash_hash_breadcrumb (controlling);
MonoStateWriter writer;
memset (&writer, 0, sizeof (writer));
+4
View File
@@ -4925,6 +4925,10 @@ mono_method_verify (MonoMethod *method, int level)
return NULL;
}
// Disable for now
if (TRUE)
return NULL;
memset (&ctx, 0, sizeof (VerifyContext));
//FIXME use mono_method_get_signature_full
+5
View File
@@ -175,6 +175,11 @@ mono_w32process_get_modules (pid_t pid)
return g_slist_reverse (ret);
}
void
mono_w32process_platform_init_once (void)
{
}
#else
MONO_EMPTY_SOURCE_FILE (w32process_unix_bsd);
+5
View File
@@ -360,4 +360,9 @@ mono_w32process_get_modules (pid_t pid)
#endif
}
void
mono_w32process_platform_init_once (void)
{
}
#endif
+5
View File
@@ -57,6 +57,11 @@ mono_w32process_get_modules (pid_t pid)
return g_slist_reverse (ret);
}
void
mono_w32process_platform_init_once (void)
{
}
#else
MONO_EMPTY_SOURCE_FILE (w32process_unix_haiku);
@@ -40,6 +40,9 @@ mono_w32process_get_name (pid_t pid);
GSList*
mono_w32process_get_modules (pid_t pid);
void
mono_w32process_platform_init_once (void);
static void G_GNUC_UNUSED
mono_w32process_module_free (MonoW32ProcessModule *module)
{
+112 -41
View File
@@ -15,6 +15,7 @@
#include <sys/utsname.h>
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>
#include <dlfcn.h>
/* sys/resource.h (for rusage) is required when using osx 10.3 (but not 10.4) */
#ifdef __APPLE__
@@ -117,58 +118,128 @@ mono_w32process_get_path (pid_t pid)
#endif
}
GSList*
struct mono_dyld_image_info
{
const void *header_addr;
const void *data_section_start;
const void *data_section_end;
const char *name;
guint64 order;
};
static guint64 dyld_order = 0;
static GHashTable *images;
static mono_mutex_t images_mutex;
static int
sort_modules_by_load_order (gconstpointer a, gconstpointer b)
{
MonoW32ProcessModule *ma = (MonoW32ProcessModule *) a;
MonoW32ProcessModule *mb = (MonoW32ProcessModule *) b;
return ma->inode == mb->inode ? 0 : ma->inode < mb->inode ? -1 : 1;
}
GSList *
mono_w32process_get_modules (pid_t pid)
{
GSList *ret = NULL;
MonoW32ProcessModule *mod;
guint32 count;
int i = 0;
MONO_ENTER_GC_SAFE;
if (pid != getpid ())
return NULL;
goto done;
count = _dyld_image_count ();
for (i = 0; i < count; i++) {
#if SIZEOF_VOID_P == 8
const struct mach_header_64 *hdr;
const struct section_64 *sec;
#else
const struct mach_header *hdr;
const struct section *sec;
#endif
const char *name;
GHashTableIter it;
g_hash_table_iter_init (&it, images);
name = _dyld_get_image_name (i);
#if SIZEOF_VOID_P == 8
hdr = (const struct mach_header_64*)_dyld_get_image_header (i);
sec = getsectbynamefromheader_64 (hdr, SEG_DATA, SECT_DATA);
#else
hdr = _dyld_get_image_header (i);
sec = getsectbynamefromheader (hdr, SEG_DATA, SECT_DATA);
#endif
gpointer val;
/* Some dynlibs do not have data sections on osx (#533893) */
if (sec == 0)
continue;
mod = g_new0 (MonoW32ProcessModule, 1);
mod->address_start = GINT_TO_POINTER (sec->addr);
mod->address_end = GINT_TO_POINTER (sec->addr+sec->size);
mono_os_mutex_lock (&images_mutex);
while (g_hash_table_iter_next (&it, NULL, &val)) {
struct mono_dyld_image_info *info = (struct mono_dyld_image_info *) val;
MonoW32ProcessModule *mod = g_new0 (MonoW32ProcessModule, 1);
mod->address_start = GINT_TO_POINTER (info->data_section_start);
mod->address_end = GINT_TO_POINTER (info->data_section_end);
mod->perms = g_strdup ("r--p");
mod->address_offset = 0;
mod->device = makedev (0, 0);
mod->inode = i;
mod->filename = g_strdup (name);
if (g_slist_find_custom (ret, mod, mono_w32process_module_equals) == NULL) {
ret = g_slist_prepend (ret, mod);
} else {
mono_w32process_module_free (mod);
}
mod->device = 0;
mod->inode = info->order;
mod->filename = g_strdup (info->name);
ret = g_slist_prepend (ret, mod);
}
mono_os_mutex_unlock (&images_mutex);
ret = g_slist_sort (ret, &sort_modules_by_load_order);
done:
MONO_EXIT_GC_SAFE;
return ret;
}
return g_slist_reverse (ret);
static void
mono_dyld_image_info_free (void *info)
{
struct mono_dyld_image_info *dinfo = (struct mono_dyld_image_info *) info;
g_free ((void *) dinfo->name);
g_free (dinfo);
}
static void
image_added (const struct mach_header *hdr32, intptr_t vmaddr_slide)
{
#if SIZEOF_VOID_P == 8
const struct mach_header_64 *hdr64 = (const struct mach_header_64 *)hdr32;
const struct section_64 *sec = getsectbynamefromheader_64 (hdr64, SEG_DATA, SECT_DATA);
#else
const struct section *sec = getsectbynamefromheader (hdr32, SEG_DATA, SECT_DATA);
#endif
Dl_info dlinfo;
if (!dladdr (hdr32, &dlinfo)) return;
if (sec == NULL) return;
mono_os_mutex_lock (&images_mutex);
gpointer found = g_hash_table_lookup (images, (gpointer) hdr32);
mono_os_mutex_unlock (&images_mutex);
if (found == NULL) {
struct mono_dyld_image_info *info = g_new0 (struct mono_dyld_image_info, 1);
info->header_addr = hdr32;
info->data_section_start = GINT_TO_POINTER (sec->addr);
info->data_section_end = GINT_TO_POINTER (sec->addr + sec->size);
info->name = g_strdup (dlinfo.dli_fname);
info->order = dyld_order;
++dyld_order;
mono_os_mutex_lock (&images_mutex);
g_hash_table_insert (images, (gpointer) hdr32, info);
mono_os_mutex_unlock (&images_mutex);
}
}
static void
image_removed (const struct mach_header *hdr32, intptr_t vmaddr_slide)
{
mono_os_mutex_lock (&images_mutex);
g_hash_table_remove (images, hdr32);
mono_os_mutex_unlock (&images_mutex);
}
void
mono_w32process_platform_init_once (void)
{
mono_os_mutex_init (&images_mutex);
images = g_hash_table_new_full (NULL, NULL, NULL, &mono_dyld_image_info_free);
/* Ensure that the functions used within the lock-protected region in
* mono_w32process_get_modules have been loaded, in case these symbols
* are lazily bound. g_new0 and g_strdup will be called by
* _dyld_register_func_for_add_image when it calls image_added with the
* current list of all loaded dynamic libraries
*/
GSList *dummy = g_slist_prepend (NULL, NULL);
g_slist_free (dummy);
GHashTableIter it;
g_hash_table_iter_init (&it, images);
g_hash_table_iter_next (&it, NULL, NULL);
_dyld_register_func_for_add_image (&image_added);
_dyld_register_func_for_remove_image (&image_removed);
}
#else
+4
View File
@@ -85,6 +85,7 @@
#include <mono/utils/mono-io-portability.h>
#include <mono/utils/w32api.h>
#include <mono/utils/mono-errno.h>
#include <mono/utils/mono-once.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-threads-coop.h>
#include "object-internals.h"
@@ -594,6 +595,8 @@ process_set_name (MonoW32HandleProcess *process_handle)
}
}
static mono_once_t init_state = MONO_ONCE_INIT;
void
mono_w32process_init (void)
{
@@ -615,6 +618,7 @@ mono_w32process_init (void)
g_assert (current_process != INVALID_HANDLE_VALUE);
mono_coop_mutex_init (&processes_mutex);
mono_once (&init_state, &mono_w32process_platform_init_once);
}
void
+4 -2
View File
@@ -3386,12 +3386,14 @@ get_shared_ginst_ref (MonoAotCompile *acfg, MonoGenericInst *ginst)
guint32 offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->ginst_blob_hash, ginst));
if (!offset) {
guint8 *buf2, *p2;
int len;
buf2 = (guint8 *)g_malloc (1024);
len = 1024 + (ginst->type_argc * 32);
buf2 = (guint8 *)g_malloc (len);
p2 = buf2;
encode_ginst (acfg, ginst, p2, &p2);
g_assert (p2 - buf2 < 1024);
g_assert (p2 - buf2 < len);
offset = add_to_blob (acfg, buf2, p2 - buf2);
g_free (buf2);
+40 -15
View File
@@ -220,7 +220,7 @@ static gsize aot_code_high_addr = 0;
static gint32 async_jit_info_size;
#ifdef MONOTOUCH
#define USE_PAGE_TRAMPOLINES (mono_defaults.corlib->aot_module->use_page_trampolines)
#define USE_PAGE_TRAMPOLINES (mscorlib_aot_module->use_page_trampolines)
#else
#define USE_PAGE_TRAMPOLINES 0
#endif
@@ -2079,6 +2079,32 @@ init_amodule_got (MonoAotModule *amodule, gboolean preinit)
mono_loader_unlock ();
}
#ifdef MONOTOUCH
// Follow branch islands on ARM iOS machines.
static inline guint8 *
method_address_resolve (guint8 *code_addr) {
#if defined(TARGET_ARM)
// Skip branches to thumb destinations; the convention used is that the
// lowest bit is set if the destination is thumb. See
// get_call_table_entry.
if (((uintptr_t) code_addr) & 0x1)
return code_addr;
#endif
for (;;) {
// `mono_arch_get_call_target` takes the IP after the branch
// instruction, not before. Add 4 bytes to compensate.
guint8 *next = mono_arch_get_call_target (code_addr + 4);
if (next == NULL) return code_addr;
code_addr = next;
}
}
#else
static inline guint8 *
method_address_resolve (guint8 *code_addr) {
return code_addr;
}
#endif
static void
load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer user_data, MonoError *error)
{
@@ -2379,6 +2405,8 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer
g_assert (addr);
if (addr == amodule->info.method_addresses)
addr = NULL;
else
addr = method_address_resolve ((guint8 *) addr);
}
if (addr == NULL)
amodule->methods [i] = GINT_TO_POINTER (-1);
@@ -2426,10 +2454,6 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer
init_amodule_got (amodule, TRUE);
if (info->flags & MONO_AOT_FILE_FLAG_WITH_LLVM)
/* Directly called methods might make calls through the PLT */
init_plt (amodule);
if (amodule->jit_code_start)
mono_jit_info_add_aot_module (assembly->image, amodule->jit_code_start, amodule->jit_code_end);
if (amodule->llvm_code_start)
@@ -2444,6 +2468,10 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer
/*g_warning ("using page trampolines: %d", amodule->use_page_trampolines);*/
}
if (info->flags & MONO_AOT_FILE_FLAG_WITH_LLVM)
/* Directly called methods might make calls through the PLT */
init_plt (amodule);
/*
* Register the plt region as a single trampoline so we can unwind from this code
*/
@@ -5537,13 +5565,12 @@ read_page_trampoline_uwinfo (MonoTrampInfo *info, int tramp_type, gboolean is_ge
else
g_assert_not_reached ();
read_unwind_info (mono_defaults.corlib->aot_module, info, symbol_name);
read_unwind_info (mscorlib_aot_module, info, symbol_name);
}
static unsigned char*
get_new_trampoline_from_page (int tramp_type)
{
MonoAotModule *amodule;
MonoImage *image;
TrampolinePage *page;
int count;
@@ -5565,13 +5592,11 @@ get_new_trampoline_from_page (int tramp_type)
return code;
}
mono_aot_page_unlock ();
/* the trampoline template page is in the mscorlib module */
image = mono_defaults.corlib;
g_assert (image);
psize = MONO_AOT_TRAMP_PAGE_SIZE;
amodule = image->aot_module;
/* the trampoline template page is in the mscorlib module */
MonoAotModule *amodule = mscorlib_aot_module;
g_assert (amodule);
if (tramp_type == MONO_AOT_TRAMP_SPECIFIC)
@@ -5795,7 +5820,7 @@ no_specific_trampoline (void)
* Return a specific trampoline from the AOT file.
*/
gpointer
mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
mono_aot_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
{
MonoAotModule *amodule;
guint32 got_offset, tramp_size;
@@ -6024,7 +6049,7 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
{
char *symbol;
gpointer code;
MonoAotModule *amodule = mono_defaults.corlib->aot_module;
MonoAotModule *amodule = mscorlib_aot_module;
guint32 index = MONO_RGCTX_SLOT_INDEX (slot);
static int count = 0;
@@ -6046,7 +6071,7 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
}
symbol = mono_get_rgctx_fetch_trampoline_name (slot);
code = load_function (mono_defaults.corlib->aot_module, symbol);
code = load_function (amodule, symbol);
g_free (symbol);
/* The caller expects an ftnptr */
return mono_create_ftnptr (mono_domain_get (), code);
@@ -6360,7 +6385,7 @@ mono_aot_get_plt_info_offset (host_mgreg_t *regs, guint8 *code)
}
gpointer
mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
mono_aot_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
{
g_assert_not_reached ();
return NULL;
+1 -1
View File
@@ -247,7 +247,7 @@ MonoJitInfo* mono_aot_find_jit_info (MonoDomain *domain, MonoImage *imag
gpointer mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error);
void mono_aot_patch_plt_entry (guint8 *code, guint8 *plt_entry, gpointer *got, host_mgreg_t *regs, guint8 *addr);
gpointer mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot, MonoError *error);
gpointer mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
gpointer mono_aot_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
gpointer mono_aot_get_trampoline (const char *name);
gpointer mono_aot_get_trampoline_full (const char *name, MonoTrampInfo **out_tinfo);
gpointer mono_aot_get_unbox_trampoline (MonoMethod *method, gpointer addr);
+77 -18
View File
@@ -226,6 +226,8 @@ struct _DebuggerTlsData {
* Number of times this thread has been resumed using resume_thread ().
*/
guint32 resume_count;
guint32 resume_count_internal;
guint32 suspend_count;
MonoInternalThread *thread;
intptr_t thread_id;
@@ -292,7 +294,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
#define MINOR_VERSION 54
#define MINOR_VERSION 57
typedef enum {
CMD_SET_VM = 1,
@@ -726,7 +728,7 @@ static void invalidate_frames (DebuggerTlsData *tls);
/* Callbacks used by debugger-engine */
static MonoContext* tls_get_restore_state (void *the_tls);
static gboolean try_process_suspend (void *tls, MonoContext *ctx);
static gboolean try_process_suspend (void *tls, MonoContext *ctx, gboolean from_breakpoint);
static gboolean begin_breakpoint_processing (void *tls, MonoContext *ctx, MonoJitInfo *ji, gboolean from_signal);
static void begin_single_step_processing (MonoContext *ctx, gboolean from_signal);
static void ss_discard_frame_context (void *the_tls);
@@ -2715,6 +2717,8 @@ reset_native_thread_suspend_state (gpointer key, gpointer value, gpointer user_d
tls->async_state.valid = FALSE;
invalidate_frames (tls);
}
tls->resume_count_internal++;
}
typedef struct {
@@ -2823,19 +2827,24 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx)
/* Conditionally call process_suspend depending oh the current state */
static gboolean
try_process_suspend (void *the_tls, MonoContext *ctx)
try_process_suspend (void *the_tls, MonoContext *ctx, gboolean from_breakpoint)
{
DebuggerTlsData *tls = (DebuggerTlsData*)the_tls;
if (suspend_count > 0) {
/* if there is a suspend pending that is not executed yes */
if (suspend_count > 0) {
/* Fastpath during invokes, see in process_suspend () */
if (suspend_count - tls->resume_count == 0)
/* if there is a suspend pending but this thread is already resumed, we shouldn't suspend it again and the breakpoint/ss can run */
if (suspend_count - tls->resume_count == 0)
return FALSE;
if (tls->invoke)
/* if there is in a invoke the breakpoint/step should be executed even with the suspend pending */
if (tls->invoke)
return FALSE;
/* with the multithreaded single step check if there is a suspend_count pending in the current thread and not in the vm */
if (from_breakpoint && tls->suspend_count <= tls->resume_count_internal)
return FALSE;
process_suspend (tls, ctx);
return TRUE;
}
} /* if there isn't any suspend pending, the breakpoint/ss will be executed and will suspend then vm when the event is sent */
return FALSE;
}
@@ -2945,6 +2954,8 @@ resume_thread (MonoInternalThread *thread)
DEBUG_PRINTF (1, "[sdb] Resuming thread %p...\n", (gpointer)(gssize)thread->tid);
tls->resume_count += suspend_count;
tls->resume_count_internal += tls->suspend_count;
tls->suspend_count = 0;
/*
* Signal suspend_count without decreasing suspend_count, the threads will wake up
@@ -3901,7 +3912,10 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
return;
}
}
if (event == EVENT_KIND_VM_START)
suspend_policy = agent_config.suspend ? SUSPEND_POLICY_ALL : SUSPEND_POLICY_NONE;
nevents = g_slist_length (events);
buffer_init (&buf, 128);
buffer_add_byte (&buf, suspend_policy);
@@ -4012,7 +4026,6 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
}
if (event == EVENT_KIND_VM_START) {
suspend_policy = agent_config.suspend ? SUSPEND_POLICY_ALL : SUSPEND_POLICY_NONE;
if (!agent_config.defer) {
ERROR_DECL (error);
start_debugger_thread (error);
@@ -4035,6 +4048,8 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
* returns.
*/
save_thread_context (ctx);
DebuggerTlsData *tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, mono_thread_internal_current ());
tls->suspend_count++;
suspend_vm ();
if (keepalive_obj)
@@ -4337,6 +4352,9 @@ send_types_for_domain (MonoDomain *domain, void *user_data)
MonoDomain* old_domain;
AgentDomainInfo *info = NULL;
if (mono_domain_is_unloading (domain))
return;
info = get_agent_domain_info (domain);
g_assert (info);
@@ -4357,6 +4375,9 @@ send_assemblies_for_domain (MonoDomain *domain, void *user_data)
GSList *tmp;
MonoDomain* old_domain;
if (mono_domain_is_unloading (domain))
return;
old_domain = mono_domain_get ();
mono_domain_set_fast (domain, TRUE);
@@ -4962,7 +4983,6 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx)
if (MONO_CONTEXT_GET_IP (ctx) == orig_ip - 1)
MONO_CONTEXT_SET_IP (ctx, orig_ip);
}
static void
ss_args_destroy (SingleStepArgs *ss_args)
{
@@ -4973,7 +4993,9 @@ ss_args_destroy (SingleStepArgs *ss_args)
static int
handle_multiple_ss_requests (void)
{
return DE_ERR_NOT_IMPLEMENTED;
if (!CHECK_PROTOCOL_VERSION (2, 57))
return DE_ERR_NOT_IMPLEMENTED;
return 1;
}
static int
@@ -5125,6 +5147,7 @@ ss_clear_for_assembly (SingleStepReq *req, MonoAssembly *assembly)
static void
mono_debugger_agent_send_crash (char *json_dump, MonoStackHash *hashes, int pause)
{
MONO_ENTER_GC_UNSAFE;
#ifndef DISABLE_CRASH_REPORTING
int suspend_policy;
GSList *events;
@@ -5167,6 +5190,7 @@ mono_debugger_agent_send_crash (char *json_dump, MonoStackHash *hashes, int paus
// Don't die before it is sent.
sleep (4);
#endif
MONO_EXIT_GC_UNSAFE;
}
/*
@@ -6235,7 +6259,7 @@ clear_event_request (int req_id, int etype)
if (req->event_kind == EVENT_KIND_BREAKPOINT)
mono_de_clear_breakpoint ((MonoBreakpoint *)req->info);
if (req->event_kind == EVENT_KIND_STEP) {
mono_de_cancel_ss ();
mono_de_cancel_ss ((SingleStepReq *)req->info);
}
if (req->event_kind == EVENT_KIND_METHOD_ENTRY)
mono_de_clear_breakpoint ((MonoBreakpoint *)req->info);
@@ -6516,7 +6540,10 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
else {
ERROR_DECL (error);
this_arg = mono_object_new_checked (domain, m->klass, error);
mono_error_assert_ok (error);
if (!is_ok (error)) {
mono_error_cleanup (error);
return ERR_INVALID_ARGUMENT;
}
}
} else {
return ERR_INVALID_ARGUMENT;
@@ -6840,6 +6867,10 @@ get_types (gpointer key, gpointer value, gpointer user_data)
MonoType *t;
GSList *tmp;
MonoDomain *domain = (MonoDomain*)key;
if (mono_domain_is_unloading (domain))
return;
MonoAssemblyLoadContext *alc = mono_domain_default_alc (domain);
GetTypesArgs *ud = (GetTypesArgs*)user_data;
@@ -6879,6 +6910,9 @@ get_types_for_source_file (gpointer key, gpointer value, gpointer user_data)
GetTypesForSourceFileArgs *ud = (GetTypesForSourceFileArgs*)user_data;
MonoDomain *domain = (MonoDomain*)key;
if (mono_domain_is_unloading (domain))
return;
AgentDomainInfo *info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info;
/* Update 'source_file_to_class' cache */
@@ -6937,6 +6971,12 @@ get_types_for_source_file (gpointer key, gpointer value, gpointer user_data)
}
}
static void add_error_string (Buffer *buf, const char *str)
{
if (CHECK_PROTOCOL_VERSION (2, 56))
buffer_add_string (buf, str);
}
static ErrorCode
vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf)
{
@@ -7241,6 +7281,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf)
ignore_case = decode_byte (p, &p, end);
if (!mono_reflection_parse_type_checked (name, &info, error)) {
add_error_string (buf, mono_error_get_message (error));
mono_error_cleanup (error);
g_free (name);
mono_reflection_free_type_info (&info);
@@ -7729,6 +7770,8 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
case CMD_ASSEMBLY_GET_TYPE: {
ERROR_DECL (error);
char *s = decode_string (p, &p, end);
char* original_s = g_strdup_printf ("\"%s\"", s);
gboolean ignorecase = decode_byte (p, &p, end);
MonoTypeNameParse info;
MonoType *t;
@@ -7744,20 +7787,33 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
mono_error_cleanup (error);
t = NULL;
} else {
if (info.assembly.name)
NOT_IMPLEMENTED;
if (info.assembly.name) {
mono_reflection_free_type_info (&info);
g_free (s);
mono_domain_set_fast (d, TRUE);
char* error_msg = g_strdup_printf ("Unexpected assembly-qualified type %s was provided", original_s);
add_error_string (buf, error_msg);
g_free (error_msg);
g_free (original_s);
return ERR_INVALID_ARGUMENT;
}
t = mono_reflection_get_type_checked (alc, ass->image, ass->image, &info, ignorecase, TRUE, &type_resolve, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME don't swallow the error */
mono_reflection_free_type_info (&info);
g_free (s);
mono_domain_set_fast (d, TRUE);
char* error_msg = g_strdup_printf ("Invalid type name %s", original_s);
add_error_string (buf, error_msg);
g_free (error_msg);
g_free (original_s);
return ERR_INVALID_ARGUMENT;
}
}
buffer_add_typeid (buf, domain, t ? mono_class_from_mono_type_internal (t) : NULL);
mono_reflection_free_type_info (&info);
g_free (s);
g_free (original_s);
mono_domain_set_fast (d, TRUE);
break;
@@ -7814,6 +7870,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
error_init (error);
MonoClass* mono_class = mono_class_get_checked (ass->image, token, error);
if (!is_ok (error)) {
add_error_string (buf, mono_error_get_message (error));
mono_error_cleanup (error);
return ERR_INVALID_ARGUMENT;
}
@@ -7830,6 +7887,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
error_init (error);
MonoMethod* mono_method = mono_get_method_checked (ass->image, token, NULL, NULL, error);
if (!is_ok (error)) {
add_error_string (buf, mono_error_get_message (error));
mono_error_cleanup (error);
return ERR_INVALID_ARGUMENT;
}
@@ -8682,6 +8740,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
header = mono_method_get_header_checked (method, error);
if (!header) {
add_error_string (buf, mono_error_get_message (error));
mono_error_cleanup (error); /* FIXME don't swallow the error */
return ERR_INVALID_ARGUMENT;
}
@@ -9513,7 +9572,7 @@ string_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
if (!is_ok (error)) {
if (s)
g_free (s);
add_error_string (buf, mono_error_get_message (error));
return ERR_INVALID_ARGUMENT;
}
buffer_add_string (buf, s);
+61 -27
View File
@@ -378,6 +378,9 @@ collect_domain_bp (gpointer key, gpointer value, gpointer user_data)
CollectDomainData *ud = (CollectDomainData*)user_data;
MonoMethod *m;
if (mono_domain_is_unloading (domain))
return;
mono_domain_lock (domain);
g_hash_table_iter_init (&iter, domain_jit_info (domain)->seq_points);
while (g_hash_table_iter_next (&iter, (void**)&m, (void**)&seq_points)) {
@@ -591,8 +594,26 @@ mono_de_clear_breakpoints_for_domain (MonoDomain *domain)
/* Number of single stepping operations in progress */
static int ss_count;
/* The single step request instance */
static SingleStepReq *the_ss_req;
/* The single step request instances */
static GPtrArray *the_ss_reqs;
static void
ss_req_init (void)
{
the_ss_reqs = g_ptr_array_new ();
}
static void
ss_req_cleanup (void)
{
dbg_lock ();
g_ptr_array_free (the_ss_reqs, TRUE);
the_ss_reqs = NULL;
dbg_unlock ();
}
/*
* mono_de_start_single_stepping:
@@ -717,18 +738,28 @@ ss_destroy (SingleStepReq *req)
}
static SingleStepReq*
ss_req_acquire (void)
ss_req_acquire (MonoInternalThread *thread)
{
SingleStepReq *req;
SingleStepReq *req = NULL;
dbg_lock ();
req = the_ss_req;
if (req)
req->refcount ++;
int i;
for (i = 0; i < the_ss_reqs->len; ++i) {
SingleStepReq *current_req = (SingleStepReq *)g_ptr_array_index (the_ss_reqs, i);
if (current_req->thread == thread) {
current_req->refcount ++;
req = current_req;
}
}
dbg_unlock ();
return req;
}
static int
ss_req_count ()
{
return the_ss_reqs->len;
}
static void
mono_de_ss_req_release (SingleStepReq *req)
{
@@ -739,24 +770,31 @@ mono_de_ss_req_release (SingleStepReq *req)
req->refcount --;
if (req->refcount == 0)
free = TRUE;
dbg_unlock ();
if (free) {
if (req == the_ss_req)
the_ss_req = NULL;
g_ptr_array_remove (the_ss_reqs, req);
ss_destroy (req);
}
dbg_unlock ();
}
void
mono_de_cancel_ss (SingleStepReq *req)
{
if (the_ss_reqs) {
mono_de_ss_req_release (req);
}
}
void
mono_de_cancel_ss (void)
mono_de_cancel_all_ss ()
{
if (the_ss_req) {
mono_de_ss_req_release (the_ss_req);
the_ss_req = NULL;
int i;
for (i = 0; i < the_ss_reqs->len; ++i) {
SingleStepReq *current_req = (SingleStepReq *)g_ptr_array_index (the_ss_reqs, i);
mono_de_ss_req_release (current_req);
}
}
void
mono_de_process_single_step (void *tls, gboolean from_signal)
{
@@ -774,21 +812,17 @@ mono_de_process_single_step (void *tls, gboolean from_signal)
/* Skip the instruction causing the single step */
rt_callbacks.begin_single_step_processing (ctx, from_signal);
if (rt_callbacks.try_process_suspend (tls, ctx))
if (rt_callbacks.try_process_suspend (tls, ctx, FALSE))
return;
/*
* This can run concurrently with a clear_event_request () call, so needs locking/reference counts.
*/
ss_req = ss_req_acquire ();
ss_req = ss_req_acquire (mono_thread_internal_current ());
if (!ss_req)
// FIXME: A suspend race
return;
if (mono_thread_internal_current () != ss_req->thread)
goto exit;
ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
ji = get_top_method_ji (ip, &domain, (gpointer*)&ip);
@@ -1022,7 +1056,7 @@ mono_de_process_breakpoint (void *void_tls, gboolean from_signal)
SeqPoint sp;
gboolean found_sp;
if (rt_callbacks.try_process_suspend (tls, ctx))
if (rt_callbacks.try_process_suspend (tls, ctx, TRUE))
return;
ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
@@ -1488,7 +1522,7 @@ mono_de_ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, S
return err;
// FIXME: Multiple requests
if (the_ss_req) {
if (ss_req_count () > 1) {
err = rt_callbacks.handle_multiple_ss_requests ();
if (err == DE_ERR_NOT_IMPLEMENTED) {
@@ -1519,8 +1553,7 @@ mono_de_ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, S
err = rt_callbacks.ss_create_init_args (ss_req, &args);
if (err)
return err;
the_ss_req = ss_req;
g_ptr_array_add (the_ss_reqs, ss_req);
mono_de_ss_start (ss_req, &args);
@@ -1552,7 +1585,7 @@ mono_de_init (DebuggerEngineCallbacks *cbs)
domains_init ();
breakpoints_init ();
ss_req_init ();
mono_debugger_log_init ();
}
@@ -1561,6 +1594,7 @@ mono_de_cleanup (void)
{
breakpoints_cleanup ();
domains_cleanup ();
ss_req_cleanup ();
}
void
+3 -2
View File
@@ -232,7 +232,7 @@ mono_debugger_get_thread_state (DebuggerTlsData *ref);
typedef struct {
MonoContext *(*tls_get_restore_state) (void *tls);
gboolean (*try_process_suspend) (void *tls, MonoContext *ctx);
gboolean (*try_process_suspend) (void *tls, MonoContext *ctx, gboolean from_breakpoint);
gboolean (*begin_breakpoint_processing) (void *tls, MonoContext *ctx, MonoJitInfo *ji, gboolean from_signal);
void (*begin_single_step_processing) (MonoContext *ctx, gboolean from_signal);
@@ -284,6 +284,7 @@ void mono_de_stop_single_stepping (void);
void mono_de_process_breakpoint (void *tls, gboolean from_signal);
void mono_de_process_single_step (void *tls, gboolean from_signal);
DbgEngineErrorCode mono_de_ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req);
void mono_de_cancel_ss (void);
void mono_de_cancel_ss (SingleStepReq *req);
void mono_de_cancel_all_ss (void);
#endif
+11
View File
@@ -181,6 +181,12 @@ emit_int32 (MonoDwarfWriter *w, int value)
mono_img_writer_emit_int32 (w->w, value);
}
static void
emit_symbol (MonoDwarfWriter *w, const char *symbol)
{
mono_img_writer_emit_symbol (w->w, symbol);
}
static void
emit_symbol_diff (MonoDwarfWriter *w, const char *end, const char* start, int offset)
{
@@ -799,6 +805,7 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, const char *cu_name, GSLis
w->cie_program = base_unwind_program;
emit_section_change (w, ".debug_abbrev", 0);
emit_label (w, ".Ldebug_abbrev_start");
emit_dwarf_abbrev (w, ABBREV_COMPILE_UNIT, DW_TAG_compile_unit, TRUE,
compile_unit_attr, G_N_ELEMENTS (compile_unit_attr));
emit_dwarf_abbrev (w, ABBREV_SUBPROGRAM, DW_TAG_subprogram, TRUE,
@@ -842,7 +849,11 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, const char *cu_name, GSLis
emit_symbol_diff (w, ".Ldebug_info_end", ".Ldebug_info_begin", 0); /* length */
emit_label (w, ".Ldebug_info_begin");
emit_int16 (w, 0x2); /* DWARF version 2 */
#if !defined(TARGET_MACH)
emit_symbol (w, ".Ldebug_abbrev_start"); /* .debug_abbrev offset */
#else
emit_int32 (w, 0); /* .debug_abbrev offset */
#endif
emit_byte (w, sizeof (target_mgreg_t)); /* address size */
/* Compilation unit */
+2 -2
View File
@@ -66,7 +66,7 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
#endif
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", NULL, NULL);
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL, NULL);
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -876,7 +876,7 @@ altstack_handle_and_restore (MonoContext *ctx, MonoObject *obj, guint32 flags)
if (!ji || (!stack_ovf && !nullref)) {
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", ctx, NULL);
mono_handle_native_crash (mono_get_signame (SIGSEGV), ctx, NULL, NULL);
// if couldn't dump or if mono_handle_native_crash returns, abort
abort ();
}
+1 -1
View File
@@ -676,7 +676,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s
}
if (!ji)
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", (MonoContext*)sigctx, siginfo);
mono_handle_native_crash (mono_get_signame (SIGSEGV), (MonoContext*)sigctx, siginfo, sigctx);
/* setup a call frame on the real stack so that control is returned there
* and exception handling can continue.
* The frame looks like:
+2 -2
View File
@@ -67,7 +67,7 @@ static LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
}
#endif
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", NULL, NULL);
mono_handle_native_crash (mono_get_signame (SIGSEGV), NULL, NULL, NULL);
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -1140,7 +1140,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s
MonoContext mctx;
mono_sigctx_to_monoctx (sigctx, &mctx);
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, siginfo);
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, siginfo, sigctx);
else
abort ();
}
+25
View File
@@ -3557,4 +3557,29 @@ L3:
IL_0024: ret
}
.method public hidebysig static !!T createinstance_intrins_primitive<.ctor T>() cil managed noinlining
{
.maxstack 8
call !!0 [mscorlib]System.Activator::CreateInstance<!!0>()
ret
}
.method public static int32 test_0_createinstance_intrins_primitive () cil managed
{
.maxstack 8
call !!0 Tests::createinstance_intrins_primitive<bool>()
ldc.i4.0
beq L1
ldc.i4.1
ret
L1:
call !!0 Tests::createinstance_intrins_primitive<int64>()
ldc.i8 0
beq L2
ldc.i4.2
ret
L2:
ldc.i4.0
ret
}
}
+45 -5
View File
@@ -410,11 +410,14 @@ create_reloc (MonoImageWriter *acfg, const char *end, const char* start, int off
BinReloc *reloc;
reloc = (BinReloc *)mono_mempool_alloc0 (acfg->mempool, sizeof (BinReloc));
reloc->val1 = mono_mempool_strdup (acfg->mempool, end);
if (strcmp (start, ".") == 0) {
reloc->val2_section = acfg->cur_section;
reloc->val2_offset = acfg->cur_section->cur_offset;
} else {
reloc->val2 = mono_mempool_strdup (acfg->mempool, start);
if (start)
{
if (strcmp (start, ".") == 0) {
reloc->val2_section = acfg->cur_section;
reloc->val2_offset = acfg->cur_section->cur_offset;
} else {
reloc->val2 = mono_mempool_strdup (acfg->mempool, start);
}
}
reloc->offset = offset;
reloc->section = acfg->cur_section;
@@ -424,6 +427,13 @@ create_reloc (MonoImageWriter *acfg, const char *end, const char* start, int off
return reloc;
}
static void
bin_writer_emit_symbol (MonoImageWriter *acfg, const char *symbol)
{
create_reloc (acfg, symbol, NULL, 0);
acfg->cur_section->cur_offset += 4;
}
static void
bin_writer_emit_symbol_diff (MonoImageWriter *acfg, const char *end, const char* start, int offset)
{
@@ -1924,6 +1934,23 @@ asm_writer_emit_int32 (MonoImageWriter *acfg, int value)
fprintf (acfg->fp, "%d", value);
}
static void
asm_writer_emit_symbol (MonoImageWriter *acfg, const char *symbol)
{
if (acfg->mode != EMIT_LONG) {
acfg->mode = EMIT_LONG;
acfg->col_count = 0;
}
symbol = get_label (symbol);
if ((acfg->col_count++ % 8) == 0)
fprintf (acfg->fp, "\n\t%s ", AS_INT32_DIRECTIVE);
else
fprintf (acfg->fp, ",");
fprintf (acfg->fp, "%s", symbol);
}
static void
asm_writer_emit_symbol_diff (MonoImageWriter *acfg, const char *end, const char* start, int offset)
{
@@ -2213,6 +2240,19 @@ mono_img_writer_emit_int32 (MonoImageWriter *acfg, int value)
#endif
}
void
mono_img_writer_emit_symbol (MonoImageWriter *acfg, const char *symbol)
{
#ifdef USE_BIN_WRITER
if (acfg->use_bin_writer)
bin_writer_emit_symbol (acfg, symbol);
else
asm_writer_emit_symbol (acfg, symbol);
#else
asm_writer_emit_symbol (acfg, symbol);
#endif
}
void
mono_img_writer_emit_symbol_diff (MonoImageWriter *acfg, const char *end, const char* start, int offset)
{
+2
View File
@@ -98,6 +98,8 @@ void mono_img_writer_emit_int16 (MonoImageWriter *w, int value);
void mono_img_writer_emit_int32 (MonoImageWriter *w, int value);
void mono_img_writer_emit_symbol (MonoImageWriter *w, const char *symbol);
void mono_img_writer_emit_symbol_diff (MonoImageWriter *w, const char *end, const char* start, int offset);
void mono_img_writer_emit_zero_bytes (MonoImageWriter *w, int num);
+3
View File
@@ -1635,6 +1635,9 @@ interp_init_delegate (MonoDelegate *del, MonoError *error)
if (del->interp_method) {
/* Delegate created by a call to ves_icall_mono_delegate_ctor_interp () */
del->method = ((InterpMethod *)del->interp_method)->method;
} if (del->method_ptr && !del->method) {
/* Delegate created from methodInfo.MethodHandle.GetFunctionPointer() */
del->interp_method = (InterpMethod *)del->method_ptr;
} else if (del->method) {
/* Delegate created dynamically */
del->interp_method = mono_interp_get_imethod (del->object.vtable->domain, del->method, error);
+13 -6
View File
@@ -1867,13 +1867,20 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
method_context->method_inst->type_argc == 1 &&
cmethod->is_inflated &&
!mini_method_check_context_used (cfg, cmethod)) {
MonoClass *arg0 = mono_class_from_mono_type_internal (method_context->method_inst->type_argv [0]);
MonoType *t = method_context->method_inst->type_argv [0];
MonoClass *arg0 = mono_class_from_mono_type_internal (t);
if (m_class_is_valuetype (arg0) && !mono_class_has_default_constructor (arg0, FALSE)) {
MONO_INST_NEW (cfg, ins, MONO_CLASS_IS_SIMD (cfg, arg0) ? OP_XZERO : OP_VZERO);
ins->dreg = mono_alloc_dreg (cfg, STACK_VTYPE);
ins->type = STACK_VTYPE;
ins->klass = arg0;
MONO_ADD_INS (cfg->cbb, ins);
if (m_class_is_primitive (arg0)) {
int dreg = alloc_dreg (cfg, mini_type_to_stack_type (cfg, t));
mini_emit_init_rvar (cfg, dreg, t);
ins = cfg->cbb->last_ins;
} else {
MONO_INST_NEW (cfg, ins, MONO_CLASS_IS_SIMD (cfg, arg0) ? OP_XZERO : OP_VZERO);
ins->dreg = mono_alloc_dreg (cfg, STACK_VTYPE);
ins->type = STACK_VTYPE;
ins->klass = arg0;
MONO_ADD_INS (cfg->cbb, ins);
}
return ins;
}
}
+13 -13
View File
@@ -1399,10 +1399,10 @@ type_from_stack_type (MonoInst *ins) {
return NULL;
}
static G_GNUC_UNUSED int
type_to_stack_type (MonoCompile *cfg, MonoType *t)
MonoStackType
mini_type_to_stack_type (MonoCompile *cfg, MonoType *t)
{
t = mono_type_get_underlying_type (t);
t = mini_type_get_underlying_type (t);
switch (t->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
@@ -1426,7 +1426,7 @@ type_to_stack_type (MonoCompile *cfg, MonoType *t)
case MONO_TYPE_U8:
return STACK_I8;
case MONO_TYPE_R4:
return cfg->r4_stack_type;
return (MonoStackType)cfg->r4_stack_type;
case MONO_TYPE_R8:
return STACK_R8;
case MONO_TYPE_VALUETYPE:
@@ -1442,7 +1442,7 @@ type_to_stack_type (MonoCompile *cfg, MonoType *t)
g_assert_not_reached ();
}
return -1;
return (MonoStackType)-1;
}
static MonoClass*
@@ -4370,8 +4370,8 @@ check_inline_caller_method_name_limit (MonoMethod *caller_method)
}
#endif
static void
emit_init_rvar (MonoCompile *cfg, int dreg, MonoType *rtype)
void
mini_emit_init_rvar (MonoCompile *cfg, int dreg, MonoType *rtype)
{
static double r8_0 = 0.0;
static float r4_0 = 0.0;
@@ -4433,7 +4433,7 @@ emit_dummy_init_rvar (MonoCompile *cfg, int dreg, MonoType *rtype)
} else if (((t == MONO_TYPE_VAR) || (t == MONO_TYPE_MVAR)) && mini_type_var_is_vt (rtype)) {
MONO_EMIT_NEW_DUMMY_INIT (cfg, dreg, OP_DUMMY_VZERO);
} else {
emit_init_rvar (cfg, dreg, rtype);
mini_emit_init_rvar (cfg, dreg, rtype);
}
}
@@ -4445,11 +4445,11 @@ emit_init_local (MonoCompile *cfg, int local, MonoType *type, gboolean init)
if (COMPILE_SOFT_FLOAT (cfg)) {
MonoInst *store;
int reg = alloc_dreg (cfg, (MonoStackType)var->type);
emit_init_rvar (cfg, reg, type);
mini_emit_init_rvar (cfg, reg, type);
EMIT_NEW_LOCSTORE (cfg, store, local, cfg->cbb->last_ins);
} else {
if (init)
emit_init_rvar (cfg, var->dreg, type);
mini_emit_init_rvar (cfg, var->dreg, type);
else
emit_dummy_init_rvar (cfg, var->dreg, type);
}
@@ -4639,7 +4639,7 @@ inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig,
if (bb->last_ins && bb->last_ins->opcode == OP_NOT_REACHED) {
cfg->cbb = bb;
emit_init_rvar (cfg, rvar->dreg, fsig->ret);
mini_emit_init_rvar (cfg, rvar->dreg, fsig->ret);
}
}
}
@@ -4653,7 +4653,7 @@ inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig,
* set, so set it to a dummy value.
*/
if (!ret_var_set)
emit_init_rvar (cfg, rvar->dreg, fsig->ret);
mini_emit_init_rvar (cfg, rvar->dreg, fsig->ret);
EMIT_NEW_TEMPLOAD (cfg, ins, rvar->inst_c0);
*sp++ = ins;
@@ -8738,7 +8738,7 @@ calli_end:
} else {
if (m_class_is_valuetype (cmethod->klass)) {
iargs [0] = mono_compile_create_var (cfg, m_class_get_byval_arg (cmethod->klass), OP_LOCAL);
emit_init_rvar (cfg, iargs [0]->dreg, m_class_get_byval_arg (cmethod->klass));
mini_emit_init_rvar (cfg, iargs [0]->dreg, m_class_get_byval_arg (cmethod->klass));
EMIT_NEW_TEMPLOADA (cfg, *sp, iargs [0]->inst_c0);
alloc = NULL;
+18 -19
View File
@@ -1786,6 +1786,9 @@ mono_summarize_unmanaged_stack (MonoThreadSummary *out)
if (out->unmanaged_frames [i].str_descr [0] != '\0')
out->unmanaged_frames [i].unmanaged_data.has_name = TRUE;
out->hashes.offset_free_hash = summarize_offset_free_hash (out->hashes.offset_free_hash, frame);
out->hashes.offset_rich_hash = summarize_offset_rich_hash (out->hashes.offset_rich_hash, frame);
}
#endif
@@ -3363,7 +3366,6 @@ print_stack_frame_to_string (StackFrameInfo *frame, MonoContext *ctx, gpointer d
}
#ifndef MONO_CROSS_COMPILE
static gboolean handle_crash_loop = FALSE;
/*
* mono_handle_native_crash:
@@ -3372,30 +3374,30 @@ static gboolean handle_crash_loop = FALSE;
* printing diagnostic information and aborting.
*/
void
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, void *context)
{
MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
if (handle_crash_loop)
return;
#ifdef MONO_ARCH_USE_SIGACTION
struct sigaction sa;
sa.sa_handler = SIG_DFL;
sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
/* Remove our SIGABRT handler */
/* Mono has crashed - remove our handlers except SIGTERM, which is used by crash reporting */
/* TODO: Combine with mono_runtime_cleanup_handlers (but with an option to not de-allocate anything) */
if (mini_debug_options.handle_sigint) {
g_assert (sigaction (SIGINT, &sa, NULL) != -1);
}
g_assert (sigaction (SIGABRT, &sa, NULL) != -1);
/* On some systems we get a SIGILL when calling abort (), because it might
* fail to raise SIGABRT */
g_assert (sigaction (SIGFPE, &sa, NULL) != -1);
g_assert (sigaction (SIGSYS, &sa, NULL) != -1);
g_assert (sigaction (SIGSEGV, &sa, NULL) != -1);
g_assert (sigaction (SIGQUIT, &sa, NULL) != -1);
g_assert (sigaction (SIGBUS, &sa, NULL) != -1);
g_assert (sigaction (SIGILL, &sa, NULL) != -1);
/* Remove SIGCHLD, it uses the finalizer thread */
g_assert (sigaction (SIGCHLD, &sa, NULL) != -1);
/* Remove SIGQUIT, we are already dumping threads */
g_assert (sigaction (SIGQUIT, &sa, NULL) != -1);
#endif
@@ -3408,11 +3410,8 @@ mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLE
}
}
/* prevent infinite loops in crash handling */
handle_crash_loop = TRUE;
/*
* A SIGSEGV indicates something went very wrong so we can no longer depend
* A crash indicates something went very wrong so we can no longer depend
* on anything working. So try to print out lots of diagnostics, starting
* with ones which have a greater chance of working.
*/
@@ -3438,13 +3437,13 @@ mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLE
g_async_safe_printf ("=================================================================\n");
}
mono_post_native_crash_handler (signal, mctx, info, mono_do_crash_chaining);
mono_post_native_crash_handler (signal, mctx, info, mono_do_crash_chaining, context);
}
#else
void
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info)
mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, void *context)
{
g_assert_not_reached ();
}
+22 -18
View File
@@ -1169,6 +1169,8 @@ get_wrapper_shared_vtype (MonoType *t)
if ((mono_class_get_flags (klass) & TYPE_ATTRIBUTE_LAYOUT_MASK) != TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT)
return NULL;
mono_class_setup_fields (klass);
if (mono_class_has_failure (klass))
return NULL;
int num_fields = mono_class_get_field_count (klass);
MonoClassField *klass_fields = m_class_get_fields (klass);
@@ -2261,7 +2263,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
if (mono_class_field_is_special_static (field)) {
gpointer addr;
mono_class_vtable_checked (domain, klass, error);
mono_class_vtable_checked (domain, field->parent, error);
mono_error_assert_ok (error);
/* Return the TLS offset */
@@ -3894,12 +3896,15 @@ shared_gparam_equal (gconstpointer ka, gconstpointer kb)
MonoType*
mini_get_shared_gparam (MonoType *t, MonoType *constraint)
{
MonoImageSet *set;
MonoGenericParam *par = t->data.generic_param;
MonoGSharedGenericParam *copy, key;
MonoType *res;
MonoImage *image = NULL;
char *name;
set = mono_metadata_merge_image_sets (mono_metadata_get_image_set_for_type (t), mono_metadata_get_image_set_for_type (constraint));
memset (&key, 0, sizeof (key));
key.parent = par;
key.param.gshared_constraint = constraint;
@@ -3911,23 +3916,24 @@ mini_get_shared_gparam (MonoType *t, MonoType *constraint)
* Need a cache to ensure the newly created gparam
* is unique wrt T/CONSTRAINT.
*/
mono_image_lock (image);
if (!image->gshared_types) {
image->gshared_types_len = MONO_TYPE_INTERNAL;
image->gshared_types = g_new0 (GHashTable*, image->gshared_types_len);
mono_image_set_lock (set);
if (!set->gshared_types) {
set->gshared_types_len = MONO_TYPE_INTERNAL;
set->gshared_types = g_new0 (GHashTable*, set->gshared_types_len);
}
if (!image->gshared_types [constraint->type])
image->gshared_types [constraint->type] = g_hash_table_new (shared_gparam_hash, shared_gparam_equal);
res = (MonoType *)g_hash_table_lookup (image->gshared_types [constraint->type], &key);
mono_image_unlock (image);
if (!set->gshared_types [constraint->type])
set->gshared_types [constraint->type] = g_hash_table_new (shared_gparam_hash, shared_gparam_equal);
res = (MonoType *)g_hash_table_lookup (set->gshared_types [constraint->type], &key);
mono_image_set_unlock (set);
if (res)
return res;
copy = (MonoGSharedGenericParam *)mono_image_alloc0 (image, sizeof (MonoGSharedGenericParam));
copy = (MonoGSharedGenericParam *)mono_image_set_alloc0 (set, sizeof (MonoGSharedGenericParam));
memcpy (&copy->param, par, sizeof (MonoGenericParamFull));
copy->param.info.pklass = NULL;
constraint = mono_metadata_type_dup (image, constraint);
// FIXME:
constraint = mono_metadata_type_dup (NULL, constraint);
name = get_shared_gparam_name (constraint->type, ((MonoGenericParamFull*)copy)->info.name);
copy->param.info.name = mono_image_strdup (image, name);
copy->param.info.name = mono_image_set_strdup (set, name);
g_free (name);
copy->param.owner = par->owner;
@@ -3938,12 +3944,10 @@ mini_get_shared_gparam (MonoType *t, MonoType *constraint)
res = mono_metadata_type_dup (NULL, t);
res->data.generic_param = (MonoGenericParam*)copy;
if (image) {
mono_image_lock (image);
/* Duplicates are ok */
g_hash_table_insert (image->gshared_types [constraint->type], copy, res);
mono_image_unlock (image);
}
mono_image_set_lock (set);
/* Duplicates are ok */
g_hash_table_insert (set->gshared_types [constraint->type], copy, res);
mono_image_set_unlock (set);
return res;
}
+1 -1
View File
@@ -10715,7 +10715,7 @@ mono_llvm_emit_aot_module (const char *filename, const char *cu_name)
* result to 0 (indicating success). */
LLVMWriteBitcodeToFile (module->lmodule, filename);
#if 1
#if 0
{
char *verifier_err;
+16 -6
View File
@@ -231,7 +231,7 @@ MONO_SIG_HANDLER_FUNC (static, sigabrt_signal_handler)
return;
mono_sigctx_to_monoctx (ctx, &mctx);
if (mono_dump_start ())
mono_handle_native_crash ("SIGABRT", &mctx, info);
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info, ctx);
else
abort ();
}
@@ -240,6 +240,7 @@ MONO_SIG_HANDLER_FUNC (static, sigabrt_signal_handler)
MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
{
#ifndef DISABLE_CRASH_REPORTING
MONO_SIG_HANDLER_INFO_TYPE *info = MONO_SIG_HANDLER_GET_INFO ();
MONO_SIG_HANDLER_GET_CONTEXT;
// Note: this is only run from the non-controlling thread
@@ -252,7 +253,7 @@ MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
// running. Returns FALSE on unrecoverable error.
if (mono_dump_start ()) {
// Process was killed from outside since crash reporting wasn't running yet.
mono_handle_native_crash ("SIGTERM", &mctx, NULL);
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, NULL, ctx);
} else {
// Crash reporting already running and we got a second SIGTERM from as part of thread-summarizing
if (!mono_threads_summarize_execute (&mctx, &output, &hashes, FALSE, NULL, 0))
@@ -437,6 +438,7 @@ mono_runtime_posix_install_handlers (void)
sigset_t signal_set;
sigemptyset (&signal_set);
mono_load_signames ();
if (mini_debug_options.handle_sigint) {
add_signal_handler (SIGINT, mono_sigint_signal_handler, SA_RESTART);
sigaddset (&signal_set, SIGINT);
@@ -446,7 +448,7 @@ mono_runtime_posix_install_handlers (void)
sigaddset (&signal_set, SIGFPE);
add_signal_handler (SIGQUIT, sigquit_signal_handler, SA_RESTART);
sigaddset (&signal_set, SIGQUIT);
add_signal_handler (SIGILL, mono_sigill_signal_handler, 0);
add_signal_handler (SIGILL, mono_crashing_signal_handler, 0);
sigaddset (&signal_set, SIGILL);
add_signal_handler (SIGBUS, mono_sigsegv_signal_handler, 0);
sigaddset (&signal_set, SIGBUS);
@@ -454,6 +456,8 @@ mono_runtime_posix_install_handlers (void)
add_signal_handler (SIGUSR2, sigusr2_signal_handler, SA_RESTART);
sigaddset (&signal_set, SIGUSR2);
}
add_signal_handler (SIGSYS, mono_crashing_signal_handler, 0);
sigaddset (&signal_set, SIGSYS);
/* it seems to have become a common bug for some programs that run as parents
* of many processes to block signal delivery for real time signals.
@@ -498,6 +502,7 @@ mono_runtime_cleanup_handlers (void)
remove_signal_handler (SIGBUS);
if (mono_jit_trace_calls != NULL)
remove_signal_handler (SIGUSR2);
remove_signal_handler (SIGSYS);
remove_signal_handler (SIGABRT);
@@ -1022,10 +1027,10 @@ dump_native_stacktrace (const char *signal, MonoContext *mctx)
g_async_safe_printf ("=================================================================\n");
if (!leave) {
mono_summarize_timeline_start ();
mono_summarize_timeline_start (signal);
mono_summarize_toggle_assertions (TRUE);
int mono_max_summary_len = 500000;
int mono_max_summary_len = 10000000;
int mono_state_tmp_file_tag = 1;
mono_state_alloc_mem (&merp_mem, mono_state_tmp_file_tag, mono_max_summary_len * sizeof (gchar));
@@ -1153,7 +1158,7 @@ mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HAN
}
void
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining)
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context)
{
if (!crash_chaining) {
/*Android abort is a fluke, it doesn't abort, it triggers another segv. */
@@ -1163,6 +1168,11 @@ mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_
abort ();
#endif
}
mono_chain_signal (info->si_signo, info, context);
// we remove Mono's signal handlers from crashing signals in mono_handle_native_crash(), so re-raising will now allow the OS to handle the crash
// TODO: perhaps we can always use this to abort, instead of explicit exit()/abort() as we do above
raise (info->si_signo);
}
#endif /* !MONO_CROSS_COMPILE */
+16 -25
View File
@@ -2358,6 +2358,7 @@ lookup_start:
g_assert (vtable);
if (!mono_runtime_class_init_full (vtable, error))
return NULL;
MONO_PROFILER_RAISE (jit_done, (method, info));
return mono_create_ftnptr (target_domain, info->code_start);
}
}
@@ -3227,11 +3228,8 @@ MONO_SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
mono_sigctx_to_monoctx (ctx, &mctx);
if (mono_dump_start ())
mono_handle_native_crash ("SIGFPE", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
goto exit;
}
mono_handle_native_crash (mono_get_signame (SIGFPE), &mctx, info, ctx);
goto exit;
}
mono_arch_handle_exception (ctx, exc);
@@ -3240,7 +3238,7 @@ exit:
MONO_EXIT_GC_UNSAFE_UNBALANCED;
}
MONO_SIG_HANDLER_FUNC (, mono_sigill_signal_handler)
MONO_SIG_HANDLER_FUNC (, mono_crashing_signal_handler)
{
MonoContext mctx;
MONO_SIG_HANDLER_INFO_TYPE *info = MONO_SIG_HANDLER_GET_INFO ();
@@ -3251,12 +3249,11 @@ MONO_SIG_HANDLER_FUNC (, mono_sigill_signal_handler)
mono_sigctx_to_monoctx (ctx, &mctx);
if (mono_dump_start ())
mono_handle_native_crash ("SIGILL", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
return;
}
#if defined(HAVE_SIG_INFO) && !defined(HOST_WIN32) // info is a siginfo_t
mono_handle_native_crash (mono_get_signame (info->si_signo), &mctx, info, ctx);
#else
mono_handle_native_crash (mono_get_signame (SIGTERM), &mctx, info, ctx);
#endif
}
#if defined(MONO_ARCH_USE_SIGACTION) || defined(HOST_WIN32)
@@ -3326,6 +3323,9 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
mono_aot_handle_pagefault (info->si_addr);
return;
}
int signo = info->si_signo;
#else
int signo = SIGSEGV;
#endif
/* The thread might no be registered with the runtime */
@@ -3333,11 +3333,7 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
if (!mono_do_crash_chaining && mono_chain_signal (MONO_SIG_HANDLER_PARAMS))
return;
if (mono_dump_start())
mono_handle_native_crash ("SIGSEGV", &mctx, info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
return;
}
mono_handle_native_crash (mono_get_signame (signo), &mctx, info, ctx);
}
#endif
@@ -3376,7 +3372,7 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
} else {
// FIXME: This shouldn't run on the altstack
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, info);
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, info, ctx);
}
#endif
}
@@ -3387,19 +3383,14 @@ MONO_SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
return;
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
if (mono_do_crash_chaining) {
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
return;
}
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info, ctx);
}
if (mono_is_addr_implicit_null_check (fault_addr)) {
mono_arch_handle_exception (ctx, NULL);
} else {
if (mono_dump_start ())
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
mono_handle_native_crash (mono_get_signame (SIGSEGV), &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info, ctx);
}
#endif
}
+2 -2
View File
@@ -556,7 +556,7 @@ void
mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info);
void
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining);
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context);
gboolean
mono_is_addr_implicit_null_check (void *addr);
@@ -571,7 +571,7 @@ mono_is_addr_implicit_null_check (void *addr);
#endif
void MONO_SIG_HANDLER_SIGNATURE (mono_sigfpe_signal_handler) ;
void MONO_SIG_HANDLER_SIGNATURE (mono_sigill_signal_handler) ;
void MONO_SIG_HANDLER_SIGNATURE (mono_crashing_signal_handler) ;
void MONO_SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler);
void MONO_SIG_HANDLER_SIGNATURE (mono_sigint_signal_handler) ;
gboolean MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal);
+2 -2
View File
@@ -1142,7 +1142,7 @@ mono_delegate_trampoline (host_mgreg_t *regs, guint8 *code, gpointer *arg, guint
}
}
if (tramp_info->method == NULL && delegate->target != NULL && method->flags & METHOD_ATTRIBUTE_VIRTUAL) {
if (delegate->method_ptr == NULL && tramp_info->method == NULL && delegate->target != NULL && method->flags & METHOD_ATTRIBUTE_VIRTUAL) {
/* tramp_info->method == NULL happens when someone asks us to JIT some delegate's
* Invoke method (see compile_special). In that case if method is virtual, the target
* could be some derived class, so we need to find the correct override.
@@ -1326,7 +1326,7 @@ mono_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, M
guint32 len;
if (mono_aot_only)
code = mono_aot_create_specific_trampoline (mono_defaults.corlib, arg1, tramp_type, domain, &len);
code = mono_aot_create_specific_trampoline (arg1, tramp_type, domain, &len);
else
code = mono_arch_create_specific_trampoline (arg1, tramp_type, domain, &len);
mono_lldb_save_specific_trampoline_info (arg1, tramp_type, domain, code, len);
+3 -3
View File
@@ -153,7 +153,7 @@ tls_get_restore_state (void *tls)
}
static gboolean
try_process_suspend (void *tls, MonoContext *ctx)
try_process_suspend (void *tls, MonoContext *ctx, gboolean from_breakpoint)
{
return FALSE;
}
@@ -239,7 +239,7 @@ process_breakpoint_events (void *_evts, MonoMethod *method, MonoContext *ctx, in
BpEvents *evts = (BpEvents*)_evts;
if (evts) {
if (evts->is_ss)
mono_de_cancel_ss ();
mono_de_cancel_all_ss ();
mono_wasm_fire_bp ();
g_free (evts);
}
@@ -293,7 +293,7 @@ ss_args_destroy (SingleStepArgs *ss_args)
static int
handle_multiple_ss_requests (void) {
mono_de_cancel_ss ();
mono_de_cancel_all_ss ();
return 1;
}
+2 -2
View File
@@ -193,7 +193,7 @@ mono_runtime_install_handlers (void)
#ifndef MONO_CROSS_COMPILE
win32_seh_init();
win32_seh_set_handler(SIGFPE, mono_sigfpe_signal_handler);
win32_seh_set_handler(SIGILL, mono_sigill_signal_handler);
win32_seh_set_handler(SIGILL, mono_crashing_signal_handler);
win32_seh_set_handler(SIGSEGV, mono_sigsegv_signal_handler);
if (mini_debug_options.handle_sigint)
win32_seh_set_handler(SIGINT, mono_sigint_signal_handler);
@@ -281,7 +281,7 @@ mono_dump_native_crash_info (const char *signal, MonoContext *mctx, MONO_SIG_HAN
}
void
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining)
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining, void *context)
{
if (!crash_chaining)
abort ();
+3 -1
View File
@@ -2098,6 +2098,7 @@ guint mono_type_to_load_membase (MonoCompile *cfg, MonoType *type);
guint mono_type_to_store_membase (MonoCompile *cfg, MonoType *type);
guint32 mono_type_to_stloc_coerce (MonoType *type);
guint mini_type_to_stind (MonoCompile* cfg, MonoType *type);
MonoStackType mini_type_to_stack_type (MonoCompile *cfg, MonoType *t);
MonoJitInfo* mini_lookup_method (MonoDomain *domain, MonoMethod *method, MonoMethod *shared);
guint32 mono_reverse_branch_op (guint32 opcode);
void mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id);
@@ -2241,6 +2242,7 @@ void mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset,
void mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val, int align);
void mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native);
void mini_emit_initobj (MonoCompile *cfg, MonoInst *dest, const guchar *ip, MonoClass *klass);
void mini_emit_init_rvar (MonoCompile *cfg, int dreg, MonoType *rtype);
int mini_emit_sext_index_reg (MonoCompile *cfg, MonoInst *index);
MonoInst* mini_emit_ldelema_1_ins (MonoCompile *cfg, MonoClass *klass, MonoInst *arr, MonoInst *index, gboolean bcheck);
MonoInst* mini_emit_get_gsharedvt_info_klass (MonoCompile *cfg, MonoClass *klass, MonoRgctxInfoType rgctx_type);
@@ -2501,7 +2503,7 @@ typedef gboolean (*MonoJitStackWalk) (StackFrameInfo *frame, MonoCont
void mono_exceptions_init (void);
gboolean mono_handle_exception (MonoContext *ctx, gpointer obj);
void mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo);
void mono_handle_native_crash (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo, void *context);
MONO_API void mono_print_thread_dump (void *sigctx);
MONO_API void mono_print_thread_dump_from_ctx (MonoContext *ctx);
void mono_walk_stack_with_ctx (MonoJitStackWalk func, MonoContext *start_ctx, MonoUnwindOptions unwind_options, void *user_data);
+4 -12
View File
@@ -72,20 +72,12 @@ mono_arch_patch_plt_entry (guint8 *code, gpointer *got, host_mgreg_t *regs, guin
guint8*
mono_arch_get_call_target (guint8 *code)
{
guint32 imm;
int disp;
code -= 4;
imm = *(guint32*)code;
guint32 ins = *(guint32 *)code;
/* Should be a b/bl */
g_assert (((imm >> 26) & 0x7) == 0x5);
disp = (imm & 0x3ffffff);
if ((disp >> 25) != 0)
/* Negative, sing extend to 32 bits */
disp = disp | 0xfc000000;
if (((ins >> 26) & 0x1f) != 0x5)
return NULL;
gint32 disp = ((gint32)((ins & 0x3ffffff) << 6)) >> 6;
return code + (disp * 4);
}
+2
View File
@@ -3730,6 +3730,8 @@ sgen_gc_init (void)
} else if (!strcmp (opt, "nursery-canaries")) {
do_verify_nursery = TRUE;
enable_nursery_canaries = TRUE;
/* If aot code is used, allocation from there won't expect the layout with canaries enabled */
sgen_set_use_managed_allocator (FALSE);
} else if (!sgen_client_handle_gc_debug (opt)) {
sgen_env_var_error (MONO_GC_DEBUG_NAME, "Ignoring.", "Unknown option `%s`.", opt);
+11
View File
@@ -386,6 +386,7 @@ TESTS_CS_SRC= \
interface.cs \
interface-2.cs \
dim-generic.cs \
dim-issue-18917.cs \
iface.cs \
iface2.cs \
iface3.cs \
@@ -689,6 +690,7 @@ TESTS_CS_SRC= \
monitor.cs \
generic-xdomain.2.cs \
threadpool-exceptions7.cs \
threadpool-exceptions8.cs \
cross-domain.cs \
generic-unloading.2.cs \
namedmutex-destroy-race.cs \
@@ -724,6 +726,7 @@ TESTS_CS_SRC= \
bug-gh-9507.cs \
async-generic-enum.cs \
null-blob-main.cs \
rgctx-thread-static.cs \
last-error.cs
# some tests fail to compile on mcs
@@ -1108,6 +1111,12 @@ PLATFORM_DISABLED_TESTS += bug-58782-plain-throw.exe bug-58782-capture-and-throw
# see https://github.com/mono/mono/issues/9739
PLATFORM_DISABLED_TESTS += verbose.exe
if ENABLE_CXX
# see https://github.com/mono/mono/issues/18827
PLATFORM_DISABLED_TESTS += bug-10127.exe
endif
endif
@@ -1386,6 +1395,7 @@ PROFILE_DISABLED_TESTS += \
monitor.exe \
generic-xdomain.2.exe \
threadpool-exceptions7.exe \
threadpool-exceptions8.exe \
cross-domain.exe \
generic-unloading.2.exe \
appdomain-threadpool-unload.exe
@@ -1599,6 +1609,7 @@ PROFILE_DISABLED_TESTS += \
suspend-stress-test.exe \
thread6.exe \
threadpool-exceptions7.exe \
threadpool-exceptions8.exe \
unhandled-exception-7.exe \
unhandled-exception-test-case.2.exe \
unload-appdomain-on-shutdown.exe \
+36 -23
View File
@@ -1,6 +1,33 @@
using System;
using System.Reflection;
public enum WasCalled {
BaseWasCalled,
DerivedWasCalled
}
public delegate WasCalled Del1 (string s);
public delegate WasCalled Del2 (string s);
public class Base
{
public virtual WasCalled Foo (string s)
{
Console.WriteLine ("Base.Foo called. Expected {0}", s);
return WasCalled.BaseWasCalled;
}
}
public class Derived : Base
{
public override WasCalled Foo (string s)
{
Console.WriteLine ("Derived.Foo called. Expected {0}", s);
return WasCalled.DerivedWasCalled;
}
}
internal class Program
{
public static int Main (string[] args)
@@ -14,29 +41,15 @@ internal class Program
// newobj Del2::.ctor
Del2 f = new Del2 (b.Invoke);
// should call Derived.Foo not Base.Foo
var r = f ("abcd");
return r;
}
}
public delegate int Del1 (string s);
public delegate int Del2 (string s);
public class Base
{
public virtual int Foo (string s)
{
Console.WriteLine ("Base.Foo called. Bad");
return 1;
}
}
public class Derived : Base
{
public override int Foo (string s)
{
Console.WriteLine ("Derived.Foo called. Good");
var r = f ("Derived.Foo");
if (r != WasCalled.DerivedWasCalled)
return 1;
// should call Base.Foo not Derived.Foo
var boundDelegate = (Del2)Activator.CreateInstance (typeof (Del2), b, typeof (Base).GetMethod (nameof (Base.Foo)).MethodHandle.GetFunctionPointer());
r = boundDelegate ("Base.Foo");
if (r != WasCalled.BaseWasCalled)
return 2;
return 0;
}
}
+38
View File
@@ -0,0 +1,38 @@
using System;
public interface IInterface
{
int getRet() { return -10; }
}
public interface IInterface2 : IInterface
{
int IInterface.getRet() { return -1; }
}
public class AbstractClass : IInterface2
{
int IInterface.getRet() { return 0; }
}
public class FinalClass : AbstractClass
{
}
public class Test
{
public static int test_0_dim_18917()
{
var var0 = new FinalClass();
var var4 = (IInterface2)var0;
var var5 = var4.getRet();
return var5;
}
public static int Main (string[] args) {
return TestDriver.RunTests (typeof (Test), args);
}
}
+59
View File
@@ -8,6 +8,7 @@
#include <time.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include "../utils/mono-errno.h"
#include "../utils/mono-compiler.h"
@@ -8011,6 +8012,64 @@ mono_test_MerpCrashUnhandledExceptionHook (void)
g_assert_not_reached ();
}
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalTerm (void)
{
raise (SIGTERM);
}
// for the rest of the signal tests, we use SIGTERM as a fallback
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalAbrt (void)
{
#if defined (SIGABRT)
raise (SIGABRT);
#else
raise (SIGTERM);
#endif
}
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalFpe (void)
{
#if defined (SIGFPE)
raise (SIGFPE);
#else
raise (SIGTERM);
#endif
}
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalBus (void)
{
#if defined (SIGBUS)
raise (SIGBUS);
#else
raise (SIGTERM);
#endif
}
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalSegv (void)
{
#if defined (SIGSEGV)
raise (SIGSEGV);
#else
raise (SIGTERM);
#endif
}
LIBTEST_API void STDCALL
mono_test_MerpCrashSignalIll (void)
{
#if defined (SIGILL)
raise (SIGILL);
#else
raise (SIGTERM);
#endif
}
#ifdef __cplusplus
} // extern C
#endif
+210 -25
View File
@@ -11,15 +11,35 @@ class C
{
class CrasherClass
{
public static List<Tuple<String, Action>> Crashers;
public struct Crasher {
public string Name {get;}
public Action Action {get; }
public Action<object> Validator {get; }
public Crasher (string name, Action action, Action<object> validator = null)
{
Name = name;
Action = action;
Validator = validator;
}
}
public class ValidationException : Exception {
public ValidationException () : base () {}
public ValidationException (string msg) : base (msg) {}
public ValidationException (string msg, Exception inner) : base (msg, inner) {}
}
public static List<Crasher> Crashers;
public static int StresserIndex;
static CrasherClass ()
{
Crashers = new List<Tuple<String, Action>> ();
Crashers = new List<Crasher> ();
// Basic functionality
Crashers.Add(new Tuple<String, Action> ("MerpCrashManaged", MerpCrashManaged));
Crashers.Add(new Crasher ("MerpCrashManaged", MerpCrashManaged));
// Run this test for stress tests
//
// I've ran a burn-in with all of them of
@@ -28,16 +48,24 @@ class C
// Feel free to change by moving this line.
StresserIndex = Crashers.Count - 1;
Crashers.Add(new Tuple<String, Action> ("MerpCrashMalloc", MerpCrashMalloc));
Crashers.Add(new Crasher ("MerpCrashMalloc", MerpCrashMalloc));
Crashers.Add(new Crasher ("MerpCrashFailFast", MerpCrashFailFast, ValidateFailFastMsg));
Crashers.Add(new Tuple<String, Action> ("MerpCrashNullFp", MerpCrashNullFp));
Crashers.Add(new Tuple<String, Action> ("MerpCrashExceptionHook", MerpCrashUnhandledExceptionHook));
Crashers.Add(new Crasher ("MerpCrashNullFp", MerpCrashNullFp));
Crashers.Add(new Crasher ("MerpCrashExceptionHook", MerpCrashUnhandledExceptionHook));
// Specific Edge Cases
Crashers.Add(new Tuple<String, Action> ("MerpCrashDladdr", MerpCrashDladdr));
Crashers.Add(new Tuple<String, Action> ("MerpCrashSnprintf", MerpCrashSnprintf));
Crashers.Add(new Tuple<String, Action> ("MerpCrashDomainUnload", MerpCrashDomainUnload));
Crashers.Add(new Tuple<String, Action> ("MerpCrashUnbalancedGCSafe", MerpCrashUnbalancedGCSafe));
Crashers.Add(new Crasher ("MerpCrashDladdr", MerpCrashDladdr));
Crashers.Add(new Crasher ("MerpCrashSnprintf", MerpCrashSnprintf));
Crashers.Add(new Crasher ("MerpCrashDomainUnload", MerpCrashDomainUnload));
Crashers.Add(new Crasher ("MerpCrashUnbalancedGCSafe", MerpCrashUnbalancedGCSafe));
Crashers.Add(new Crasher ("MerpCrashSignalTerm", MerpCrashSignalTerm));
Crashers.Add(new Crasher ("MerpCrashSignalTerm", MerpCrashSignalAbrt));
Crashers.Add(new Crasher ("MerpCrashSignalKill", MerpCrashSignalFpe));
Crashers.Add(new Crasher ("MerpCrashSignalKill", MerpCrashSignalBus));
Crashers.Add(new Crasher ("MerpCrashSignalSegv", MerpCrashSignalSegv));
Crashers.Add(new Crasher ("MerpCrashSignalIll", MerpCrashSignalIll));
Crashers.Add(new Crasher ("MerpCrashTestBreadcrumbs", MerpCrashTestBreadcrumbs, validator: ValidateBreadcrumbs));
}
public static void
@@ -46,6 +74,37 @@ class C
unsafe { Console.WriteLine("{0}", *(int*) -1); }
}
const string failfastMsg = "abcd efgh";
public static void
MerpCrashFailFast ()
{
Environment.FailFast (failfastMsg);
}
public static void ValidateFailFastMsg (object json)
{
string s = jsonGetKeys (json, "payload", "failfast_message") as string;
if (s != failfastMsg)
throw new ValidationException (String.Format ("incorrect fail fast message (expected: {0}, got: {1})", failfastMsg, s));
}
public static void ValidateBreadcrumbs (object json)
{
var monoType = Type.GetType ("Mono.Runtime", false);
var m = monoType.GetMethod ("CheckCrashReportReason", BindingFlags.NonPublic | BindingFlags.Static);
var m_params = new object [] { "./", false };
string o = (string)m.Invoke(null, m_params);
if (o != "segv")
throw new Exception ("Crash report reason should be 'segv'");
m = monoType.GetMethod ("CheckCrashReportHash", BindingFlags.NonPublic | BindingFlags.Static);
long hash = (long)m.Invoke (null, m_params);
if (hash == 0)
throw new Exception ("Crash hash should not be zero");
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSnprintf ();
@@ -113,6 +172,60 @@ class C
[DllImport("libtest")]
public static extern void mono_test_MerpCrashUnhandledExceptionHook ();
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalTerm ();
public static void
MerpCrashSignalTerm ()
{
mono_test_MerpCrashSignalTerm ();
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalAbrt ();
public static void
MerpCrashSignalAbrt ()
{
mono_test_MerpCrashSignalAbrt ();
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalFpe ();
public static void
MerpCrashSignalFpe ()
{
mono_test_MerpCrashSignalFpe ();
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalBus ();
public static void
MerpCrashSignalBus ()
{
mono_test_MerpCrashSignalBus ();
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalSegv ();
public static void
MerpCrashSignalSegv ()
{
mono_test_MerpCrashSignalSegv ();
}
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSignalIll ();
public static void
MerpCrashSignalIll ()
{
mono_test_MerpCrashSignalIll ();
}
public static void
MerpCrashUnhandledExceptionHook ()
{
@@ -125,6 +238,26 @@ class C
Console.WriteLine ("And now to crash inside the hook");
mono_test_MerpCrashUnhandledExceptionHook ();
}
public static void
MerpCrashTestBreadcrumbs ()
{
mono_test_MerpCrashSignalSegv ();
}
private static object jsonGetKey (object o, string key) => (o as Dictionary<string,object>)[key];
private static object jsonGetKeys (object o, params string[] keys) {
try {
foreach (var key in keys) {
o = jsonGetKey (o, key);
}
return o;
} catch (KeyNotFoundException e) {
throw new ValidationException (String.Format ("{0}, key not found, looking for key path [{1}]", e.ToString(), String.Join (", ", keys)));
}
}
}
static string configDir = "./merp-crash-test/";
@@ -133,7 +266,7 @@ class C
CrashWithMerp (int testNum)
{
SetupCrash (configDir);
CrasherClass.Crashers [Convert.ToInt32 (testNum)].Item2 ();
CrasherClass.Crashers [Convert.ToInt32 (testNum)].Action ();
}
public static string env = Environment.GetEnvironmentVariable ("MONO_PATH");
@@ -161,10 +294,8 @@ class C
}
public static void
TestValidate (string configDir, bool silent)
TestValidate (string configDir, bool silent, Action<object> validator = null)
{
DumpLogCheck ();
var xmlFilePath = String.Format("{0}CustomLogsMetadata.xml", configDir);
var paramsFilePath = String.Format("{0}MERP.uploadparams.txt", configDir);
var crashFilePath = String.Format("{0}lastcrashlog.txt", configDir);
@@ -204,8 +335,12 @@ class C
Console.WriteLine("Validating: {0}", crashFile);
try {
var obj = checker.DeserializeObject (crashFile);
if (validator is object)
validator (obj);
} catch (CrasherClass.ValidationException e) {
throw new Exception (String.Format ("Validation failed '{0}', json: {1}", e.Message, crashFile));
} catch (Exception e) {
throw new Exception (String.Format ("Invalid json: {0}", crashFile));
throw new Exception (String.Format ("Invalid json ({0}:{1}): {2}", e.GetType(), e.Message, crashFile));
}
File.Delete (crashFilePath);
@@ -214,6 +349,8 @@ class C
Console.WriteLine ("Crash file {0} missing", crashFilePath);
}
DumpLogCheck (expected_level: "MerpInvoke"); // we are expecting merp invoke to fail
if (!xmlFileExists)
throw new Exception (String.Format ("Did not produce {0}", xmlFilePath));
@@ -244,7 +381,7 @@ class C
convert.Invoke(null, new object[] { null });
}
static void DumpLogCheck ()
static void DumpLogCheck (string expected_level = "Done")
{
var monoType = Type.GetType ("Mono.Runtime", false);
var convert = monoType.GetMethod("CheckCrashReportLog", BindingFlags.NonPublic | BindingFlags.Static);
@@ -252,11 +389,17 @@ class C
// Value of enum
string [] levels = new string [] { "None", "Setup", "SuspendHandshake", "UnmanagedStacks", "ManagedStacks", "StateWriter", "StateWriterDone", "MerpWriter", "MerpInvoke", "Cleanup", "Done", "DoubleFault" };
if ("MerpInvoke" == levels [result]) {
Console.WriteLine ("Merp invoke command failed, expected failure?");
} else if ("Done" != levels [result]) {
throw new Exception (String.Format ("Crash level not done, failed in stage: {0}", levels [result]));
}
if (expected_level != levels [result])
throw new Exception (String.Format ("Crash level {0} does not match expected {1}", levels [result], expected_level));
// also clear hash and reason breadcrumbs
convert = monoType.GetMethod("CheckCrashReportHash", BindingFlags.NonPublic | BindingFlags.Static);
var hash_result = (long) convert.Invoke(null, new object[] { "./", true });
convert = monoType.GetMethod("CheckCrashReportReason", BindingFlags.NonPublic | BindingFlags.Static);
var reason_result = (string) convert.Invoke(null, new object[] { "./", true });
if (reason_result == string.Empty)
throw new Exception("Crash reason should not be an empty string");
}
@@ -271,7 +414,7 @@ class C
pi.Environment ["MONO_PATH"] = env;
if (!silent) {
Console.WriteLine ("Running {0}", CrasherClass.Crashers [testNum].Item1);
Console.WriteLine ("Running {0}", CrasherClass.Crashers [testNum].Name);
Console.WriteLine ("MONO_PATH={0} {1} {2} {3}", env, runtime, asm, testNum);
}
@@ -286,12 +429,46 @@ class C
var process = Diag.Process.Start (pi);
process.WaitForExit ();
TestValidate (configDir, silent);
TestValidate (configDir, silent, CrasherClass.Crashers [testNum].Validator);
} finally {
Cleanup (configDir);
}
}
public static void TestManagedException ()
{
if (Directory.Exists (configDir)) {
Console.WriteLine ("Cleaning up left over configDir {0}", configDir);
Cleanup (configDir);
}
Directory.CreateDirectory (configDir);
SetupCrash (configDir);
var monoType = Type.GetType ("Mono.Runtime", false);
var m = monoType.GetMethod ("ExceptionToState", BindingFlags.NonPublic | BindingFlags.Static);
var exception = new Exception ("test managed exception");
var m_params = new object[] { exception };
var result = m.Invoke (null, m_params) as Tuple<String, ulong, ulong>;
DumpLogCheck (expected_level: "StateWriterDone");
Cleanup (configDir);
}
public static Exception RunManagedExceptionTest ()
{
Console.WriteLine ("Testing ExceptionToState()...");
Exception exception_test_failure = null;
try {
TestManagedException();
}
catch (Exception e)
{
return e;
}
return null;
}
public static int Main (string [] args)
{
if (args.Length == 0) {
@@ -316,20 +493,28 @@ class C
}
}
// Also test sending a managed exception
Exception exception_test_failure = RunManagedExceptionTest ();
Console.WriteLine ("\n\n##################");
Console.WriteLine ("Merp Test Results:");
Console.WriteLine ("##################\n\n");
if (exception_test_failure != null)
{
Console.WriteLine ("Sending managed exception to MERP failed: {0}\n{1}\n", exception_test_failure.Message, exception_test_failure.StackTrace);
}
if (failure_count > 0) {
for (int i=0; i < CrasherClass.Crashers.Count; i++) {
if (failures [i] != null) {
Console.WriteLine ("Crash reporter failed test {0}", CrasherClass.Crashers [i].Item1);
Console.WriteLine ("Crash reporter failed test {0}", CrasherClass.Crashers [i].Name);
Console.WriteLine ("Cause: {0}\n{1}\n", failures [i].Message, failures [i].StackTrace);
}
}
}
if (failure_count > 0)
if (failure_count > 0 || exception_test_failure != null)
return 1;
Console.WriteLine ("\n\n##################");
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Runtime.CompilerServices;
public class TlsClass<T> {
[ThreadStatic]
public static string staticTls;
}
public class AccessClass<T> {
[MethodImpl(MethodImplOptions.NoInlining)]
public string GetStatic ()
{
// Get field offset through rgctx_fetch of a class not yet initialized
return TlsClass<T>.staticTls;
}
}
public class Program {
public static int Main (string[] args)
{
AccessClass<string> ac1 = new AccessClass<string> ();
if (ac1.GetStatic () != null)
return 1;
return 0;
}
}
+158
View File
@@ -0,0 +1,158 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
public class Tests {
public static int Main (string[] args) {
runner ();
return 63; // should not be reached
}
public static void runner () {
// need to run the test in a domain so that we can deal with unhandled exceptions
var ad = AppDomain.CreateDomain ("Inner Domain");
var helperType = typeof(TaskAwaiterOnCompletedHelper);
var helper = (TaskAwaiterOnCompletedHelper)ad.CreateInstanceAndUnwrap (helperType.Assembly.ToString(), helperType.FullName);
var holder = new ResultHolder ();
helper.TheTest (holder);
// HACK: If everything went well, a thread is running in the other domain and is blocked in OnUnhandled
// waiting for AllDone(). Don't send it. Instead just exit without waiting. If we send AllDone, the
// process will terminate with a 255. Don't try to unload the domain either, since the other thread
// will never finish.
//
//helper.AllDone();
//AppDomain.Unload (ad);
Environment.Exit (holder.Result);
}
public class ResultHolder : MarshalByRefObject {
public ResultHolder () { }
public int Result { get; set; }
}
public class TaskAwaiterOnCompletedHelper : MarshalByRefObject {
public class SpecialExn : Exception {
public SpecialExn () : base () {}
}
public void TheTest (ResultHolder holder)
{
this.holder = holder;
holder.Result = TheRealTest ();
}
ResultHolder holder;
public int TheRealTest ()
{
// Regression test for https://github.com/mono/mono/issues/19166
//
// Check that if in a call to
// t.GetAwaiter().OnCompleted(cb) the callback cb
// throws, that the exception's stack trace includes
// the method that threw and not just the task
// machinery's frames.
// Calling "WhenCompleted" will throw "SpecialExn"
//
// If "OnUhandled" is installed as an unhandled exception handler, it will
// capture the stack trace of the SpecialExn and allow WaitForExn() to finish waiting.
// The stack trace is expected to include ThrowerMethodInfo
var helper = this;
var d = new UnhandledExceptionEventHandler (helper.OnUnhandled);
AppDomain.CurrentDomain.UnhandledException += d;
// this is TaskToApm.Begin (..., callback) where the callback is helper.WhenCompleted
Task.Delay (100).GetAwaiter().OnCompleted (helper.WhenCompleted);
var wasSet = helper.WaitForExn (10000); // wait upto 10 seconds for the task to throw
AppDomain.CurrentDomain.UnhandledException -= d;
if (!wasSet) {
Console.WriteLine ("event not set, no exception thrown?");
return 1;
}
return 0;
}
private ManualResetEventSlim coord;
private ManualResetEventSlim coord2;
private StackFrame[] frames;
public TaskAwaiterOnCompletedHelper ()
{
coord = new ManualResetEventSlim ();
coord2 = new ManualResetEventSlim ();
}
public MethodBase ThrowerMethodInfo => typeof(TaskAwaiterOnCompletedHelper).GetMethod (nameof (WhenCompletedThrower));
[MethodImpl (MethodImplOptions.NoInlining)]
public void WhenCompleted ()
{
WhenCompletedThrower ();
}
[MethodImpl (MethodImplOptions.NoInlining)]
public void WhenCompletedThrower ()
{
throw new SpecialExn ();
}
public void OnUnhandled (object sender, UnhandledExceptionEventArgs args)
{
if (args.ExceptionObject is SpecialExn exn) {
try {
var trace = new StackTrace (exn);
frames = trace.GetFrames ();
if (frames == null) {
holder.Result = 2;
return;
}
Console.WriteLine ("got {0} frames ", frames.Length);
bool found = false;
foreach (var frame in frames) {
if (frame.GetMethod ().Equals (ThrowerMethodInfo)) {
found = true;
break;
}
}
if (!found) {
Console.WriteLine ("expected to see {0} in stack trace, but it wasn't there", ThrowerMethodInfo.ToString());
holder.Result = 3;
return;
}
} finally {
coord.Set ();
coord2.Wait ();
}
}
}
public StackFrame[] CapturedStackTraceFrames => frames;
public bool WaitForExn (int timeoutMilliseconds)
{
return coord.Wait (timeoutMilliseconds);
}
public void AllDone ()
{
coord2.Set ();
}
}
}
+1
View File
@@ -0,0 +1 @@
*.pyc
@@ -1,5 +1,4 @@
This is a tool to generate offsets file for use by the mono cross compilers.
It depends on python and libclang. The 'clang' directory contains the python bindings to libclang, they are taken from:
https://github.com/llvm/llvm-project/commits/master/clang/bindings/python/clang
rev 8a12e40185cd0ce7031e6abab4af12e6fc923110
https://github.com/llvm/llvm-project/tree/8a12e40185cd0ce7031e6abab4af12e6fc923110/clang/bindings/python/clang
+1
View File
@@ -206,6 +206,7 @@ monoutils_sources = \
bsearch.h \
bsearch.c \
mono-signal-handler.h \
mono-signal-handler.c \
mono-conc-hashtable.h \
mono-conc-hashtable.c \
json.h \
+19 -6
View File
@@ -40,6 +40,7 @@
#include <mono/utils/json.h>
#include <mono/utils/mono-state.h>
#include <utils/mono-threads-debug.h>
#include <utils/mono-signal-handler.h>
static const char *
kernel_version_string (void)
@@ -144,7 +145,8 @@ typedef enum
MERP_EXC_SIGFPE = 7 ,
MERP_EXC_SIGTRAP = 8,
MERP_EXC_SIGKILL = 9,
MERP_EXC_HANG = 10
MERP_EXC_HANG = 10,
MERP_EXC_MANAGED_EXCEPTION = 11
} MERPExcType;
typedef struct {
@@ -261,6 +263,8 @@ get_merp_exctype (MERPExcType exc)
return "0x04000000";
case MERP_EXC_HANG:
return "0x02000000";
case MERP_EXC_MANAGED_EXCEPTION:
return "0x05000000";
case MERP_EXC_NONE:
// Exception type documented as optional, not optional
g_assert_not_reached ();
@@ -272,23 +276,32 @@ get_merp_exctype (MERPExcType exc)
static MERPExcType
parse_exception_type (const char *signal)
{
if (!strcmp (signal, "SIGSEGV"))
if (!strcmp (signal, mono_get_signame (SIGSEGV)))
return MERP_EXC_SIGSEGV;
if (!strcmp (signal, "SIGFPE"))
if (!strcmp (signal, mono_get_signame (SIGFPE)))
return MERP_EXC_SIGFPE;
if (!strcmp (signal, "SIGILL"))
if (!strcmp (signal, mono_get_signame (SIGILL)))
return MERP_EXC_SIGILL;
if (!strcmp (signal, "SIGABRT"))
if (!strcmp (signal, mono_get_signame (SIGABRT)))
return MERP_EXC_SIGABRT;
if (!strcmp (signal, mono_get_signame (SIGTRAP)))
return MERP_EXC_SIGTRAP;
if (!strcmp (signal, mono_get_signame (SIGSYS)))
return MERP_EXC_SIGSYS;
// Force quit == hang?
// We need a default for this
if (!strcmp (signal, "SIGTERM"))
if (!strcmp (signal, mono_get_signame (SIGTERM)))
return MERP_EXC_HANG;
if (!strcmp (signal, "MANAGED_EXCEPTION"))
return MERP_EXC_MANAGED_EXCEPTION;
// FIXME: There are no other such signal
// strings passed to mono_handle_native_crash at the
// time of writing this
+78
View File
@@ -0,0 +1,78 @@
#include "config.h"
#include <signal.h>
#include <string.h>
#include "mono/utils/mono-signal-handler.h"
struct mono_sigpair
{
int signo;
const char* signame;
};
#if !defined (HAVE_SYSSIGNAME)
static struct mono_sigpair mono_signames[] =
{
{SIGABRT, "SIGABRT"},
#if defined (SIGKILL)
{SIGKILL, "SIGKILL"},
#endif
#if defined (SIGTRAP)
{SIGTRAP, "SIGTRAP"},
#endif
#if defined (SIGSYS)
{SIGSYS, "SIGSYS"},
#endif
{SIGSEGV, "SIGSEGV"},
#if defined (SIGQUIT)
{SIGQUIT, "SIGQUIT"},
#endif
{SIGFPE, "SIGFPE"},
{SIGILL, "SIGILL"},
#if defined (SIGBUS)
{SIGBUS, "SIGBUS"} // How come this is seems not available on Android, but is used unconditionally in mini-posix.c:mono_runtime_posix_install_handlers ?
#endif
};
#endif
static struct mono_sigpair *sigpair_buf;
static int sigpair_buflen;
void
mono_load_signames ()
{
if (sigpair_buf)
return;
#if defined (HAVE_SYSSIGNAME)
sigpair_buflen = sizeof (sys_signame) / sizeof (sys_signame [0]);
sigpair_buf = (struct mono_sigpair *) g_malloc (sigpair_buflen * sizeof (struct mono_sigpair));
struct mono_sigpair *cur = sigpair_buf;
for (int i = 0; i < sigpair_buflen; ++i)
{
cur->signo = i;
cur->signame = sys_signame [i];
cur++;
}
#else
sigpair_buflen = sizeof (mono_signames) / sizeof (mono_signames [0]);
sigpair_buf = mono_signames;
#endif
}
const char *
mono_get_signame (int signo)
{
const char *result = "UNKNOWN";
struct mono_sigpair *cur = sigpair_buf;
for (int i = 0; i < sigpair_buflen; ++i)
{
if (cur->signo == signo)
{
result = cur->signame;
break;
}
cur++;
}
return result;
}
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff. Show more