bugKawa - Bugs: bug #8817, Race condition in ClassType.java...

 
 

bug #8817: Race condition in ClassType.java and cxr.java

Submitted by:  Chris Dean <ctdean>
Submitted on:  Thu 06 May 2004 04:08:22 AM UTC  
 
Category: Scheme languageSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 13 May 2004 09:12:48 PM UTC, comment #5:

I don't think Chris's patch is safe according to the memory model: A thread may call addMethods, and then the flags fields might get written out from cache to main memory before the newly constructed Method objects are.

The solution (alas) is to always synchronize.
See http://www.javaworld.com/jw-02-2001/jw-0209-double.html
and JSR 133 http://www.jcp.org/en/jsr/detail?id=133.

I checked in a patch.

Per Bothner <bothner>
Project Administrator
Fri 07 May 2004 06:11:20 AM UTC, comment #4:

I check in a patch for cxr.java.

Per Bothner <bothner>
Project Administrator
Thu 06 May 2004 05:54:15 AM UTC, comment #3:

Patch to fix is attached.

Chris Dean <ctdean>
Thu 06 May 2004 05:15:34 AM UTC, comment #2:

Sure, I'll make those changes and send you a patch.

Chris Dean <ctdean>
Thu 06 May 2004 05:04:36 AM UTC, comment #1:

For addMethods, I'd make that synchronized, and add an extra
if ((flags & ADD_METHODS_DONE) != 0) return;
We need to do the same for addFields.
One caveat: is this prey to the warnings about "double-locking" and does tha matter in practice?

For cxr.java, I don't think we need locking. Just replace the mask and count variables in the program method by local variables, and then set mask and then finally count at the end.

Per Bothner <bothner>
Project Administrator
Thu 06 May 2004 04:08:22 AM UTC, original submission:

There are two race conditions that I'm seeing when running under heavy multi-threaded scenarios.

In ClassType.java we have a few test/set blocks that need a syncronized block around them. For example:
public Method getDeclaredMethods()
{
if ((flags & (ADD_METHODS_DONE|EXISTING_CLASS)) == EXISTING_CLASS)
addMethods(getReflectClass());
return methods;
}

A similar situation exists in cxr.java:
public Object apply1 (Object arg1)
{
if (count == 0)
program(getName().toString());
...

I can provide patches if you'de like.

Chris Dean <ctdean>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #1289:  race.patch added by ctdean (4KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 13 May 2004 09:12:48 PM UTCbothnerStatusNone=>Fixed
  Open/ClosedOpen=>Closed
Thu 06 May 2004 05:54:15 AM UTCctdeanAttached File-=>Added race.patch, #1274

Back to the top


Powered by Savane 3.1-cleanup1