Skip to content
Tcl Source Code History Of Ticket d07f42998d
Login

History Of Ticket d07f42998d

Artifacts Associated With Ticket d07f42998d

  1. Ticket change [6c1881e6a4] (rid 214106) by apnadkarni on 2023-04-30 07:56:37:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-markdown"
    4. comment initialized to:
      The new Tcl_CreateObjCommand2 API permits creation of commands which accept more than `2**31` arguments. The following anomalous behavior is seen.
      
      When called through the 8.x wrapper, argument count wraps around. Instead, an error should be raised.
      
      ```
      % set cmd [testbigdata list 0x100000008]; llength $cmd
      4294967304
      % ledit cmd 0 0 testcmdobj2 ; llength $cmd
      4294967304
      % testcmdinfo call $cmd
      8 1 7
      ```
      
      `testcmdobj2` uses the Tcl_CreateObjCommand2 API to register itself and accepts ptrdiff_t sized counts. Its return is objc, first and last argument. As seen above, 0x100000008 is wraps around to 8. An error should be raised instead.
      
      Conversely, an old style command (e.g. lappend) also truncates when called through the new or old API when called with more than 2**32 arguments.
      
      ```
      % set l [testbigdata list 0x100000008]; llength $l
      4294967304
      % ledit l 0 1 lappend x ; llength $l
      4294967304
      % testcmdinfo call $l
      2 3 4 5 6 7
      % unset x
      % testcmdinfo call2 $l
      2 3 4 5 6 7
      ```
      
      When called with objc between INT_MAX and UINT_MAX, it does give an error but a misleading one.
      
      ```
      % set cmd [testbigdata list 0x80000008]; llength $cmd
      2147483656
      % ledit cmd 0 1 lappend X ; llength $cmd
      2147483656
      % testcmdinfo call $cmd
      wrong # args: should be "lappend varName ?value ...?"
      % testcmdinfo call2 $cmd
      wrong # args: should be "lappend varName ?value ...?"
      ```
      
      This error message, while not entirely wrong, is misleading and confusing since the error message text for lappend seems to indicate any number of arguments are accepted. A more informative error would be one that states that max argument count exceeded.
      
    5. foundin initialized to: "9.0"
    6. is_private initialized to: "0"
    7. login: "apnadkarni"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "apnadkarni"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to:
      Tcl_CreateObjCommand2 misleading error message and argument truncation
      
    16. type initialized to: "Bug"
  2. Ticket change [c9bdb2b8e3] (rid 214112) by apnadkarni on 2023-04-30 08:10:10:

    1. assignee changed to: "apnadkarni"
    2. icomment: "Working on a proposed fix in [bug-d07f42998d]."
    3. login: "apnadkarni"
    4. mimetype: "text/x-fossil-plain"
    5. title changed to:
      Tcl_CreateObjCommand2 argument truncation and misleading error message
      
  3. Ticket change [7c3644da57] (rid 214186) by apnadkarni on 2023-05-01 11:43:49:

    1. closedate changed to: "2460065.9887648"
    2. closer changed to: "apnadkarni"
    3. icomment: "Fixed in [71cab27557]"
    4. login: "apnadkarni"
    5. mimetype: "text/x-fossil-plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  4. Ticket change [99c9c5f435] (rid 214765) by jan.nijtmans on 2023-05-09 16:48:56:

    1. closer changed to: "nobody"
    2. icomment:
      Trying now:
      <pre>
      % set cmd [testbigdata list 0x80000008]; llength $cmd
      2147483656
      % ledit cmd 0 1 lappend X ; llength $cmd
      2147483656
      % testcmdinfo call $cmd
      wrong # args: should be "lappend varName ?value ...?"
      % testcmdinfo call2 $cmd
      Number of words (2147483656) in command exceeds limit 2147483647.
      % eval $cmd
      wrong # args: should be "lappend varName ?value ...?"
      </pre>
      
      So "lappend" cannot handle so many arguments. But why do the error-messages differ between "call" and "call2"? Isn't "eval" the same as "testcmdinfo call"? I still see the old error-message there
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
    5. resolution changed to: "None"
    6. status changed to: "Open"
  5. Ticket change [6ace5481d8] (rid 214766) by apnadkarni on 2023-05-09 17:27:30:

    1. icomment:
      With respect to call vs call2 - That is by intent. The purpose of the testcmdinfo is to test the exact C API by calling the underlying C functions without any argument checks. When the "Call" interface is used, the C API by definition cannot pass more than INT_MAX arguments (or negative ones). testcmdinfo does not check for that as a test command it expects the caller (test script) to pass arguments that match the type of the C API. Like much of the test framework, it does not check for errors on the part of the script. One can add that check to the implementation of testcmdinfo if one wishes, not to the core code.
      
      In other words, with the call command which maps to the 8.6 "int" based interfaces, it is impossible to pass more than INT_MAX arguments. You can pass negative objc (between INT_MAX and UINT_MAX) values which results in the wrong # args message. You cannot pass > INT_MAX positive values which result in "limit exceeded
      
      /Ashok
      
      /Ashok
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  6. Ticket change [f27e8b5ced] (rid 216044) by apnadkarni on 2023-06-29 16:09:57:

    1. closedate changed to: "2460125.17357841"
    2. closer changed to: "apnadkarni"
    3. login: "apnadkarni"
    4. mimetype: "text/plain"
    5. resolution changed to: "Fixed"
    6. status changed to: "Closed"