Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues

Bug 1003

Summary: A ConcurrentModificationException may occur while the IMR is serializing the server table to disk if a new POA is registered at the same time
Product: JacORB Reporter: Weiqi Gao <weiqigao>
Component: Implementation RepositoryAssignee: Mailinglist to track bugs <jacorb-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: jacorb
Priority: P5    
Version: 3.5   
Hardware: PC   
OS: Linux   
Attachments: This patch introduces a ResourceLock to prevent a race condition described in the but report.

Description Weiqi Gao 2015-03-05 11:23:31 UTC
One of our customers has reported a CuncurrentModicationException during system start up:

2015-02-03 12:45:10.049 SEVERE Exception while saving server table
    java.util.ArrayList.writeObject(ArrayList.java:766)
    sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ...
    org.jacorb.imr.ImplementationRepositoryImpl.save_server_table(ImplementationRepositoryImpl.java:825)

This is a manifestation of a race condition that exists between the WriteThread, which serializes the server_table to disk, and the thread calling register_poa() with a new POA.  While adquate locking is provided for the fields in the ServerTable class through its table_lock, the call to

    _server.addPOA(_poa);

while registering a new POA does not fall into the scope of that lock.

This bug was reported against an older version of JacORB, JacORB 2.3.1.  However, by reviewing the code in the latest head of the upstream, I see that it is also present there.

I will attach a patch that introduce a new lock to prevent the ConcurrentModificationException.

--
Weiqi Gao
Principal Software Engineer
Object Computing, Inc.
Comment 1 Weiqi Gao 2015-03-05 11:34:15 UTC
Created attachment 457 [details]
This patch introduces a ResourceLock to prevent a race condition described in the but report.
Comment 2 Nick Cross 2015-03-05 11:53:02 UTC
Given ResourceLock is isolated to the IMR its fine to keep using it I think.

Can you produce a junit regression test for this? (byteman?)

Can you supply a pull request via github?
Comment 3 Nick Cross 2015-03-28 19:04:03 UTC
Fixed by SHA 3753b586bac0b1e23fb578726cb4e927e535dc01