From e073c96dc5e22130196cfc49828d8a19b05e9abd Mon Sep 17 00:00:00 2001 From: "shravanrn@gmail.com" Date: Fri, 5 Nov 2021 16:46:34 +0000 Subject: [PATCH] Bug 1739654 - Update RLBox so that locks aren't used for app_pointer in single threaded contexts r=bholley Differential Revision: https://phabricator.services.mozilla.com/D130482 --- third_party/rlbox/README-mozilla | 2 +- third_party/rlbox/include/rlbox_app_pointer.hpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/third_party/rlbox/README-mozilla b/third_party/rlbox/README-mozilla index ffce36206f53..38d54d560ff7 100644 --- a/third_party/rlbox/README-mozilla +++ b/third_party/rlbox/README-mozilla @@ -1,7 +1,7 @@ This directory contains the rlbox source from the upstream repo: https://github.com/PLSysSec/rlbox_sandboxing_api/ -Current version: [commit 298c785d94fe3f502c52649be292fa9da71de2e9] +Current version: [commit 543a85c32652df9088302e9130b6b4ff5b0c0584] UPDATING: diff --git a/third_party/rlbox/include/rlbox_app_pointer.hpp b/third_party/rlbox/include/rlbox_app_pointer.hpp index 3d7e2023ab9a..5fa13ad5e32d 100644 --- a/third_party/rlbox/include/rlbox_app_pointer.hpp +++ b/third_party/rlbox/include/rlbox_app_pointer.hpp @@ -23,7 +23,9 @@ private: std::map pointer_map; T_PointerTypeUnsigned counter = 1; +#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS RLBOX_SHARED_LOCK(map_mutex); +#endif T_PointerType get_unused_index() { @@ -55,7 +57,9 @@ public: T_PointerType get_app_pointer_idx(void* ptr) { +#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS RLBOX_ACQUIRE_UNIQUE_GUARD(lock, map_mutex); +#endif T_PointerType idx = get_unused_index(); T_PointerTypeUnsigned idx_int = (T_PointerTypeUnsigned)idx; pointer_map[idx_int] = ptr; @@ -64,7 +68,9 @@ public: void remove_app_ptr(T_PointerType idx) { +#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS RLBOX_ACQUIRE_UNIQUE_GUARD(lock, map_mutex); +#endif T_PointerTypeUnsigned idx_int = (T_PointerTypeUnsigned)idx; auto it = pointer_map.find(idx_int); detail::dynamic_check(it != pointer_map.end(), @@ -74,7 +80,9 @@ public: void* lookup_index(T_PointerType idx) { +#ifndef RLBOX_SINGLE_THREADED_INVOCATIONS RLBOX_ACQUIRE_SHARED_GUARD(lock, map_mutex); +#endif T_PointerTypeUnsigned idx_int = (T_PointerTypeUnsigned)idx; auto it = pointer_map.find(idx_int); detail::dynamic_check(it != pointer_map.end(),