Menu ▾ ▴

#503 Bug for instruction AALOAD when evaluation simplification

v4.5
closed-fixed
None
6
2014-12-16
2014-03-17
No

Consider the following method:

public Object test()
{
Object[] o = null;
return o[0];
}

When doing code simplification, code is transformed like this:

public static Object test()
{
return null;
}

To avoid this, in method EvaluationSimplifier.replaceReferencePushInstruction(), the test:
if (pushedValue.isParticular())
should be replaced by:
if (pushedValue.isParticular() && (instruction.opcode != InstructionConstants.OP_AALOAD))

Discussion

  • Christophe FRANCHI

    The milestone is for ProGuard 4.11.

     
  • Tadeas Palusga

    Tadeas Palusga - 2014-03-25

    I disagree that this is a bug ...

    quote from http://proguard.sourceforge.net/#manual/limitations.html

    For best results, ProGuard's optimization algorithms assume that the processed code never intentionally throws NullPointerExceptions or ArrayIndexOutOfBoundsExceptions, or even OutOfMemoryErrors or StackOverflowErrors, in order to achieve something useful. For instance, it may remove a method call myObject.myMethod() if that call wouldn't have any effect. It ignores the possibility that myObject might be null, causing a NullPointerException. In some way this is a good thing: optimized code may throw fewer exceptions. Should this entire assumption be false, you'll have to switch off optimization using the -dontoptimize option."

     
  • Eric Lafortune

    Eric Lafortune - 2014-03-25

    This optimization indeed is intentional. I have introduced the java system property "optimize.conservatively" in ProGuard 4.9 to optionally be more strict about such cases, at the expense of other optimization opportunities. I'll see if I can add it under the same umbrella.

     
  • Christophe FRANCHI

    Hello,

    Eric, optimize conservatively does not manage this.

    If you optimize the following code :

    public static Object test(Object a)
    {
    Object[] o = null;
    o[0] = a;
    return o[0];
    }

    It is translated to :

    public static Object test(Object a)
    {
    null[0] = a;

    return null;
    

    }

    the reference of the array is confused with the element inside of the array.
    }

     
  • Eric Lafortune

    Eric Lafortune - 2014-03-31

    This indeed still needs to be handled, most likely joining other corner-cases with the flag "optimize.conservatively".

     
  • Eric Lafortune

    Eric Lafortune - 2014-04-19

    ProGuard now handles this case, with -Doptimize.conservatively, in the upcoming version 5.0 beta1.

     
  • Eric Lafortune

    Eric Lafortune - 2014-04-19
    • status: open --> open-fixed
    • assigned_to: Eric Lafortune
    • Priority: 5 --> 6
     
  • Eric Lafortune

    Eric Lafortune - 2014-08-19
    • Status: open-fixed --> closed-fixed
     
  • Christophe FRANCHI

    Hello Eric,

    Using ProGuard 5.1 with 'optimize conservaively', these issue is still existing.

    I still have to do what I described previosuly :

    "To avoid this, in method EvaluationSimplifier.replaceReferencePushInstruction(), the test:
    if (pushedValue.isParticular())
    should be replaced by:
    if (pushedValue.isParticular() && (instruction.opcode != InstructionConstants.OP_AALOAD))"

     

Log in to post a comment.