platform/upstream/dotnet/runtime.git
2 years agoUse a better endpoint for backport workflows runs (#69617)
Adeel Mujahid [Mon, 23 May 2022 15:31:52 +0000 (18:31 +0300)]
Use a better endpoint for backport workflows runs (#69617)

2 years agoAllow StoreLclVar src to be IND/FLD. (#59315)
Sergey Andreenko [Mon, 23 May 2022 13:47:22 +0000 (09:47 -0400)]
Allow StoreLclVar src to be IND/FLD. (#59315)

* Allow StoreLclVar src to be IND/FLD.

* disable for arm64

* use OperIsInitVal

* fix format

2 years ago[main] Update dependencies from dotnet/linker (#69644)
dotnet-maestro[bot] [Mon, 23 May 2022 08:22:56 +0000 (10:22 +0200)]
[main] Update dependencies from dotnet/linker (#69644)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoRename and reenable test (#69648)
Aaron Robinson [Mon, 23 May 2022 00:52:04 +0000 (17:52 -0700)]
Rename and reenable test (#69648)

2 years agoClear NO_CSE on struct addrs in MorphCommaBlock (#69210)
SingleAccretion [Sun, 22 May 2022 18:37:49 +0000 (21:37 +0300)]
Clear NO_CSE on struct addrs in MorphCommaBlock (#69210)

A small CQ improvement for cases where we set it unnecessarily.

2 years agoFix R2RDump (#69656)
Jakob Botsch Nielsen [Sun, 22 May 2022 18:18:25 +0000 (20:18 +0200)]
Fix R2RDump (#69656)

Looks like the default for these changes to empty array instead of null.

Fixes #69655

2 years agoStart morphing `TYP_STRUCT` local indirections in `LocalAddressVisitor` (#68515)
SingleAccretion [Sun, 22 May 2022 17:55:27 +0000 (20:55 +0300)]
Start morphing `TYP_STRUCT` local indirections in `LocalAddressVisitor` (#68515)

* Refactor "MorphLocalIndir"

Separate the transformation from "analysis".

This will be helpful when we start morphing TYP_STRUCT indirections,
which have a complex matrix of supported IR shapes.

No diffs.

* Don't use types of location nodes

They're meaningless.

Couple small positive diffs from more folding taking place.

* Fold local struct field access to OBJ(ADDR(LCL_FLD))

Only when used by ASGs for now.

* Delete NO_LAYOUT

* Do not create handle-less OBJ nodes

Fixes the asserts uncovered by stress.

* Delete obsolete code

2 years ago[wasm-mt] Add coop GC transitions to various EMSCRIPTEN_KEEPALIVE functions; define...
Aleksey Kliger (λgeek) [Sun, 22 May 2022 17:31:45 +0000 (13:31 -0400)]
[wasm-mt] Add coop GC transitions to various EMSCRIPTEN_KEEPALIVE functions; define to noop if no threads (#69515)

* [wasm-mt] fix GC transition in mono_set_timeout_exec

   It's called from JS

* Add GC transitions to other EMSCRIPTEN_KEEPALIVE functions in the runtime

* define GC Safe / Unsafe macros to no-ops if DISABLE_THREADS is defined

   We don't need to do GC transitions if there's no threading since we won't ever suspend ourselves

2 years agoFix Create/StartActivity parentId nullability (#69636)
Stephen Halter [Sun, 22 May 2022 01:38:50 +0000 (18:38 -0700)]
Fix Create/StartActivity parentId nullability (#69636)

2 years agoStyle improvements for generated p/invokes (#69638)
Elinor Fung [Sat, 21 May 2022 18:42:41 +0000 (11:42 -0700)]
Style improvements for generated p/invokes (#69638)

- Remove '_gen` part of suffix
- Remove unnecessary braces in fixed block

2 years agoProfiler RequestReJITWithInliners did not work properly if all methods in the module...
David Wrighton [Sat, 21 May 2022 17:37:46 +0000 (10:37 -0700)]
Profiler RequestReJITWithInliners did not work properly if all methods in the module were not loaded (#69634)

- Add unused functions into rejit.cs test to expose the problematic behavior
- Fix by using tokens throughout the handling of R2R inlining information instead of converting to MethodDescs at times

2 years agoMove dead code removal in lower after last updategraph (#69421)
Kunal Pathak [Sat, 21 May 2022 15:14:39 +0000 (08:14 -0700)]
Move dead code removal in lower after last updategraph (#69421)

* Move dead code removal in lower after last updategraph

* Add back in non-optimizing

2 years agoFix IsSupported guard check for use of Ssse3.Shuffle in Span.Reverse (#69623)
Andy Ayers [Sat, 21 May 2022 15:06:50 +0000 (08:06 -0700)]
Fix IsSupported guard check for use of Ssse3.Shuffle in Span.Reverse (#69623)

We were checking for SSE2 support and then using SSSE3 instructions.

Fixes #68880.

2 years agoFix SystemNative_SendFile on iOS/tvOS devices (#69436)
Alexander Köplinger [Sat, 21 May 2022 09:00:51 +0000 (11:00 +0200)]
Fix SystemNative_SendFile on iOS/tvOS devices (#69436)

Even though the `sendfile()` function exists it causes a SIGSYS signal which crashes the process on devices whenever you use it (this doesn't happen on simulators).

Implement a read/write loop as a fallback to fix this, loosely based on CopyFile_ReadWrite in pal_io.c.

See similar issues in other projects:
- https://github.com/golang/go/commit/029dfbcc83123cb62e52f2aaedc46397815e3fa6
- https://github.com/ndfred/iperf-ios/issues/17

2 years agoUpdating to a version of Roslyn that contains the NumericIntPtr feature (#69627)
Tanner Gooding [Sat, 21 May 2022 04:54:11 +0000 (21:54 -0700)]
Updating to a version of Roslyn that contains the NumericIntPtr feature (#69627)

* Update MicrosoftNetCompilersToolsetVersion to 4.3.0-2.22270.2

* Updating IntPtr/UIntPtr and a handful of tests to handle the numeric-intptr feature

* Ensure IntPtr.TestExplicitCast and UIntPtr.TestExplicitCast correctly check the overflow exception

* Update the Microsoft.Dotnet.Compatibility analyzer to 2.0.0-preview.4.22252.4

* Updating the CompatibilitySuppressions for the NumericIntPtr feature

* Handle a difference in how the OverflowException is thrown for a reflected call on Mono

* Use Assert.ThrowsAny as that includes derived types for xUnit

2 years ago[wasm] CI build improvements (#69519)
Ankit Jain [Fri, 20 May 2022 22:18:01 +0000 (18:18 -0400)]
[wasm] CI build improvements (#69519)

- Run all the debugger tests in one helix job, because most of them take a couple of minutes to run. And this would avoid the overhead of individual helix jobs

- Add a no-workloads variant for `Wasm.Build.Tests`, instead of `EMSDK`
  - This replaces the job that used `WasmApp.LocalBuild*` stuff to build
with a `EMSDK` checkout. That case already gets tested with library tests.
   - The `EMSDK` case had been disabled recently due to an Arcade issue
  - Since we have very few tests to run for the noworkloads case, they are
all run in a single helix work item.

Fixes https://github.com/dotnet/runtime/issues/58159
Fixes https://github.com/dotnet/runtime/issues/67887 (by completely removing the `EMSDK` run)

2 years agoRefactoring which numeric interface exposes which methods to match latest API review...
Tanner Gooding [Fri, 20 May 2022 22:02:27 +0000 (15:02 -0700)]
Refactoring which numeric interface exposes which methods to match latest API review decisions (#69582)

* Refactoring which numeric interface exposes which methods to match latest API review decisions

* Refactoring the generic math tests to have a consistent order, allowing coverage to be more easily seen

* Adding test coverage for the APIs that were moved down to INumber and INumberBase

* Adding generic-math tests for System.Numerics.Complex

* Fixing some copy/paste issues that came about from resolving the Int128/UInt128 merge conflicts

2 years ago[main] Update dependencies from dotnet/linker (#69246)
dotnet-maestro[bot] [Fri, 20 May 2022 21:54:55 +0000 (14:54 -0700)]
[main] Update dependencies from dotnet/linker (#69246)

* Update dependencies from https://github.com/dotnet/linker build 20220511.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22261.1

* Update dependencies from https://github.com/dotnet/linker build 20220512.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22262.1

* Update dependencies from https://github.com/dotnet/linker build 20220513.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22263.1

* Update dependencies from https://github.com/dotnet/linker build 20220515.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22265.1

* Update dependencies from https://github.com/dotnet/linker build 20220516.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22266.1

* Update dependencies from https://github.com/dotnet/linker build 20220518.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22268.1

* Update dependencies from https://github.com/dotnet/linker build 20220519.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.22260.1 -> To Version 7.0.100-1.22269.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoGetTotalPauseDuration implementation (#68835)
Andrew Au [Fri, 20 May 2022 21:09:19 +0000 (14:09 -0700)]
GetTotalPauseDuration implementation (#68835)

2 years agoUse span to pass type modifiers in RuntimeTypeHandle.GetTypeHelper (#69425)
Huo Yaoyuan [Fri, 20 May 2022 19:31:10 +0000 (03:31 +0800)]
Use span to pass type modifiers in RuntimeTypeHandle.GetTypeHelper (#69425)

* Use span to pass type modifiers

* Use switch statement

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoZipFile UnixCreateSetsPermissionsInExternalAttributes test fails on Apple OSes (...
Eric Erhardt [Fri, 20 May 2022 18:56:49 +0000 (13:56 -0500)]
ZipFile UnixCreateSetsPermissionsInExternalAttributes test fails on Apple OSes (#69583)

* ZipFile UnixCreateSetsPermissionsInExternalAttributes test fails on Apple OSes

There are scenarios where chmod succeeds, but the OS clears certain bits, like S_ISGID and S_ISUID. When this happens, the ZipFile tests fail because the .zip file doesn't contain the expected ExternalAttributes.

To fix this, read the file mode after calling chmod, and update the expected file mode so the tests still pass.

Fix #68293
Fix #60581

* Fix the tests to expect the correct file name

2 years ago[wasm] improve memory access and marshaling range checks (#64845)
Pavel Savara [Fri, 20 May 2022 18:49:54 +0000 (20:49 +0200)]
[wasm] improve memory access and marshaling range checks (#64845)

* new memory accessors setI52, setI64Big, getI52, getI64Big
* removed support for long form automatic marshaler. It has impact to mono_bind_static_method
* made assert silent on Release config
* test for not marshaling long from C# to JS
* negative test for marshaling NaN as long
* fixed marshaling of uint32, uint16 and byte to be unsigned
* implemented range check on all set memory operations
* implemented also uint52
* differentiated bool marshaling because it shoud have different validation and message
* inlined asserts
* rename assert to mono_assert

2 years agoAdd `BStrStringMarshaller` to source generator (#69213)
Aaron Robinson [Fri, 20 May 2022 14:58:35 +0000 (07:58 -0700)]
Add `BStrStringMarshaller` to source generator (#69213)

* Add BStrStringMarshaller to source generator

* Convert to use void* for BStr and Utf16 marshallers' native types.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoAdd Stream ReadAtLeast and ReadExactly (#69272)
Eric Erhardt [Fri, 20 May 2022 14:20:06 +0000 (09:20 -0500)]
Add Stream ReadAtLeast and ReadExactly (#69272)

* Add Stream ReadAtLeast and ReadExactly

Adds methods to Stream to read at least a minimum amount of bytes, or a full buffer, of data from the stream.
ReadAtLeast allows for the caller to specify whether an exception should be thrown or not on the end of the stream.

Make use of the new methods where appropriate in net7.0.

Fix #16598

* Add ReadAtLeast and ReadExactly unit tests

* Add XML docs to the new APIs

* Preserve behavior in StreamReader.FillBuffer when passed 0.

* Handle ReadExactly with an empty buffer, and ReadAtLeast with minimumBytes == 0.

Both of these cases are a no-op. No exception is thrown. A read won't be issued to the underlying stream. They won't block until data is available.

2 years agoFix HTTP3 stress (#69182)
Radek Zikmund [Fri, 20 May 2022 10:46:48 +0000 (03:46 -0700)]
Fix HTTP3 stress (#69182)

* Build msquic locally

* Use IPv4 addresses only when testing HTTP3

* Code review changes

* fixup! Use IPv4 addresses only when testing HTTP3

* Make listening on IPv6Any accept IPv4 connections as well

* Minor changes

* Don't continue if runtime image build fails

* Switch to 1es-ubuntu-1804-open image

* Code review feedback

2 years agoEnable analyzers for System.Text.Json.SourceGeneration (#69581)
Stephen Toub [Fri, 20 May 2022 10:35:47 +0000 (06:35 -0400)]
Enable analyzers for System.Text.Json.SourceGeneration (#69581)

* Enable analyzers for System.Text.Json.SourceGeneration

* Fix another warning in release builds

2 years agoChange location where we output message about notification profilers being disabled...
David Mason [Fri, 20 May 2022 07:26:52 +0000 (00:26 -0700)]
Change location where we output message about notification profilers being disabled (#69538)

2 years agoavoid pulling Ssl internals to other assemblies (#69539)
Tomas Weinfurt [Fri, 20 May 2022 05:23:40 +0000 (22:23 -0700)]
avoid pulling Ssl internals to other assemblies (#69539)

2 years agoOptimize string.EndsWith(char) for const values (#69038)
Levi Broderick [Fri, 20 May 2022 05:21:16 +0000 (22:21 -0700)]
Optimize string.EndsWith(char) for const values (#69038)

2 years agoAdd NativeMemory.ZeroMemory API (#69500)
Sergio Pedri [Fri, 20 May 2022 04:32:05 +0000 (21:32 -0700)]
Add NativeMemory.ZeroMemory API (#69500)

* Add NativeMemory.ZeroMemory API

* Replace Random.NextBytes with Span<byte>.Fill

* Add ZeroMemory unit tests for zeroed region within buffer

* Add remarks for ptr and byteCount parameters

* Add test for ZeroMemory(null, 0) not throwing

* Add unit tests for zeroing memory with a size of 0

* Move test cases with 0 byte count to separate method

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoEnable analyzers for Microsoft.Extensions.Logging.Generators (#69579)
Stephen Toub [Fri, 20 May 2022 02:28:07 +0000 (22:28 -0400)]
Enable analyzers for Microsoft.Extensions.Logging.Generators (#69579)

2 years agofix GetContentAsync_ErrorStatusCode_ExpectedExceptionThrown test (#69228)
Tomas Weinfurt [Fri, 20 May 2022 01:06:58 +0000 (18:06 -0700)]
fix GetContentAsync_ErrorStatusCode_ExpectedExceptionThrown test (#69228)

* fix GetContentAsync_ErrorStatusCode_ExpectedExceptionThrown test

* feedback from ewview

2 years agomake sure socket is intialized before connecting TCPClient (#69540)
Tomas Weinfurt [Fri, 20 May 2022 01:05:49 +0000 (18:05 -0700)]
make sure socket is intialized before connecting TCPClient (#69540)

* make sure socket is intialized before connecting TCPClient

* feedback from review

2 years ago[RyuJIT] Emit shlx, sarx, shrx on x64 (#67182)
Julie Lee [Fri, 20 May 2022 00:51:27 +0000 (17:51 -0700)]
[RyuJIT] Emit shlx, sarx, shrx on x64 (#67182)

* Emit shlx, sarx, shrx: resolve merge conflict in emitxarch.cpp.

* Shrx: Swap operand and ShiftBy registers to swap rcx and rdx in correct order.

* Change only TYP_LONG to Shlx, Sarx and Shrx.

* Shlx, Sarx, Shrx test cases

* Shlx, sarx, shrx code clean-up

* Emit shlx, sarx, shrx: Enable 32 bit shifts and addressed feedback.

* [shlx/sarx/shrx] Addressed CR feedback.
  - Removed some tests from Arm/Arm64 due to a known undefined behavior
  - Excluded the test from Mono due to a known undefined behavior
  - Resolved merge conflict

* shlx, sarx, shrx: added ifdef to target x64 only

* shlx, sarx, shrx jit-format fix

* [shlx/sarx/shrx] Addressed feedback.

* [Emit shlx, sarx, shrx] addressed feedback on unit test

* [Emit shlx, sarx, shrx] Removed x86 unit tests.

* [Emit shlx, sarx, shrx] Remove 32bit test cases.

* [Emit shlx, sarx, shrx] Update a comment in lsraxarch.cpp

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
* [Emit shlx, sarx, shrx] Added uint, int, ushort and short test cases.

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
2 years agoIterative generic math changes to match API review (#69391)
Tanner Gooding [Thu, 19 May 2022 22:26:24 +0000 (15:26 -0700)]
Iterative generic math changes to match API review (#69391)

* Change GetShortestBitLength to return int and add WriteBigEndian APIs

* Add WriteExponentBigEndian and WriteSignificandBigEndian APIs

* Update System.Char to explicitly implement the numeric interfaces

* Ensure BigInteger.TryWriteBigEndian correctly offsets the address

* Fixing two usages of `var` in decimal

* Ensure lo64 is ulong and hi32 is uint

* Ensure Int128/UInt128 implement TryWriteBigEndian and return `int` for `GetShortestBitLength`

* Ensure that `GetByteCount` and `GetShortestBitLength` correctly handle the one's complement format

* Ensure the ReverseEndianness calls in TryWrite* for Int128/UInt128 are correct

* Ensure BigInteger.TryWriteLittleEndian has a correct assert

2 years agoEnable analyzers for regex generator project (#69564)
Stephen Toub [Thu, 19 May 2022 21:48:53 +0000 (17:48 -0400)]
Enable analyzers for regex generator project (#69564)

2 years agoFix dependencymodel typo (#69566)
Weihan Li [Thu, 19 May 2022 19:30:52 +0000 (03:30 +0800)]
Fix dependencymodel typo (#69566)

2 years agoLinux-bionic (Android libc w/o Android interop) initial implementation (#66147)
Jo Shields [Thu, 19 May 2022 19:27:40 +0000 (15:27 -0400)]
Linux-bionic (Android libc w/o Android interop) initial implementation (#66147)

Implement support for "Linux Bionic", a RID which builds a Linux runtime against an Android libc but without Android OS functions like JNI, Dalvik, Instrumentation, etc. This configuration has been requested by a team working on an IoT scenario.

* The new RID is linux-bionic-arm64/linux-bionic-x64.
* The build reuses the existing Android build dockerfiles and Helix queues
* Since we don't have JNI, we don't have Android Crypto - instead, use an Android build of OpenSSL. As an errata, it is incumbent upon the end user to supply this in their OS environment (we download one ad-hoc for testing purposes, which was compiled by Google)
* Some tests cannot be completed due to SELinux policies affecting the shell user executing tests via adb shell in the world-writable /data/local/tmp directory. We expect those tests would pass if they pass on Android, in a real-world IoT scenario with a custom OS (rather than recycling Google's OS images intended for phones)

Closes: #66027

2 years agoRevert "[main] Update dependencies from dotnet/arcade (#69126)" (#69535)
Matt Galbraith [Thu, 19 May 2022 16:33:45 +0000 (09:33 -0700)]
Revert "[main] Update dependencies from dotnet/arcade (#69126)" (#69535)

This reverts commit c481c04c279c22d9f0c6b496231470c356df0e6b.

2 years ago[mono][eventpipe] Implementing MethodDetails and BulkType events (#68571)
Mitchell Hwang [Thu, 19 May 2022 16:26:53 +0000 (12:26 -0400)]
[mono][eventpipe] Implementing MethodDetails and BulkType events (#68571)

* [coreclr]Extend lttngDataTypeMapping for mono

Writing arrays in generateWriteEventBody had not been previously hit on Mono.
With a goal of emitting MethodDetails events on Mono, lttngDataTypeMapping
needs to be extended to be compatible with mono types.

* [mono][eventpipe] Implement SendMethodDetailsEvents on mono

* [mono][eventpipe] Utilize method signature getter to avoid uncreated signature

* [mono][eventpipe] Implement BulkType on mono

* debug traces

* Address struct tab formatting feedback

* Address rg_type_parameter preallocated stack array size

* [mono][eventpipe] Add helper function to get mono type unique type identifier

* [mono][eventpipe] Differentiate MonoType and TypeID and pass separately

* Address array max rank feedback

* Address byte_count bug feedback

* Address Etw Type Flags feedback

* Address cor_element_type underlying type feedback

* Address logger instance and if_necessary feedback

* Fix s_name

* Cleanup comment tab spacing

* Address feedback

Fix bulk type event buffer

Fix mono type check

Fix mono type check

Clear bulk type event logger

Debug bulktype event firing

Fix tab bulktype firing

Fix fixed_sized_data byte copy

Address constants feedback

Add maximum event size constant
Add maximum bulk type value type parameters constant
Add maximum method type argument count constant

Fix typo

Address BulkType Value s_name type size feedback

Address softcode buffer size increment

Address switch case feedback

Address fixed sized array feedback

Fix spacing

Add init/fini for BulkTypeEventLogger and BulkTypeValue instances

Fix return type ep_rt_mono_log_single_type

Add get_typeid_for_class helper

Add assertion for large types

Fix lttng map

Use helper methods to write into bulk type event logger buffer

Fix typo ep_rt_mono_send_method_details_event definition

Change s_name to ep_char8_t and write with gunichar2

* Removed temporary debug traces

Set BulkTypeValue s_name to null for now

Fixed debug trace formatting for pointers

Fix type_name_id for types with no token

Remove write_event_buffer_intptr as the size is different on Windows x86

Rename ep_rt_bulk_type_value_init to ep_rt_bulk_type_value_clear

* Utilize macros for array size initialization

Cleanup formatting and style

Remove unused write_event_buffer_utf16_str

Add BulkTypeEventLogger pointer to function description

* [mono] Mark mono_class_has_finalizer as MONO_COMPONENT_API

* Set global static const to macros

Change ep_rt_mono_get_byte_count_in_event type

* Address feedback

Drop variable prefixes

Clear BulkTypeValue via memset

Rename bulk_type_event_logger helpers to alloc and free

Remove redundant bulk type value byte count calculation

Utilize memcpy to copy type parameter arrays

Reduce padding by moving bulk_type_event_buffer field in struct

* Change Event struct parameter _ElementSize type to size_t

* Remove parallel type id array to reduce bookkeeping and create type ids from mono types when needed

Change type id type from intptr_t to uint64_t as ids in eventpipe are standardized to uint64_t

* [mono][eventpipe] Add dedicated mempool for BulkTypeEventLogger to dynamically allocate enough space for type parameters

* Revert "Change Event struct parameter _ElementSize type to size_t"

This reverts commit 87f87f2f93457bed292d979668dbad01beb1e5f1.

* Fix write_event_buffer parameter type to avoid C4267 error on windows

* Move mem_pool under BulkTypeEventLogger

2 years agoAllocate less with X500DistinguishedName
Kevin Jones [Thu, 19 May 2022 16:22:12 +0000 (12:22 -0400)]
Allocate less with X500DistinguishedName

This cleanup happens to break parsing strings like OID.STREET=something on macOS and Linux, which was not an intentional feature.

It's not expected that this functionality was ever utilized, and it doesn't work on Windows (or .NET Framework).

2 years agoUpdate libraries build instructions on Unix (#69553)
Adeel Mujahid [Thu, 19 May 2022 15:16:52 +0000 (18:16 +0300)]
Update libraries build instructions on Unix (#69553)

Delete platform specific ones which are no longer relavant to this
repository.

2 years agoCorrect MSVC version in requirements documentation (#68078)
Jerry King [Thu, 19 May 2022 15:03:41 +0000 (11:03 -0400)]
Correct MSVC version in requirements documentation (#68078)

* Correct MSVC version in requirements documentation

* Fix version constraint

2 years agoFix check in test for output on unhandled exception (#69528)
Elinor Fung [Thu, 19 May 2022 14:46:45 +0000 (07:46 -0700)]
Fix check in test for output on unhandled exception (#69528)

2 years agoMake superpmi.py collect easier to use (#69487)
Jakob Botsch Nielsen [Thu, 19 May 2022 13:17:58 +0000 (15:17 +0200)]
Make superpmi.py collect easier to use (#69487)

* Add COMPlus_JitPath variable in debug/checked builds and use it from SuperPMI

* Do not change current dir for SPMI collections

2 years agoAdd AppContext data support for DefaultMaxConnectionsPerServer (#68952)
Radek Zikmund [Thu, 19 May 2022 12:47:46 +0000 (14:47 +0200)]
Add AppContext data support for DefaultMaxConnectionsPerServer (#68952)

* Add AppContext data support for DefaultMaxConnectionsPerServer

* Move code to GlobalHttpSettings

* Rename the switch

* Fix build

* Fix build of System.Net.Http.WinHttpHandler

* Remove changes from WinHttpHandler

* Cleanup

* Merge new GlobalHttpSettings into SocketsHttpHandler inner class

* Code review feedback

2 years agoClean up code for CPU_Group_Info structs (#69533)
Anton Lapounov [Thu, 19 May 2022 06:23:17 +0000 (23:23 -0700)]
Clean up code for CPU_Group_Info structs (#69533)

2 years agoAdding Int128 and UInt128 with a base software implementation (#69204)
Tanner Gooding [Thu, 19 May 2022 04:41:17 +0000 (21:41 -0700)]
Adding Int128 and UInt128 with a base software implementation (#69204)

* Adding barebones Int128 and UInt128 structs

* Special case Int128 and UInt128 alignment on x64 Unix and Arm64

* Implementing Int128 and UInt128

* Adding tests for Int128 and UInt128

* Updating Int128/UInt128 to respect the System V ABI ordering

* Fixing an issue with UInt128->BigInteger setting the wrong sign

* Don't use Unsafe.As in the Int128/UInt128 hex parsing logic

* Adding Int128 P/Invoke tests and ensure R2R correctly sets the packing

* Fixing some issues with the Int128 interop test for non-Windows

* Ensure that floating-point conversions exist for Int128 and UInt128

* Fixing the casing of a couple fields

* Revert "Don't use Unsafe.As in the Int128/UInt128 hex parsing logic"

This reverts commit 09e8bfc52d5b1b7f7b341f318bf1046b19768dd3.

* Adjusting the Int128/UInt128 generic math tests to have consistent ordering

* Responding to PR feedback

* Ensure that pNativeLayoutInfo alignment is initialized for Int128/UInt128

* Don't use Unsafe.As in the Int128/UInt128 hex parsing logic

* Skip the Interop/PInvoke/Int128 tests on Mono

2 years agoUse span instead of array in PublicKey
Kevin Jones [Thu, 19 May 2022 03:00:38 +0000 (23:00 -0400)]
Use span instead of array in PublicKey

2 years agoRun host tests with dotnet test and enable crash/hang dumps (#69340)
Elinor Fung [Thu, 19 May 2022 02:02:11 +0000 (19:02 -0700)]
Run host tests with dotnet test and enable crash/hang dumps (#69340)

2 years agoDo not automatically mark Stephen Toub as the issue triager or PR champion (#69452)
Jeff Handley [Thu, 19 May 2022 01:11:08 +0000 (18:11 -0700)]
Do not automatically mark Stephen Toub as the issue triager or PR champion (#69452)

2 years ago[wasm-ep] Minimal diagnostic tracing configuration and sample (#69158)
Aleksey Kliger (λgeek) [Thu, 19 May 2022 00:27:44 +0000 (20:27 -0400)]
[wasm-ep] Minimal diagnostic tracing configuration and sample (#69158)

* Adds a `/p:WasmEnablePerfTracing=true` configuration.

   In this configuration the runtime is built with threading (`MonoWasmThreads` property is true), but user C# code is not allowed to start threads and doesn't use the portable threadpool (`MonoWasmThreadsNoUser` property is also true).

   The upshot is that EventPipe can start threads but user code is still single-threaded.

* Adds a `MONO.diagnostics` interface in JavaScript.  There's a single method for now `createEventPipeSession` which creates a session that can save a trace to a file on the virtual file system.  JS code (or a user in a dev console) needs to call `start()` and `stop()` on the session object to begin collecting samples.    The data is saved temporarily to the Emscripten VFS and can be retrived into a JavaScript Blob (and from there downloaded to a file outside the browser).

* Adds a sample that runs an async task for five seconds and collects samples and then triggers a `click()` to download the trace file out of the browser.

* Adds a TS module to help with working with uint64_t values in the emscripten heap.

* Exposes empscripten Module.stackSave, stackRestore and stackAlloc operations to the runtime TS modules.  Use for working with event pipe session ID outparam.

---

* add DISABLE_WASM_USER_THREADS mono cmake option

* Disable Thread.StartInternal icall if DISABLE_WASM_USER_THREADS

   if threading is enabled for the runtime internally, but disabled for user code, throw PNSE

* add an eventpipe sample

* [wasm-ep] (browser-eventpipe sample) run loop for longer

* [samples/wasm-eventpipe] make an async task sample

   change the sample to do some work asynchronously using setTimeout instead of blocking

* [wasm] Add MONO.diagnostics interface

   Binds enable, start, disable methods defaulting to non-streaming FILE mode

* if wasm threads are disabled, but perftracing is enabled, don't log overlapped io events

* fix whitespace and nits

* don't need try/finally in the sample anymore

* more whitespace

* add start method to EventPipeSession interface

* don't run wasm-eventpipe sample on CI lanes without perftracing

* more whitespace

* fix eslint warnings, default rundown to true, allow callback for traceFilePath option

* add EventPipeSession.getTraceBlob

   for retrieving the collected traces instead of exposing the emscripten VFS directly.

   update the sample to use URL.createObjectURL (session.getTraceBlob()) to create the download link

* [browser-eventpipe sample] remove unnecessary ref assemblies

* use ep_char8_t for C decls of event pipe wasm exports

* Use stack allocation for temporaries

   Expose the emscripten stack allocation API

* Use 32-bit EventPipe session ID on WASM

   64 bit integers are awkward to work with in JavaScript.

   The EventPipe session ID is derived from a pointer address, so even though it is nominally a 64-bit value, in practice the top bits are zero.

   Use a 32-bit int to represent the session ID on the javascript side and convert to 64-bit in C when calling down to the EventPipe APIs

* Make the sample do more work in managed

   give the sample profiler some non-empty samples to collect

* Move withStackAlloc to memory.ts

* simplify VFS .nettrace file naming

   Just use consecutive integers to uniquify the session traces.  Dont' need a fancy timestamp in the VFS (which would also not be unique if you create sessions below the timestamp resolution)

* Add overloads to memory.withStackAlloc to avoid creating closures

   Pass additional arguments to the callback function

* sample: explain why there's a 10s pause

* move createEventPipeSession callback to a function

   ensures the closure is created once

* Use a tuple type for withStackAlloc

* use unsigned 32-bit get/set in cuint64 get/set

* fix whitespace

2 years agoUse shared settings for enabling analyzers in LibraryImportGenerator (#69511)
Elinor Fung [Wed, 18 May 2022 23:27:38 +0000 (16:27 -0700)]
Use shared settings for enabling analyzers in LibraryImportGenerator (#69511)

2 years agoDisable nativeruntimeeventsource test on unix arm and arm64 (#69510)
John Salem [Wed, 18 May 2022 23:04:03 +0000 (16:04 -0700)]
Disable nativeruntimeeventsource test on unix arm and arm64 (#69510)

2 years agoJIT: Abandon loop search if we are about to walk off end of the bbNext chain (#69503)
Andy Ayers [Wed, 18 May 2022 22:44:06 +0000 (15:44 -0700)]
JIT: Abandon loop search if we are about to walk off end of the bbNext chain (#69503)

In #69323 the 6.0.4 jit caused an AV because it walked off the end of the
bbNext chain during `optFindNaturalLoops`.

Analysis of a customer-provided dump showed that `MakeCompactAndFindExits`
might fail to find an expected loop block and so walk the entire bbNext chain
and then fall off the end. Details from the dump suggested that this happened
because a prior call to `MakeCompactAndFindExits` had moved most but not all of
a loop's blocks later in bbNext order, leaving that loop's bottom block earlier
in the bbNext chain then it's top. This ordering was unexpected.

I cannot repro this failure. The customer was using PGO and it's likely that
earlier PGO-driven block reordering contributed to this problem by interleaving
the blocks from two loops. We can recover the root method PGO schema from the
dump, but applying this is insufficient to cause the problem. This method does
quite a bit of inlining so it's likely that some inlinee PGO data must also be
a contributing factor.

At any rate, we can guard against this case easily enough, and simply abandon
recognition of any loop where we fail to find an expected loop block during
the bbNext chain walk.

2 years agoExpand the GC hole fix for explicitly initialized structs (#69501)
SingleAccretion [Wed, 18 May 2022 20:40:46 +0000 (23:40 +0300)]
Expand the GC hole fix for explicitly initialized structs (#69501)

* Expand the fix for explicitly initialized structs

Liveness code already recognizes that it cannot delete certain local
stores with the implicit side effect of "explicit initialization".

However, it was only doing that for indirect "InitBlk" forms, while
the store can have more or less arbitrary shape (the only requirement
is that is must be "entire").

Fix this by not constraining the check to "InitBlk"s.

* Add a test

2 years agoMinor cleanup and reduce allocations in managed X.509 certificate PAL
Kevin Jones [Wed, 18 May 2022 19:52:18 +0000 (15:52 -0400)]
Minor cleanup and reduce allocations in managed X.509 certificate PAL

Removes a few allocations, pre-sizes a list to the correct size, and remove redundant debugging code.

2 years agoFix data race on incoming MsQuicStream abort event (#69483)
Radek Zikmund [Wed, 18 May 2022 16:15:20 +0000 (18:15 +0200)]
Fix data race on incoming MsQuicStream abort event (#69483)

* Fix data race on MsQuicStream abort

* fixup! Fix data race on MsQuicStream abort

2 years agoAdd more char.Is* helpers for common ASCII sets (#69318)
Stephen Toub [Wed, 18 May 2022 15:04:39 +0000 (11:04 -0400)]
Add more char.Is* helpers for common ASCII sets (#69318)

* Add more char.Is helpers for common ASCII sets

* Fix hex tests

2 years agoFixing problem for decimals. (#66979)
Ilona Tomkowicz [Wed, 18 May 2022 14:33:42 +0000 (16:33 +0200)]
Fixing problem for decimals. (#66979)

2 years agoAdd current-outgoing-connect-attempts counter to Sockets (#66651)
Miha Zupan [Wed, 18 May 2022 14:01:15 +0000 (16:01 +0200)]
Add current-outgoing-connect-attempts counter to Sockets (#66651)

* Add current-outgoing-connect-attempts counter to Sockets

* Use instance methods, add early exit to hot path

* Add comment about Accept/Connect check

* Fix race in test

2 years ago[wasm] Give is_nullish() a type guard type (#69473)
Aleksey Kliger (λgeek) [Wed, 18 May 2022 12:43:46 +0000 (08:43 -0400)]
[wasm] Give is_nullish() a type guard type (#69473)

* [wasm] Give is_nullish() a type guard type

allow callers to refine the type of the argument to just `T` on the false
brach

```
let obj: number | null | undefined = ...
if (is_nullish (obj))
   return;
// otherwise obj is known to TS to be 'number'.
```

2 years ago[monoapi] Add MONO_IMAGE_NOT_SUPPORTED to MonoImageOpenStatus (#69062)
Aleksey Kliger (λgeek) [Wed, 18 May 2022 12:42:58 +0000 (08:42 -0400)]
[monoapi] Add MONO_IMAGE_NOT_SUPPORTED to MonoImageOpenStatus (#69062)

* [monoapi] Add MONO_IMAGE_NOT_SUPPORTED to MonoImageOpenStatus

Use it as a return value for public API functions that pass `ref_only` set to `TRUE`.  We don't support opening assemblies for reflection-only in .NET 6+

2 years ago[main] Update dependencies from dotnet/arcade (#69126)
dotnet-maestro[bot] [Wed, 18 May 2022 12:24:33 +0000 (14:24 +0200)]
[main] Update dependencies from dotnet/arcade (#69126)

* Update dependencies from https://github.com/dotnet/arcade build 20220509.5

Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.GenAPI , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.GenFacades , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk
 From Version 2.5.1-beta.22255.2 -> To Version 2.5.1-beta.22259.5

* Update dependencies from https://github.com/dotnet/arcade build 20220510.2

Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.GenAPI , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.GenFacades , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk
 From Version 2.5.1-beta.22255.2 -> To Version 2.5.1-beta.22260.2

* Update dependencies from https://github.com/dotnet/arcade build 20220511.14

Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.GenAPI , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.GenFacades , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk
 From Version 2.5.1-beta.22255.2 -> To Version 2.5.1-beta.22261.14

* Update dependencies from https://github.com/dotnet/arcade build 20220512.8

Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.GenAPI , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.GenFacades , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk
 From Version 2.5.1-beta.22255.2 -> To Version 2.5.1-beta.22262.8

* Update dependencies from https://github.com/dotnet/arcade build 20220516.1

Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.GenAPI , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.GenFacades , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk
 From Version 2.5.1-beta.22255.2 -> To Version 2.5.1-beta.22266.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Marek Safar <marek.safar@gmail.com>
2 years agoDo not print anything to stderr running SCD app without deps.json (#69314)
Vitek Karas [Wed, 18 May 2022 11:07:16 +0000 (04:07 -0700)]
Do not print anything to stderr running SCD app without deps.json (#69314)

When we're running self-contained app the `hostfxr` tries to figure out the location of `hostpolicy.dll`. This is done also by looking into the `.deps.json` for the app (which should have a record for `hostpolicy.dll` in it). If the file is missing the code will move on and find the `hostpolicy.dll` in the app's folder, but it will also print out a message to stderr.

This means that running such app will actually work, but the host outputs a message to stderr - effectively "corrupting" the app's own output.

Note that this doesn't affects framework dependent apps without `.deps.json` since they look into the framework's `.deps.json` for `hostpolicy.dll`.

2 years agoDisable System.Reflection tests on NativeAOT (#69477)
Jan Kotas [Wed, 18 May 2022 10:44:45 +0000 (03:44 -0700)]
Disable System.Reflection tests on NativeAOT (#69477)

Workarounds #69476

2 years agoFix several regex loop issues (#69413)
Stephen Toub [Wed, 18 May 2022 10:04:15 +0000 (06:04 -0400)]
Fix several regex loop issues (#69413)

* Fix several regex loop issues

1. Atomic greedy loop stack fixing.  We were leaving some state on the backtracking stack after an atomic greedy loop successfully matched; if an earlier construct needed to pop something from the stack, it could end up getting state from that loop rather than its own.
2. Lazy loop backtracking pos.  When a lazy loop backtracks to add an additional iteration, it needs to pick up where the previous iteration left off, but it wasn't properly storing/restoring the pos.
3. Improve RightToLeft (lookbehind) backreference matching.  This wasn't broken, but it was unnecessarily complex and making the resulting code harder to debug through.  This only affects the source generator, as RegexCompiler uses slightly different codegen due to also handling IgnoreCase.
4. Reuse loop logic for repeater atomic lazy loops.  Atomic lazy loops end up being functionally identical to the equivalent greedy loop due to having the lazy upper bound lowered to the lazy lower bound.  We can consolidate the implementations to avoid duplication.
5. .* Singeline loop in RightToLeft (lookbehind).  Mainly to reduce the noise while investigating these issues, but it avoids an unnecessary loop.

* Address PR feedback

2 years agoARM64 - Do not emit possible DIV_BY_ZERO/OVERFLOW exception blocks for non-zero/non...
Will Smith [Wed, 18 May 2022 08:03:39 +0000 (01:03 -0700)]
ARM64 - Do not emit possible DIV_BY_ZERO/OVERFLOW exception blocks for non-zero/non-(negative one) constants (#68945)

* Do not emit possible DIV_BY_ZERO exception for non-zero constants

* Added overflow check

* Added second divzero check change

* Update morph.cpp

* Update morph.cpp

2 years agoDelete securitywrapper/securityutil (#69468)
Elinor Fung [Wed, 18 May 2022 04:10:31 +0000 (21:10 -0700)]
Delete securitywrapper/securityutil (#69468)

2 years agoSpanify some Windows X.509 PAL and improve formatting
Kevin Jones [Wed, 18 May 2022 03:05:40 +0000 (23:05 -0400)]
Spanify some Windows X.509 PAL and improve formatting

2 years agoUse Rfc3279DerSequence for signatures in ECDsaX509SignatureGenerator
Kevin Jones [Wed, 18 May 2022 02:51:29 +0000 (22:51 -0400)]
Use Rfc3279DerSequence for signatures in ECDsaX509SignatureGenerator

2 years agoAdd comment about PipeReader.ReadAtLeastAsync(0) (#69217)
William Godbe [Tue, 17 May 2022 22:44:56 +0000 (15:44 -0700)]
Add comment about PipeReader.ReadAtLeastAsync(0) (#69217)

* Add comment about PipeReader.ReadAtLeastAsync(0)

* Update PipeReader.cs

* Update PipeReader.cs

* Update PipeReader.cs

* Fixup

2 years agoUOH alloc fix for hardlimit (#69345)
Maoni Stephens [Tue, 17 May 2022 22:27:01 +0000 (15:27 -0700)]
UOH alloc fix for hardlimit (#69345)

2 years agoArm64: Make unroll code for cpblk non-interruptible (#69202)
Kunal Pathak [Tue, 17 May 2022 22:20:31 +0000 (15:20 -0700)]
Arm64: Make unroll code for cpblk non-interruptible (#69202)

* make unroll code non-interruptible

* jit format

* Disable GC only in specific scenarios:

* add a comment

2 years agoReuse the throw away buffer in ZipHelper (#69439)
Eric Erhardt [Tue, 17 May 2022 22:01:04 +0000 (17:01 -0500)]
Reuse the throw away buffer in ZipHelper (#69439)

* Reuse the throw away buffer in ZipHelper

ZipHelper.AdvanceToPosition was allocating a new temporary buffer every time through the loop while reading from the stream. Changing the code to reuse the same buffer through the loop.

2 years ago#69424 disabled failing equals nan tests on tvos (#69429)
Meri Khamoyan [Tue, 17 May 2022 20:30:53 +0000 (00:30 +0400)]
#69424 disabled failing equals nan tests on tvos (#69429)

Disabling failing tests on tvos for issue #69424

2 years agoFix executable memory reservation when range is not requested (#69430)
Jan Vorlicek [Tue, 17 May 2022 20:22:14 +0000 (22:22 +0200)]
Fix executable memory reservation when range is not requested (#69430)

The VMToOSInterface::ReserveDoubleMappedMemory on Unix currently
doesn't use the range of memory reserved for executable purposes
in PAL in case there was no specific range of memory requested.
This is incorrect and it leads to steady state performance
degradation when W^X is enabled.

This change fixes it by using the PAL reserved memory even for
requests without specified range. This makes the steady state
performance the same both with and without W^X enabled.
This is very well visible on the Orchards and Fortunes benchmarks
performance where the regression was 17% resp 12% with W^X enabled.

2 years agoWasm conditional audit + remove CompileFunction (#69283)
Katelyn Gadd [Tue, 17 May 2022 20:05:05 +0000 (13:05 -0700)]
Wasm conditional audit + remove CompileFunction (#69283)

* Revise some if statements that implicitly treat the empty string as null
Add is_nullish utility function
Fix string decoder's handling of empty strings and query of string length
* Fix some uses of the logical or operator
* Remove unused CompileFunction interop API

2 years agoWrap exceptions from array constructors in TargetInvocationException (#69440)
Jan Kotas [Tue, 17 May 2022 19:21:16 +0000 (12:21 -0700)]
Wrap exceptions from array constructors in TargetInvocationException (#69440)

Fixes #69336

2 years ago[mono] Fix a crash during stack trace construction if a this object is null. (#69292)
Zoltan Varga [Tue, 17 May 2022 18:42:16 +0000 (14:42 -0400)]
[mono] Fix a crash during stack trace construction if a this object is null. (#69292)

Fixes https://github.com/dotnet/runtime/issues/67354.

2 years agoReduce max shared memory object name length (#68541)
Adam Sitnik [Tue, 17 May 2022 18:27:52 +0000 (20:27 +0200)]
Reduce max shared memory object name length (#68541)

* reduce max shared memory object name to 30

* use the fallback to be 100% safe

2 years agoRevert "Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)" (#69442)
Carlos Sanchez [Tue, 17 May 2022 17:37:21 +0000 (10:37 -0700)]
Revert "Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)" (#69442)

This reverts commit 54083237da17f8ce04a98bf70ddd716d604ce628.

2 years ago[wasm][debugger] Extract the main run loop from DevToolsClient, and (#69219)
Ankit Jain [Tue, 17 May 2022 17:01:00 +0000 (13:01 -0400)]
[wasm][debugger] Extract the main run loop from DevToolsClient, and (#69219)

* [wasm][debugger] Extract the main run loop from DevToolsClient, and

.. DevToolsProxy into a separate class, which would allow having the
same features, and having only one place for the fixes.

* Fix harness tests

* fix merge error

2 years agoAdd clang 14 to known compiler versions. (#69249)
Tom Deseyn [Tue, 17 May 2022 16:34:49 +0000 (18:34 +0200)]
Add clang 14 to known compiler versions. (#69249)

* Add clang 14 to known compiler versions.

* NativeExports: strip 'unknown compiler' and other stderr output when determining compiler path.

2 years agoSupport ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`. (#69378)
Theodore Tsirpanis [Tue, 17 May 2022 16:31:36 +0000 (19:31 +0300)]
Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`. (#69378)

* Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`.
Fixes #68309.
A test case was added.

2 years agoremove duplicate Connect logic from TcpClient (#67951)
Tomas Weinfurt [Tue, 17 May 2022 16:22:41 +0000 (09:22 -0700)]
remove duplicate Connect logic from TcpClient (#67951)

2 years agoFix for GetMemberWithSameMetadataDefinitionAs (#69284)
Lakshan Fernando [Tue, 17 May 2022 14:28:28 +0000 (07:28 -0700)]
Fix for GetMemberWithSameMetadataDefinitionAs (#69284)

* Test fix for GetMemberWithSameMetadataDefinitionAs

* get reflection tests clean

* add doc info to test a library in native aot

2 years agoFixed work with QUIC_BUFFER (#69351)
Marie Píchová [Tue, 17 May 2022 14:17:47 +0000 (16:17 +0200)]
Fixed work with QUIC_BUFFER (#69351)

2 years agoAdd some assertions to Stream.Read in System.Text.Encoding.CodePages (#69414)
Eric Erhardt [Tue, 17 May 2022 13:27:07 +0000 (08:27 -0500)]
Add some assertions to Stream.Read in System.Text.Encoding.CodePages (#69414)

* Add some assertions to Stream.Read in System.Text.Encoding.CodePages

BaseCodePageEncoding is relying on Stream.Read to read a full buffer of data in a single read. This is safe to assume because the only stream ever used is an UnmanagedMemoryStream, which will just copy the data to the buffer.

Adding some asserts to the code to make this assumption explicit.

2 years agoMake json source generation cancellable (#69332)
CyrusNajmabadi [Tue, 17 May 2022 13:19:12 +0000 (06:19 -0700)]
Make json source generation cancellable (#69332)

* Make json generation cancellable

* Simplify

* no var

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
2 years agoOptimize ManifestResourceStream.Read(Span<byte>) (#69412)
Eric Erhardt [Tue, 17 May 2022 10:55:34 +0000 (05:55 -0500)]
Optimize ManifestResourceStream.Read(Span<byte>) (#69412)

ManifestResourceStream is derived from UnmanagedMemoryStream. UnmanagedMemoryStream optimizes Read(Span<byte>), but only if the instance is concretely an UnmanagedMemoryStream. This is to protect in case the derived Stream overriddes Read(byte[], int, int) prior to the Read(Span<byte>) overload being introduced.

Optimize ManifestResourceStream by overriding Read(Span<byte>) and call ReadCore, so the Stream.Read(Span<byte>) logic of using a pooled byte[] buffer isn't used.

2 years agoAllow the inliner to substitute for small arguments (#69068)
Jakob Botsch Nielsen [Tue, 17 May 2022 10:19:18 +0000 (12:19 +0200)]
Allow the inliner to substitute for small arguments (#69068)

Since we no longer have contextual nodes to indicate small arguments,
this should be safe to do. For register arguments it does not matter and
for stack arguments it is handled in codegen (for macOS arm64).

2 years agoUse intrinsic for genLog2() (#69333)
Kunal Pathak [Tue, 17 May 2022 03:30:02 +0000 (20:30 -0700)]
Use intrinsic for genLog2() (#69333)

* Use intrinsic for genLog2()

* Use correct macro

* Fix non-msvc build

* fix 32-bit build

* just do for TARGET_64BIT

* Review comments

2 years agoAddress some System.Formats.Tar TODOs (infra and syscalls) (#69107)
Carlos Sanchez [Tue, 17 May 2022 02:45:30 +0000 (19:45 -0700)]
Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)

* Fix Design time build errors by removing src project as dependency of the test project.

* Add Browser to target platform identifiers. Ensure Browser can consume the Unix specific ArchivingUtils file too.

* Remove nullable enable from csproj since it's now default

* Use FileStream constructor with FileMode.CreateNew to detect and throw if destination file exists when creating archive.

* No error checking on syscalls that do not set errno.

* Add RDev field in FileStatus and retrieve it with stat/lstat so devmajor and devminor get their correct values.

* Simplify some File.Open calls with direct FileStream constructor calls. Simplify FileStreamOptions objects too.

* Implement and consume p/invokes to retrieve uname from uid and gname from gid.

* size_t variables should not be checked for negative values

* FileStream calls simplified to File.OpenRead

* Remove check for RDev > 0

* Use dictionary to preserve repeated unames and gnames mapped to uids and gids

* Missing documentation in pal_uid.h new PALEXPORT methods.

* Adjust syscalls to thread-safe ones. Start with stackalloc, then use loop.

* Make dicts readonly and non-nullable, use TryGetValue

* Reuse 'GetNameFromUid' from pal_networking.c, move to pal_uid.c, use similar logic for Gid method. Simplify Interop.Sys method.

* Remove unnecessary comment

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
* Put TargetFrameworks back in the first position of the PropertyGroup.

* Address eerhardt suggestions

* Update src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs

* Clarify in pal_uid.h methods comments that new memory is returned

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
2 years agoDelete ClrDirectoryEnumerator (#69400)
Adeel Mujahid [Tue, 17 May 2022 01:43:57 +0000 (04:43 +0300)]
Delete ClrDirectoryEnumerator (#69400)

* Delete unused PAL functions

* Delete ClrDirectoryEnumerator

2 years agoAdd support for marshalling signed/unsigned boolean types. (#69402)
Aaron Robinson [Tue, 17 May 2022 01:38:26 +0000 (18:38 -0700)]
Add support for marshalling signed/unsigned boolean types. (#69402)

2 years agoCleanup some X509 PAL allocations
Kevin Jones [Tue, 17 May 2022 00:33:55 +0000 (20:33 -0400)]
Cleanup some X509 PAL allocations

2 years agoAdd correct assembly context name to InvalidCastException message (#69346)
Jan Kotas [Mon, 16 May 2022 23:57:47 +0000 (16:57 -0700)]
Add correct assembly context name to InvalidCastException message (#69346)

* Add correct assembly context name to InvalidCastException message

Fixes #69341

* Move GetNameForDiagnostics to assemblybinder.cpp/assemblybinder.h

2 years agoFix LibraryImportGenerator.UnitTests.Compiles.ValidateSnippetsFallbackForwarder ...
Elinor Fung [Mon, 16 May 2022 23:23:34 +0000 (16:23 -0700)]
Fix LibraryImportGenerator.UnitTests.Compiles.ValidateSnippetsFallbackForwarder (#69398)

2 years agoFix ASAN violation under Samsung's netcoredbg (#69339)
Mike McLaughlin [Mon, 16 May 2022 22:11:36 +0000 (15:11 -0700)]
Fix ASAN violation under Samsung's netcoredbg (#69339)

* Fix ASAN violation under Samsung's netcoredbg

Fixes issue https://github.com/dotnet/runtime/issues/62281

The wrong holder was being used in DacDbiInterfaceImpl::GetNativeVarData(); change to NewArrayHolder.

Added new/delete operators to Exception so when it is thrown from the DAC and caught/deleted in DBI, the
correct C++ allocator is used. When the DAC is called by DBI, g_pAllocator points to the DBI allocator.

* Code review feedback