Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e6d35a93844713346385549c4942dd3f01efcd2bf7d010e55eb545cd42c1e6e8
Ticket: 7c2716733a526ba6d08eccbf27b6a07f8b081cff
App Verifier shows use-after-free on event handle for Windows pipes
User & Date: apnadkarni on 2025-06-14 14:31:09
Changes

  1. icomment:
    Proposed fix is [here](https://core.tcl-lang.org/tcl/info/e85c44529a9b3d58).
    
    Looking more closely at the code, I did not see why that event handle was needed at all. In summary,
    
    * the handle in question is `TclPipeThreadInfo.evWakeup`. This is initialized from the `readable` or `writable` event handles from the channel structure.
    
    * the worker thread however signal read or write completions directly using the `readable`/`writable` handles from the channel structure, not evWakeup.
    
    * the only time `TclPipeThreadInfo.evWakeup` is signalled is on worker thread exit which is when it has already been deallocated by the main thread causing the use-after-free error!
    
    The proposed fix simply expunges all references to the `TclPipeThreadInfo.evWakeup`. The test suite passes and Application Verifier no longer complains. But someone should review before merge.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"