Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4441a7cbdc67a3cdbfd2ba2f3d0cfa6ea9ca77fa3a74d116803aca803b881c1b
Ticket: 4eb3a155ac6f73f48b270a19e543841d26bf2e6f
apply causes memory corruption / crash
User & Date: apnadkarni on 2022-07-23 04:30:17
Changes

  1. icomment:
    *Comments from sebres on the chat:*
    
    <sebres>: apn: nice catch... just as for the fix [072cffce6f] - it is a bit too heavy, I mean always to shimmer to pure string body (for instance it'd never use a list eval, if body is list), also could lost some large object internal representations (apply [list args [list ... $largeObj]]), and would need to recreate it by the evaluation e. g. shimmer back to expected type)
    
    <sebres>: apn: isn't possible to correct procPtr->numCompiledLocals or even force that recompilation only in case where it is wrong (we assuming invocation of byteCode vs. lambda/proc byteCode)?
    
    *My response on the chat:*
    
    @sebres, regarding [072cffce6f], I was just glad I was not completely off-track a few days ago when I logged a bogus ticket about bug in apply! Regarding the fix, my first thought had been that it might be potentially heavyweight as you say  because of the internal rep being discarded. But then rethinking, I concluded any internal rep is going to get shimmered to a ByteCode object anyways when the script (in bodyPtr) is compiled by TclCompileScript. So it is only being discarded a little earlier.  This was the cleanest solution I could find but this is my foray into the byte code world so I could be wrong about that.
    
    It is also a rare case that the lambda object does not have a internal Lambda representation but the body object has an internal ByteCode representation.
    
    "apn: isn't possible to correct procPtr->numCompiledLocals or even force that recompilation only in case where it is wrong (we assuming invocation of byteCode vs. lambda/proc byteCode)?" - I went down that path too (have body store that value and update procPtr in the case the body is not recompiled) but beyond my abilities at this time. I'm not sure what other side effects the body compilation has and what else might need to be fixed/restored.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"