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

Windows MT layer bug fixes #3364

Merged
merged 4 commits into from
Dec 19, 2022

Commits on Dec 17, 2022

  1. Fixes two bugs in the Windows thread / pthread translation layer

    1. If threads are resized the threads' `ZSTD_pthread_t` might move
    while the worker still holds a pointer into it (see more details in facebook#3120).
    2. The join operation was waiting for a thread and then return its `thread.arg`
    as a return value, but since the `ZSTD_pthread_t thread` was passed by value it
    would have a stale `arg` that wouldn't match the thread's actual return value.
    
    This fix changes the `ZSTD_pthread_join` API and removes support for returning
    a value. This means that we are diverging from the `pthread_join` API and this
    is no longer just an alias.
    In the future, if needed, we could return a Windows thread's return value using
    `GetExitCodeThread`, but as this path wouldn't be excised in any case, it's
    preferable to not add it right now.
    yoniko committed Dec 17, 2022
    Configuration menu
    Copy the full SHA
    500f02e View commit details
    Browse the repository at this point in the history
  2. Fix race condition in the Windows thread / pthread translation layer

    When spawning a Windows thread we have small worker wrapper function that translates
    between the interfaces of Windows and POSIX threads.
    This wrapper is given a pointer that might get stale before the worker starts running,
    resulting in UB and crashes.
    This commit adds synchronization so that we know the wrapper has finished reading the data
    it needs before we allow the main thread to resume execution.
    yoniko committed Dec 17, 2022
    Configuration menu
    Copy the full SHA
    ec42c92 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    aaa38b2 View commit details
    Browse the repository at this point in the history

Commits on Dec 19, 2022

  1. CR fixes

    yoniko committed Dec 19, 2022
    Configuration menu
    Copy the full SHA
    26f1bf7 View commit details
    Browse the repository at this point in the history