Skip to content

libc: give make_absolute a thread-local join buffer - #142

Open
UnitBuilds wants to merge 1 commit into
wasix-org:mainfrom
UnitBuilds-CC:fix/make-absolute-thread-buffer
Open

UnitBuilds wants to merge 1 commit into
wasix-org:mainfrom
UnitBuilds-CC:fix/make-absolute-thread-buffer

Conversation

@UnitBuilds

Copy link
Copy Markdown

Summary

make_absolute() resolved a relative path through one process-wide static buffer (make_absolute_buf / make_absolute_len). Under WASIX threads, concurrent relative opens from different threads could interleave on that shared buffer and bind a name to the wrong file — a data-corruption race, not just a wrong path.

What this changes

  • libc-bottom-half/sources/chdir.c: give make_absolute a per-thread join buffer (__thread), so each thread's relative-path resolution has its own storage.

Test plan

  • Concurrent relative opens from multiple threads resolve to their own cwd-derived path (verified via pgrust's concurrent catalog reads).
  • No regression in single-threaded chdir/relative-open behavior.

make_absolute() resolved relative paths through one process-wide static
buffer (make_absolute_buf/_len), so concurrent relative opens from
different threads could bind a name to the wrong file. Make the buffer
per-thread (__thread).
@UnitBuilds
UnitBuilds marked this pull request as ready for review September 29, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant