<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.jacorb.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://www.jacorb.org/bugzilla/"
          
          maintainer="jacorb@goots.org"
>

    <bug>
          <bug_id>1003</bug_id>
          
          <creation_ts>2015-03-05 11:23:31 +0000</creation_ts>
          <short_desc>A ConcurrentModificationException may occur while the IMR is serializing the server table to disk if a new POA is registered at the same time</short_desc>
          <delta_ts>2015-03-28 19:04:03 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>JacORB</product>
          <component>Implementation Repository</component>
          <version>3.5</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Weiqi Gao">weiqigao</reporter>
          <assigned_to name="Mailinglist to track bugs">jacorb-bugs</assigned_to>
          <cc>jacorb</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3275</commentid>
    <comment_count>0</comment_count>
    <who name="Weiqi Gao">weiqigao</who>
    <bug_when>2015-03-05 11:23:31 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3276</commentid>
    <comment_count>1</comment_count>
      <attachid>457</attachid>
    <who name="Weiqi Gao">weiqigao</who>
    <bug_when>2015-03-05 11:34:15 +0000</bug_when>
    <thetext>Created attachment 457
This patch introduces a ResourceLock to prevent a race condition described in the but report.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3277</commentid>
    <comment_count>2</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2015-03-05 11:53:02 +0000</bug_when>
    <thetext>
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?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3286</commentid>
    <comment_count>3</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2015-03-28 19:04:03 +0000</bug_when>
    <thetext>Fixed by SHA 3753b586bac0b1e23fb578726cb4e927e535dc01</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>457</attachid>
            <date>2015-03-05 11:34:15 +0000</date>
            <delta_ts>2015-03-05 11:34:15 +0000</delta_ts>
            <desc>This patch introduces a ResourceLock to prevent a race condition described in the but report.</desc>
            <filename>0001-Introduced-ResourceLock-to-prevent-a-race-condition-.patch</filename>
            <type>text/plain</type>
            <size>2288</size>
            <attacher name="Weiqi Gao">weiqigao</attacher>
            
              <data encoding="base64">RnJvbSAyYWEwYTllNWY5MTk0MjhmYThhMTI5YTFjZDBlODUy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IHRoaXMubG9nZ2VyLmRl
YnVnKCJJbVI6IG5ldyBwb2EgcmVnaXN0ZXJlZCIpOwpAQCAtMTYyNCwxMiArMTYzMSwxNyBAQCBw
dWJsaWMgY2xhc3MgSW1wbGVtZW50YXRpb25SZXBvc2l0b3J5SW1wbAogICAgICAgICAgICAgewog
ICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAg
ICAgc2VydmVyX3RhYmxlX3Nlcl9sb2NrLmdhaW5FeGNsdXNpdmVMb2NrKCk7CiAgICAgICAgICAg
ICAgICAgICAgIHNhdmVfc2VydmVyX3RhYmxlICh0YWJsZV9maWxlKTsKICAgICAgICAgICAgICAg
ICB9CiAgICAgICAgICAgICAgICAgY2F0Y2ggKEZpbGVPcEZhaWxlZCBleCkKICAgICAgICAgICAg
ICAgICB7CiAgICAgICAgICAgICAgICAgICAgIGxvZ2dlci5lcnJvcigiRXhjZXB0aW9uIHdoaWxl
IHNhdmluZyBzZXJ2ZXIgdGFibGUiLCBleCk7CiAgICAgICAgICAgICAgICAgfQorICAgICAgICAg
ICAgICAgIGZpbmFsbHkKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIHNl
cnZlcl90YWJsZV9zZXJfbG9jay5yZWxlYXNlRXhjbHVzaXZlTG9jaygpOworICAgICAgICAgICAg
ICAgIH0KIAogICAgICAgICAgICAgICAgIGlmIChkb25lKQogICAgICAgICAgICAgICAgIHsKLS0g
CjIuMS4wCgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>