Page 1 of 1

Floating point operations randomly resulting in NaN

Posted: Mon Sep 25, 2023 3:46 pm
by abellofiore
ESP32-S3 Running IDF Release v5.1

I'm seeing simple floating point operations randomly resulting in NaN.
I have a few non-pinned tasks running PID loops and other polling operations; nothing out of the ordinary.
Naturally, my first assumption was a memory corruption, so I spent a good amount of time trying to catch one using watchpoints to no avail. I have also been running the entire time with full Heap and Stack corruption enabled. I am very confident this is not a corruption on my side of the code.

UPDATE:
It seem that any operations involving floats are subject to weirdness; calls to "log()", "isnan()", etc., can give back false results.
I found the following bug report:

https://github.com/espressif/esp-idf/issues/11225

It seems I can reduce the problem areas by surrounding those calculations with "vTaskSuspendAll()"/"xTaskResumeAll()", but that is down right terrible!

Anyone else seen this?