-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Goal
Add thread-safety to global libc state with proper locking to enable safe concurrent use of C standard library.
Context
Currently, libc has no concurrency protection:
- stdio buffers (FILE* streams) aren't locked
- Environment variable access isn't protected
- Allocator (malloc/free) may not be thread-safe
- Global state (errno, strtok static buffer, etc.) has no protection
With pthread support (#109), programs will crash or corrupt data when multiple threads use libc simultaneously.
Definition of Done
- Thread-safe stdio (flockfile/funlockfile, per-FILE mutexes)
- Thread-safe environment (getenv/putenv/setenv locking)
- Thread-safe allocator (malloc/free locking if needed)
- Thread-local errno
- Reentrant variants (_r functions: strtok_r, localtime_r, etc.)
- Testing with multithreaded programs
Dependencies
Required
- Implement pthread API and POSIX threading support #109 - pthread API and POSIX threading
Related
- Implement thread-safe C library (libc) #110 - Thread-safe C library (parent issue, may be duplicate)
Priority
Medium - Required after pthread implementation
Estimated Time
6-8 weeks part-time
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
libcC standard library implementationC standard library implementation