Skip to content

[NativeAOT/arm32] punning test failure in Checked build  #98493

Closed
@filipnavara

Description

@filipnavara

The following test fails in Checked builds:

public static void Via_Ldftn_Generics()
{
Console.WriteLine($"Running {nameof(Via_Ldftn_Generics)}...");
IntPtr fptr = B.Class.GetFunctionPointerGeneric();
Assert.NotEqual(IntPtr.Zero, fptr);
var b = new Caller.Struct<object>()
{
Field = 0x55
};
int fieldValue = Caller.Class.CallGetField(b, fptr, null);
Assert.Equal(b.Field, fieldValue);
}

with the following stack trace:

  * frame #0: 0x007513da punning
    frame #1: 0x0065fd46 punning`punning_punning__Via_Ldftn_Generics at punning.cs:67
    frame #2: 0x006600f6 punning`punning___GeneratedMainWrapper__Main at SimpleRunner.g.cs:10
    frame #3: 0x006b6f24 punning`__managed__Main at Utilities.cs:71
    frame #4: 0xf7deb3c0 libc.so.6`__libc_start_call_main(main=(libc.so.6`__libc_start_call_main + 140 at libc_start_call_main.h:74:3), argc=-135024640, argv=0x00556d19) at libc_start_call_main.h:58:16
    frame #5: 0xf7deb4c8 libc.so.6`__libc_start_main_impl(main=(punning`main + 1 at main.cpp:205), argc=1, argv=0xfffef4c4, init=0xf7fef048, fini=0x00000000, rtld_fini=0xf7fcb310, stack_end=0xfffef4c4) at libc-star

The address 0x007513da is a fat pointer (notice that the bit 2 is set on the address). The optimized code strips away the far pointer invocation (at address 0x65fd44):

punning`punning_punning__Via_Ldftn_Generics:
    0x65fd00 <+0>:   push.w {r4, r5, r11, lr}
    0x65fd04 <+3>:   add.w  r11, sp, #0x8
    0x65fd08 <+7>:   movw   r0, #0x5450
    0x65fd0c <+11>:  movt   r0, #0xd
    0x65fd10 <+15>:  add    r0, pc
    0x65fd12 <+17>:  bl     0x5a9d20                  ; System_Console_System_Console__WriteLine_12
    0x65fd16 <+21>:  movw   r4, #0x16b8
    0x65fd1a <+25>:  movt   r4, #0xf
    0x65fd1e <+29>:  add    r4, pc
    0x65fd20 <+31>:  movw   r0, #0x9868
    0x65fd24 <+35>:  movt   r0, #0x10
    0x65fd28 <+39>:  add    r0, pc
    0x65fd2a <+41>:  bl     0x59c1a4                  ; RhpNewFast
    0x65fd2e <+45>:  mov    r5, r0
    0x65fd30 <+47>:  mov    r0, r5
    0x65fd32 <+49>:  movs   r1, #0x0
    0x65fd34 <+51>:  bl     0x670990                  ; System.Collections.Generic.GenericEqualityComparer`1<IntPtr>__GetHashCode_0 + 15 at EqualityComparer.cs:140
    0x65fd38 <+55>:  mov    r2, r5
    0x65fd3a <+57>:  mov    r1, r4
    0x65fd3c <+59>:  movs   r0, #0x0
    0x65fd3e <+61>:  bl     0x6cfd50                  ; xunit_assert_Xunit_Assert__NotEqual_11<IntPtr>
    0x65fd42 <+65>:  movs   r0, #0x55
    0x65fd44 <+67>:  blx    r4
    0x65fd46 <+69>:  mov    r4, r0
    0x65fd48 <+71>:  movw   r0, #0x7c14
    0x65fd4c <+75>:  movt   r0, #0x10
    0x65fd50 <+79>:  add    r0, pc
    0x65fd52 <+81>:  bl     0x59c1a4                  ; RhpNewFast
    0x65fd56 <+85>:  mov    r5, r0
    0x65fd58 <+87>:  mov    r0, r5
    0x65fd5a <+89>:  movs   r1, #0x0
    0x65fd5c <+91>:  bl     0x669330                  ; System.Buffers.SharedArrayPool`1_<>c<Int32>___InitializeTlsBucketsAndTrimming_b__11_0 + 47 at SharedArrayPool.cs:291
    0x65fd60 <+95>:  mov    r2, r5
    0x65fd62 <+97>:  mov    r1, r4
    0x65fd64 <+99>:  movs   r0, #0x55
    0x65fd66 <+101>: bl     0x6cd930                  ; xunit_assert_Xunit_Assert__Equal_11<Int32>
    0x65fd6a <+105>: pop.w  {r4, r5, r11, pc}

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-arm32area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions