diff options
| -rw-r--r-- | generic/tclInterp.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/generic/tclInterp.c b/generic/tclInterp.c index 88e52d0..a2072b5 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -157,9 +157,7 @@ typedef struct { /* * Limit callbacks handled by scripts are modelled as structures which are - * stored in hashes indexed by a two-word key. Note that the type of the - * 'type' field in the key is not int; this is to make sure that things are - * likely to work properly on 64-bit architectures. + * stored in hashes indexed by a two-word key. */ typedef struct { @@ -175,11 +173,19 @@ typedef struct { * table. */ } ScriptLimitCallback; +/* + * ScriptLimitCallbackKey is the key used in the hash table storing callbacks. + * Such hash table keys must NOT have any pad bytes and therefore the "type" + * field is defined as intptr_t. Its real type is int but that introduces + * trailing pad bytes resulting in valgrind errors. intptr_t is always (?) + * same size as a pointer and will not have this padding issue. Details at + * https://core.tcl-lang.org/tcl/info/f7495f63c01ea800 + */ typedef struct { Tcl_Interp *interp; /* The interpreter that the limit callback was * attached to. This is not the interpreter * that the callback runs in! */ - int type; /* The type of callback that this is. */ + intptr_t type; /* The type of callback that this is. */ } ScriptLimitCallbackKey; /* @@ -4331,7 +4337,7 @@ TclRemoveScriptLimitCallbacks( while (hashPtr != NULL) { keyPtr = (ScriptLimitCallbackKey *) Tcl_GetHashKey(&iPtr->limit.callbacks, hashPtr); - Tcl_LimitRemoveHandler(keyPtr->interp, keyPtr->type, + Tcl_LimitRemoveHandler(keyPtr->interp, (int) keyPtr->type, CallScriptLimitCallback, Tcl_GetHashValue(hashPtr)); hashPtr = Tcl_NextHashEntry(&search); } |
