6 years, 1 month ago.

Mutex lock failed on Mbed OS5.10.x

I wrote a following program and works fine on OS5.9.7 but error is happened on OS5.10. 0, 5.10.1 and 5.10.2.
Target Board: Nucleo-F446RE

Import programMutex_lock_failed_on_os_5_10

Mutex lock failed error is happened on OS5.10.x(Works fine on OS5.9.7)


The error message is below.

++ MbedOS Error Info ++
       Error Status: 0x80020115 Code: 277 Module: 2
       Error Message: Mutex lock failed
       Location: 0x8005B01
       Error Value: 0xFFFFFFFA
       Current Thread: Id: 0x200024D8 Entry: 0x8007045 StackSize: 0x1000 StackMem: 0x200014D8 SP: 0x2001FF50
       For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115
-- MbedOS Error Info --

Looks like OS internal RTX Kernel bug.
Please give me an advice how to overcome this issue.

I have just encountered exactly the same bug.

Something which worked fine on an earlier version now fails since I ran the "mbed update" command (to mbed-os-5.10.1)

I have set MBED_CONF_APP_ERROR_FILENAME_CAPTURE_ENABLED to True, so have the more detailed error description which shows both the filename and line number where the error occurs.

++ MbedOS Error Info ++ Error Status: 0x80020115 Code: 277 Module: 2 Error Message: Mutex lock failed Location: 0x1DD4B File:Mutex.cpp+62 Error Value: 0xFFFFFFFA Current Thread: Id: 0x200049F4 Entry: 0x1E2BD StackSize: 0x1000 StackMem: 0x20004A38 SP: 0x20007EB0 For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115 MbedOS Error Info

posted by Philip Hart 24 Oct 2018

2 Answers

6 years ago.

I created the GitHub issue here: https://github.com/ARMmbed/mbed-os/issues/8518

Accepted Answer
6 years, 1 month ago.

You trying to read serial within interrupt, mutex can't be locked in interrupt - please see https://github.com/ARMmbed/mbed-os/blob/master/drivers/Serial.h#L37

if you want simple solution try events https://os.mbed.com/blog/entry/Simplify-your-code-with-mbed-events/ especially the part Using mbed-events

Hi Pavel,
Thank you for your reply.
I did NOT intend to use "mutex" function but I used "CircularBuffer" function which provides as Mbed OS5 platform.
In the docs as below.....
https://os.mbed.com/docs/v5.6/reference/circularbuffer.html
[CircularBuffer class is interrupt safe; all data operations are performed inside the critical section.]
As a matter of fact, I could use it in old revision.
I think this is a problem inside of Mbed OS5.

posted by Kenji Arai 23 Oct 2018

I know you don't use mutex but OS does, as you can see here https://github.com/ARMmbed/mbed-os/blob/master/drivers/SerialBase.cpp#L61 when you try to call pc.readable() it will try to lock mutex so this will fail. Just use events to attach intertupt and you done. If you use older OS where it worked you might see some random restarts as this is what i had a problem with.

posted by Pavel S 23 Oct 2018

Hi Pavel,
Thanks your comments.

posted by Kenji Arai 24 Oct 2018