Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failure: System.Drawing.Common.Tests #38889

Closed
BruceForstall opened this issue Jul 7, 2020 · 2 comments · Fixed by #40698
Closed

Test failure: System.Drawing.Common.Tests #38889

BruceForstall opened this issue Jul 7, 2020 · 2 comments · Fixed by #40698
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI JitStress CLR JIT issues involving JIT internal stress modes
Milestone

Comments

@BruceForstall
Copy link
Member

BruceForstall commented Jul 7, 2020

Windows x86 and arm64 with:

COMPlus_TailcallStress=1
COMPlus_TieredCompilation=0

Doesn't fail on Windows x64.

x86:

C:\h\w\ADD60980\w\AB530912\e>set COMPlus 
COMPlus_TailcallStress=1
COMPlus_TieredCompilation=0

C:\h\w\ADD60980\w\AB530912\e>call RunTests.cmd --runtime-path C:\h\w\ADD60980\p 
----- start Tue 07/07/2020  9:13:41.98 ===============  To repro directly: ===================================================== 
pushd C:\h\w\ADD60980\w\AB530912\e\
"C:\h\w\ADD60980\p\dotnet.exe" exec --runtimeconfig System.Drawing.Common.Tests.runtimeconfig.json --depsfile System.Drawing.Common.Tests.deps.json xunit.console.dll System.Drawing.Common.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing 
popd
===========================================================================================================

C:\h\w\ADD60980\w\AB530912\e>"C:\h\w\ADD60980\p\dotnet.exe" exec --runtimeconfig System.Drawing.Common.Tests.runtimeconfig.json --depsfile System.Drawing.Common.Tests.deps.json xunit.console.dll System.Drawing.Common.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing  
  Discovering: System.Drawing.Common.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Drawing.Common.Tests (found 1934 of 1969 test cases)
  Starting:    System.Drawing.Common.Tests (parallel test collections = on, max threads = 2)
    System.Drawing.Tests.GdiplusTests.IsAtLeastLibgdiplus6 [SKIP]
      Condition(s) not met: "IsOSX"
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SystemDefault) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: AntiAlias) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: AntiAliasGridFit) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SingleBitPerPixel) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: SingleBitPerPixelGridFit) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(textRenderingHint: ClearTypeGridFit) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(832,0): at System.Drawing.Tests.FontTests.ToLogFont_InvokeGraphics_ReturnsExpected(TextRenderingHint textRenderingHint)
    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Bold | Italic | Strikeout, gdiCharSet: 255, gdiVerticalFont: True, expectedNamePrefix: "@", expectedWeight: 700) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 0, gdiVerticalFont: False, expectedNamePrefix: "", expectedWeight: 400) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 10, gdiVerticalFont: False, expectedNamePrefix: "", expectedWeight: 400) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   0
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
    System.Drawing.Imaging.Tests.EncoderParameterTests.Ctor_Encoder_NegativeNumberOfValues_Type_Value_OutOfMemoryException(numberOfValues: -1) [SKIP]
      backwards compatibility on 32 bit platforms may not throw
    System.Drawing.Imaging.Tests.EncoderParameterTests.Ctor_Encoder_NegativeNumberOfValues_Type_Value_OutOfMemoryException(numberOfValues: -2147483648) [SKIP]
      backwards compatibility on 32 bit platforms may not throw
  Finished:    System.Drawing.Common.Tests
=== TEST EXECUTION SUMMARY ===
   System.Drawing.Common.Tests  Total: 4675, Errors: 0, Failed: 9, Skipped: 3, Time: 72.518s
----- end Tue 07/07/2020  9:15:21.31 ----- exit code 1 ----------------------------------------------------------

https://dev.azure.com/dnceng/public/_build/results?buildId=718587&view=ms.vss-test-web.build-test-results-tab&runId=22273786&resultId=178432&paneView=debug

category:correctness
theme:tail-call
skill-level:expert
cost:medium

@BruceForstall BruceForstall added JitStress CLR JIT issues involving JIT internal stress modes area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Jul 7, 2020
@BruceForstall BruceForstall added this to the 5.0.0 milestone Jul 7, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jul 7, 2020
@BruceForstall
Copy link
Member Author

Windows arm64 also fails with:

    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Bold | Italic | Strikeout, gdiCharSet: 255, gdiVerticalFont: True, expectedNamePrefix: "@", expectedWeight: 700) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   64026284
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 0, gdiVerticalFont: False, expectedNamePrefix: "", expectedWeight: 400) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   64026284
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)
    System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(fontStyle: Regular, gdiCharSet: 10, gdiVerticalFont: False, expectedNamePrefix: "", expectedWeight: 400) [FAIL]
      Assert.Equal() Failure
      Expected: -13
      Actual:   64026284
      Stack Trace:
        /_/src/libraries/System.Drawing.Common/tests/FontTests.cs(795,0): at System.Drawing.Tests.FontTests.ToLogFont_Invoke_ReturnsExpected(FontStyle fontStyle, Byte gdiCharSet, Boolean gdiVerticalFont, String expectedNamePrefix, Int32 expectedWeight)

BruceForstall added a commit to BruceForstall/runtime that referenced this issue Jul 7, 2020
@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label Jul 7, 2020
@erozenfeld
Copy link
Member

erozenfeld commented Aug 6, 2020

The bad tail call is here:

https://github.com/dotnet/runtime/blob/master/src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs#L274-L303

public unsafe void ToLogFont(object logFont, Graphics graphics)
{
    if (logFont == null)
    {
        throw new ArgumentNullException(nameof(logFont));
    }

    Type type = logFont.GetType();
    int nativeSize = sizeof(Interop.User32.LOGFONT);
    if (Marshal.SizeOf(type) != nativeSize)
    {
        // If we don't actually have an object that is LOGFONT in size, trying to pass
        // it to GDI+ is likely to cause an AV.
        throw new ArgumentException(null, nameof(logFont));
    }

    Interop.User32.LOGFONT nativeLogFont = ToLogFontInternal(graphics);

    // PtrToStructure requires that the passed in object not be a value type.
    if (!type.IsValueType)
    {
         Marshal.PtrToStructure(new IntPtr(&nativeLogFont), logFont);
    }
    else
    {
        GCHandle handle = GCHandle.Alloc(logFont, GCHandleType.Pinned);
        Buffer.MemoryCopy(&nativeLogFont, (byte*)handle.AddrOfPinnedObject(), nativeSize, nativeSize);
        handle.Free();
    }
}

We are passing a pointer to a local (new IntPtr(&nativeLogFont)) to the call to Marshal.PtrToStructure. So it's a tailcallstress issue.

erozenfeld added a commit to erozenfeld/runtime that referenced this issue Aug 14, 2020
Improve validation of tail calls that are not tail-prefixed in the IL
but are marked as such because of TailCallStress. We now do the same
correctness validation in morph for such tail calls as we do for
implicit tail calls. That blocks tail calls when we have address-taken
locals, struct promoted params, and pinned vars.

Fixes dotnet#39398.
Fixes dotnet#39309.
Fixes dotnet#38892.
Fixes dotnet#38889.
Fixes dotnet#38887.
Fixes dotnet#37117.
Fixes dotnet#8017.
erozenfeld added a commit that referenced this issue Aug 15, 2020
Improve validation of tail calls that are not tail-prefixed in the IL
but are marked as such because of TailCallStress. We now do the same
correctness validation in morph for such tail calls as we do for
implicit tail calls. That blocks tail calls when we have address-taken
locals, struct promoted params, and pinned vars.

Fixes #39398.
Fixes #39309.
Fixes #38892.
Fixes #38889.
Fixes #38887.
Fixes #37117.
Fixes #8017.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
ViktorHofer pushed a commit to dotnet/winforms that referenced this issue Dec 5, 2022
Improve validation of tail calls that are not tail-prefixed in the IL
but are marked as such because of TailCallStress. We now do the same
correctness validation in morph for such tail calls as we do for
implicit tail calls. That blocks tail calls when we have address-taken
locals, struct promoted params, and pinned vars.

Fixes dotnet/runtime#39398.
Fixes dotnet/runtime#39309.
Fixes dotnet/runtime#38892.
Fixes dotnet/runtime#38889.
Fixes dotnet/runtime#38887.
Fixes dotnet/runtime#37117.
Fixes dotnet/runtime#8017.

Commit migrated from dotnet/runtime@7742b57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI JitStress CLR JIT issues involving JIT internal stress modes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants