Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System libraries (e.g libSystem.B.dylib) are missing from the modules list on macOS #41

Closed
sfackler opened this issue Jul 13, 2022 · 1 comment · Fixed by #42
Closed

Comments

@sfackler
Copy link
Contributor

sfackler commented Jul 13, 2022

It looks like system libraries are not present in minidumps I generate on macOS. As test case, I ran the diskwriter example from the minidumper crate, and then examined its output with minidump-stackwalk --dump:

...

MinidumpModuleList
  module_count = 1

module[0]
MINIDUMP_MODULE
  base_of_image                   = 0x100924000
  size_of_image                   = 0xd8000
  checksum                        = 0x0
  time_date_stamp                 = 0x0 1970-01-01T00:00:00Z
  module_name_rva                 = 0x244e
  version_info.signature          = 0x0
  version_info.struct_version     = 0x0
  version_info.file_version       = 0x0:0x0
  version_info.product_version    = 0x0:0x0
  version_info.file_flags_mask    = 0x0
  version_info.file_flags         = 0x0
  version_info.file_os            = 0x0
  version_info.file_type          = 0x0
  version_info.file_subtype       = 0x0
  version_info.file_date          = 0x0:0x0
  cv_record.data_size             = 34
  cv_record.rva                   = 0x24d8
  misc_record.data_size           = 0
  misc_record.rva                 = 0x0
  (code_file)                     = "/Users/sfackler/code/crash-handling/target/debug/examples/diskwrite"
  (code_identifier)               = "fddd3fdfe88a3bc9aab0a7837ce1e896"
  (cv_record).cv_signature        = 0x53445352
  (cv_record).signature           = fddd3fdf-e88a-3bc9-aab0-a7837ce1e896
  (cv_record).age                 = 0
  (cv_record).pdb_file_name       = "diskwrite"
  (misc_record)                   = (null)
  (debug_file)                    = "diskwrite"
  (debug_identifier)              = "fddd3fdf-e88a-3bc9-aab0-a7837ce1e896"
  (version)                       = ""

...

However, otool -L shows several other libraries linked to it, which I would expect to be present:

../../crash-handling/target/debug/examples/diskwrite:
        /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
        /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

Concretely, this prevents stack walking from handling frames inside of libSystem properly.

This may be related to some linker shenanigans starting on Big Sur:

New in macOS Big Sur 11.0.1, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)

https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes

@Jake-Shadle
Copy link
Collaborator

Thanks for the report! I thought maybe I had messed up handling those shenanigans as well which is why I added a test https://github.com/rust-minidump/minidump-writer/blob/main/tests/task_dumper.rs to validate against otool output, it turns out this was instead a mistake in the retrieval of the module's file path from the process memory, working on a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants