Bug 306297 - disInstr(thumb): unhandled instruction 0xE883 0x000C
Summary: disInstr(thumb): unhandled instruction 0xE883 0x000C
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.9.0.SVN
Platform: Android Android 4.x
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-05 15:25 UTC by Kartikaya Gupta
Modified: 2012-09-17 11:37 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Valgrind log including unrecognized instruction (7.75 KB, text/plain)
2012-09-05 15:26 UTC, Kartikaya Gupta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kartikaya Gupta 2012-09-05 15:25:12 UTC
I ran valgrind on Firefox in the Android emulator (ARM) using the instructions I posted to https://staktrace.com/spout/entry.php?id=762 and after a while it eventually crashed. I'll attach the full valgrind log output. This happened both times I ran it (once on massif and once on memcheck) but I haven't tried to reproduce it more than than.

Reproducible: Didn't try

Steps to Reproduce:
1. Follow instructions at https://staktrace.com/spout/entry.php?id=762
2. If running massif, just wait for Fennec to finish starting up. If running memcheck, try opening the awesomebar once Fennec is started up.
Actual Results:  
Crash

Expected Results:  
No crash
Comment 1 Kartikaya Gupta 2012-09-05 15:26:49 UTC
Created attachment 73674 [details]
Valgrind log including unrecognized instruction
Comment 2 Philippe Waroquiers 2012-09-05 19:30:59 UTC
(In reply to comment #0)
> 1. Follow instructions at https://staktrace.com/spout/entry.php?id=762
These instructions are telling:
"...you need to build Valgrind. Unfortunately the release tarballs available on the Valgrind website seem to be missing some files,..."

Can you indicate which files are missing, so that this can be fixed (e.g. in 3.8.1) ?
(the best would be to enter a new bug for these missing files).

Thanks
Comment 3 Kartikaya Gupta 2012-09-05 19:51:34 UTC
(In reply to comment #2)
> Can you indicate which files are missing, so that this can be fixed (e.g. in
> 3.8.1) ?
> (the best would be to enter a new bug for these missing files).

Filed bug 306310 for this.
Comment 4 Kartikaya Gupta 2012-09-11 19:11:45 UTC
Do you know where I can find the manuals for the thumb instruction set? I'm happy to put together a patch for this if I can find the manuals to see if the instruction is valid or not and what it does.
Comment 5 Julian Seward 2012-09-17 10:06:36 UTC
   4:   e883 000c       stmia.w r3, {r2, r3}
Comment 6 Julian Seward 2012-09-17 10:44:38 UTC
This is "STM<c>.W <Rn>{!},<registers> (Encoding T2)".

It is in fact handled by V, at guest_arm_toIR.c around line 16404,
with the section heading "{LD,ST}M{IA,DB}".

Problem here is that the base register, r3, is in the list ..

  stmia.w r3, {r2, r3}

.. and the ARM docs have the following restriction on validity:

  Encoding T2 is not available for instructions with the base register
  in the list and ! specified, and the use of such instructions is
  deprecated.  If the base register is not the lowest-numbered
  register in the list, such an instruction stores an UNKNOWN value
  for the base register.

The first sentence does not apply, since ! is not specified (no
writeback).

The second sentence is ambiguous.  In this case the base register r3
is not the lowest numbered register in the list.  But whether the
second sentence applies in all situations or only when ! is specified
is unclear (to me) so in short I am unclear if this is a valid
instruction.  V takes the conservative approach and rejects it, hence
this failure.

This insn has clearly been created by a JIT, either Dalvik or one of
the Fx JITs, as it is in /dev/ashmem.  If the insn is indeed valid
then this is a bug in V.  If it is invalid then it is a bug in the JIT
that created it.
Comment 7 Peter Maydell 2012-09-17 11:00:13 UTC
(In reply to comment #6)
You seem to be quoting from revision B of the ARM ARM; the most recent revision is C.b, where this text has been slightly revised and now reads:

"ARM deprecates the use of instructions with the base register in the list and ! specified. If the base register is not the lowest-numbered register in the list, such an instruction stores an UNKNOWN value for the base register.
An instruction with the base register in the list and ! specified cannot use encoding T2."

The pseudocode is also fairly clear and resolves any lingering ambiguity: basereg-in-list with writeback is UNPREDICTABLE for encoding T2; for encodings T1/A1 it stores an UNKNOWN value if the basereg isn't the earliest register in the list. The non-writeback case is neither deprecated, UNPREDICTABLE nor UNKNOWN.

So I think this is a bug in Valgrind.
Comment 8 Julian Seward 2012-09-17 11:37:00 UTC
Thanks for the analysis; also to jbramley who made the same observations
on irc.  Fixed, r2531 (trunk) and will be in 3.8.1 too.

Kats, pls verify.