Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 38078 invoked from network); 15 Feb 2007 11:33:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2007 11:33:29 -0000 Received: (qmail 12338 invoked by uid 500); 15 Feb 2007 11:33:35 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 12317 invoked by uid 500); 15 Feb 2007 11:33:34 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 12308 invoked by uid 99); 15 Feb 2007 11:33:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 03:33:34 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 03:33:26 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6D5D57141A2 for ; Thu, 15 Feb 2007 03:33:06 -0800 (PST) Message-ID: <31596189.1171539186445.JavaMail.jira@brutus> Date: Thu, 15 Feb 2007 03:33:06 -0800 (PST) From: "Elena Semukhina (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-2982) [classlib][net ] java.net.URLClassLoader implementation is not thread safe. In-Reply-To: <1080705.1168605507559.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-2982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12473352 ] Elena Semukhina commented on HARMONY-2982: ------------------------------------------ Mikhail, I think there is a kind of misunderstanding here :) Actually a agreed with what you suggested. I just think that wrapping resCache is redundant because we place its modification in a synchronized block. Here is my reasoning: You suggested to keep the first call to get() out of the synch block and I fully agree with this: jf = resCache.get(thisUrl); // yes, I missed this in my previous comment but I meant it :) If after that jf == null, the thread should find jf and put it to the map. We know that this needs to be done only once for each JarFile. If some thread has started this job and entered synch block, any other thread which got jf == null will wait until the first thread exits the block. Then the second thread enters the block and calls resCache.get() again to check if it is still null (this is your suggestion and I again agree with it). If jf is not null at this moment (and it obviously shouldn't be null here because the first thread should have put a value), the second thread won't look for it and will exit synch block. This is exactly your suggestion except resCache is not wrapped. Do you think this won't work properly? > [classlib][net ] java.net.URLClassLoader implementation is not thread safe. > --------------------------------------------------------------------------- > > Key: HARMONY-2982 > URL: https://issues.apache.org/jira/browse/HARMONY-2982 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Elena Semukhina > Attachments: H-2982.patch, H-2982_1.patch > > > The DRLVM smoke test classloader.StressLoader fails intermittently on both Linux and Windows. > To reproduce the failure you should run the test iteratively in the following way: > while true; do $DRLVM -cp classloader.StressLoader; done > I observe two sorts of intermittent failures: > 1. java.lang.NullPointerException > at java.net.URLClassLoader.explore(URLClassLoader.java:1200) > at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:809) > at java.net.URLClassLoader$5.run(URLClassLoader.java:667) > at java.net.URLClassLoader$5.run(URLClassLoader.java) > at java.security.AccessController.doPrivilegedImpl(Unknown Source) > at java.security.AccessController.doPrivileged(Unknown Source) > at java.net.URLClassLoader.findResource(URLClassLoader.java:665) > at java.lang.ClassLoader$BootstrapLoader.findResource(Unknown Source) > at java.lang.ClassLoader.getResource(Unknown Source) > at java.lang.ClassLoader.getResourceAsStream(Unknown Source) > at java.lang.ClassLoader.getSystemResourceAsStream(Unknown Source) > at classloader.LogLoader.loadClass(Unknown Source) > at classloader.StressLoader.run(Unknown Source) > 2. java.lang.ArrayIndexOutOfBoundsException > at java.util.IdentityHashMap.rehash(IdentityHashMap.java:501) > at java.util.IdentityHashMap.put(IdentityHashMap.java:463) > at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:720) > at java.net.URLClassLoader$5.run(URLClassLoader.java:667) > at java.net.URLClassLoader$5.run(URLClassLoader.java) > at java.security.AccessController.doPrivilegedImpl(Unknown Source) > at java.security.AccessController.doPrivileged(Unknown Source) > at java.net.URLClassLoader.findResource(URLClassLoader.java:665) > at java.lang.ClassLoader$BootstrapLoader.findResource(Unknown Source) > at java.lang.ClassLoader.getResource(Unknown Source) > at java.lang.ClassLoader.getResourceAsStream(Unknown Source) > at java.lang.ClassLoader.getSystemResourceAsStream(Unknown Source) > at classloader.LogLoader.loadClass(Unknown Source) > at classloader.StressLoader.run(Unknown Source) > java.lang.ArrayIndexOutOfBoundsException > at java.util.IdentityHashMap.rehash(IdentityHashMap.java:501) > at java.util.IdentityHashMap.put(IdentityHashMap.java:463) > at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:720) > at java.net.URLClassLoader$5.run(URLClassLoader.java:667) > at java.net.URLClassLoader$5.run(URLClassLoader.java) > at java.security.AccessController.doPrivilegedImpl(Unknown Source) > at java.security.AccessController.doPrivileged(Unknown Source) > at java.net.URLClassLoader.findResource(URLClassLoader.java:665) > at java.lang.ClassLoader$BootstrapLoader.findResource(Unknown Source) > at java.lang.ClassLoader.getResource(Unknown Source) > at java.lang.ClassLoader.getResourceAsStream(Unknown Source) > at java.lang.ClassLoader.getSystemResourceAsStream(Unknown Source) > at classloader.LogLoader.loadClass(Unknown Source) > at classloader.StressLoader.run(Unknown Source) > java.lang.ArrayIndexOutOfBoundsException > at java.util.IdentityHashMap.rehash(IdentityHashMap.java:501) > at java.util.IdentityHashMap.put(IdentityHashMap.java:463) > at java.net.URLClassLoader.findResourceImpl(URLClassLoader.java:720) > at java.net.URLClassLoader$5.run(URLClassLoader.java:667) > at java.net.URLClassLoader$5.run(URLClassLoader.java) > at java.security.AccessController.doPrivilegedImpl(Unknown Source) > at java.security.AccessController.doPrivileged(Unknown Source) > at java.net.URLClassLoader.findResource(URLClassLoader.java:665) > at java.lang.ClassLoader$BootstrapLoader.findResource(Unknown Source) > at java.lang.ClassLoader.getResource(Unknown Source) > at java.lang.ClassLoader.getResourceAsStream(Unknown Source) > at java.lang.ClassLoader.getSystemResourceAsStream(Unknown Source) > at classloader.LogLoader.loadClass(Unknown Source) > at classloader.StressLoader.run(Unknown Source) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.