Skip to content

Newlib has no synchronization #33164

@andyross

Description

@andyross

I can't find any implementation of locking or synchronization hooks for newlib.

I bumped into what I thought briefly was a SMP race in newlib malloc (it wasn't) and went looking to be sure that we were doing the locking correctly. And... we aren't?

I see that this was filed a year and a half ago (which is inexplicably an Enhancement and not a Bug): #21519 and was seemingly addressed by #21518 , which never merged.

The relevant hooks (e.g. __malloc_lock) are indeed compiled into our newlib libc.a binaries, but it looks like they also contain a weak fallback stub that just noops.

Am I wrong, or did we drop this? Without locking newlib's heap and stdio layers are fundamentally unsafe in any context that can be preempted, which is... mostly useless (especially when compared to our own heap and console layers that are threadsafe, SMP-aware and interrupt clean!).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: C LibraryC Standard Libraryarea: SMPSymmetric multiprocessingbugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions