Return-Path: X-Original-To: apmail-groovy-dev-archive@minotaur.apache.org Delivered-To: apmail-groovy-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 097F017B93 for ; Fri, 30 Oct 2015 03:58:05 +0000 (UTC) Received: (qmail 59085 invoked by uid 500); 30 Oct 2015 03:56:12 -0000 Delivered-To: apmail-groovy-dev-archive@groovy.apache.org Received: (qmail 59027 invoked by uid 500); 30 Oct 2015 03:56:11 -0000 Mailing-List: contact dev-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.incubator.apache.org Delivered-To: mailing list dev@groovy.incubator.apache.org Received: (qmail 54576 invoked by uid 99); 30 Oct 2015 03:49:43 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2015 03:49:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 15AFEC14D7; Fri, 30 Oct 2015 03:43:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id v2460AMEG4nQ; Fri, 30 Oct 2015 03:43:43 +0000 (UTC) Received: from mail26c25-1785.carrierzone.com (mail26c25-1785.carrierzone.com [64.29.147.53]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 164D820F4D; Fri, 30 Oct 2015 03:43:42 +0000 (UTC) X-Authenticated-User: keith.suderman.suderman.com Received: from picard-2.home (pool-173-62-62-12.pghkny.fios.verizon.net [173.62.62.12]) (authenticated bits=0) by mail26c25-1785.carrierzone.com (8.14.9/8.13.1) with ESMTP id t9U3hXpQ010374; Fri, 30 Oct 2015 03:43:35 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Groovy category throwing MissingMethodException and MissingPropertyException when using multiple threads From: Keith Suderman In-Reply-To: <563278FA.8070404@gmx.org> Date: Thu, 29 Oct 2015 23:43:33 -0400 Cc: dev@groovy.incubator.apache.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <56311C00.9020702@gmx.net> <1BCD07F2-703A-4EA8-B5C9-FBC5B99DC116@cs.vassar.edu> <563278FA.8070404@gmx.org> To: users@groovy.incubator.apache.org X-Mailer: Apple Mail (2.2104) X-CSC: 0 X-CHA: v=2.1 cv=bpB1Wiqi c=1 sm=1 tr=0 a=sppqdbktd/EjMwmfzB9pWw==:117 a=sppqdbktd/EjMwmfzB9pWw==:17 a=o1OHuDzbAAAA:8 a=g0qM3YM6AAAA:8 a=M6WH0NL8AAAA:8 a=IkcTkHD0fZMA:10 a=85_eKfjrAAAA:8 a=tp6NSNb6658eHGKNVM0A:9 a=QEXdDO2ut3YA:10 X-CTCH-RefID: str=0001.0A020204.5632E767.0116,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 Hi Jochen, I am not positive this is the cause of the problem here, but it sets off = alarm bells in my head. Consider lines 75 and 76: atomicCategoryUsageCounter.incrementAndGet(); categoriesInUse =3D atomicCategoryUsageCounter.get(); Line 75 does an incrementAndGet() but ignores the result. The value is = then obtained again on the next line with another call to get() leaving = a tiny window for another thread to increment/decrement the counter. = That is what I meant by =E2=80=9Cnon-atomic usage=E2=80=9D. This should = be: categoriesInUse =3D = atomicCategoryUsageCounter.incrementAndGet(); The same thing happens in the endScope() method (lines 99-100); the code = calls getAndDecrement(), ignores the result, and then calls the get() = method again on the next line, leaving another tiny window for another = thread to change the value.=20 I haven=E2=80=99t had a chance to figure out why Groovy won=E2=80=99t = build on my system so I can=E2=80=99t submit a PR for this. Cheers, Keith > On Oct 29, 2015, at 3:52 PM, Jochen Theodorou = wrote: >=20 > On 29.10.2015 11:48, Suderman Keith wrote: >> There are (at least) two race conditions in = GroovyCategorySupport.java >> that would explain the intermittent and hard to reproduce bugs. >>=20 >> I was hoping to submit this as my first official pull request to the >> Groovy project, but gradle has different ideas=E2=80=A6 >>=20 >> However, the offending code is in on lines 75-76 and 99-100 where >> atomicCategoryUsageCounter is used non-atomically. If no one beats me = to >> it I will submit a PR once I puzzle out why ./gradlew test is failing >> for me. >=20 > Can you explain the non-atomic usage and why it leads to a problem = here? >=20 > bye blackdrag ------------------------------ Research Associate Department of Computer Science Vassar College Poughkeepsie, NY