Re: [rvm-research] Possible race hazard in RVMClass

David P Grove <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <OF7B4E1035.18CDC96C-ON85257B32.007875D7-85257B32.00789DE5@us.ibm.com>
Thanks for the bug reports.

The second stack trace is also due to a concurrency bug arising from an
unsynchronized use of a WeakHashMap.    I should be pushing fixes for both
shortly.

--dave


UGAWA Tomoharu <[email protected]> wrote on 03/18/2013 11:56:32 AM:

> From: UGAWA Tomoharu <[email protected]>
> To: [email protected],
> Cc: Jones Richard <[email protected]>, "Ritson C.G."
> <[email protected]>
> Date: 03/18/2013 12:55 PM
> Subject: [rvm-research] Possible race hazard in RVMClass
>
> Hi
>
> I am afraid that we found a possible bug.
>
> There may be a race in org.jikesrvm.classloader.RVMClass.
> The addSubClass method can be used by multiple threads simultaneously
> causing corruption of the subClasses array.
>
>   /**
>    * Add to list of classes that derive from this one.
>    */
>   private void addSubClass(RVMClass sub) {
>     int n = subClasses.length;
>     RVMClass[] tmp = new RVMClass[n + 1];
>
>     for (int i = 0; i < n; ++i) {
>       tmp[i] = subClasses[i];
>     }
>     tmp[n] = sub;
>
>     subClasses = tmp;
>   }
>
> This bug manifests when testing our concurrent collector with DaCapo
> 2006 jython.
> However it can be reproduced in Jikes tip using the attached example
program.
> The example program uses a script to create a large number of class
> files which
> are then loaded by separate threads using reflection.
>
> We tested on Linux:
> > Linux enju 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC
> 2012 x86_64 x86_64 x86_64 GNU/Linux
> with Jikes version:
> > e6fab50149e5 tip
> The configuration was:
> > FastAdaptiveGenImmix_x86_64-linux
>
> This occasionally produces two different error messages:
>
> Exception in thread "Thread-3"
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2466
>    at org.jikesrvm.classloader.RVMClass.addSubClass(RVMClass.java:1646)
>    at org.jikesrvm.classloader.RVMClass.<init>(RVMClass.java:1011)
>    at org.jikesrvm.classloader.RVMClass.createReflectionClass
> (RVMClass.java:1935)
>    at org.jikesrvm.classloader.RVMMethod.getInvoker(RVMMethod.java:881)
>    at java.lang.reflect.VMMethod.<init>(VMMethod.java:42)
>    at java.lang.reflect.JikesRVMSupport.createMethod
(JikesRVMSupport.java:27)
>    at java.lang.Class.getMethods(Class.java:1018)
>    at Ref.run(Unknown Source:0)
>    at java.lang.Thread.run(Thread.java:745)
>
> Exception in thread "Thread-2" java.lang.InternalError: WeakHashMap
> in incosistent state
>    at java.lang.Error.<init>(Error.java:81)
>    at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:71)
>    at java.lang.InternalError.<init>(InternalError.java:70)
>    at java.util.WeakHashMap.internalRemove(WeakHashMap.java:706)
>    at java.util.WeakHashMap.cleanQueue(WeakHashMap.java:595)
>    at java.util.WeakHashMap.put(WeakHashMap.java:776)
>    at org.jikesrvm.classloader.MethodVector.finish(MethodVector.java:74)
>    at org.jikesrvm.classloader.RVMClass.resolve(RVMClass.java:1200)
>    at
> org.jikesrvm.runtime.RuntimeEntrypoints.initializeClassForDynamicLink
> (RuntimeEntrypoints.java:608)
>    at org.jikesrvm.classloader.RVMClass.createReflectionClass
> (RVMClass.java:1942)
>    at org.jikesrvm.classloader.RVMMethod.getInvoker(RVMMethod.java:881)
>    at java.lang.reflect.VMMethod.<init>(VMMethod.java:42)
>    at java.lang.reflect.JikesRVMSupport.createMethod
(JikesRVMSupport.java:27)
>    at java.lang.Class.getMethods(Class.java:1018)
>    at Ref.run(Unknown Source:0)
>    at java.lang.Thread.run(Thread.java:745)
>
> The first of these relates to the addSubClass method and can be
> fixed by making the
> method synchronized.
>
> diff -r fb5276512eae rvm/src/org/jikesrvm/classloader/RVMClass.java
> --- a/rvm/src/org/jikesrvm/classloader/RVMClass.java   Fri Feb 15
> 23:30:49 2013 +0100
> +++ b/rvm/src/org/jikesrvm/classloader/RVMClass.java   Tue Feb 19
> 07:16:34 2013 +0000
> @@ -1638,7 +1638,7 @@
>    /**
>     * Add to list of classes that derive from this one.
>     */
> -  private void addSubClass(RVMClass sub) {
> +  private synchronized void addSubClass(RVMClass sub) {
>      int n = subClasses.length;
>      RVMClass[] tmp = new RVMClass[n + 1];
>
> Attached is a PDF containing graphs of the first run performance for
> DaCapo 2006 without patch (prod-tip) and with patch (prod-ascp).
> These show this patch does not cause a performance regression.
>
> As for the second message, we have not yet located the cause.
>
> Kind regards
> Tomoharu
>
> [attachment "reflection.tar.gz" deleted by David P Grove/Watson/IBM]
> [attachment "ascp-cryo.pdf" deleted by David P Grove/Watson/IBM]
>
------------------------------------------------------------------------------

> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Jikesrvm-researchers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar

_______________________________________________
Jikesrvm-researchers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.