bazel: Android master build causes dexing issue with ArrayIndexOutOfBoundsException

Description of the problem / feature request:

The Bazel Master is causing a dexing exception to be thrown. This succeeds with the stable 0.17.2 version.

Feature requests: what underlying problem are you trying to solve with this feature?

Build with the latest master branch.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Assumes an executable version of the Bazel master branch called bazel-master

  1. git clone git@github.com:sunyal/bazel.git
  2. git checkout dexing-issue
  3. Update WORKSPACE androidndk path
  4. bazel-master build //examples/android/java/bazel:hello_world

What operating system are you running Bazel on?

MacOS High Sierra version 10.13.6

What’s the output of bazel info release?

Source downloaded on “02 Oct 18 17:00”

What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

git@github.com:sunyal/bazel.git 4cc28d8679c62bb42e9a05bcc546c584b8d2d60a 07ed27a7b7f682cfbe29fff28af1e16533a45ace

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

This is the stacktrace that gets produced

ERROR: /Users/abeggs/projects/bazel/bazel/third_party_additional/BUILD.bazel:2:1: Dexing third_party_additional/_dx/com_googlecode_mp4parser__isoparser__1_1_21/isoparser-1.1.21.jar_desugared.jar with applicable dexopts [] failed (Exit 1)
java.util.concurrent.ExecutionException: com.android.dx.cf.code.SimException: 3
	at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
	at com.google.devtools.build.android.dexer.DexBuilder.produceDexArchive(DexBuilder.java:253)
	at com.google.devtools.build.android.dexer.DexBuilder.processRequest(DexBuilder.java:218)
	at com.google.devtools.build.android.dexer.DexBuilder.runPersistentWorker(DexBuilder.java:173)
	at com.google.devtools.build.android.dexer.DexBuilder.main(DexBuilder.java:121)
Caused by: com.android.dx.cf.code.SimException: 3
	at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:814)
	at com.android.dx.cf.code.Simulator.simulate(Simulator.java:117)
	at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:789)
	at com.android.dx.cf.code.Ropper.doit(Ropper.java:744)
	at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
	at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:309)
	at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:150)
	at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:102)
	at com.google.devtools.build.android.dexer.Dexing.addToDexFile(Dexing.java:198)
	at com.google.devtools.build.android.dexer.DexConverter.toDexFile(DexConverter.java:31)
	at com.google.devtools.build.android.dexer.DexConversionEnqueuer$ClassToDex.call(DexConversionEnqueuer.java:173)
	at com.google.devtools.build.android.dexer.DexConversionEnqueuer$ClassToDex.call(DexConversionEnqueuer.java:156)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
	at com.android.dx.cf.code.ExecutionStack.setLocal(ExecutionStack.java:187)
	at com.android.dx.cf.code.BaseMachine.storeResults(BaseMachine.java:571)
	at com.android.dx.cf.code.ValueAwareMachine.run(ValueAwareMachine.java:208)
	at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:306)
	at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:649)
	at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:412)
	... 15 more
Target //examples/android/java/bazel:hello_world failed to build

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Based on history around this I would guess that the problematic Jar, com.googlecode.mp4parser:isoparser:1.1.21, has missing or invalid stack map frames. you’ll want to fix those (either by fixing at the source, or by recomputing them using, e.g., ASM) before depending on the Jar from an android_binary.

For anyone who wants a quick fix, here goes:

genrule(
    name = "good_jar",
    srcs = ["bad.jar"],
    outs = ["good.jar"],
    tools = [
        "@bazel_tools//third_party/java/proguard",
    ],
    cmd = """\
$(location @bazel_tools//third_party/java/proguard) \
    -injars $< -outjars $@ \
    -dontwarn -dontoptimize -dontobfuscate -dontshrink > /dev/null
""",
)

You can then depend on :good_jar