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


##########
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:
   `Metrics::Storage::addBlob()` has an off-by-one bound check: 
`debug_assert(_cur_blob < MAX_BLOBS);` allows `_cur_blob == MAX_BLOBS - 1`, 
then `++_cur_blob` writes `_blobs[MAX_BLOBS]` (out of bounds) and also produces 
IDs that wrap in `_splitID()` (mask is `0x1FFF`). This should be a 
`release_assert` (or equivalent) and the check should account for the 
pre-increment.



-- 
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