Menu

#683 Abnormal behavior of class files generated by ProGuard

v6.0
closed-wont-fix
None
5
2018-01-28
2018-01-24
Tianxiao Gu
No

Description:

The original jar throws an exception while the obfuscated jar exits normally.

Reproducing steps:

  1. Generate the output (referred to as C0-outjars.jar for following steps) for the attached C0-injars.jar.

  2. Run the two jars.

$ java -cp C0-injars.jar C0
Exception in thread "main" java.lang.NegativeArraySizeException
    at C0.main(Unknown Source)
$ java -cp C0-outjars.jar C0
$ echo $?
0

This issue may relate to #681 and #682.

This issue may also relate to an issue of r8. https://issuetracker.google.com/issues/72413928.

1 Attachments

Discussion

  • Tianxiao Gu

    Tianxiao Gu - 2018-01-24

    Note that the C0.class here is different from that of https://issuetracker.google.com/issues/72413928

     
  • Tianxiao Gu

    Tianxiao Gu - 2018-01-27

    Sorry, this is not a bug. The behavior is expected. java throws an exception since the program allocates an unused array with a negative size, while the optimization of proguard removes the allocation instruction.

     
  • Eric Lafortune

    Eric Lafortune - 2018-01-28

    Thanks for your report and the update. ProGuard indeed makes a few pragmatic assumptions, like code not intentionally throwing NegativeArraySizeExceptions or ArrayIndexOutOfBoundsExceptions. The assumptions don't hold for this intentionally obfuscated code. You can probably work around it with with the ProGuard system property -Doptimize.conservatively .

     
  • Eric Lafortune

    Eric Lafortune - 2018-01-28
    • status: open --> closed-wont-fix
    • assigned_to: Eric Lafortune
     

Log in to post a comment.

MongoDB Logo MongoDB