From 701f15b27273caf2ddf9f2c332c7f403d4a96bd3 Mon Sep 17 00:00:00 2001 From: Laxmikant Kale Date: Sat, 26 Sep 2026 19:25:05 -0500 Subject: [PATCH 1/2] Restore the vtable pointer of received cache nodes Nodes in a cache reply are copied as raw bytes, vtable pointer included. Where processes map the executable at different addresses (a position-independent executable under address-space randomization, as on macOS) that pointer is invalid in the receiver and the first virtual call on a received node crashes: two-process runs failed on macOS this way. Fixed-address executables (readelf type EXEC, the usual Linux HPC build) are unaffected. The restore was already written and commented out; enable it. Co-Authored-By: Claude Fable 5.1 --- CacheInterface.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CacheInterface.cpp b/CacheInterface.cpp index 296130ad..9df8841f 100644 --- a/CacheInterface.cpp +++ b/CacheInterface.cpp @@ -380,11 +380,13 @@ void EntryTypeGravityNode::unpackSingle(CkCacheFillMsg *msg, Tree::Bina *(CkCacheFillMsg **) (((char*)node)-PAD_reply) = msg; - // Overwrite virtual pointer table. Something like this will be - // needed for heterogeneous architectures. Commented out for now - // since it breaks on the PGI compiler. + // Restore the virtual function table pointer: the nodes arrive as raw + // bytes from another process, and where processes map the executable + // at different addresses (position-independent executables under + // address-space randomization, e.g. macOS) the sender's pointer is not + // valid here. Harmless where the addresses agree. - // memcpy(node, &vptr, sizeof(void*)); + memcpy(node, &vptr, sizeof(void*)); if (!isRoot) CmiReference(UsrToEnv(msg)); for (int i=0; i < 2; ++i) { From 9fe84bfa2c3d500556f8de16ef28aa77ed02c4b3 Mon Sep 17 00:00:00 2001 From: Laxmikant Kale Date: Mon, 28 Sep 2026 23:54:53 -0500 Subject: [PATCH 2/2] Correct the vptr comment in EntryTypeGravityNode's constructor The saved pointer is now used by unpackSingle(). Co-Authored-By: Claude Opus 5.5 --- CacheInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CacheInterface.cpp b/CacheInterface.cpp index 9df8841f..34a75408 100644 --- a/CacheInterface.cpp +++ b/CacheInterface.cpp @@ -339,9 +339,9 @@ void TreePiece::flushSmoothParticles(CkCacheFillMsg *msg) { EntryTypeGravityNode::EntryTypeGravityNode() { BinaryTreeNode node; - // save the virtual function table. - // Note that this is compiler dependent; also note that it is unused - // at the moment -- see unpackSingle() below. + // save the virtual function table pointer; unpackSingle() below + // writes it into every node received from another process. + // Note that this is compiler dependent. memcpy((void *)&vptr, (void *)&node, sizeof(void*)); }