Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 449953ad352dab398df3e9011f8dee87140e47e4db6744ded795ce4a6e14cf3b
Ticket: 983f933f114af3a77d9df39359205811637ee2c2
source test triggers undefined behavior
User & Date: chrstphrchvz on 2025-12-20 02:07:37
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Example command (based on test source-7.4) and UBSan error:
    
    <pre>
    % source -encoding bogus /dev/null
    tcl91/generic/tclEncoding.c:2477:18: runtime error: applying zero offset to null pointer
    tcl91/generic/tclEncoding.c:1236:6: runtime error: applying zero offset to null pointer
    unknown encoding "bogus"
    </pre>
    
    As with [c9e68eb6], this sort of problem is not because of functions where the undefined behavior occurs, but rather because of whatever is passing <tt>NULL</tt> to those functions. LLDB backtrace for first error:
    
    <pre>
      * frame #0: 0x0000000100557920 libclang_rt.asan_osx_dynamic.dylib`__ubsan_on_report
        frame #1: 0x0000000100552000 libclang_rt.asan_osx_dynamic.dylib`__ubsan::Diag::~Diag() + 240
        frame #2: 0x000000010055707a libclang_rt.asan_osx_dynamic.dylib`handlePointerOverflowImpl(__ubsan::PointerOverflowData*, unsigned long, unsigned long, __ubsan::ReportOptions) + 1066
        frame #3: 0x0000000100556c46 libclang_rt.asan_osx_dynamic.dylib`__ubsan_handle_pointer_overflow + 54
        frame #4: 0x0000000101a2fa27 libtcl9.1.dylib`UtfToUtfProc(clientData=0x0000000000000200, src=0x0000000000000000, srcLen=0, flags=16778243, statePtr=0x00007ff7bfefbb20, dst="", dstLen=199, srcReadPtr=0x00007ff7bfefbb40, dstWrotePtr=0x00007ff7bfefbb50, dstCharsPtr=0x00007ff7bfefbb60) at tclEncoding.c:2477:18
        frame #5: 0x0000000101a3e534 libtcl9.1.dylib`Tcl_ExternalToUtfDStringEx(interp=0x0000000000000000, encoding=0x0000607000000fe0, src=0x0000000000000000, srcLen=0, flags=16778243, dstPtr=0x00007ff7bfefbf20, errorLocPtr=0x0000000000000000) at tclEncoding.c:1231:11
        frame #6: 0x0000000101a3dce7 libtcl9.1.dylib`Tcl_ExternalToUtfDString(encoding=0x0000000000000000, src=0x0000000000000000, srcLen=0, dstPtr=0x00007ff7bfefbf20) at tclEncoding.c:1132:5
        frame #7: 0x0000000101f83f7b libtcl9.1.dylib`TclGetProcessGlobalValue(pgvPtr=0x000000010277f240) at tclUtil.c:4258:2
        frame #8: 0x0000000101a45ab0 libtcl9.1.dylib`OpenEncodingFileChannel(interp=0x0000619000003780, name="bogus") at tclEncoding.c:1768:20
        frame #9: 0x0000000101a3a774 libtcl9.1.dylib`LoadEncodingFile(interp=0x0000619000003780, name="bogus") at tclEncoding.c:1884:12
        frame #10: 0x0000000101a2bc33 libtcl9.1.dylib`Tcl_GetEncoding(interp=0x0000619000003780, name="bogus") at tclEncoding.c:757:12
        frame #11: 0x0000000101c0cdee libtcl9.1.dylib`Tcl_SetChannelOption(interp=0x0000619000003780, chan=0x00006060000b13e0, optionName="-encoding", newValue="bogus") at tclIO.c:8299:17
        frame #12: 0x0000000101cee7b5 libtcl9.1.dylib`TclNREvalFile(interp=0x0000619000003780, pathPtr=0x0000604000297f90, encodingName="bogus") at tclIOUtil.c:1879:9
        frame #13: 0x00000001017fc685 libtcl9.1.dylib`TclNRSourceObjCmd(dummy1170=0x0000000000000000, interp=0x0000619000003780, objc=4, objv=0x0000611000014ae0) at tclCmdMZ.c:1217:14
        frame #14: 0x00000001016535bb libtcl9.1.dylib`Dispatch(data=0x00006040002982d8, interp=0x0000619000003780, dummy4623=0) at tclBasic.c:4662:12
        frame #15: 0x0000000101635eed libtcl9.1.dylib`TclNRRunCallbacks(interp=0x0000619000003780, result=0, rootPtr=0x0000000000000000) at tclBasic.c:4678:11
        frame #16: 0x00000001016484f8 libtcl9.1.dylib`TclEvalObjEx(interp=0x0000619000003780, objPtr=0x00006040001cb210, flags=131072, invoker=0x0000000000000000, word=0) at tclBasic.c:6125:12
        frame #17: 0x0000000101648373 libtcl9.1.dylib`Tcl_EvalObjEx(interp=0x0000619000003780, objPtr=0x00006040001cb210, flags=131072) at tclBasic.c:6106:12
        frame #18: 0x0000000101bb91b2 libtcl9.1.dylib`Tcl_RecordAndEvalObj(interp=0x0000619000003780, cmdPtr=0x00006040001cb210, flags=131072) at tclHistory.c:182:11
        frame #19: 0x0000000101d86d81 libtcl9.1.dylib`Tcl_MainEx(argc=-1, argv=0x00007ff7bfeff560, appInitProc=(tclsh9.1`Tcl_AppInit at tclAppInit.c:124), interp=0x0000619000003780) at tclMain.c:523:13
        frame #20: 0x0000000100001e2d tclsh9.1`main(argc=1, argv=0x00007ff7bfeff560) at tclAppInit.c:98:5
        frame #21: 0x00007ff803fe8530 dyld`start + 3056
    </pre>
    
  5. foundin changed to: "core-8-6-branch"
  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: "source test triggers undefined behavior"
  16. type changed to: "Bug"