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

Set tube->ev_listen to NULL to prevent double unregister in winsock code path #774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 1, 2022

  1. Set tube->ev_listen to NULL to prevent double unregister

    On windows when using threaded mode (i.e. `ub_ctx_async(ctx, 1)`)
    tube_remove_bg_listen gets called twice: once when the thread does its
    own cleanup, then again in `tube_delete()`.  Because `ev_listen` doesn't
    get cleared, however, we end we calling ub_winsock_unregister_wsaevent
    with a freed pointer.
    
    This doesn't always manifest because, apparently, for various compilers
    and settings that memory *might* be overwritten in which case the
    additional check for ev->magic will prevent anything actually happening,
    but in my case under mingw32 that doesn't happen and we end up
    eventually crashing.
    
    This fixes the crash by properly NULLing the pointer so that the second
    ub_winsock_unregister_wsaevent(...) becomes a no-op.
    jagerman committed Nov 1, 2022
    Configuration menu
    Copy the full SHA
    56d8160 View commit details
    Browse the repository at this point in the history