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

Why do we mmap data that is already mmapped? #668

Open
workingjubilee opened this issue Sep 9, 2024 · 5 comments
Open

Why do we mmap data that is already mmapped? #668

workingjubilee opened this issue Sep 9, 2024 · 5 comments
Labels
docs gimli Related to the gimli implementation OS-linux

Comments

@workingjubilee
Copy link
Member

The basic strategy for backtrace symbolication on Linux:

  • We use a combination of dl_iterate_phdr and opening /proc/self/maps to learn about what memory objects are loaded
  • We obtain a bunch of filenames for these memory objects, their dynamic libraries
  • We then later mmap these filenames into memory.
  • ...WAIT A TICK?!?

...why do we map things into memory that we almost certainly know are already in-memory objects?

@workingjubilee workingjubilee added question gimli Related to the gimli implementation OS-linux labels Sep 9, 2024
@workingjubilee
Copy link
Member Author

we probably have to occasionally map something anyways, but it seems we shouldn't need to always? anyway, would be happy to have your insight into this bout of madness, or a correction if I am wrong, @bjorn3 or @philipc

@sudoBash418
Copy link
Contributor

I had the same question when I was working on Android support (sorry if this is an unwanted comment).

AFAICT, it's because the sections containing the symbol tables and DWARF debug info aren't (normally) mapped, so it's needed for symbolication to work properly. But I'm not totally sure.

@philipc
Copy link
Contributor

philipc commented Sep 9, 2024

The debugging information is in parts of the file that aren't mapped into memory. (e.g for ELF, it isn't in a PT_LOAD segment).

@workingjubilee
Copy link
Member Author

Huh, okay!

@workingjubilee
Copy link
Member Author

workingjubilee commented Sep 9, 2024

Thank you for the answer! We should probably write it down somewhere if it regularly puzzles both contributors and maintainers, then we can close this issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs gimli Related to the gimli implementation OS-linux
Projects
None yet
Development

No branches or pull requests

3 participants