Skip to content
Tcl Source Code Artifact [d66b0d9643]
Login

Artifact [d66b0d9643]

Artifact d66b0d964355e33fc7ffe9eaa44e660786f0dfb9f3a698e4231d29329a5139e7:

Ticket change [d66b0d9643] - Ticket [5c3679820afa2aca|5c3679820a] <i>64-Bit Extensions Do Not Work With Old Tcl Applications</i> status still Open with 3 other changes by jan.nijtmans on 2025-03-03 15:00:43.
D 2025-03-03T15:00:43.284
J icomment >\sIs\sit\sreally\scorrect\sthat\sonly\sthe\s64\sbit\sapplications\s(version\s8\sand\s9)\sare\sbinary\sincompatible\sand\sthe\s32\sbit\sapplications\sremain\sbinary\scompatible?\r\n\r\nFirst\squestion:\sYes!\sFor\sexample,\stry:\r\n<pre>\r\nTcl_Obj\s*obj\s=\sTcl_NewStringObj("hello",\s-1);\r\nprintf(obj->bytes);\r\n</pre>\r\nIf\syou\sdo\sthis\sin\sa\s64-bit\sTcl-8.6-compiled\sextension,\srunning\sin\sTcl\s9.0.\sthe\ssecond\sargument\sof\sTcl_NewStringObj()\sis\sa\s"int",\sso\sthe\svalue\s0xFFFFFFFF\s(4\sbytes)\swill\sbe\spushed\son\sstack.\sTcl9.0\swill\spull\s8\sbytes\soff\sthe\sstack,\swhich\swill\sbe\s4\s0xFF\sbytes\sfollowed\sby\s4\sbytes\sof\srandom\sdata.\sThat\swill\scrash,\sunless\s....\smodern\scompilers\sdon't\suse\sthe\sstack\sfor\ssuch\sfunction\sparameters\sbut\sinternal\sregisters.\sThat\swill\swork.\sPhew,\syou\sare\slucky.\sThen,\sthe\sobj->bytes\sfield\sis\sjust\safter\sthe\sobj->refCount\sfield,\swhich\sis\s4\sbytes\sin\sTcl\s8.6\sand\s8\sbytes\sin\sTcl\s9.0.\sSince\smost\scompilers\salign\sthe\sobj->bytes\sfields\son\sa\smultiple\sof\s8\sbytes,\syou\sare\slucky\sagain:\sit\swill\swork.\sBut\s-\syou\ssee\s-\syou\scannot\sdepend\son\sthat.\sMore\scomplicated\sexamples\swill\scertainly\scrash.\sYou\swill\sbe\son\syour\sown\strying\sthat,\sthat's\swhy\sthe\smagic\svalue\swas\schanged.\r\n\r\nOn\s32-bit\smachines,\sit\swill\sbe\salmost\sbinary\scompatible.\sThere\sare\s2\sthings\syou\scannot\sdo:\r\n*\sCall\sany\sof\sthe\sdeprecated\sfunctions,\slike\sTcl_MakeSafe().\sThey\sonly\swork\sin\sTcl\s8.6\r\n*\sCall\sany\sof\sthe\sinternal\sfunctions\s(in\stclIntDecls.h),\sthey\smoved\sto\sdifferent\sstub\sentries\r\nSince\sthere\sis\sno\sway\sto\sknow\sif\san\salready-compiled\sextension\svoilates\sthat,\sI\sdon't\srecommend\srunning\sa\sTcl\s8.6\sextension\sin\sTcl\s9.0\sor\sreverse.\sIf\sit\sworks,\syou\sare\slucky.\sBetter\srecompile\sit\sin\sa\sTcl\s9.0\senvironment,\sthen\sthe\scompiler\sshould\scomplain\sif\sthere\sis\sa\sproblem.
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K 5c3679820afa2aca58ef3bb2041181669fab5ac7
U jan.nijtmans
Z 4657f6241165a279cda9e90d4d9b5bdd