Skip to content

Commit

Permalink
i#7162 div sample: Ensure clean call opnd reg is ptr sized (#7164)
Browse files Browse the repository at this point in the history
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. On affected
environments, it did show up on the sample.div test also.

Fixes: #7162
  • Loading branch information
abhinav92003 authored Dec 21, 2024
1 parent da0e8ef commit fa2eaa8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/samples/div.c
Original file line number Diff line number Diff line change
@@ -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.
* **********************************************************/

Expand Down Expand Up @@ -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(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;
}

0 comments on commit fa2eaa8

Please sign in to comment.