Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f0badc00d63e9f4f834b5b1077efae05a4fc506079b935dca0593db0e9e669d1
Ticket: 89fbf1f86e4935a146f30dcf3829f44e90a564d5
Unclean memory handling
User & Date: pointsman on 2023-10-16 22:13:09
Changes

  1. icomment:
    I agree with apnadkarni and chrstphrchvz that both spots reported by
    valgrind here as 'definitely lost' are harmless. The code inspection
    is backed up by this script:
    
        set interp [interp create]
        $interp eval [list proc exit args {return -code return}]
        $interp eval [list set argv0 $argv0]
        $interp eval [list set argv $argv]
        $interp eval [list set argc $argc]
        $interp eval source sak.tcl
        interp delete $interp
    
    Running this under valgrind as sibling to sak.tcl returns:
    
    ==488001== LEAK SUMMARY:
    ==488001==    definitely lost: 0 bytes in 0 blocks
    ==488001==    indirectly lost: 0 bytes in 0 blocks
    ==488001==      possibly lost: 0 bytes in 0 blocks
    ==488001==    still reachable: 780 bytes in 14 blocks
    ==488001==         suppressed: 0 bytes in 0 blocks
    
    So Tcl is able to cleanly turn down an interpeter which runs this
    code.
    
    But it does not in the example given in the ticket. This is obviously
    a problem no matter (as I wrote in the ticket) if this can be
    exploited for an ever growing process.
    
    We have explict code to handle this case (start with
    [https://core.tcl-lang.org/tcl/info?udc=1&ln=692-726&name=aedf4a0025345ada1b844749ff2fc854ba880153257829320e2c84f150004d19]).
    
    Clear memory shutdown is obviously a good thing to have for memory
    leaks hunting. The current state makes automatic checks more
    difficult. For sure nobody mandates a list of "harmless 'definitely
    lost reports'". Every serious contributor will stumble over this with
    a wtf moment at some point. There is no other way than to fix this.
    
  2. login: "pointsman"
  3. mimetype: "text/x-fossil-plain"