Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7e56fd6cd28cdfdba59066705c0748d21570b27fd3f1d89ec7c10dc6a5deae5d
Ticket: 75d525d37c931812e9b00a80f6f43ac062598d54
Memory corruption transferring server (listening) sockets between threads
User & Date: sebres on 2020-05-29 20:23:04
Changes

  1. assignee changed to: "apnadkarni"
  2. icomment:
    Although it is fixed in branch [./timeline?r=bug-75d525d37c-sf-chan-transfer|[bug-75d525d37c-sf-chan-transfer]] now (platform-unrelated), the fix is a bit tricky: since as Ashok correctly said, Tcl-API doesn't provide any possibility to inform socket that this going attached to some interpreter.<br/>
    So one could reset interp in accept-data by thread (interp) detach, but it is impossible to be informed that it is attached again.
    
    Check-in [455c680c3a] provides now such information (interp set in statePtr of the channel now), that allows to use this in every socket handler, with prerequisite that socket would be not shared in multiple interpreter of same thread, or (like accept handler of server socket) it does not intended to be used in all interpreters.
    
    This also allows extremely simplify the (un)registering mechanism of socket handlers (like accept-proc and its client-data) and it could be protected by <code>(statePtr->interp == NULL)</code> inside handler and/or simple ref-counter now.
    
    Test, similar to attached by apn, that illustrating the bug, is provided also (just the segfault is not always reproducible).
    
    To use it in modules or extensions either internal structures of tclIO.h are expected, or we must implement new function like "Tcl_GetChannelInterp" (for the single or main interpreter mode only).
    
  3. login: "sebres"
  4. mimetype: "text/x-fossil-wiki"
  5. resolution changed to: "Fixed"
  6. status changed to: "Pending"