Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 42f31524a5b80d6f2c22cf21070d92d9a65cdbae551b79eff633ab36ba4ee756
Ticket: 8ab8a138c9156e5a5a4a386310c6fd11608b8805
Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc
User & Date: chrstphrchvz on 2023-10-11 07:23:35
Changes

  1. icomment:
    Jan, I am sorry if the title I gave this ticket was misleading, but unfortunately the work so far on the bug-8ab8a138c9 branch ultimately does not solve the problem.
    
    What matters is the type of actual function declarations/definitions, and not the type of function pointers passed to <tt>Tcl_EventuallyFree()</tt>.
    
    At runtime, when <tt>freeProc()</tt> is called from <tt>Tcl_EventuallyFree()</tt> or <tt>Tcl_Release()</tt>, UBSan <tt>-fsanitize=function</tt> checks whether the function pointed to by <tt>freeProc</tt> was actually declared/defined with a signature matching the type of <tt>freeProc</tt>, which is <tt>Tcl_FreeProc</tt>. It does not matter to this UBSan check whether the function pointer in <tt>freeProc</tt> was originally passed to <tt>Tcl_EventuallyFree()</tt> through any casts, so I do not see what is accomplished by additional intermediate casting through <tt>void *</tt>.
    
    I still believe the correct fix for this problem is to declare/define functions correctly, which is what I meant in the title: only pointers to functions whose actual declarations/definitions match <tt>Tcl_FreeProc</tt> should be passed to <tt>Tcl_EventuallyFree()</tt> (which can be done without casts), so that UBSan does not complain when the function is later called from <tt>Tcl_EventuallyFree()</tt> or <tt>Tcl_Release()</tt>.
    
  2. login: "chrstphrchvz"
  3. mimetype: "text/x-fossil-wiki"