Bug

Erez Hadad <[email protected]> Sun, 17 Apr 2005 19:47:08 +0300
Newsgroups gmane.comp.corba.orbacus
Message-ID <[email protected]>
Hi,

I'm using JOB-4.1.3 (Linux/JDK1.4.2). I think I may have just recovered and 
fixed a bug in ob/src/com/ooc/PortableInterceptor/Current_impl.java: the 
private member stateKey_ is defined as an un-synchronized WeakHashMap. Thus 
calls to establishTSD() by multiple threads may create a race condition in 
which one thread changes the map while another accesses it. According to the 
JDK documentation, this is a forbidden situation and it might result in an 
erratic behavior. In my case, I found this as my server crashed with the 
exception in the attached file log.txt

My explanation is as following: when two or more threads access the stateKey_ 
map simultaneously in establishTSD(), a reader thread might get a null value 
although it has a valid entry in the map. Next, the reader thread creates a 
new stack entry (since it got null) with a single element. If the reader 
thread called establishTSD() from within _OB_popSlotData() then the new stack 
returned has its single element removed. As a result, it becomes empty and 
the assertion in line 173 fails.

I have fixed this problem by replacing line 46 with the following line:
    private java.util.Map stateKey_ = 
java.util.Collections.synchronizedMap(new java.util.WeakHashMap());

Please verify the bug and its fix. I know it exists in JOB-4.2.2 as well.

Sincerely,
Erez Hadad

_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html
log.txt (text/plain, 1.2 KB)
com.ooc.OB.AssertionFailed: ORBacus encountered an internal error
        at com.ooc.OB.Assert._OB_assert(Assert.java:19)
        at com.ooc.PortableInterceptor.Current_impl._OB_popSlotData(Current_impl .java:173)
        at com.ooc.PortableInterceptor.ServerRequestInfo_impl._OB_contextSwitch( ServerRequestInfo_impl.java:605)
        at com.ooc.OB.PIManager.serverContextSwitch(PIManager.java:494)
        at com.ooc.OB.PIUpcall.contextSwitch(PIUpcall.java:237)
        at com.ooc.OBPortableServer.POA_impl._OB_createUpcall(POA_impl.java:1657 )
        at com.ooc.OBPortableServer.POAOAInterface_impl.createUpcall(POAOAInterf ace_impl.java:94)
        at com.ooc.OB.GIOPServerWorker.executeRequest(GIOPServerWorker.java:461)
        at com.ooc.OB.GIOPServerWorker.execute(GIOPServerWorker.java:323)
        at com.ooc.OB.GIOPServerWorkerThreaded.receiverRun(GIOPServerWorkerThrea ded.java:524)
        at com.ooc.OB.GIOPServerWorkerThreaded$ReceiverThread.run(GIOPServerWork erThreaded.java:70)
com.ooc.OB.AssertionFailed: ORBacus encountered an internal error
        at com.ooc.OB.Assert._OB_assert(Assert.java:19)
        at com.ooc.OB.GIOPServerWorkerThreaded$ReceiverThread.run(GIOPServerWork erThreaded.java:75)