ARMmbed / mbed-littlefs

[experimental] Mbed OS wrapper for LittleFS v2.0 (alpha)
https://github.com/ARMmbed/littlefs
76 stars 34 forks source link

Possible infinite loop in dir fetch match #17

Open felipeLeast opened 3 years ago

felipeLeast commented 3 years ago

Hi,

We are using lfs2 along with Mbed-OS and FlashIAP for the STM32G0 target. During our usage in development we've experienced no issue running the application. But after the deployment stage in a client, it occurred that power supply was cutoff from about 100 devices and all experienced the same outcome. They all got stuck on LittleFS initialization, more precisely in the lfs2_dir_fetchmatch while(true) loop, which is called by lfs2_mount. We can't understand exactly why this is happening, and we can't debug further. So far, with the help of GDB and OpenOCD, the only clue we could get is that in normal operation it should in some moment break in the following statement:

 if (!lfs2_tag_isvalid(tag)) {
    dir->erased = (lfs2_tag_type1(ptag) == LFS2_TYPE_CRC &&
            dir->off % lfs2->cfg->prog_size == 0);
    break;
}

We are not sure if the application is just getting stuck in an infinite loop or if some internal error are being thrown out and then the board stops.

I'm attaching a print from GDB server with its backtrace until the application reaches the watchdog timeout handler. image