RFR: 8004138: ForkJoinTask leaks exceptions

Martin Buchholz martinrb at google.com
Thu Oct 17 18:09:51 UTC 2013


Thanks for making a proper regtest.
A variant of this is now checked in to jsr166 CVS
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/test/jtreg/util/concurrent/forkjoin/FJExceptionTableLeak.java?view=markup

with these improvements:
- fix indent level
- Fix ForJoinPool typo
- more careful exception checking.

Please re-sync.



On Thu, Oct 17, 2013 at 9:51 AM, Mike Duigou <mike.duigou at oracle.com> wrote:

> Hello all;
>
> (Chris is on holiday so I agreed to finish the review on this change)
>
> I have updated the changeset with the regression test Doug provided. I
> have also verified that the regression test fails without the provided
> patch.
>
> http://cr.openjdk.java.net/~mduigou/JDK-8004138/0/webrev/
>
> Mike
>
> On Oct 14 2013, at 08:52 , Chris Hegarty <chris.hegarty at oracle.com> wrote:
>
> > This is a request to pull a small change to ForkJoinTask into jdk8, from
> the jsr166 CVS. This was first discussed over on c-i [1] a few weeks back.
> >
> > diff -r 077237e4613f
> src/share/classes/java/util/concurrent/ForkJoinTask.java
> > --- a/src/share/classes/java/util/concurrent/ForkJoinTask.java  Mon Oct
> 14 11:47:54 2013 +0100
> > +++ b/src/share/classes/java/util/concurrent/ForkJoinTask.java  Mon Oct
> 14 16:44:01 2013 +0100
> > @@ -439,11 +439,13 @@ public abstract class ForkJoinTask<V> im
> >         final Throwable ex;
> >         ExceptionNode next;
> >         final long thrower;  // use id not ref to avoid weak cycles
> > +        final int hashCode;  // store task hashCode before weak ref
> disappears
> >         ExceptionNode(ForkJoinTask<?> task, Throwable ex, ExceptionNode
> next) {
> >             super(task, exceptionTableRefQueue);
> >             this.ex = ex;
> >             this.next = next;
> >             this.thrower = Thread.currentThread().getId();
> > +            this.hashCode = System.identityHashCode(task);
> >         }
> >     }
> >
> > @@ -605,9 +607,9 @@ public abstract class ForkJoinTask<V> im
> >     private static void expungeStaleExceptions() {
> >         for (Object x; (x = exceptionTableRefQueue.poll()) != null;) {
> >             if (x instanceof ExceptionNode) {
> > -                ForkJoinTask<?> key = ((ExceptionNode)x).get();
> > +                int hashCode = ((ExceptionNode)x).hashCode;
> >                 ExceptionNode[] t = exceptionTable;
> > -                int i = System.identityHashCode(key) & (t.length - 1);
> > +                int i = hashCode & (t.length - 1);
> >                 ExceptionNode e = t[i];
> >                 ExceptionNode pred = null;
> >                 while (e != null) {
> >
> >
> > -Chris
> >
> > [1]
> http://jsr166-concurrency.10961.n7.nabble.com/ForkJoinTask-leaks-exceptions-td10134.html
>
>



More information about the core-libs-dev mailing list