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

Evaluate writing out a MemoryInfoListStream #8

Closed
gabrielesvelto opened this issue Oct 22, 2021 · 12 comments · Fixed by #70
Closed

Evaluate writing out a MemoryInfoListStream #8

gabrielesvelto opened this issue Oct 22, 2021 · 12 comments · Fixed by #70

Comments

@gabrielesvelto
Copy link
Contributor

To improve stack walking heuristics we'd like to validate ambiguous instruction pointers by checking if they fall within an executable reason. On Windows this is already possible because windbg.dll populates the MemoryInfoListStream with the whole state of the process' memory when it snapshots it. On Linux we currently have /proc/self/maps which contains the required information but we'd have to parse it in the stackwalker to yield the same information. Alternatively we might try and populate the MemoryInfoListStream on Linux too in order to be able to use the same code across different platforms.

Populating the stream should be relatively simple, info regarding the header and entries are readily available. The biggset issue is that the AllocationProtect, State, Protect and Type fields are supposed to contain Windows-specific constants. There's two ways to tackle this: either we use those fields to store Linux-specific constants - but that would defeat the purpose of having identical code for all platforms in the stack walker - or we map them to their closest Windows equivalents. Interestingly crashpad does the latter for fuchsia but it does not populate the stream on Linux and macOS.

@luser
Copy link

luser commented Mar 22, 2022

If someone writes a useful parser for maps you could just reuse the same implementation in this crate + the stackwalker. :)

@afranchuk
Copy link
Contributor

@luser Would minidump-common be an okay common place for the maps parser? Or should it be a separate crate entirely?

@luser
Copy link

luser commented Jan 10, 2023

That doesn't quite feel like the right place for it, since currently minidump-common is mostly type definitions.

n.b.: @Gankra implemented stackwalker parsing of this along with a unified interface atop that + MemoryInfoListStream in rust-minidump/rust-minidump#268 . See also rust-minidump/rust-minidump#256

@afranchuk
Copy link
Contributor

afranchuk commented Jan 10, 2023

I agree, I was asking on the off-chance that others didn't agree with my thought so it'd be simpler :)

Thanks for the info, I was aware of the existing impl. I was just going to move it somewhere common and maybe slightly clean up the interface so that it could be used in minidump-writer!

@afranchuk
Copy link
Contributor

Any suggestion on crate name/location? Alternatively, maybe we could contribute to the procfs crate and expose its process::MemoryMap::from_line() implementation?

@gabrielesvelto
Copy link
Contributor Author

Contributing to an external crate sounds like a good idea if the crate is sufficiently widespread and useful. We parse /proc files in a lot of places within Firefox code and the procfs crate sounds like something we'll end up using eventually.

@afranchuk
Copy link
Contributor

afranchuk commented Jan 16, 2023

Yeah, I figured with the other procfs needs we have, it'd be great to take advantage of procfs. My only hesitation is that procfs describes itself as a crate for accessing the current system's procfs mount, so I'd like to confirm with the main developers as to whether they'd be okay with expanding the purpose of the crate (I don't expect anyone would have a problem with it, but it's best to confirm).

@afranchuk
Copy link
Contributor

The procfs team seems open to contribution along these lines, so that is probably the path to follow.

@gabrielesvelto
Copy link
Contributor Author

The procfs team seems open to contribution along these lines, so that is probably the path to follow.

Excellent!

@afranchuk
Copy link
Contributor

I'm currently waiting (patiently, there's no rush) for procfs to tag a new version. Then this can proceed.

@eminence
Copy link

eminence commented Feb 9, 2023

procfs maintainer here 👋 To set some rough expectations, I'm going to try to get a new release of procfs out within a week. Thanks to @afranchuk who did the implementation within procfs

@afranchuk
Copy link
Contributor

@eminence thanks for chiming in with an update! I will set a reminder to check on things in a week.

afranchuk added a commit to afranchuk/minidump-writer that referenced this issue Feb 24, 2023
This makes it easier for consumers to read the minidumps, rather than
needing to parse linux-specific information.

Closes rust-minidump#8.
afranchuk added a commit to afranchuk/minidump-writer that referenced this issue Apr 19, 2023
This makes it easier for consumers to read the minidumps, rather than
needing to parse linux-specific information.

Closes rust-minidump#8.
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.

4 participants