Skip to content

Bug in Hashtable (or CLR_RT_HeapBlock::ObjectsEqual) #1390

Closed
nanoframework/nf-interpreter
#2836
@MateuszKlatecki

Description

@MateuszKlatecki

Target name(s)

ALL

Firmware version

1.8.1.685

Was working before? On which version?

No response

Device capabilities

No response

Description

Attempting to run the code below results in the device hanging.

using System.Collections;
using System.Diagnostics;
using System.Threading;

namespace HashtableProblem
{
    public class SomeElement
    {

    }
    public class Program
    {
        public static void Main()
        {
            Thread.Sleep(10000);

            Debug.WriteLine("Hello from nanoFramework!");

            Hashtable ht = new Hashtable();

            for (ulong i = 1; i <= 100; i++)
            {
                SomeElement se = new SomeElement();
                Debug.WriteLine($"Adding element no {i}");
                ht.Add(se, i);
            }

            Thread.Sleep(Timeout.Infinite);

        }
    }
}

The problem occurs when the ObjectsEquals method is called for the first time in the Hashtable::InsertNative method.

The leftDataType and rightDataType variables have the values DATATYPE_CLASS and it looks like in CLR_RT_HeapBlock::ObjectsEqual method is missing such a case and the firmware stops at this assert

How to reproduce

Run code from description

Expected behaviour

No response

Screenshots

No response

Aditional information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions