Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues
Bug 1003 - A ConcurrentModificationException may occur while the IMR is serializing the server table to disk if a new POA is registered at the same time
Summary: A ConcurrentModificationException may occur while the IMR is serializing the ...
Status: RESOLVED FIXED
Alias: None
Product: JacORB
Classification: Unclassified
Component: Implementation Repository (show other bugs)
Version: 3.5
Hardware: PC Linux
: P5 normal
Assignee: Mailinglist to track bugs
URL:
Depends on:
Blocks:
 
Reported: 2015-03-05 11:23 CET by Weiqi Gao
Modified: 2015-03-28 19:04 CET (History)
1 user (show)

See Also:


Attachments
This patch introduces a ResourceLock to prevent a race condition described in the but report. (2.23 KB, patch)
2015-03-05 11:34 CET, Weiqi Gao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Weiqi Gao 2015-03-05 11:23:31 CET
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 CET
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 CET
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 CET
Fixed by SHA 3753b586bac0b1e23fb578726cb4e927e535dc01