summaryrefslogtreecommitdiff
path: root/openjdkjvmti/events.h
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-11-29 15:26:38 -0800
committer Alex Light <allight@google.com> 2017-12-01 15:54:33 -0800
commit74c84408ad56606514304c9ecc643bebbf11d73e (patch)
treeeac08986f86f00962327c07441c088a3e62cc132 /openjdkjvmti/events.h
parent1f541bf57dfdfe4faf169b811aadb91298a886ca (diff)
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
Diffstat (limited to 'openjdkjvmti/events.h')
-rw-r--r--openjdkjvmti/events.h12
1 files changed, 10 insertions, 2 deletions
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