Guarantee strict weak order in Probe::finalize_locations
authorEddie Elizondo <eelizondo@fb.com>
Mon, 15 Nov 2021 06:12:07 +0000 (01:12 -0500)
committeryonghong-song <ys114321@gmail.com>
Mon, 15 Nov 2021 17:31:10 +0000 (09:31 -0800)
src/cc/usdt/usdt.cc

index 0c6213fe5d5180fc8cce9e84eb2a5029d87126a2..bd3f26517127d056b75898ec150f629b1e05e7f9 100644 (file)
@@ -222,7 +222,7 @@ void Probe::add_location(uint64_t addr, const std::string &bin_path, const char
 void Probe::finalize_locations() {
   std::sort(locations_.begin(), locations_.end(),
             [](const Location &a, const Location &b) {
-              return a.bin_path_ < b.bin_path_ || a.address_ < b.address_;
+              return std::tie(a.bin_path_, a.address_) < std::tie(b.bin_path_, b.address_);
             });
   auto last = std::unique(locations_.begin(), locations_.end(),
                           [](const Location &a, const Location &b) {