Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc/free are not thread-safe under newlib nano #826

Closed
m-mcgowan opened this issue Jan 19, 2016 · 1 comment

Comments

@m-mcgowan
Copy link
Contributor

commented Jan 19, 2016

When linking against the newlib C runtime, calls to malloc/free can be guarded by a critical section by implementing __malloc_lock and __malloc_unlock. We have implementations of these functions on the Photon and Electron. However, to conserve space, these runtimes are linked with the newlib-nano version of newlib which doesn't call the lock/unlock functions, leaving the heap open to corruption when memory allocation routines are accessed concurrently.

I tried using regular newlib as a fallback but this increased the code size and SRAM usage beyond the available space.

@m-mcgowan

This comment has been minimized.

Copy link
Contributor Author

commented Jan 20, 2016

Fixed in PR #827

@m-mcgowan m-mcgowan closed this Jan 20, 2016

@m-mcgowan m-mcgowan added this to the 0.4.9 milestone Jan 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.