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

Using IsEqual with reference types cause device to restart #1143

Closed
KiwiBryn opened this issue Sep 16, 2022 · 1 comment · Fixed by nanoframework/nf-interpreter#2439
Closed

Comments

@KiwiBryn
Copy link

KiwiBryn commented Sep 16, 2022

Target name(s)

ST_STM32F769I_DISCOVERY, ESP32

Firmware version

ST_STM32F769I_DISCOVERY-1.8.0.503

Was working before? On which version?

NA

Device capabilities

System Information
HAL build info: nanoCLR running @ ST_STM32F769I_DISCOVERY
Target: ST_STM32F769I_DISCOVERY
Platform: STM32F7

Firmware build Info:
Date: Sep 15 2022
Type: MinSizeRel build with ChibiOS v2021.11.2.11
CLR Version: 1.8.0.503
Compiler: GNU ARM GCC v11.3.1

OEM Product codes (vendor, model, SKU): 0, 0, 0

Serial Numbers (module, system):
00000000000000000000000000000000
0000000000000000

Target capabilities:
Has nanoBooter: YES
nanoBooter: v1.8.0.503
IFU capable: NO
Has proprietary bootloader: NO

AppDomains:

Assemblies:

Native Assemblies:
mscorlib v100.5.0.17, checksum 0x004CF1CE
nanoFramework.Runtime.Native v100.0.9.0, checksum 0x109F6F22
nanoFramework.Hardware.Stm32 v100.0.4.4, checksum 0x0874B6FE
nanoFramework.Device.Can v100.0.5.1, checksum 0x5B569036
nanoFramework.Graphics v100.0.0.6, checksum 0x7BD8E418
nanoFramework.Device.OneWire v100.0.4.0, checksum 0xB95C43B4
nanoFramework.Networking.Sntp v100.0.4.4, checksum 0xE2D9BDED
nanoFramework.ResourceManager v100.0.0.1, checksum 0xDCD7DF4D
nanoFramework.System.Collections v100.0.1.0, checksum 0x2DC2B090
nanoFramework.System.Text v100.0.0.1, checksum 0x8E6EB73D
nanoFramework.Runtime.Events v100.0.8.0, checksum 0x0EAB00C9
EventSink v1.0.0.0, checksum 0xF32F4C3E
System.IO.FileSystem v1.0.0.0, checksum 0x3AB74021
System.Math v100.0.5.4, checksum 0x46092CB1
System.Net v100.1.5.0, checksum 0x5BAB8CB3
System.Device.Adc v100.0.0.0, checksum 0xE5B80F0B
System.Device.Dac v100.0.0.6, checksum 0x02B3E860
System.Device.Gpio v100.1.0.5, checksum 0x097E7BC5
System.Device.I2c v100.0.0.1, checksum 0xFA806D33
System.Device.Pwm v100.1.0.4, checksum 0xABF532C3
System.IO.Ports v100.1.6.1, checksum 0xB798CE30
System.Device.Spi v100.1.2.0, checksum 0x3F6E2A7E
Windows.Storage v100.0.2.0, checksum 0x954A4192

++++++++++++++++++++++++++++++++
++ Memory Map ++
++++++++++++++++++++++++++++++++
Type Start Size
++++++++++++++++++++++++++++++++
RAM 0xc0000000 0x01000000
FLASH 0x08000000 0x00200000

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ Flash Sector Map ++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Region Start Blocks Bytes/Block Usage
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0 0x08000000 1 0x008000 nanoBooter
1 0x08008000 1 0x008000 Configuration
2 0x08010000 2 0x008000 nanoCLR
3 0x08020000 1 0x020000 nanoCLR
4 0x08040000 2 0x040000 nanoCLR
5 0x080C0000 5 0x040000 Deployment

+++++++++++++++++++++++++++++++++++++++++++++++++++
++ Storage Usage Map ++
+++++++++++++++++++++++++++++++++++++++++++++++++++
Start Size (kB) Usage
+++++++++++++++++++++++++++++++++++++++++++++++++++
0x08000000 0x008000 (32kB) nanoBooter
0x08008000 0x008000 (32kB) Configuration
0x08010000 0x0B0000 (704kB) nanoCLR
0x080C0000 0x140000 (1280kB) Deployment

Deployment Map
Empty

Description

While debugging the BME680 library I found that if IsEqual was used (tried on ESP32, STM769Dsico) the device would restart

Around line
289 in Bme680.cs,
58 in Bme680.sample.cs

65 in Bme280.sample.cs

How to reproduce

Have attached sample code

        AStruct s1 = new AStruct() { a = 1 };
        AStruct s2 = new AStruct() { a = 2 };

        //These go pop
        Debug.WriteLine($"s1.Equals(s1):{s1.Equals(s1)}"); 
        Debug.WriteLine($"s1.Equals(s2):{s1.Equals(s2)}");
        Debug.WriteLine($"s1.Equals(null):{s1.Equals(null)}");
        Debug.WriteLine($"s1.Equals(null):{s2.Equals(null)}");

Program.cs.txt

Expected behaviour

Maybe compilation should fail, the .Equals should not make the device restart

Screenshots

image
image

Aditional information

I think that a "nullable reference type" hangover from the .NET Core Devices code port is root cause of BMXX80 problem so I will create an issue for that

@josesimoes
Copy link
Member

Issue confirmed.

Running on full .NET produces the expected output: https://dotnetfiddle.net/d1WVQ4
Need fix at native CLR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants