Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4736

Deadlock when GroovyClassLoader is used in multi-threaded environment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.7.9
    • None
    • groovy-runtime
    • Multiple OS: development server: Ubuntu 32-bit, desktop machine: Windows 7 64-bit, Java 1.6 Update 21

    Description

      When multiple threads uses GroovyClassLoader to get Groovy classes or just work with them (instantiation, etc.) and an other(s) threads change the sources (followed by clearCache call), then deadlock can happen related to synchronizations on InnerLoader and HashMap (GroovyClassLoader.sourceCache)

      I attached simple test scenation when 3 threads load Groovy classes and instantiate them and 3 other threads replace sources and call GroocyClassLoader.clearCache(). There is a synchronization on writeToFile to be ensure that the same file is not being written at the same time but this synchronization does not take part in a deadlock.

      Please just run the test and wait a moment. Deadlock happens usually in 1 second at this test scenario. I hope this test will be also useful in Your future development as a standard test case.

      Attachments

        1. GroovyEngineTest.jar
          5.45 MB
          Szymon Kuklewicz
        2. GroovyEngineTest.java
          5 kB
          Szymon Kuklewicz
        3. GroovyEngineTest.java
          6 kB
          Szymon Kuklewicz
        4. ReentrantReadWriteLock_for_the_cache_cleaning.patch
          6 kB
          Guillaume Sauthier
        5. temporary_hack_for_deadlock_in_gcl.patch
          0.7 kB
          Guillaume Sauthier

        Activity

          People

            blackdrag Jochen Theodorou
            skuklewicz Szymon Kuklewicz
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: