jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-4292

ClassHelper.ClassHelperCache#classCache is not thread-safe

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.7.3
  • Fix Version/s: 2.0-rc-1, 1.8.7, 1.7.11
  • Component/s: class generator
  • Labels:
    None

Description

When parsing Groovy scripts from multiple threads at a time, the call to WeakHashMap.get() may never return due to internal corruption due to the concurrent access. Since IntelliJ IDEA does its GDSL parsing in parallel threads, this blocks it completely.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 05/Jul/10 1:53 PM

No wonder, mos of the compiler infrastructure is designed for single thread usage only. I would have suggested to use makeWithoutCaching, but that ends in makeCached too, which uses the map. I think that must be changed then.

As for a workaround... is it impossible to do some kind of warmup?

Show
blackdrag blackdrag added a comment - 05/Jul/10 1:53 PM No wonder, mos of the compiler infrastructure is designed for single thread usage only. I would have suggested to use makeWithoutCaching, but that ends in makeCached too, which uses the map. I think that must be changed then. As for a workaround... is it impossible to do some kind of warmup?
Hide
Permalink
Peter Gromov added a comment - 05/Jul/10 2:07 PM

As a workaround, we'll now do the parsing in a single thread. But that may take quite long. A warmup could help, if I knew exactly what to invoke to ensure everything's warmed up.

If it were IDEA sources, I'd just replace WeakHashMap with ConcurrentWeakHashMap, as we have one

Show
Peter Gromov added a comment - 05/Jul/10 2:07 PM As a workaround, we'll now do the parsing in a single thread. But that may take quite long. A warmup could help, if I knew exactly what to invoke to ensure everything's warmed up. If it were IDEA sources, I'd just replace WeakHashMap with ConcurrentWeakHashMap, as we have one
Hide
Permalink
blackdrag blackdrag added a comment - 05/Jul/10 2:21 PM

the warmup would have to contain all the ClassHelper#make calls you usually do. The problem cannot be there for the static stuff that is in that class, since the WeakHashMap may not be able to handle concurrent writes, but concurrent reads are no problem

Show
blackdrag blackdrag added a comment - 05/Jul/10 2:21 PM the warmup would have to contain all the ClassHelper#make calls you usually do. The problem cannot be there for the static stuff that is in that class, since the WeakHashMap may not be able to handle concurrent writes, but concurrent reads are no problem
Hide
Permalink
Peter Gromov added a comment - 05/Jul/10 3:22 PM

The problem is that I don't do any ClassHelper#make calls. I just say new GroovyShell().parse(text) for different script texts. So it's not clear to me which classes should be cached in the map to account for any possible script text.

Show
Peter Gromov added a comment - 05/Jul/10 3:22 PM The problem is that I don't do any ClassHelper#make calls. I just say new GroovyShell().parse(text) for different script texts. So it's not clear to me which classes should be cached in the map to account for any possible script text.
Hide
Permalink
blackdrag blackdrag added a comment - 23/May/12 6:05 AM

I replaced the map with an internal concurrent version from our runtime

Show
blackdrag blackdrag added a comment - 23/May/12 6:05 AM I replaced the map with an internal concurrent version from our runtime

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Peter Gromov
Vote (9)
Watch (3)

Dates

  • Created:
    05/Jul/10 12:48 PM
    Updated:
    Today 6:05 AM
    Resolved:
    Today 6:05 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.