Tcl Source Code

View Ticket
Login
Ticket UUID: 0b9200888e2fd6dd14fee5fc8471f6e8cb864a96
Title: TIP #660 breaks TIP #628/#630
Type: Bug Created on: 2023-04-11 22:49:40
Submitter: jan.nijtmans Assigned to: pooryorick
Subsystem: - New Builtin Commands Severity: Severe
Priority: 5 Medium Last modified: 2023-09-12 12:32:01
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2023-09-12 12:32:01
Version:
Description:

A testcase showing the problem is pkgt.c, in the unix/dltest directory

This function does:

    Tcl_CreateObjCommand2(interp, "pkgt_eq", Pkgt_EqObjCmd2, NULL, NULL);
    Tcl_CreateObjTrace2(interp, 0, 0, TraceProc2, NULL, NULL);

The "2" API is supposed to register 64-bit capable commands/traces. But with TIP #660, the types are using Tcl_Size, which is "int" when compiled for Tcl 8.7. That doesn't match the 8.7 version of tcl.h. So, the functions registered have the wrong signature then. Solution: the typedefs for Tcl_CmdObjTraceProc2 and Tcl_ObjCmdProc2 should use ptrdiff_t, not Tcl_Size

User Comments:
jan.nijtmans added on 2023-04-11 22:53:14:

Proposed fix [a409b62d344f4dde|here]


jan.nijtmans added on 2023-04-12 08:58:44:

Fixed [796eb2ec4be21c66|here]


apnadkarni added on 2023-04-12 13:28:03:

Thanks for the fix but I'm not sure that is the right solution. I don't believe from a practical point of view the "2" API's will ever be functional on Tcl 8.7 with 64-bit width. (As an aside, I'm doubtful that even 32-bit Tcl 9 will usefully support that internally but that is another matter.)

Given that, I think the "2" API's should really be defined as dealing with Tcl_Size width objc in both Tcl 8.7 and Tcl 9 as opposed to 64-bit widths. For 8.7 then, and 32-bit Tcl 9, they would be functionally equivalent to their non-"2" counterparts and present only for source compatibility with 64-bit builds that do support (in the future) the larger objc range.

But I don't find this distinction sufficiently important to discuss so I'm ok with whatever you decide.

/Ashok


jan.nijtmans added on 2023-04-13 14:08:18:

Follow-up [3a6e95a25219a787|here], regarding TIP #627.

I'm aware that you don't care about breaking earlier TIP's, that's why I'm jumping in here. TIP #660 does not describe its effects on other TIP's other than #494.

One day you will discover that Tcl_MethodCallProc2 and Tcl_NRCallObjProc2 are still using size_t, and you will be tempted to change it to Tcl_Size. That's wrong for the same reasons I already explained, whether you like it or not!


apnadkarni added on 2023-04-16 12:51:04:

I think you missed my point. I'm saying that 8.7 API's should NOT be introducing API's that take 64-bit arguments in the first place. To achieve the intended purpose of source compatibility, the older Tcl_CreateObjCommand etc. would continue to take int parameters. The new "2" version would take Tcl_Size parameters, not size_t or ptrdiff_t. The purpose is source compatibility, not 64-bit length support in Tcl 8.7 which is completely pointless.

Regarding your comment on TIP 660 not mentioning TIP's other than 494, it does say primarily 494 and does not enumerate all the other TIP's because I felt there was no point in enumerating every single TIP that switched parameters from signed to unsigned. It does say all parameters to public and private API's referring to lengths and indices will be changed to signed.

Also, you are wrong about my not caring about breaking earlier TIP's. But it is true that I don't care to stick to previous TIP's that were themselves broken to begin with as gospel! 494 was in that category and that led to 660. I view others like "2" definitions that use 64-bit lengths that serve no practical purpose in 8.7 the same way, but unlike 494, not critical.

/Ashok


jan.nijtmans added on 2023-04-16 18:25:27:

> Also, you are wrong about my not caring about breaking earlier TIP's

Well, just saw [23c8313c59eafea1|this] commit, which I expected you were overlooking. That's - indeed - the right thing to do, so I'm finally glad you didn't overlook. Instead of discussing the usefulness of past (accepted) TIP's, let's focus on real work. The challenge in TIP #660 is already big enough.


jan.nijtmans added on 2023-05-03 10:41:55:

Re-opening, because commit [cd426d20a9327f49] broke it again.

Nathan, please revert this change. See discussion below


pooryorick added on 2023-05-03 15:30:02:

I was going to reply, but now see that TIP 666 addresses this, so maybe that's good enough (assuming it passes).


jan.nijtmans added on 2023-05-03 15:41:37:

Note: the TIP number is pure coincidence!


pooryorick added on 2023-05-03 16:00:58:

The devil is in the details ;)


jan.nijtmans added on 2023-09-12 12:32:01:

Since TIP #666 is accepted and merged now, Tcl 8.7 and 9.0 are once-again source-compatible. So, this ticket can be closed now, once and for all.