Overview
| Artifact ID: | 473fc1ecbe07da9b76da8ce503340dd1d2e558401e13e5c578ef160f5747edd5 |
|---|---|
| Ticket: | 8ab8a138c9156e5a5a4a386310c6fd11608b8805
Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc |
| User & Date: | chrstphrchvz on 2023-10-07 13:13:17 |
Changes
- comment changed to:
LLVM Clang 17 makes <tt>-fsanitize=function</tt> available for C (previously it was just for C++). It is implied by <tt>-fsanitize=undefined</tt>. It complains about calls to <tt>freeProc(clientData)</tt> from <tt>Tcl_EventuallyFree()</tt> and <tt>Tcl_Release()</tt>. Unlike warnings from e.g. <tt>-Wincompatible-function-pointer-types</tt>, this UBSan error is not suppressed by casts to <tt>(Tcl_FreeProc *)</tt>. Example when exiting tclsh: <pre> <span style="font-weight:bold">tcl/generic/tclPreserve.c:229:3: <span style="color:firebrick">runtime error:</span> call to function DeleteInterpProc through pointer to incorrect function type 'void (*)(char *)' tclBasic.c:1422: <span style="color:gray">note:</span></span> DeleteInterpProc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclPreserve.c:229:3 in </pre> There are only a few instances of this in core Tcl; to patch these, I remove casts to <tt>(Tcl_FreeProc *)</tt>, then use the <tt>Tcl_FreeProc</tt> typedef for function declarations, and then fix function definitions. There are several more instances in core Tk which I am looking into patching. Any extensions passing incompatible function pointers to <tt>Tcl_EventuallyFree()</tt> will also trigger this UBSan error.
- login: "chrstphrchvz"
- mimetype: "text/plain"