Skip to content
Tcl Source Code Artifact [3c72114510]
Login

Artifact [3c72114510]

Artifact 3c72114510dfe68019372beac9426eba98d8138f641619a67a0523b9ded37d0d:

Ticket change [3c72114510] - Add attachment [/artifact/1b1aa6dc2e6e0899|0007-tclHash-Fix-strict-aliasing-violations-breaking-CHER.patch] to ticket [37108037b980ea6e|37108037b9] by jrtc27 on 2022-08-12 23:21:45.
A 0007-tclHash-Fix-strict-aliasing-violations-breaking-CHER.patch 37108037b980ea6e705f56a9d983e05ee218dd0c 1b1aa6dc2e6e08994b20dcf56a2e17ce787cfca7ac583420edaa1ddffe2f40ea
C [PATCH\s7/8]\stclHash:\sFix\sstrict\saliasing\sviolations\sbreaking\sCHERI\ssupport\r\n\r\nThis\sis\sneeded\sto\ssupport\sCHERI,\sand\sthus\sArm's\sexperimental\sMorello\r\nprototype,\swhere\spointers\sare\simplemented\susing\sunforgeable\scapabilities\r\nthat\sinclude\sbounds\sand\spermissions\smetadata\sto\sprovide\sfine-grained\r\nspatial\sand\sreferential\smemory\ssafety,\sas\swell\sas\srevocation\sby\ssweeping\r\nmemory\sto\sprovide\sheap\stemporal\smemory\ssafety.\r\n\r\nThe\scurrent\stclHash\simplementation\sused\sint[]\sas\sthe\sunderlying\sstorage\r\nfor\sarbitrary\sobjects.\sHowever,\sthis\sviolates\sstrict\saliasing,\sas\sint[]\r\ncan\sonly\sbe\sused\sto\sstore\sintegers,\sand\sint\s*\scannot\salias\snon-integers.\r\nOn\smost\sarchitectures\sthis\sends\sup\sbeing\sharmless\s(though\swith\sLTO\smay\r\nbe\sless\sharmless\sas\sthe\stranslation\sunit\sboundary\sno\slonger\sexists\sto\r\nhide\sthis\sviolation\sfrom\sthe\scompiler),\sbut\son\sCHERI\scopying\spointers\sas\r\nan\sarray\sof\sintegers\sloses\sthe\sset\stag\sbit\smarking\sthe\scapability\sas\r\nvalid/not\sforged\s(unless\susing\sa\snon-inlined\smemcpy)\ssince\sthe\r\ncapabilities\sused\sto\srepresent\sthose\spointers\smust\sbe\scopied\sas\sa\ssingle\r\nunit.\sThis\sstrict\saliasing\sviolation\sis\sperhaps\salso\swhy\sTcl_GetHashKey\r\ndid\snot\sdistinguish\sthe\sstring\skey\scase\sfrom\sthe\sarray\skey\scase,\salways\r\nusing\sthe\sstring\smember;\susing\sthe\swords\smember\swould\shave\smade\sthe\r\nstrict\saliasing\sviolation\svisible\soutside\sthe\stranslation\sunit\sand\sbeen\r\nat\srisk\sof\sbreaking\sdue\sto\scompiler\soptimisations.\r\n\r\nFix\sthis\sby\susing\sa\schar[]\sas\sthe\sunderlying\sstorage\sinstead,\swith\r\nmemcpy\sand\smemcmp\sused\sto\simplement\scopying\sand\scomparing\srespectively.\r\nSince\sthis\sis\sthe\ssame\stype\sas\sis\salready\sused\sfor\sstring\swe\scan\sunify\r\nthe\stwo\sunion\smembers\sinto\sa\ssingle\sbytes\smember.\sThis\salso\ssimplifies\r\nthe\simplementation.\r\n\r\nNote\sthat\sfor\sAPI\scompatibility\skeyType\scontinues\sto\sbe\sin\sunits\sof\r\nsizeof(int)\sfor\sthat\scase\srather\sthan\sbytes.
D 2022-08-12T23:21:45.636
U jrtc27
Z ca8973f03d4b8b960d7fee611d94b093