Skip to content

Assert in mini-codegen.c on Mono x86 #60347

Closed

Description

@akoeplinger

Run the following code on x86 Mono, e.g. on Android:

float resultF = Add(1.0f, 2.0f);
double resultD = Add(1.0, 2.0);

Console.WriteLine(resultF);
Console.WriteLine(resultD);

static T Add<T>(T left, T right) where T : struct
{
    unchecked
    {
        if      (left is short)  return (T)(ValueType)(short)  ( (short) (ValueType)left + (short) (ValueType)right );
        else if (left is int)    return (T)(ValueType)(int)    ( (int)   (ValueType)left + (int)   (ValueType)right );
        else if (left is long)   return (T)(ValueType)(long)   ( (long)  (ValueType)left + (long)  (ValueType)right );
        else if (left is ushort) return (T)(ValueType)(ushort) ( (ushort)(ValueType)left + (ushort)(ValueType)right );
        else if (left is uint)   return (T)(ValueType)(uint)   ( (uint)  (ValueType)left + (uint)  (ValueType)right );
        else if (left is ulong)  return (T)(ValueType)(ulong)  ( (ulong) (ValueType)left + (ulong) (ValueType)right );
        else if (left is byte)   return (T)(ValueType)(byte)   ( (byte)  (ValueType)left + (byte)  (ValueType)right );
        else if (left is sbyte)  return (T)(ValueType)(sbyte)  ( (sbyte) (ValueType)left + (sbyte) (ValueType)right );
        else if (left is float)  return (T)(ValueType)(float)  ( (float) (ValueType)left + (float) (ValueType)right );
        else if (left is double) return (T)(ValueType)(double) ( (double)(ValueType)left + (double)(ValueType)right );
        else throw new NotImplementedException();
    }
}

It crashes with this runtime assert:

* Assertion at /Users/alexander/dev/runtime/src/mono/mono/mini/mini-codegen.c:2306, condition `sp < 8' not met

I saw that x86 is the only platform where we define MONO_ARCH_USE_FPSTACK to true, that's why we only see it there.

Activity

  1. added this to the 7.0.0 milestone on Oct 13, 2021
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Oct 13, 2021
  3. removed
    untriagedNew issue has not been triaged by the area owner
    on Oct 13, 2021
  4. akoeplinger commented on Oct 13, 2021

    @akoeplinger
    MemberAuthor
  5. modified the milestones: 7.0.0, 8.0.0 on Aug 4, 2022
  6. vargaz commented on Aug 9, 2022

    @vargaz
    Contributor

    Should be fixed by
    #65723

  7. akoeplinger commented on Aug 10, 2022

    @akoeplinger
    MemberAuthor

    Confirmed it is fixed in Android x86

  8. modified the milestones: 8.0.0, 7.0.0 on Aug 10, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Sep 9, 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