Menu

#486 Infinite while loop with try..catch..finally may cause OOM

v4.7
open-works-for-me
None
5
2013-11-29
2013-11-25
fish47
No

Environment

Ubuntu 12.04 3.5.0-43-generic 32bit
Java version "1.6.0_45"
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Proguard 4.7

Problem

When I try to optimize a project using proguard, it leads to OOM. The stacktraces of ant are incomplete, because proguard always catches OOM. Logging stackstraces need memory, but system crashed at that time. The stacktrace attached was captured using jstack.
I can't provide the full source code or bytecode because this isn't a open-source project, nor can I abstract them as a minimal and bug-reproducable project. I'm sorry about that.

"Buggy" Programme Code

Thread thread = new Thread() {
public void run()
{
while (true)
{
try
{
// Doing something that may block current thread,
// such as Object.wait()
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally
{
// PAY ATTENTION TO THIS BLOCK!!!
// Once I move it out of the finally block,
// the proguard's optimization works again.
continue;
}
}
}
}
// Do something here
thread.start();

Advice

Try to code defensively, if optimizing a subroutine may lead to infinite recursion / loop, or some fatal errors are catched in the meanwhile, then give up optimizing that subroutine.

1 Attachments

Discussion

  • Eric Lafortune

    Eric Lafortune - 2013-11-29

    You can try the latest version of ProGuard, version 4.10 or version 4.11 beta6 at this time.

     
  • Eric Lafortune

    Eric Lafortune - 2013-11-29
    • status: open --> open-works-for-me
     

Log in to post a comment.