Overview
| Artifact ID: | cb73bae87ffbb8a159a343cc31355b4f327a46a2162c00d0b8e9fa9d8205dd26 |
|---|---|
| Ticket: | 8ab8a138c9156e5a5a4a386310c6fd11608b8805
Functions passed to Tcl_EventuallyFree() must be declared/defined as Tcl_FreeProc |
| User & Date: | chrstphrchvz on 2023-10-07 12:30:45 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- 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 of 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.
- foundin changed to: "8.6.13"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- private_contact changed to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "42. Memory Preservation"
- title changed to:
Do not pass incompatible function pointers to Tcl_EventuallyFree()
- type changed to: "Patch"