JesusFreke / smali

smali/baksmali
6.29k stars 1.07k forks source link

Unterminated character literal - no viable alt; token #805

Closed iBotPeaches closed 3 years ago

iBotPeaches commented 3 years ago

I had a test that started failing on 2.5.0, and I thought it was related to some other issues, but now I'm stumped.

brut.androlib.decode.DecodeKotlinCoroutinesTest > kotlinCoroutinesEncodeAfterDecodeTest FAILED
    brut.androlib.AndrolibException: Could not smali file: kotlin/text/Typography.smali

As far as I can tell, it looks like a regular kotlin dex to me. Working directly through baksmali/smali I get.

➜  Desktop smali a out --verbose 
out/kotlin/text/Typography.smali[76,35] Error for input ''&': Unterminated character literal
out/kotlin/text/Typography.smali[78,0] [smali_file, field, literal]  no viable alt; token=[@259,4361:4366='.field',<FIELD_DIRECTIVE>,78:0] (decision=22 state 0) decision=<<>>
out/kotlin/text/Typography.smali[88,38] Error for input ''$': Unterminated character literal
out/kotlin/text/Typography.smali[90,0] [smali_file, field, literal]  no viable alt; token=[@355,4644:4649='.field',<FIELD_DIRECTIVE>,90:0] (decision=22 state 0) decision=<<>>
out/kotlin/text/Typography.smali[98,39] Error for input ''>': Unterminated character literal
out/kotlin/text/Typography.smali[100,0] [smali_file, field, literal]  no viable alt; token=[@435,4890:4895='.field',<FIELD_DIRECTIVE>,100:0] (decision=22 state 0) decision=<<>>
out/kotlin/text/Typography.smali[110,36] Error for input ''<': Unterminated character literal
out/kotlin/text/Typography.smali[112,0] [smali_file, field, literal]  no viable alt; token=[@531,5202:5207='.field',<FIELD_DIRECTIVE>,112:0] (decision=22 state 0) decision=<<>>
out/kotlin/text/Typography.smali[136,37] Error for input ''"': Unterminated character literal
out/kotlin/text/Typography.smali[138,0] [smali_file, field, literal]  no viable alt; token=[@739,5846:5851='.field',<FIELD_DIRECTIVE>,138:0] (decision=22 state 0) decision=<<>>

I thought it was related to the writer changes, but even using bare smali/baksmali.

classes.dex.zip

JesusFreke commented 3 years ago

Found the problem. Fix incoming. I'll let you test it out before I make a new version, haha :)

JesusFreke commented 3 years ago

Fixed in 5842cee8ec458327c1f59b8921bf93008bcd3e91.

I actually did a disassemble/assemble roundtrip on all the apps/framework jars from my android device, I'm a bit surprised that didn't flush this problem out.

But anyway, added a test at least. :)

If you can give it a try and report back, I'll go ahead and do another release if it looks good.

iBotPeaches commented 3 years ago
➜  Desktop baksmali d classes.dex
➜  Desktop smali a out
➜  Desktop smali --version
smali 2.5.1-5842cee8-dirty (http://smali.org)
Copyright (C) 2010 Ben Gruver (JesusFreke@JesusFreke.com)
BSD license (http://www.opensource.org/licenses/bsd-license.php)
➜  Desktop
➜  duplicatedex git:(smali-2.5.0) baksmali d duplicatedex.apk 
➜  duplicatedex git:(smali-2.5.0) smali a out            
➜  duplicatedex git:(smali-2.5.0)  
➜  testkotlin git:(smali-2.5.0) baksmali d testkotlin.apk 
➜  testkotlin git:(smali-2.5.0) smali a out 
➜  testkotlin git:(smali-2.5.0)

We are good. I'll admit I'm not the best talented at overriding maven dependencies with a locally built archive to run the entire suite at once, so I just ran through the few dex tests we have and those all passed. Thanks again

JesusFreke commented 3 years ago

Thanks. The fix is in v2.5.2