Skip to content

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

Closed

Description

@jakobbotsch

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

Activity

  1. BruceForstall commented on Aug 12, 2019

    @BruceForstall
    Contributor

    I presume this depends on dotnet/coreclr#26090

  2. jakobbotsch commented on Aug 12, 2019

    @jakobbotsch
    MemberAuthor

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

  3. jakobbotsch commented on Aug 14, 2019

    @jakobbotsch
    MemberAuthor

    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.
  4. transferred this issue fromdotnet/coreclron Jan 31, 2020
  5. added this to the 5.0 milestone on Jan 31, 2020
  6. BruceForstall commented on Apr 29, 2020

    @BruceForstall
    Contributor

    The assert is in StubLinkerCPU::EmitShuffleThunk()

  7. added and removed
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Apr 29, 2020
  8. jakobbotsch commented on Apr 29, 2020

    @jakobbotsch
    MemberAuthor

    Maybe this could be similar to #13225?

  9. modified the milestones: 5.0.0, 6.0.0 on Jul 22, 2020
  10. modified the milestones: 6.0.0, 7.0.0 on Jul 6, 2021
  11. jakobbotsch commented on Mar 13, 2022

    @jakobbotsch
    MemberAuthor

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

  12. jakobbotsch commented on Mar 13, 2022

    @jakobbotsch
    MemberAuthor

    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
  13. added a commit that references this issue on Mar 15, 2022
    638fb16
  14. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 15, 2022
  15. added a commit that references this issue on Mar 15, 2022
    9f2ff3f
  16. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 15, 2022
  17. added a commit that references this issue on Mar 30, 2022
    b7be9ed
  18. ghost locked as resolved and limited conversation to collaborators on Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions