Skip to content
Tcl Source Code Attachment Details
Login

Attachment Details

Overview

Artifact ID: d74723a6beb5416d8f7869f2a03bf71fd1acaa43264530fe1fff1e4bcaff525d
Ticket: 37108037b980ea6e705f56a9d983e05ee218dd0c
Date: 2022-08-12 23:20:46
User: jrtc27
Artifact Attached: 90c8e607b4b43da4ad6ef8d3e22f19be2d688837b2aa8d18c183f168998aa040
Filename:0004-tclExecute-Fix-for-CHERI-by-not-assuming-ptrdiff_t-i.patch
Description:[PATCH 4/8] tclExecute: Fix for CHERI by not assuming ptrdiff_t is a pointer This is needed to support CHERI, and thus Arm's experimental Morello prototype, where pointers are implemented using unforgeable capabilities that include bounds and permissions metadata to provide fine-grained spatial and referential memory safety, as well as revocation by sweeping memory to provide heap temporal memory safety. ptrdiff_t is an integer type that can hold a signed offset within an object. On CHERI, this is a word-sized integer, but pointers are capabilities, twice the size of that. The type pointed to by catchTop must be the same size as the actual object stack entries (Tcl_Obj *) but catchTop is currently a ptrdiff_t * so on CHERI this does not currently hold, giving similar behaviour as sen on 64-bit Windows with the initial backed-out fix for bug 3274728. Instead, use a pointer type for catchTop's pointee type. We could use intptr_t and that would work on CHERI, but the C standard does not in fact guarantee that (u)intptr_t are the same size as object pointers, merely that a pointer can be cast to (u)intptr_t and back losslessly (thus, (u)int64_t would be a conforming, if foolish, implementation of (u)intptr_t on a system where pointers themselves are represented as 32-bit integers). To be sure the sizes agree, use Tcl_Obj * as the pointee type for catchTop as well and (un)wrap with PTR2INT/INT2PTR as needed; this also allows stack to be a Tcl_Obj *[1] and removes casting in initCatchTop and initTosPtr, making it clear these types are meant to be the same.
Content:
(file is 0 bytes of binary data)