Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

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

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. 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-&gt;proc</tt> is <tt>Tcl_NotifyChannel</tt> so that <tt>Tcl_NotifyChannel()</tt> can be called directly.
    
  5. foundin changed to: "8.6.13"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "chrstphrchvz"
  14. subsystem changed to: "01. Notifier"
  15. title changed to:
    Functions passed to Tcl_CreateFileHandler() must be declared/defined as Tcl_FileProc
    
  16. type changed to: "Patch"