[SERVER-41787] heapprofile may crash Created: 17/Jun/19  Updated: 29/Oct/23  Resolved: 31/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: deyukong Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-44010 heap_profiler.cpp has a few bugs Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2021-08-09
Participants:
Story Points: 2

 Description   

  auto sortByActiveBytes = [](StackInfo* a, StackInfo* b) -> bool {
    return a->activeBytes > b->activeBytes;
  }; 
  std::stable_sort(stackInfos.begin(), stackInfos.end(), sortByActiveBytes);

 

the sort functor here uses pointer to StackInfo, which is mutable, and may change during the sort procedure, violates strict weak ordering that is required by c++ standard lib and crashes.

 

The crash behavior has been witten during the product environment.



 Comments   
Comment by Githook User [ 30/Jul/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-41787 fix bad sort order in HeapProfiler
Branch: master
https://github.com/mongodb/mongo/commit/4e0eecad3a764e2f85e77e78901ce4b19661d832

Comment by Billy Donahue [ 21/Jul/21 ]

Code Review:
https://mongodbcr.appspot.com/804850004/

This review is for the reported sort comparator issue, but also eliminating an unused BSONObj attached to each stack capture object.

Generated at Thu Feb 08 04:58:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.