moonchen commented on code in PR #13310:
URL: https://github.com/apache/trafficserver/pull/13310#discussion_r3456042839


##########
src/tsutil/Metrics.cc:
##########
@@ -57,8 +57,8 @@ Metrics::Storage::addBlob() // The mutex must be held before 
calling this!
 Metrics::IdType
 Metrics::Storage::create(std::string_view name, const MetricType type)
 {
-  std::lock_guard lock(_mutex);
-  auto            it = _lookups.find(name);
+  ts::scoped_writer_lock lock(_mutex);
+  auto                   it = _lookups.find(name);

Review Comment:
   Good catch, and confirmed real: with `MAX_BLOBS == 8192`, 
`debug_assert(_cur_blob < MAX_BLOBS)` permits `_cur_blob == 8191`, and the 
pre-increment in `_blobs[++_cur_blob]` then writes `_blobs[8192]`, one past the 
array. It is also silent in release builds since `debug_assert` is a no-op 
under `NDEBUG`. This is pre-existing on master (unchanged since #11214/#12238) 
and outside the scope of this thread-safety PR, so I will address it in a 
separate PR rather than expand this one. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to