Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 57ddd2c8ad02e79ca6618065a76bdd064e10ec8b
Ticket: 2820349fffffffffffffffffffffffffffffffff
Tcl_ThreadQueueEvent can lead to memory leaks
User & Date: flatworm on 2009-07-12 12:15:44
Changes

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Tcl_ThreadQueueEvent() only calls QueueEvent() which actually adds the event to the specified notifier's queue if such notifier was found, that is, if there is a notifier bound to the thread specified in the call.
    
    As the specification states that after a call to Tcl_ThreadQueueEvent() the event's memory will be owned by the approptiate notifier, and the function does not return any information to the caller about whether the event was delivered or not, then if the target thread does not exist, the event memory will be lost.
    
    Since this function is a part of the public API (and therefore can be called with arbitrary arguments) the possibility of the non-existing target thread is possible.
    
    I think that turning
    
    if (tsdPtr) {
        QueueEvent(tsdPtr, evPtr, position);
    }
    
    into
    
    if (tsdPtr) {
        QueueEvent(tsdPtr, evPtr, position);
    } else {
        ckfree((char*) evPtr);
    }
    
    would fulfill the contract about the event's memory handling.
    
  4. foundin changed to: "obsolete: 8.6b1.1"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "flatworm"
  10. subsystem changed to: "01. Notifier"
  11. title changed to: "Tcl_ThreadQueueEvent can lead to memory leaks"
  12. type changed to: "Bug"