Skip to content
Tcl Source Code History Of Ticket f4b0cb208044f175
Login

History Of Ticket f4b0cb208044f175

Artifacts Associated With Ticket f4b0cb208044f175

  1. Ticket change [5b5c7a388f] (rid 191317) by anticrisis on 2021-01-22 22:38:12:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Code introduced in tclDecls.h to handle 64 bit issues causes sqlite to fail to compile, because the new code does not allow passing NULL as a lengthPtr.
      
      Here is a godbolt link to an isolated sample. Note that calling Tcl_GetStringFromObj with 0 as the lengthPtr argument causes a compile error.
      
          https://godbolt.org/z/vxzv53
      
      The problem is this, in tclDecls.h:
      
      #define Tcl_GetStringFromObj(objPtr, sizePtr) \
      	(sizeof(*sizePtr) <= sizeof(int) ? tclStubsPtr->tcl_GetStringFromObj(objPtr, (int *)sizePtr) : tclStubsPtr->tclGetStringFromObj(objPtr, (size_t *)sizePtr))
      
      This macro fails if sizePtr is 0, because (*sizePtr) is not valid C code.
      
      Documentation for Tcl_GetStringFromObj indicates that sizePtr may be NULL, but this macro does not allow that.
      
    5. foundin initialized to: "core-8-branch"
    6. is_private initialized to: "0"
    7. login: "anticrisis"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "00d9ff853328848f3f7df354bd59967669224d5d"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "anticrisis"
    14. subsystem initialized to: "- New Stub Entries"
    15. title initialized to: "Cannot compile sqlite against core-8-branch Tcl"
    16. type initialized to: "Bug"
  2. Ticket change [33cb808056] (rid 191320) by anticrisis on 2021-01-23 00:09:32:

    1. icomment:
      I'm not sure I understand the logic of these macros. Is the Tcl C API changing from using int to using size_t? Wouldn't it be easier to simply stay with int, which will always be the same size on a given platform and compiler?
      
      It seems these macros are intending to support the case where a particular C extension may sometimes use int and sometimes use size_t. But shouldn't the C extension conform to the interface provided by the API documentation? If we're changing to size_t, then people will have to update their code. If we're staying with int, then we don't need these macros.
      
    2. login: "anticrisis"
    3. mimetype: "text/plain"
    4. username: "anticrisis"
  3. Ticket change [1ed8dad761] (rid 191321) by anticrisis on 2021-01-23 03:09:30:

    1. icomment:
      I found TIP 481, which indicates we are intending to support both int and size_t arguments. I just don’t know how a macro can work when 0 is a valid argument.
      
    2. login: "anticrisis"
    3. mimetype: "text/plain"
    4. username: "anticrisis"
  4. Ticket change [af9b447991] (rid 191331) by anticrisis on 2021-01-25 08:30:06:

    1. comment changed to:
      Code recently introduced in tclDecls.h to handle 64 bit issues causes compile errors when NULL (0) is used as a lengthPtr. This is a common practice when using this function, and is a documented feature.
      
      Here is a godbolt link to an isolated sample. Note that calling Tcl_GetStringFromObj with 0 as the lengthPtr argument causes a compile error.
      
          https://godbolt.org/z/vxzv53
      
      The problem is this, in tclDecls.h:
      
      #define Tcl_GetStringFromObj(objPtr, sizePtr) \
      	(sizeof(*sizePtr) <= sizeof(int) ? tclStubsPtr->tcl_GetStringFromObj(objPtr, (int *)sizePtr) : tclStubsPtr->tclGetStringFromObj(objPtr, (size_t *)sizePtr))
      
      This macro fails if sizePtr is 0, because (*sizePtr) is not valid C code.
      
      Documentation for Tcl_GetStringFromObj indicates that sizePtr may be NULL, but this macro does not allow that.
      
    2. login: "anticrisis"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
    5. title changed to:
      Calling Tcl_GetStringFromObj with NULL lengthPtr causes compile error
      
  5. Ticket change [b0f933c909] (rid 191352) by jan.nijtmans on 2021-01-25 10:32:18:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2459239.93910251"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      It is true that '0' as argument doesn't work, but NULL does! Since lengthPtr is a pointer to an integer, it - actually - should be (int *)NULL, and that works too. However, since '0' was accepted as argument in Tcl 8.6, we cannot just change that in a minor release, pity. In Tcl 9.0, strings can be larger than MAX_INT, this group of functions should - then - be able to account for that.
      
      In Tcl 9.0, either use an (int *)NULL argument, or use the function Tcl_GetString() (which is a macro doing the same). It's a small burden for extensions to make that change, but it opens up the 64-bit world for string lengths, that's what TIP 481 is about.
      
      Thanks for your report!
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  6. Ticket change [0832572d2d] (rid 191396) by anticrisis on 2021-01-27 06:08:48:

    1. closedate changed to: "2459241.75612089"
    2. closer changed to: "anticrisis"
    3. icomment:
      Ah, thank you! I learned something about C today. And, sqlite now compiles successfully again with core-8-branch.
      
    4. login: "anticrisis"
    5. mimetype: "text/plain"
  7. Ticket change [ba63be506a] (rid 195241) by dgp on 2021-07-26 17:35:29:

    1. closedate changed to: "2459422.23297884"
    2. closer changed to: "dgp"
    3. icomment:
      
      I cannot reproduce the issue reported here, but I created a branch
      bug-f4b0cb2080 with a potential fix.  Any comment or testing?
      
    4. login: "dgp"
    5. mimetype: "text/plain"