From 74c84408ad56606514304c9ecc643bebbf11d73e Mon Sep 17 00:00:00 2001 From: Alex Light Date: Wed, 29 Nov 2017 15:26:38 -0800 Subject: Ensure that updates to the global event mask are atomic We were setting and testing the global event mask in a way that allowed races with other threads. This could cause issues if multiple threads write to the mask at the same time and could cause changes to the current event state to be missed. Test: ./test.py --host -j50 Bug: 69657830 Change-Id: I5e2759af598e6179fd25fcbe6b211a9369217156 --- openjdkjvmti/events.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'openjdkjvmti/events.h') diff --git a/openjdkjvmti/events.h b/openjdkjvmti/events.h index c73215f07b..d21a587f03 100644 --- a/openjdkjvmti/events.h +++ b/openjdkjvmti/events.h @@ -149,8 +149,16 @@ struct EventMasks { EventMask& GetEventMask(art::Thread* thread); EventMask* GetEventMaskOrNull(art::Thread* thread); - void EnableEvent(art::Thread* thread, ArtJvmtiEvent event); - void DisableEvent(art::Thread* thread, ArtJvmtiEvent event); + // Circular dependencies mean we cannot see the definition of ArtJvmTiEnv so the mutex is simply + // asserted in the function. + // Note that the 'env' passed in must be the same env this EventMasks is associated with. + void EnableEvent(ArtJvmTiEnv* env, art::Thread* thread, ArtJvmtiEvent event); + // REQUIRES(env->event_info_mutex_); + // Circular dependencies mean we cannot see the definition of ArtJvmTiEnv so the mutex is simply + // asserted in the function. + // Note that the 'env' passed in must be the same env this EventMasks is associated with. + void DisableEvent(ArtJvmTiEnv* env, art::Thread* thread, ArtJvmtiEvent event); + // REQUIRES(env->event_info_mutex_); bool IsEnabledAnywhere(ArtJvmtiEvent event); // Make any changes to event masks needed for the given capability changes. If caps_added is true // then caps is all the newly set capabilities of the jvmtiEnv. If it is false then caps is the -- cgit v1.2.3-59-g8ed1b