Tcl Source Code

View Ticket
Login
Ticket UUID: fc35093cef269e906512ad028d7590f883edb0fe
Title: Better error-message than "interpreter uses an incompatible stubs mechanism"
Type: Bug Created on: 2025-01-03 15:02:11
Submitter: jan.nijtmans Assigned to: jan.nijtmans
Subsystem: 40. Dynamic Loading Severity: Minor
Priority: 5 Medium Last modified: 2025-05-06 13:31:07
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2025-05-06 13:31:07
Version: 9.0
Description:

If a shared library compiled for Tcl 8.x is loaded in Tcl 9.0, the error-message is: "interpreter uses an incompatible stubs mechanism".

We can do better than that, because Tcl 9.0 has a different 'magic' value which is unique compared to other possible error-situations.

Proposal: "this extension is compiled for Tcl 8.x"

User Comments:
jan.nijtmans added on 2025-01-03 16:52:05:

Implementation giving the improved error-message: [4260a19710f69a03|here]


jan.nijtmans added on 2025-01-07 12:31:48:

Fixed [7704f91f2ee08a30|here]


sbron added on 2025-05-06 09:05:33:

The current fix will produce the "this extension is compiled for Tcl 8.x" error message for any library with an incompatible stubs mechanism. While that describes the only reason that can happen at present, it fails to take into account that there may be incompatible changes to the stubs mechanism in the future. I can imagine that at some point in the future there may be a Tcl 10 with yet another change to the stubs mechanism. Loading an extension compiled for Tcl 10 into Tcl 9 would then also give the (misleading) indication that the extension was compiled for Tcl 8.x.

I suppose the easiest fix is to change the message to "this extension is compiled for a different Tcl major version", assuming incompatible changes to the stubs mechanism only happen in a major version. Alternative, in case "major version" is considered jargon that may not be clear to the average user, "this extension is not compiled for Tcl 9.x"


jan.nijtmans added on 2025-05-06 09:27:41:

Don't worry, all you are mentioning is already taken into account.

See: https://core.tcl-lang.org/tcl/file?name=generic/tclStubLib.c&ci=399d648cc325acd7&ln=80-97


dgp added on 2025-05-06 13:31:07:

Related background is found here [3588687]