Repository: getsentry/symbolic
Pull request #869 (2024-09-17 11:01:12)

ref(debuginfo): Replace dmsort with std sort
We're using an unstable sorting algorithm (dmsort) to sort symbols upon collection. It behaves differently under Rust 1.81 than 1.80, so some snapshots change.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getsentry/symbolic/pull/869?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.44%. Comparing base [(`bd90dfb`)](https://app.codecov.io/gh/getsentry/symbolic/commit/bd90dfb893c95abda477b464d438077581add717?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) to head [(`f62903d`)](https://app.codecov.io/gh/getsentry/symbolic/commit/f62903d4274d0aa52853d3b58384dcbc89667d75?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry).
> Report is 31 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #869      +/-   ##
==========================================
+ Coverage   74.45%   77.44%   +2.98%     
==========================================
  Files          63       61       -2     
  Lines       15432    14853     -579     
==========================================
+ Hits        11490    11503      +13     
+ Misses       3942     3350     -592     
```

</details>
loewenheim: If we switch to `std` sort, we might also do `sort_unstable`, wdyt?

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1eadeca8..4eed8a25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## Unreleased
+
+**Internal**:
+
+- Removed `dmsort` dependency and replaced uses with stable std sorts. ([#869](https://github.com/getsentry/symbolic/pull/869))
+
 ## 12.11.0
 
 - Add callback to `symbolic::debuginfo::sourcebundle::SourceBundleWriter` which handles files skipped while writing to the source bundle. ([#864](https://github.com/getsentry/symbolic/pull/864))
diff --git a/Cargo.lock b/Cargo.lock
index 0158be66..fb7b6c73 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -592,12 +592,6 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "dmsort"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0bc8fbe9441c17c9f46f75dfe27fa1ddb6c68a461ccaed0481419219d4f10d3"
-
 [[package]]
 name = "dump_cfi"
 version = "12.11.0"
@@ -2207,7 +2201,6 @@ version = "12.11.0"
 dependencies = [
  "criterion",
  "debugid",
- "dmsort",
  "elementtree",
  "elsa",
  "fallible-iterator 0.3.0",
diff --git a/Cargo.toml b/Cargo.toml
index 2111c070..82346d28 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,6 @@ clap = "4.4.5"
 cpp_demangle = "0.4.1"
 criterion = { version = "0.5.1", features = ["html_reports"] }
 debugid = "0.8.0"
-dmsort = "1.0.2"
 elementtree = "1.2.3"
 elsa = "1.8.0"
 fallible-iterator = "0.3.0"
diff --git a/symbolic-debuginfo/Cargo.toml b/symbolic-debuginfo/Cargo.toml
index 20fb5bf9..d56c547e 100644
--- a/symbolic-debuginfo/Cargo.toml
+++ b/symbolic-debuginfo/Cargo.toml
@@ -87,7 +87,6 @@ js = []
 wasm = ["dwarf", "wasmparser"]
 
 [dependencies]
-dmsort = { workspace = true }
 debugid = { workspace = true }
 elementtree = { workspace = true, optional = true }
 elsa = { workspace = true, optional = true }
diff --git a/symbolic-debuginfo/src/base.rs b/symbolic-debuginfo/src/base.rs
index 1b20314c..01d981aa 100644
--- a/symbolic-debuginfo/src/base.rs
+++ b/symbolic-debuginfo/src/base.rs
@@ -413,7 +413,7 @@ impl<'d> From<Vec<Symbol<'d>>> for SymbolMap<'d> {
             //
             // Inlined functions will generally not appear in this list, unless they _also_ have an
             // explicit function body, in which case they will have a unique address, again.
-            dmsort::sort_by_key(&mut symbols, Self::key);
+            symbols.sort_by_key(Self::key);
 
             // Compute sizes of consecutive symbols if the size has not been provided by the symbol
             // iterator. In the same go, drop all but the first symbols at any given address. We do
diff --git a/symbolic-debuginfo/src/dwarf.rs b/symbolic-debuginfo/src/dwarf.rs
index 8c35fe0a..3153e13c 100644
--- a/symbolic-debuginfo/src/dwarf.rs
+++ b/symbolic-debuginfo/src/dwarf.rs
@@ -330,7 +330,7 @@ impl<'d> DwarfLineProgram<'d> {
         }
 
         // Sequences are not guaranteed to be in order.
-        dmsort::sort_by_key(&mut sequences, |x| x.start);
+        sequences.sort_by_key(|x| x.start);
 
         DwarfLineProgram {
             header: state_machine.header().clone(),


Test patch:
diff --git a/symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap
index 2e0c5f3e..a7bb1d23 100644
--- a/symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap
+++ b/symbolic-debuginfo/tests/snapshots/test_objects__elf_symbols.snap
@@ -1,7 +1,5 @@
 ---
-created: "2019-02-27T13:05:25.490529Z"
-creator: insta@0.6.3
-source: debuginfo/tests/test_objects.rs
+source: symbolic-debuginfo/tests/test_objects.rs
 expression: SymbolsDebug(&symbols)
 ---
             1558 _init
@@ -42,7 +40,7 @@ expression: SymbolsDebug(&symbols)
             3670 _ZN15google_breakpad16ExceptionHandlerC1ERKNS_18MinidumpDescriptorEPFbPvEPFbS3_S4_bES4_bi
             3a10 _ZN15google_breakpad16ExceptionHandler13WriteMinidumpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFbRKNS_18MinidumpDescriptorEPvbESC_
             3cb0 _ZNSt6vectorIPN15google_breakpad16ExceptionHandlerESaIS2_EE19_M_emplace_back_auxIIS2_EEEvDpOT_
-            3da0 _ZN15google_breakpad18MinidumpDescriptorC1ERKS0_
+            3da0 _ZN15google_breakpad18MinidumpDescriptorC2ERKS0_
             3f20 _ZN15google_breakpad18MinidumpDescriptor10UpdatePathEv
             42f0 _ZN15google_breakpad18MinidumpDescriptoraSERKS0_
             43c0 _ZN6logger5writeEPKcm
@@ -50,7 +48,7 @@ expression: SymbolsDebug(&symbols)
             6e10 _ZNSt6vectorIhN15google_breakpad16PageStdAllocatorIhEEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS3_EET_SB_St20forward_iterator_tag
             71f0 _ZN15google_breakpad11LinuxDumper8LateInitEv
             7200 _ZN15google_breakpad11LinuxDumper17EnumerateMappingsEv
-            7ac0 _ZN15google_breakpad11LinuxDumperC1EiPKc
+            7ac0 _ZN15google_breakpad11LinuxDumperC2EiPKc
             8300 _ZN15google_breakpad11LinuxDumperD2Ev
             8370 _ZN15google_breakpad11LinuxDumperD0Ev
             8390 _ZNK15google_breakpad11LinuxDumper20GetCrashSignalStringEv
@@ -71,14 +69,14 @@ expression: SymbolsDebug(&symbols)
             94a0 _ZNK15google_breakpad17LinuxPtraceDumper12IsPostMortemEv
             94b0 _ZN15google_breakpad17LinuxPtraceDumper15CopyFromProcessEPviPKvm
             9640 _ZN15google_breakpad17LinuxPtraceDumper13ThreadsResumeEv
-            9700 _ZNK15google_breakpad17LinuxPtraceDumper13BuildProcPathEPciPKc
+            9700 _ZNK15google_breakpad17LinuxPtraceDumper13BuildProcPathEPciPKc.localalias.19
             97c0 _ZN15google_breakpad17LinuxPtraceDumper16EnumerateThreadsEv
             9e50 _ZN15google_breakpad17LinuxPtraceDumperC1Ei
             9e80 _ZN15google_breakpad17LinuxPtraceDumper15ReadRegisterSetEPNS_10ThreadInfoEi
             9f70 _ZN15google_breakpad17LinuxPtraceDumper13ReadRegistersEPNS_10ThreadInfoEi
             a050 _ZN15google_breakpad17LinuxPtraceDumper20GetThreadInfoByIndexEmPNS_10ThreadInfoE
             a690 _ZN15google_breakpad17LinuxPtraceDumper14ThreadsSuspendEv
-            a8f0 _ZN15google_breakpad17LinuxPtraceDumperD1Ev
+            a8f0 _ZN15google_breakpad17LinuxPtraceDumperD2Ev
             a910 _ZN15google_breakpad17LinuxPtraceDumperD0Ev
             a930 _ZNSt6vectorIiN15google_breakpad16PageStdAllocatorIiEEE17_M_default_appendEm
             abc0 _ZN12_GLOBAL__N_114MinidumpWriter21WriteThreadListStreamEP14MDRawDirectory.constprop.105
@@ -120,7 +118,7 @@ expression: SymbolsDebug(&symbols)
            11220 _ZN15google_breakpad8ElfClassEPKv
            11230 _ZN15google_breakpad14FindElfSectionEPKvPKcjPS1_Pm
            116a0 _ZN15google_breakpad15FindElfSegmentsEPKvjPNS_15wasteful_vectorINS_10ElfSegmentEEE
-           11990 _ZNSt6vectorIN15google_breakpad10ElfSegmentENS0_16PageStdAllocatorIS1_EEE19_M_emplace_back_auxIIRKS1_EEEvDpOT_
+           11990 _ZNSt6vectorIN15google_breakpad10ElfSegmentENS0_16PageStdAllocatorIS1_EEE19_M_emplace_back_auxIJRKS1_EEEvDpOT_
            11be0 _ZN15google_breakpad6FileIDC2EPKc
            11cc0 _ZN15google_breakpad6FileID29ConvertIdentifierToUUIDStringB5cxx11ERKNS_15wasteful_vectorIhEE
            11e70 _ZN15google_breakpad6FileID25ConvertIdentifierToStringB5cxx11ERKNS_15wasteful_vectorIhEE
@@ -146,11 +144,11 @@ expression: SymbolsDebug(&symbols)
            13160 my_isspace
            13210 _ZN15google_breakpad16MemoryMappedFileC2Ev
            13220 _ZN15google_breakpad16MemoryMappedFile5UnmapEv
-           13270 _ZN15google_breakpad16MemoryMappedFileD2Ev
+           13270 _ZN15google_breakpad16MemoryMappedFileD1Ev
            13280 _ZN15google_breakpad16MemoryMappedFile3MapEPKcm
-           13430 _ZN15google_breakpad16MemoryMappedFileC1EPKcm
+           13430 _ZN15google_breakpad16MemoryMappedFileC2EPKcm
            13450 _ZN15google_breakpad12SafeReadLinkEPKcPcm
-           13490 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD1Ev
+           13490 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD2Ev
            134a0 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImpl11RequestDumpEPKvm
            136c0 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD0Ev
            136d0 _ZN15google_breakpad21CrashGenerationClient9TryCreateEi
@@ -171,4 +169,3 @@ expression: SymbolsDebug(&symbols)
            14c30 __libc_csu_init
            14ca0 __libc_csu_fini
            14ca4 _fini
-
diff --git a/symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap b/symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap
index d5e9f649..03a3a070 100644
--- a/symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap
+++ b/symbolic-debuginfo/tests/snapshots/test_objects__pdb_symbols.snap
@@ -48,7 +48,7 @@ expression: SymbolsDebug(&symbols)
             2e72 ??0bad_array_new_length@std@@QAE@XZ
             2e8a ??0exception@std@@QAE@ABV01@@Z
             2eb6 ??1bad_alloc@std@@UAE@XZ
-            2ec7 ??_Eexception@std@@UAEPAXI@Z
+            2ec7 ??_Gexception@std@@UAEPAXI@Z
             2ef4 ?__scrt_throw_std_bad_alloc@@YAXXZ
             2f11 ?__scrt_throw_std_bad_array_new_length@@YAXXZ
             2f2e ?what@exception@std@@UBEPBDXZ
@@ -61,11 +61,11 @@ expression: SymbolsDebug(&symbols)
             3166 __onexit
             31a1 _atexit
             3205 ___security_init_cookie
-            3250 __matherr
+            3250 __get_startup_commit_mode
             3253 __get_startup_argv_mode
             3257 __get_startup_file_mode
             325d ?__scrt_initialize_type_info@@YAXXZ
-            3269 ___vcrt_uninitialize
+            3269 __should_initialize_environment
             326c __initialize_default_precision
             328d @_guard_check_icall_nop@4
             328e ___local_stdio_scanf_options
@@ -122,4 +122,3 @@ expression: SymbolsDebug(&symbols)
             37e6 _terminate
             37ec _IsProcessorFeaturePresent@4
             37f2 _memcpy
-
diff --git a/symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap b/symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap
index 3c7b4cbc..610322bf 100644
--- a/symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap
+++ b/symbolic-symcache/tests/snapshots/test_writer__functions_linux.snap
@@ -1,7 +1,6 @@
 ---
 source: symbolic-symcache/tests/test_writer.rs
 expression: FunctionsDebug(&symcache)
-
 ---
             1558 _init
             1900 _ZN15google_breakpad13PageAllocator7FreeAllEv.isra.6
@@ -41,7 +40,7 @@ expression: FunctionsDebug(&symcache)
             3670 _ZN15google_breakpad16ExceptionHandlerC1ERKNS_18MinidumpDescriptorEPFbPvEPFbS3_S4_bES4_bi
             3a10 _ZN15google_breakpad16ExceptionHandler13WriteMinidumpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFbRKNS_18MinidumpDescriptorEPvbESC_
             3cb0 _ZNSt6vectorIPN15google_breakpad16ExceptionHandlerESaIS2_EE19_M_emplace_back_auxIIS2_EEEvDpOT_
-            3da0 _ZN15google_breakpad18MinidumpDescriptorC1ERKS0_
+            3da0 _ZN15google_breakpad18MinidumpDescriptorC2ERKS0_
             3f20 _ZN15google_breakpad18MinidumpDescriptor10UpdatePathEv
             42f0 _ZN15google_breakpad18MinidumpDescriptoraSERKS0_
             43c0 _ZN6logger5writeEPKcm
@@ -49,7 +48,7 @@ expression: FunctionsDebug(&symcache)
             6e10 _ZNSt6vectorIhN15google_breakpad16PageStdAllocatorIhEEE15_M_range_insertIPKhEEvN9__gnu_cxx17__normal_iteratorIPhS3_EET_SB_St20forward_iterator_tag
             71f0 _ZN15google_breakpad11LinuxDumper8LateInitEv
             7200 _ZN15google_breakpad11LinuxDumper17EnumerateMappingsEv
-            7ac0 _ZN15google_breakpad11LinuxDumperC1EiPKc
+            7ac0 _ZN15google_breakpad11LinuxDumperC2EiPKc
             8300 _ZN15google_breakpad11LinuxDumperD2Ev
             8370 _ZN15google_breakpad11LinuxDumperD0Ev
             8390 _ZNK15google_breakpad11LinuxDumper20GetCrashSignalStringEv
@@ -70,14 +69,14 @@ expression: FunctionsDebug(&symcache)
             94a0 _ZNK15google_breakpad17LinuxPtraceDumper12IsPostMortemEv
             94b0 _ZN15google_breakpad17LinuxPtraceDumper15CopyFromProcessEPviPKvm
             9640 _ZN15google_breakpad17LinuxPtraceDumper13ThreadsResumeEv
-            9700 _ZNK15google_breakpad17LinuxPtraceDumper13BuildProcPathEPciPKc
+            9700 _ZNK15google_breakpad17LinuxPtraceDumper13BuildProcPathEPciPKc.localalias.19
             97c0 _ZN15google_breakpad17LinuxPtraceDumper16EnumerateThreadsEv
             9e50 _ZN15google_breakpad17LinuxPtraceDumperC1Ei
             9e80 _ZN15google_breakpad17LinuxPtraceDumper15ReadRegisterSetEPNS_10ThreadInfoEi
             9f70 _ZN15google_breakpad17LinuxPtraceDumper13ReadRegistersEPNS_10ThreadInfoEi
             a050 _ZN15google_breakpad17LinuxPtraceDumper20GetThreadInfoByIndexEmPNS_10ThreadInfoE
             a690 _ZN15google_breakpad17LinuxPtraceDumper14ThreadsSuspendEv
-            a8f0 _ZN15google_breakpad17LinuxPtraceDumperD1Ev
+            a8f0 _ZN15google_breakpad17LinuxPtraceDumperD2Ev
             a910 _ZN15google_breakpad17LinuxPtraceDumperD0Ev
             a930 _ZNSt6vectorIiN15google_breakpad16PageStdAllocatorIiEEE17_M_default_appendEm
             abc0 _ZN12_GLOBAL__N_114MinidumpWriter21WriteThreadListStreamEP14MDRawDirectory.constprop.105
@@ -119,7 +118,7 @@ expression: FunctionsDebug(&symcache)
            11220 _ZN15google_breakpad8ElfClassEPKv
            11230 _ZN15google_breakpad14FindElfSectionEPKvPKcjPS1_Pm
            116a0 _ZN15google_breakpad15FindElfSegmentsEPKvjPNS_15wasteful_vectorINS_10ElfSegmentEEE
-           11990 _ZNSt6vectorIN15google_breakpad10ElfSegmentENS0_16PageStdAllocatorIS1_EEE19_M_emplace_back_auxIIRKS1_EEEvDpOT_
+           11990 _ZNSt6vectorIN15google_breakpad10ElfSegmentENS0_16PageStdAllocatorIS1_EEE19_M_emplace_back_auxIJRKS1_EEEvDpOT_
            11be0 _ZN15google_breakpad6FileIDC2EPKc
            11cc0 _ZN15google_breakpad6FileID29ConvertIdentifierToUUIDStringB5cxx11ERKNS_15wasteful_vectorIhEE
            11e70 _ZN15google_breakpad6FileID25ConvertIdentifierToStringB5cxx11ERKNS_15wasteful_vectorIhEE
@@ -145,11 +144,11 @@ expression: FunctionsDebug(&symcache)
            13160 my_isspace
            13210 _ZN15google_breakpad16MemoryMappedFileC2Ev
            13220 _ZN15google_breakpad16MemoryMappedFile5UnmapEv
-           13270 _ZN15google_breakpad16MemoryMappedFileD2Ev
+           13270 _ZN15google_breakpad16MemoryMappedFileD1Ev
            13280 _ZN15google_breakpad16MemoryMappedFile3MapEPKcm
-           13430 _ZN15google_breakpad16MemoryMappedFileC1EPKcm
+           13430 _ZN15google_breakpad16MemoryMappedFileC2EPKcm
            13450 _ZN15google_breakpad12SafeReadLinkEPKcPcm
-           13490 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD1Ev
+           13490 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD2Ev
            134a0 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImpl11RequestDumpEPKvm
            136c0 _ZN15google_breakpad12_GLOBAL__N_125CrashGenerationClientImplD0Ev
            136d0 _ZN15google_breakpad21CrashGenerationClient9TryCreateEi
@@ -170,4 +169,3 @@ expression: FunctionsDebug(&symcache)
            14c30 __libc_csu_init
            14ca0 __libc_csu_fini
            14ca4 _fini
-