JesusFreke / smali

smali/baksmali
6.34k stars 1.07k forks source link

No detailed information in the error output #244

Open JesusFreke opened 9 years ago

JesusFreke commented 9 years ago

Original issue 200 created by JesusFreke on 2014-02-06T03:10:31.000Z:

What seems to be the problem? When smaling, I got this output:

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalStateException: Cannot get the location of a label that hasn't been placed yet. at org.jf.dexlib2.builder.Label.getLocation(Label.java:54) at org.jf.dexlib2.builder.Label.getCodeAddress(Label.java:48) at org.jf.dexlib2.builder.BuilderOffsetInstruction.internalGetCodeOffset(BuilderOffsetInstruction.java:60) at org.jf.dexlib2.builder.BuilderOffsetInstruction.getCodeOffset(BuilderOffsetInstruction.java:50) at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:189) at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:944) at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:759) at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:214) at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:192) at org.jf.smali.main.main(main.java:229)

I know it's my fault, but there isn't any detailed information, like caused by which file and the line number, so I can't fix it.

What is the exact smali/baksmali command that you ran? java -jar smali-2.0.3.jar . -o classes_mod.dex

What version of smali/baksmali are you using? What rom are you working from? smali 2.0.3 (also tried 2.0.2), baksmali 2.0.2, any ROM with Dalvik.

What is the airspeed velocity of an unladen swallow? ... Can't understand

Please provide any additional information below: error messages, symptoms, etc. Nothing more.

JesusFreke commented 9 years ago

Comment #1 originally posted by JesusFreke on 2014-02-06T04:05:47.000Z:

<empty>

JesusFreke commented 9 years ago

Comment #2 originally posted by JesusFreke on 2014-07-06T02:50:52.000Z:

I think it simply means that one of your labels hasn't been defined yet, but you are using it in a conditional already.

Although it would be nice to know where the error is, you may have to comb through it manually..

JesusFreke commented 9 years ago

Comment #3 originally posted by JesusFreke on 2014-07-06T10:38:15.000Z:

Yes, but it is such a huge task that I think computers will do it better.

JesusFreke commented 9 years ago

Comment #4 originally posted by JesusFreke on 2014-07-06T19:50:47.000Z:

I agree :)

JesusFreke commented 9 years ago

Comment #5 originally posted by JesusFreke on 2014-07-14T17:31:31.000Z:

Get stuck, too I got this exception when I tried to convert smali code from another assembly tools. I can't fix it without file/line detail. :[ My test smali files are in attachment if you need Help please

JesusFreke commented 9 years ago

Comment #6 originally posted by JesusFreke on 2014-07-26T20:35:24.000Z:

Would like to know as well then this or help resolve this. Came across same issue trying to port MIUI 4.4.2 and compiling my frameworks.. C:\apktool>apktool b services.jar.out
I: Using Apktool 2.0.0-dirty on services.jar.out
I: Checking whether sources has changed...
I: Smaling... services.jar.out\smali\com\android\server\NetworkManagementService.smali[6452,0] Cannot get the location of a label that hasn't been placed yet.
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file: com/android/server/NetworkManagementService.smali at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:72)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:56)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:342)
at brut.androlib.Androlib.buildSources(Androlib.java:303)
at brut.androlib.Androlib.build(Androlib.java:289)
at brut.androlib.Androlib.build(Androlib.java:262)
at brut.apktool.Main.cmdBuild(Main.java:236)
at brut.apktool.Main.main(Main.java:88)

And that line specified is the name of a method that is stock and was NOT added

JesusFreke commented 9 years ago

Comment #7 originally posted by JesusFreke on 2014-07-26T20:41:50.000Z:

@lacoursiere18: That is a different problem. You shouldn't be getting that error after disassembling with no changes. Are you sure there are no changes in that file?

The problem in this issue is that there is no context associated with the error. But your error clearly has the line and number as context.

JesusFreke commented 9 years ago

Comment #8 originally posted by JesusFreke on 2014-07-26T20:43:01.000Z:

Just as an update on this issue, the main problem is that the label resolution stuff is happening later, and doesn't have access to the original context (file and line) where the labels were created. So I've been thinking of how to improve the situation here. I could throw a quick fix in for this one problem, but I want to fix it in a more systemic way.