Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 867ce3ac5d5e7c2788a17e1d491ad6a525078185ad384736edd8651b00de2e15
Ticket: 40b1814b93e50b4a9627e6651184880233d63616
App verifier shows user-after-free on ThreadSpecificData for Windows sockets
User & Date: apnadkarni on 2025-06-14 05:37:49
Changes

  1. icomment:
    Also, use-after-free of socket handle [here](https://core.tcl-lang.org/tcl/file?ci=d2bd980da407586f&name=win/tclWinSock.c&ln=2308) on socket_inet-2.9.
    
    
    The tsdPtr bug appears to be caused by use of the same event handle to communicate socket notifications and worker thread completion to the main thread. The main thread waits for completion of worker to ensure its TSD is still available but mistakenly confuses a pending socket notification for thread completion as they use the same event and frees the TSD immediately while the worker thread is still active.
    
    
    Proposed fix for both is in commit [bug-40b1814b93](https://core.tcl-lang.org/tcl/info/bbb565eca787dfad). The tsdPtr bug is fixed by waiting on the worker thread handle rather than the notification event handle. The socket handle bug is a simple failure to mark socket closed in a loop error and then attempting to close it again.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"