Ticket Change Details
Not logged in
Overview

Artifact ID: 5e31df23db8ab233c884cb3e720fdb53308f89b935eadd222d70d8c1f1fde1c2
Ticket: 578155d5a19b348dc1a9fe96cc2c067a59326a89
Very rare bug (segfault) if set variable (with error case) using self-releasable object as new value
User & Date: sebres 2023-03-28 12:40:59
Changes

  1. closer changed to: "nobody"
  2. icomment:
    Please don't close it.<br/>
    If someone doesn't understand something (or doesn't want spent more time to go deeper), this is not a reason to close the ticket.<br/>
    Regarding the examples - the ticket contains enough of them to illustrate the wrong behavior of <code>Tcl_ObjSetVar2</code> and co in the error case.
    
    Basically since <code>Tcl_ObjSetVar2</code> doesn't create an object and doesn't realy own an object in case of error (because it doesn't in common sense), <b>it should not decrease a reference in error case</b> at all, even less on certain conditions only (depending on the reference count of object, how it does right now) - this is dirty workaround and not a solution. Especially undocumented, see [https://www.tcl-lang.org/man/tcl/TclLib/SetVar.htm|SetVar.htm]. 
    However the only way to fix it properly - use a new flag <code>TCL_OWN_OBJREF</code>, like I did it.
    
    Additionally I'd like to note that after the fix [bc5e7bdafc922baf] (and later with a new flag <code>TCL_OWN_OBJREF</code> I implemented) I never saw this bug anymore (neither the reference error, nor the leak).
    
  3. login: "sebres"
  4. mimetype: "text/x-fossil-wiki"
  5. resolution changed to: "Fixed"
  6. status changed to: "Pending"