Overview
| Artifact ID: | b2a5196b43f5205f105170b1481b920be3899b03f8d6541d83b74c2beb7b3d64 |
|---|---|
| Ticket: | ad5a57f2f271b5a40fe9abef4055dc7b547c80c0
Functions passed to Tcl_CreateFileHandler() must be declared/defined as Tcl_FileProc |
| User & Date: | chrstphrchvz on 2023-10-12 10:58:29 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
The signature of <tt>Tcl_NotifyChannel()</tt> does not match <tt>Tcl_FileProc</tt>, but in core Tcl there are 3 instances where it is passed to <tt>Tcl_CreateFileHandler()</tt> anyway. Example UBSan <tt>-fsanitize=function</tt> error when <tt>Tcl_NotifyChannel()</tt> is later called from <tt>FileHandlerEventProc()</tt>: <pre> <span style="font-weight:bold">tcl/macosx/tclMacOSXNotify.c:1223:6: <span style="color:firebrick">runtime error:</span> call to function Tcl_NotifyChannel through pointer to incorrect function type 'void (*)(void *, int)' tclIO.c:8341: <span style="color:gray">note:</span></span> Tcl_NotifyChannel defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/macosx/tclMacOSXNotify.c:1223:6 in </pre> Since <tt>Tcl_NotifyChannel()</tt> is a public API, the workaround I would propose is to use wrapper functions; see attached patch. If wanting to pass <tt>Tcl_NotifyChannel</tt> to <tt>Tcl_CreateFileHandler()</tt> is so common elsewhere that it should be allowed, then an alternative would be to add a special case to <tt>FileHandlerEventProc()</tt> which checks if <tt>filePtr->proc</tt> is <tt>Tcl_NotifyChannel</tt> so that <tt>Tcl_NotifyChannel()</tt> can be called directly.
- 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: "01. Notifier"
- title changed to:
Functions passed to Tcl_CreateFileHandler() must be declared/defined as Tcl_FileProc
- type changed to: "Patch"