Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ddd2f1ed3349d900196a6c32f270ef6022a11e7d6353377b4a5ac37f394daab8
Ticket: abd489a1cf4782f0255f307c42370d3a5e27c464
TclStringCmp() calls functions through pointer to incorrect type
User & Date: chrstphrchvz on 2023-10-13 07:20:01
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Example UBSan <tt>-fsanitize=function</tt> error:
    
    <pre>
    % string compare a b
    <span style="font-weight:bold">tcl/generic/tclCmdMZ.c:2863:10: <span style="color:firebrick">runtime error:</span> call to function TclpUtfNcmp2 through pointer to incorrect function type 'int (*)(const void *, const void *, unsigned long)'
    tclUtf.c:1233: <span style="color:gray">note:</span></span> TclpUtfNcmp2 defined here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclCmdMZ.c:2863:10 in 
    -1
    </pre>
    
    Some of the compare functions are public APIs, so I would suggest either using an enum to call functions directly, or wrapper functions (as done by the attached patch).
    
  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: "18. Commands M-Z"
  15. title changed to:
    TclStringCmp() calls functions through pointer to incorrect type
    
  16. type changed to: "Patch"