Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 84554 invoked from network); 6 Dec 2001 19:51:45 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 6 Dec 2001 19:51:45 -0000 Received: (qmail 20944 invoked by uid 97); 6 Dec 2001 19:51:19 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 20901 invoked by uid 97); 6 Dec 2001 19:51:19 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 20792 invoked from network); 6 Dec 2001 19:51:18 -0000 Message-ID: <06f301c17e8f$39c1a660$0cb1eccf@cybershop.ca> From: "Bo Xu" To: "Tomcat Developers List" References: <20011206002230.7918.qmail@nagoya.betaversion.org> Subject: Re: DO NOT REPLY [Bug 4138] - HttpProcessor threads have inconsistent ClassLoader state Date: Thu, 6 Dec 2001 14:50:15 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-MDaemon-Deliver-To: tomcat-dev@jakarta.apache.org X-Return-Path: bo@cybershop.ca X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Dear TOMCAT developers, :-) I forward the following email to you :-) Bo Dec.06, 2001 ***************************************************************** If you really want the developers to take a look at this, you should probably post it to the tomcat-dev list. It's iffy whether or not they will see it here. Thanks, --jeff ----- Original Message ----- From: "java programmer" To: Sent: Wednesday, December 05, 2001 10:44 PM Subject: Double check idiom broken - Tomcat uses it ? > Hi all: > > We all know that the lazy-double-check idiom doesn't > apply to Java because of the Java Memory Model (JMM). > > That is to say, look at code such as: > > Example a) > // Set by any other thread other than #1 > volatile boolean stop = false; > > // Thread #1 runs this as long as > // stop is false. Only T1 will call this > // method, so not synchronized. hence > // broken due to staleness of 'stop'. > // synch for _visbility_ ALSO. > void foo() { > while (!stop ) { //... } > } > > > Example b): The lazy double check idiom > public static Foo haha = null; > public static getFoo() { > if (foo == null ) { > sychronized (Foo.class) { > if (foo == null ) > foo = new Foo(); > } > } > return foo; > } > > Both examples are *guaranteed* to be incorrect. > Note, this is the case, *even* though I am using > 'volatile' for the stop variable. For more on the > JMM, consult Item #48 in Effective Java (Josh Bloch), > look at Bill Pughs' page at: > http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html > or check out Doug Lea's stuff. > Well, here is the thing: > > Quite idly, and randomly, I was looking at: > > org.apache.jasper.servlet.JspServlet > > and I found: > > > outDated = compiler.isOutDated(); > if(!jsw.isInstantiated() || outDated ) { > synchronized(jsw){ > outDated = compiler.compile(); > if(!jsw.isInstantiated() || outDated) { > if( null ==ctxt.getServletClassName() ) { > > > This is a complex use of double check type > code and is really hard to analyse because references > themselves and what they point to can have > different levels of staleness (according to the JMM). > So it's a turbo double idiom type usage, possibly > incorrect. > > I just wanted to bring this to the attention of the > development team and make sure that *someone* has > really analysed this according to the JMM. (and > any other code, similar to this). > > Best regards, > > javadesigner@yahoo.com -- To unsubscribe, e-mail: For additional commands, e-mail: