Bug 332037

Summary: Valgrind cannot handle Thumb "add pc, reg"
Product: [Developer tools] valgrind Reporter: Ben Cheng <bccheng>
Component: vexAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 3.8.0   
Target Milestone: ---   
Platform: unspecified   
OS: Android 4.x   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: unit test to be compiled in thumb mode

Description Ben Cheng 2014-03-11 18:16:12 UTC
Created attachment 85539 [details]
unit test to be compiled in thumb mode

The new Android ART runtime is generating code sequence where it is adding a register to PC as computed gotos in Thumb mode. However it is giving Valgrind problems with the following crash:

vex: external/valgrind/main/VEX/priv/guest_generic_bb_to_IR.c:402 (bb_to_IR): Assertion `irsb->next == ((void*)0)' failed.

We are seeing the same problem on 3.8.1 and trunk (3.10).

I have created a small unit test like below which can crash Valgrind in the same way.

#include <stdio.h>

int main()
{
    asm("mov r0, #-2");
    asm("add pc, r0");
    printf("Hello World!\n");
}

Looks like "add(hi)" in guest_arm_toIR.c is not handing the case properly when pc is the destination register.
Comment 1 Julian Seward 2014-03-15 08:15:20 UTC
Fixed, vex r2838.