From f1c5d4ab65ddb4f88e61c0f72ffde78a6409a9bb Mon Sep 17 00:00:00 2001 From: Abhinav Anil Sharma Date: Fri, 20 Dec 2024 16:19:48 -0500 Subject: [PATCH 1/2] i#7162 div sample: Ensure opnd reg is ptr sized Fixes the div sample client to ensure that the opnd reg passed to dr_insert_clean_call is pointer sized. This showed up as a CLIENT_ASSERT crash on an AArch64 machine when the div client was run on suite/tests/bin/simple_app. Fixes: #7162 --- api/samples/div.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/samples/div.c b/api/samples/div.c index a9f8b5029c0..dd8798e4bfe 100644 --- a/api/samples/div.c +++ b/api/samples/div.c @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright (c) 2014 Google, Inc. All rights reserved. + * Copyright (c) 2014-2024 Google, Inc. All rights reserved. * Copyright (c) 2008 VMware, Inc. All rights reserved. * **********************************************************/ @@ -137,8 +137,13 @@ event_app_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *inst /* if find div, insert a clean call to our instrumentation routine */ opnd_t opnd; if (instr_is_div(instr, &opnd)) { + opnd_t div_opnd; + if (opnd_is_reg(div_opnd)) + div_opnd = opnd_create_reg(reg_to_pointer_sized(opnd_get_reg(opnd))); + else + div_opnd = opnd; dr_insert_clean_call(drcontext, bb, instr, (void *)callback, false /*no fp save*/, - 2, OPND_CREATE_INTPTR(instr_get_app_pc(instr)), opnd); + 2, OPND_CREATE_INTPTR(instr_get_app_pc(instr)), div_opnd); } return DR_EMIT_DEFAULT; } From 8fbda2ba9029b5d249fe852514fdbb0a4389bb60 Mon Sep 17 00:00:00 2001 From: Abhinav Anil Sharma Date: Fri, 20 Dec 2024 17:04:12 -0500 Subject: [PATCH 2/2] Use opnd instead of div_opnd --- api/samples/div.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/samples/div.c b/api/samples/div.c index dd8798e4bfe..79058680443 100644 --- a/api/samples/div.c +++ b/api/samples/div.c @@ -138,7 +138,7 @@ event_app_instruction(void *drcontext, void *tag, instrlist_t *bb, instr_t *inst opnd_t opnd; if (instr_is_div(instr, &opnd)) { opnd_t div_opnd; - if (opnd_is_reg(div_opnd)) + if (opnd_is_reg(opnd)) div_opnd = opnd_create_reg(reg_to_pointer_sized(opnd_get_reg(opnd))); else div_opnd = opnd;