Repository navigation
Closed
Labels
arch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
Failure in libraries test System.Private.Uri.Tests:
public void Ctor_String_String_Int_String_String(string schemeName, string hostName, int port, string pathValue, string extraValue, string expectedScheme, string expectedHost, string expectedPath, string expecte
Query, string expectedFragment)
{
var uriBuilder = new UriBuilder(schemeName, hostName, port, pathValue, extraValue);
VerifyUriBuilder(uriBuilder, expectedScheme, "", "", expectedHost, port, expectedPath, expectedQuery, expectedFragment);
}
e.g.:
c:\bugs\System.Private.Uri.Functional.Tests\net5.0-Release>"C:\bugs\testhost\dotnet.exe" exec --runtimeconfig System.Private.Uri.Functional.Tests.runtimeconfig.json --depsfile System.Private.Uri.Functional.Tests.deps.json xunit.console.dll System.Private.Uri.Functional.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing -parallel none -maxthreads 1 -method "*.Ctor_String_String_Int_String_String"
Discovering: System.Private.Uri.Functional.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Private.Uri.Functional.Tests (found 1 of 382 test case)
Starting: System.Private.Uri.Functional.Tests (parallel test collections = off, max threads = 1)
System.PrivateUri.Tests.UriBuilderTests.Ctor_String_String_Int_String_String(schemeName: "http", hostName: "host", port: 0, pathValue: "/path", extraValue: "?query#fragment", expectedScheme: "http", expectedHost: "host", expectedPath: "/path", expectedQuery: "?query", expectedFragment: "#fragment") [FAIL]
Assert.Equal() Failure
� (pos 0)
Expected: #fragment
Actual: /path
� (pos 0)
Stack Trace:
C:\gh\runtime\src\libraries\System.Private.Uri\tests\FunctionalTests\UriBuilderTests.cs(391,0): at System.PrivateUri.Tests.UriBuilderTests.VerifyUriBuilder(UriBuilder uriBuilder, String scheme, String userName, String password, String host, Int32 port, String path, String query, String fragment)
System.PrivateUri.Tests.UriBuilderTests.Ctor_String_String_Int_String_String(schemeName: "HTTP", hostName: "host", port: 20, pathValue: "/path1/path2", extraValue: "?query&query2=value#fragment", expectedScheme: "http", expectedHost: "host", expectedPath: "/path1/path2", expectedQuery: "?query&query2=value", expectedFragment: "#fragment") [FAIL]
JIT generates a tailcall to VerifyUriBuilder. It needs to copy 3rd stack argument arg10 to be the 1st stack argument of the tailcall. It moves the argument on the stack, trashing the stack argument arg8 before it is loaded into a register for the tailcall.
G_M8925_IG03: ; offs=000064H, size=0034H, bbWeight=1 PerfScore 14.00, nogc, extend
IN000d: 000064 ldr x20, [fp,#96] // [V10 arg10]
IN000e: 000068 str x20, [fp,#80] // [V08 arg8]
IN000f: 00006C movz x2, #0x3060
IN0010: 000070 movk x2, #0xd0a0 LSL #16
IN0011: 000074 movk x2, #487 LSL #32
IN0012: 000078 ldr x3, [x2]
IN0013: 00007C mov x2, x3
IN0014: 000080 mov x0, x26
IN0015: 000084 mov x1, x24
IN0016: 000088 mov x4, x25
IN0017: 00008C mov w5, w19
IN0018: 000090 ldr x6, [fp,#80] // [V08 arg8]
*************** reading the already trashed expectedPath!
IN0019: 000094 ldr x7, [fp,#88] // [V09 arg9]
G_M8925_IG04: ; offs=000098H, size=0018H, bbWeight=1 PerfScore 6.00, epilog, nogc, extend
IN0027: 000098 ldp x25, x26, [sp,#64]
IN0028: 00009C ldp x23, x24, [sp,#48]
IN0029: 0000A0 ldp x21, x22, [sp,#32]
IN002a: 0000A4 ldp x19, x20, [sp,#16]
IN002b: 0000A8 ldp fp, lr, [sp],#80
IN002c: 0000AC b System.PrivateUri.Tests.UriBuilderTests:VerifyUriBuilder(System.UriBuilder,System.String,System.String,System.String,System.String,int,System.String,System.String,System.String)
Metadata
Metadata
Assignees
Labels
arch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Activity
BruceForstall commentedon May 23, 2020
Here is a standalone repro:
You need to run it with
JitNoInline is needed because the inliner gets in the way of tailcall.
BruceForstall commentedon May 23, 2020
We have the following IR:
Notice that for the tailcall arguments (the fast tailcall to
VerifyUriBuilder), the last three are incoming stack arguments toCtor_String_String_Int_String_Stringbut are unused in the first call (toUriBuilder). TheLCL_VARuses are marked by the register allocator withGTF_SPILLED, so they remain in their incoming stack location until they are used, at which point they are loaded from their incoming stack location to a register and placed in their outgoing argument location for the tailcall. However, when they are used is during setup of the tailcall outgoing arguments, and the single outgoing stack argument is the same location as the incomingarg8. So, incomingarg8gets trashed when the outgoing stack argument is established, then the unspill fromarg8loads the trashed value.So, what is the proper way to prevent this? Should LSRA avoid creating unspills of stack arguments in the argument list of outgoing fast tailcalls? (Or more specifically, unspills of stack arguments within the outgoing argument stack region of the fast tailcall?)
Could a situation like this happen on other platforms?
@CarolEidt @erozenfeld ?
cc @jashook
BruceForstall commentedon May 27, 2020
fwiw, I changed the default for
COMPlus_FastTailCallsfrom 1 to 0, and reran all the tests, hoping to work around this problem (at least temporarily). But that actually made my test runs worse, as every dotnet xunit invocation fails with:Coreclr pri-0 tests all pass (trying pri-1 now). Manually setting this back to 1 in the environment makes the problem go away. This variable is only used in
Compiler::fgCanFastTailCallto bail out quickly, so it would seem that we might have bad codegen in some case when not doing fast tailcall.BruceForstall commentedon May 27, 2020
@erozenfeld Fixed a related bug here: dotnet/coreclr#12200.
BruceForstall commentedon May 30, 2020
Possibly related? #31729
erozenfeld commentedon May 30, 2020
#37192 fixes the standalone repro.
Fix fast tail calls on Windows ARM64.
Fix fast tail calls on Windows ARM64. (#37192)