Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 30a8da4632876792a564964231a4a8e4f47790f39ff3c8f3ce1d4266be4a4bc3
Ticket: 8ab8a138c9156e5a5a4a386310c6fd11608b8805
Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc
User & Date: chrstphrchvz on 2023-10-13 13:58:28
Changes

  1. icomment:
    <blockquote><tt>-Wcast-function-type</tt> also works.</blockquote>
    …but not when there is an intermediate <tt>(void *)</tt> cast.
    
    The casts in tclDecls.h cause <tt>Tcl_EventuallyFree()</tt> and <tt>Tcl_SetResult()</tt> to be called from function pointers of incorrect type, and so now UBSan complains even more. A couple of examples:
    
    <pre>
    <span style="font-weight:bold">tk/generic/tkMenuDraw.c:796:2: <span style="color:firebrick">runtime error:</span> call to function Tcl_EventuallyFree through pointer to incorrect function type 'void (*)(void *, void *)'
    tclPreserve.c:265: <span style="color:gray">note:</span></span> Tcl_EventuallyFree defined here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tk/generic/tkMenuDraw.c:796:2 in 
    </pre>
    
    <pre>
    <span style="font-weight:bold">tcl/generic/tclTest.c:1117:2: <span style="color:firebrick">runtime error:</span> call to function Tcl_SetResult through pointer to incorrect function type 'void (*)(struct Tcl_Interp *, char *, void *)'
    tclResult.c:419: <span style="color:gray">note:</span></span> Tcl_SetResult defined here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclTest.c:1117:2 in 
    </pre>
    
  2. login: "chrstphrchvz"
  3. mimetype: "text/x-fossil-wiki"