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

[arm32/linux] Assert failure: dwSrcIndex > dwLastSrcIndex in ABI stress #13241

Closed
jakobbotsch opened this issue Aug 9, 2019 · 7 comments · Fixed by #66642
Closed

[arm32/linux] Assert failure: dwSrcIndex > dwLastSrcIndex in ABI stress #13241

jakobbotsch opened this issue Aug 9, 2019 · 7 comments · Fixed by #66642
Assignees
Labels
arch-arm32 area-VM-coreclr os-linux Linux OS (any supported distro)
Milestone

Comments

@jakobbotsch
Copy link
Member

jakobbotsch commented Aug 9, 2019

pinvoke stress on arm32 fails with an assert failure:

Assert failure(PID 46 [0x0000002e], Thread: 46 [0x002e]): dwSrcIndex > dwLastSrcIndex
    File: /__w/2/s/src/vm/arm/stubs.cpp Line: 1558
    Image: /root/helix/work/correlation/corerun

/root/helix/work/workitem/JIT/Stress/ABI/pinvokes_do/pinvokes_do.sh: line 271:    46 Aborted                 $LAUNCHER $ExePath "${CLRTestExecutionArguments[@]}"

Return code:      1
Raw output file:      /root/helix/work/workitem/JIT/Stress/Reports/JIT.Stress/ABI/pinvokes_do/pinvokes_do.output.txt
Raw output:
BEGIN EXECUTION
/root/helix/work/correlation/corerun pinvokes_do.exe '--pinvokes' '--num-calls' '1000' '--no-ctrlc-summary'
Stressing pinvokes
OSVersion: Unix 4.4.38.0
OSArchitecture: Arm
ProcessArchitecture: Arm
Selecting armhf ABI.
50 callers done
100 callers done
Expected: 100
Actual: 134
END EXECUTION - FAILED
Test Harness Exitcode is : 1
To run the test:
> set CORE_ROOT=/root/helix/work/correlation
> /root/helix/work/workitem/JIT/Stress/ABI/pinvokes_do/pinvokes_do.sh

Small self-contained example:

using System;
using System.Runtime.InteropServices;

public class Program
{
    public static void Main()
    {
        CalleeDelegate callee = Callee;
        callee(default, default, default, default, default, default);
        GC.KeepAlive(callee);
    }

    private static int Callee(Hfa1 a1, S1P a2, Hfa2 a3, Hfa2 a4, S9U a5, S11U a6)
    {
        return 0;
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    private delegate int CalleeDelegate(Hfa1 a1, S1P a2, Hfa2 a3, Hfa2 a4, S9U a5, S11U a6);

    public struct S1P { public byte F0; }
    public struct S9U { public byte F0, F1, F2, F3, F4, F5, F6, F7, F8; }
    public struct S11U { public byte F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10; }
    public struct Hfa1 { public float F0, F1; }
    public struct Hfa2 { public double F0, F1, F2, F3; }
}

category:correctness
theme:pinvoke
skill-level:intermediate
cost:medium

@BruceForstall
Copy link
Member

I presume this depends on dotnet/coreclr#26090

@jakobbotsch
Copy link
Member Author

Yes indeed, I opened this to have something to reference when excluding that test for arm32.

@jakobbotsch
Copy link
Member Author

The test that found this is currently disabled on ARM32:
https://github.com/dotnet/coreclr/blob/fdb2bc4233bf93e44bda4b1ae3b1432e80c9f0da/tests/issues.targets#L232-L234

As part of a fix to this issue this test should be enabled.

This test will run through a lot of different callers. To make a smaller test case, you can ask the test to run only a single caller using the arg --caller-index 1234. However since this is an assertion failure the test output does not show exactly which caller it is (only that it is in the 100-150 area). So to find the proper index the following can be done:

  1. Run with verbose, i.e. --pinvokes --num-calls 1000 --verbose
  2. It will give a lot of output. Once it asserts, scroll up to see the name of the caller that was being tested. It should be something like ABIStress_Pinvoker1234
  3. Rerun the test with only this caller, i.e. something like --pinvokes --caller-index 1234. This should reproduce the problem without going through a bunch of other callers first.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 5.0 milestone Jan 31, 2020
@BruceForstall
Copy link
Member

The assert is in StubLinkerCPU::EmitShuffleThunk()

@BruceForstall BruceForstall added area-VM-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Apr 29, 2020
@BruceForstall BruceForstall self-assigned this Apr 29, 2020
@jakobbotsch
Copy link
Member Author

Maybe this could be similar to #13225?

@mangod9 mangod9 modified the milestones: 5.0.0, 6.0.0 Jul 22, 2020
@BruceForstall BruceForstall modified the milestones: 6.0.0, 7.0.0 Jul 6, 2021
@jakobbotsch
Copy link
Member Author

Should this be assigned to someone else @BruceForstall? Since this looks like a VM bug.

@jakobbotsch
Copy link
Member Author

Small self-contained repro:

using System;
using System.Runtime.InteropServices;

public class Program
{
    public static void Main()
    {
        CalleeDelegate callee = Callee;
        callee(default, default, default, default, default, default);
        GC.KeepAlive(callee);
    }

    private static int Callee(Hfa1 a1, S1P a2, Hfa2 a3, Hfa2 a4, S9U a5, S11U a6)
    {
        return 0;
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    private delegate int CalleeDelegate(Hfa1 a1, S1P a2, Hfa2 a3, Hfa2 a4, S9U a5, S11U a6);

    public struct S1P { public byte F0; }
    public struct S9U { public byte F0, F1, F2, F3, F4, F5, F6, F7, F8; }
    public struct S11U { public byte F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10; }
    public struct Hfa1 { public float F0, F1; }
    public struct Hfa2 { public double F0, F1, F2, F3; }
}

Linux/Windows arm32 result:

Assert failure(PID 13678 [0x0000356e], Thread: 13678 [0x356e]): dwSrcIndex > dwLastSrcIndex
    File: /runtime/src/coreclr/vm/arm/stubs.cpp Line: 1507
    Image: /media/windev/dotnet/core_roots/arm32_checked/corerun

Aborted

jakobbotsch added a commit to jakobbotsch/runtime that referenced this issue Mar 13, 2022
BruceForstall added a commit to BruceForstall/runtime that referenced this issue Mar 15, 2022
Handle case where gap exists at the beginning of the stack
range.

Fix dotnet#13241
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 15, 2022
BruceForstall added a commit that referenced this issue Mar 15, 2022
Handle case where gap exists at the beginning of the stack
range.

Fix #13241
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 15, 2022
radekdoulik pushed a commit to radekdoulik/runtime that referenced this issue Mar 30, 2022
Handle case where gap exists at the beginning of the stack
range.

Fix dotnet#13241
@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm32 area-VM-coreclr os-linux Linux OS (any supported distro)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants