Browse Source

Fixed data race of concurrent processes initializing the protected header

After initializing hdr.lock, a concurrent process entering the same exclusive block might already use lock.mtx before it is properly initialized. This issue needs to be addressed in the non-generic module as well.

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7534 8c9fc860-2736-0410-a75d-ab315db34111
negelef 7 years ago
parent
commit
7335a5d8b5
1 changed files with 1 additions and 1 deletions
  1. 1 1
      source/Generic.Unix.Objects.Mod

+ 1 - 1
source/Generic.Unix.Objects.Mod

@@ -375,8 +375,8 @@ TYPE
 		NEW(lock);
 		Unix.MtxLock(lockMutex);
 		IF hdr.lock = NIL THEN
-			hdr.lock := lock;
 			lock.mtx := Unix.NewMtx( );  lock.enter := Unix.NewCond( );  hdr.lockedBy := NIL; 
+			hdr.lock := lock;
 		END;
 		Unix.MtxUnlock(lockMutex);
 	END InitProtHeader;