Menu

#732 Exception while handling very long string argument

v6.0
open
None
Low
2018-11-17
2018-11-15
No

I have a class which calls it's parent class method with several args one of them is pretty long string serialized from multidimentional double matrix to the Base64 string.
It maybe pretty rare case, but proguard 6.0.3 falls with exception:

java.lang.RuntimeException: Unexpected error while writing class [xxx/xxx/xxx/xxx/plugin/LightWMPlugin] (Overflow of unsigned short value [131064])
at proguard.io.ClassDataEntryWriter.createOutputStream(ClassDataEntryWriter.java:104)
at proguard.io.ExtraDataEntryWriter.createOutputStream(ExtraDataEntryWriter.java:135)
at proguard.io.IdleRewriter.read(IdleRewriter.java:49)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:83)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:210)
at proguard.InputReader.readInput(InputReader.java:184)
at proguard.OutputWriter.writeOutput(OutputWriter.java:191)
at proguard.OutputWriter.execute(OutputWriter.java:89)
at proguard.ProGuard.writeOutput(ProGuard.java:515)
at proguard.ProGuard.execute(ProGuard.java:210)
at proguard.ProGuard.main(ProGuard.java:572)
Caused by: java.lang.IllegalArgumentException: Overflow of unsigned short value [131064]
at proguard.classfile.io.RuntimeDataOutput.writeUnsignedShort(RuntimeDataOutput.java:213)
at proguard.classfile.io.ProgramClassWriter$ConstantBodyWriter.visitUtf8Constant(ProgramClassWriter.java:230)
at proguard.classfile.constant.Utf8Constant.accept(Utf8Constant.java:148)
at proguard.classfile.io.ProgramClassWriter.visitAnyConstant(ProgramClassWriter.java:172)
at proguard.classfile.util.SimplifiedVisitor.visitUtf8Constant(SimplifiedVisitor.java:164)
at proguard.classfile.constant.Utf8Constant.accept(Utf8Constant.java:148)
at proguard.classfile.ProgramClass.constantPoolEntriesAccept(ProgramClass.java:529)
at proguard.classfile.io.ProgramClassWriter.visitProgramClass(ProgramClassWriter.java:86)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:430)
at proguard.io.ClassDataEntryWriter.createOutputStream(ClassDataEntryWriter.java:100)
... 14 more

Sorry for not making any direct testcase, hopefully detailed stack-trace would be enough.
String is of 2Mb length, Eclipse IDE is able to handle it as text editor, although it's feeling bad about it while I scroll the code.

Discussion

  • Pavel Malyutin

    Pavel Malyutin - 2018-11-15

    it seems that eclipse, or maybe javac itself does the split of long string to sequence of StringBuilder().append().append().toString() ... String.intern()
    this seems to be ok to read it back, but somehow fail mb after some optimization

     
  • Pavel Malyutin

    Pavel Malyutin - 2018-11-15

    it maybe obvious, but commenting out all stringbuilder optimizations in the code, rebuild proguard w/o them does help - it's not failing.
    I mean proguard.optimize.peephole.InstructionSequenceConstants lines 3194 - 4554

    so maybe implement some guard logic for this, if STRING_A | STRING_B exceeds in length 0xffff, then skip this optimization..

     

    Last edit: Pavel Malyutin 2018-11-15
  • Eric Lafortune

    Eric Lafortune - 2018-11-17

    Thanks for your report; that's an interesting (and rare) case. For the time being, you can work around it with -optimizations !code/simplification/string

     
  • Eric Lafortune

    Eric Lafortune - 2018-11-17
    • assigned_to: Eric Lafortune
    • Priority: Medium --> Low
     

Log in to post a comment.

MongoDB Logo MongoDB