diff --git a/core/arch/aarchxx/mangle.c b/core/arch/aarchxx/mangle.c index b60bf2907ad..a2e7a92f700 100644 --- a/core/arch/aarchxx/mangle.c +++ b/core/arch/aarchxx/mangle.c @@ -603,6 +603,9 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci, DR_REG_LIST_LENGTH_ARM, DR_REG_LIST_ARM)); } dstack_offs += 15 * XSP_SZ; + + /* Make dstack_offs 8-byte algined, as we only accounted for 17 4-byte slots. */ + dstack_offs += XSP_SZ; ASSERT(cci->skip_save_flags || cci->num_simd_skip != 0 || cci->num_regs_skip != 0 || diff --git a/core/arch/emit_utils_shared.c b/core/arch/emit_utils_shared.c index 38a76aaf5de..880aadd6fdc 100644 --- a/core/arch/emit_utils_shared.c +++ b/core/arch/emit_utils_shared.c @@ -5011,10 +5011,10 @@ emit_new_thread_dynamo_start(dcontext_t *dcontext, byte *pc) SCRATCH_REG0 _IF_AARCH64(false)); # ifndef AARCH64 /* put pre-push xsp into priv_mcontext_t.xsp slot */ - ASSERT(offset == sizeof(priv_mcontext_t)); + ASSERT(offset == get_clean_call_switch_stack_size()); APP(&ilist, XINST_CREATE_add_2src (dcontext, opnd_create_reg(SCRATCH_REG0), - opnd_create_reg(REG_XSP), OPND_CREATE_INT32(sizeof(priv_mcontext_t)))); + opnd_create_reg(REG_XSP), OPND_CREATE_INT32(offset))); APP(&ilist, XINST_CREATE_store (dcontext, OPND_CREATE_MEMPTR(REG_XSP, offsetof(priv_mcontext_t, xsp)), opnd_create_reg(SCRATCH_REG0))); diff --git a/core/arch/mangle_shared.c b/core/arch/mangle_shared.c index b11dd64c7f8..26debfbdfbc 100644 --- a/core/arch/mangle_shared.c +++ b/core/arch/mangle_shared.c @@ -297,7 +297,8 @@ prepare_for_clean_call(dcontext_t *dcontext, clean_call_info_t *cci, ASSERT(cci->skip_save_flags || cci->num_simd_skip != 0 || cci->num_regs_skip != 0 || - dstack_offs == sizeof(priv_mcontext_t) + clean_call_beyond_mcontext()); + (int) dstack_offs == (get_clean_call_switch_stack_size() + + clean_call_beyond_mcontext())); return dstack_offs; }