This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Race condition in Make_Independent


Make_Independent decrements Wait_Count, which caused a race condition -- if the
timing is just wrong, it causes Make_Passive to find Wait_Count = 0, which
eventually causes the program to hang. This patch prevents hanging by
decrementing Wait_Count only if nonzero.
No test is available, because it's large, and only fails intermittently.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-29  Bob Duff  <duff@adacore.com>

	* s-tasuti.adb (Make_Passive): Work around race condition in
	Make_Independent, which can cause Wait_Count to be zero. So instead of
	asserting that Wait_Count > 0, and then decrementing it, decrement it
	only if Wait_Count > 0.
	* s-taskin.ads (Wait_Count, Alive_Count, Awake_Count): All of these
	should be nonnegative, so declare them Natural instead of Integer.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]