ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

LocalFileSystem & wait() triggers MbedOS Fault Handler #6624

Closed yennster closed 3 years ago

yennster commented 6 years ago

Description of defect

I'm observing an MbedOS hard fault when using the LocalFileSystem and wait(). I added a wait() command inside a loop that was writing multiple values to a CSV file. The hard fault seemed to occur when the wait() function was called.

Target(s) affected by this defect ?

LPC1768

Toolchain(s) (name and version) displaying this defect ?

GCC_ARM & Online Compiler

What version of Mbed-os are you using (tag or sha) ?

n/a

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

gcc-arm-none-eabi-7-2017-q4-major

mbed-cli version: 1.5.0

How is this defect reproduced ?

I wrote up a simple LocalFileSystem example for the Mbed Application board that writes 100 integer values to a .csv file:

#include "mbed.h"
LocalFileSystem local("local");
int main() {
    FILE *fp = fopen("/local/test.csv","w");
    for (int i = 0; i < 100; i++) {
        fprintf(fp, "%d\n", i);
    }
    fclose(fp);
}

The above code works and a TEST.CSV file is created in the local filesystem with integer values 0-99. However, when I add a wait function to the for loop, the MbedOS Fault Handler is triggered:

#include "mbed.h"
LocalFileSystem local("local");
int main() {
    FILE *fp = fopen("/local/test.csv","w");
    for (int i = 0; i < 100; i++) {
        fprintf(fp, "%d\n", i);
        wait(0.05); // triggers ++ MbedOS Fault Handler ++
    }
    fclose(fp);
}

No values are stored into the csv file as the application doesn't get to fclose(fp);

Expected behavior That the fault handler is not triggered and the for loop waits for 0.05 seconds, then saves a test.csv file with the 100 integer values.

Actual behavior Output to the serial terminal of the Fault Handler error message:

                                        ++ MbedOS Fault Handler ++

                                                                  FaultType: HardFault

                                                                                      Context:
                                                                                              R0   : 00000005
                                                                                                             R1   : 100025AC
                                                                                                                            R2   : 00000122
                                                                                                                                           R3   : 00000000
          R4   : 00000005
                         R5   : 100025AC
                                        R6   : 10002920
                                                       R7   : 10000288
                                                                      R8   : 10000288
                                                                                     R9   : 00000000
                                                                                                    R10  : 00000000
                                                                                                                   R11  : 00000000
                                                                                                                                  R12  : 00002CD9
 SP   : 100025A8
                LR   : 00000CF1
                               PC   : 00001794
                                              xPSR : 01000000
                                                             PSP  : 10002588
                                                                            MSP  : 10007FB8
                                                                                           CPUID: 412FC230
                                                                                                          HFSR : 80000000
                                                                                                                         MMFSR: 00000000
                                                                                                                                        BFSR : 00000000
       UFSR : 00000000
                      DFSR : 00000002
                                     AFSR : 00000000
                                                    SHCSR: 00000000
                                                                   Mode : Thread
                                                                                Priv : Privileged
                                                                                                 Stack: PSP

                                                                                                           Thread Info:
                                                                                                                       Current:
                                                                                                                               State: 00000002 EntryFn: 00001CF1 Stack Size: 00001000 Mem: 10001648 SP: 100025D0
                                                                Next:
                                                                     State: 00000002 EntryFn: 00001CF1 Stack Size: 00001000 Mem: 10001648 SP: 100025D0
      Wait Threads:
                   State: 00000083 EntryFn: 00003A8D Stack Size: 00000300 Mem: 10000F78 SP: 10001210
                                                                                                    Delay Threads:
                                                                                                                  Idle Thread:
                                                                                                                              State: 00000001 EntryFn: 00001E79 Stack Size: 00000200 Mem: 10001278 SP: 10001420

                                                               -- MbedOS Fault Handler --
kjbracey commented 6 years ago

Sounds like it's probably the same root cause as https://github.com/ARMmbed/mbed-os/issues/6578 . [Mirrored to Jira]

0xc0170 commented 6 years ago

@ARMmbed/team-nxp Please review [Mirrored to Jira]

yennster commented 6 years ago

@ARMmbed/team-nxp Any update on this? [Mirrored to Jira]

Carmeloning commented 5 years ago

Have you configure it? I meet something like this

cmonr commented 5 years ago

@maclobdell Is this on your radar?

ciarmcom commented 4 years ago

@yennster thank you for raising this issue.Please take a look at the following comments:

Could you add some more detail to the description? A good description should be at least 25 words. What target(s) are you using? What toolchain(s) are you using? What version of Mbed OS are you using (tag or sha)? It would help if you could also specify the versions of any tools you are using? How can we reproduce your issue?

NOTE: If there are fields which are not applicable then please just add 'n/a' or 'None'.This indicates to us that at least all the fields have been considered. Please update the issue header with the missing information, the issue will not be mirroredto our internal defect tracking system or investigated until this has been fully resolved.

adbridge commented 4 years ago

We've updated our automation, I will fix the requirements .

ciarmcom commented 4 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2455

ciarmcom commented 3 years ago

We closed this issue because it has been inactive for quite some time and we believe it to be low priority. If you think that the priority should be higher, then please reopen with your justification for increasing the priority.