Artifacts Associated With Ticket f4b0cb208044f175
Ticket change [5b5c7a388f] (rid 191317) by anticrisis on 2021-01-22 22:38:12:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "core-8-branch"
- is_private initialized to: "0"
- login: "anticrisis"
- priority initialized to: "5 Medium"
- private_contact initialized to: "00d9ff853328848f3f7df354bd59967669224d5d"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "anticrisis"
- subsystem initialized to: "- New Stub Entries"
- title initialized to: "Cannot compile sqlite against core-8-branch Tcl"
- type initialized to: "Bug"
Ticket change [33cb808056] (rid 191320) by anticrisis on 2021-01-23 00:09:32:
- 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.
- login: "anticrisis"
- mimetype: "text/plain"
- username: "anticrisis"
- icomment:
Ticket change [1ed8dad761] (rid 191321) by anticrisis on 2021-01-23 03:09:30:
- 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.
- login: "anticrisis"
- mimetype: "text/plain"
- username: "anticrisis"
- icomment:
Ticket change [af9b447991] (rid 191331) by anticrisis on 2021-01-25 08:30:06:
- 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. - login: "anticrisis"
- mimetype: "text/plain"
- priority changed to: "6"
- title changed to:
Calling Tcl_GetStringFromObj with NULL lengthPtr causes compile error
- comment changed to:
Ticket change [b0f933c909] (rid 191352) by jan.nijtmans on 2021-01-25 10:32:18:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2459239.93910251"
- closer changed to: "jan.nijtmans"
- 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!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [0832572d2d] (rid 191396) by anticrisis on 2021-01-27 06:08:48:
- closedate changed to: "2459241.75612089"
- closer changed to: "anticrisis"
- icomment:
Ah, thank you! I learned something about C today. And, sqlite now compiles successfully again with core-8-branch.
- login: "anticrisis"
- mimetype: "text/plain"
Ticket change [ba63be506a] (rid 195241) by dgp on 2021-07-26 17:35:29:
- closedate changed to: "2459422.23297884"
- closer changed to: "dgp"
- icomment:
I cannot reproduce the issue reported here, but I created a branch bug-f4b0cb2080 with a potential fix. Any comment or testing?
- login: "dgp"
- mimetype: "text/plain"