Open talih0 opened 2 months ago
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Describe the bug
Using COMMON_LIBC_MALLOC and NEWLIB_LIBC is not thread safe. Both implementations share the same heap, but each has their own locking mechanism.
This will cause memory corruptions when malloc() and newlib (i.e. printf()) are used in different threads.
To Reproduce Steps to reproduce the behavior:
Checkout out my branch where I've modified samples/basic/threads to use printf() and malloc(): https://github.com/talih0/zephyr/tree/malloc_newlib_crash
I could reproduce the crash on two boards: xmc47_relax_kit and sam_v71_xult. I did not get the crash when using qemu_86.
Expected behavior No crash.
Environment (please complete the following information):