Keil Logo

ARMCC: Heap functions are not thread safe in ArmClang compiler AC6


Information in this knowledgebase article applies to:

  • Keil MDK

SYMPTOM

I noticed that my heap is getting corrupted when using malloc() and free() in mutiple threads using the Arm Compiler 6. It seems like that the _mutex_* functions that should protect the heap functions are getting optimized out. This did not occur with Arm Compiler 5.

CAUSE

The _mutex_*() functions that are implemented in the CMSIS RTX library are being removed from the link by unused section elimination when using the ArmClang compiler/linker

RESOLUTION

In the "Options for Target..." - "Linker" tab, enter the following in the Misc Controls window:

--keep=_mutex_*

MORE INFORMATION

Last Reviewed: Thursday, October 8, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.