Skip to content

Add initial Windows implementation#19

Merged
Gankra merged 37 commits intorust-minidump:mainfrom
EmbarkStudios:main
Apr 26, 2022
Merged

Add initial Windows implementation#19
Gankra merged 37 commits intorust-minidump:mainfrom
EmbarkStudios:main

Conversation

@Jake-Shadle
Copy link
Copy Markdown
Collaborator

@Jake-Shadle Jake-Shadle commented Mar 29, 2022

  • Add first pass at windows minidump writer
  • Remove assertion info, it is functionally useless
  • Always open process handle internally
  • Use published crash-context

See EmbarkStudios/crash-handling#9 where it is being used.

@Jake-Shadle
Copy link
Copy Markdown
Collaborator Author

Oops, looks like minidump has changed, I'll fix this tomorrow.

@Jake-Shadle
Copy link
Copy Markdown
Collaborator Author

Oh, and add windows tests as well.

@Jake-Shadle
Copy link
Copy Markdown
Collaborator Author

Jake-Shadle commented Mar 30, 2022

Hmm, so I got the in process dump test working easily, but the external one doesn't work due to some problems internally in MiniDumpWriteDump failing to do ReadProcessMemory for some reason. My assumption is that the child process is maybe exiting early, or at least some variable is falling out of scope somehow, but couldn't figure it out. I'm not super concerned with that as my own tests only use external process dumping and they have worked flawlessly https://github.com/EmbarkStudios/crash-handling/tree/main/minidumper-test

@marti4d
Copy link
Copy Markdown
Collaborator

marti4d commented Apr 20, 2022

Hi @Jake-Shadle. Aria asked me to help do a first-pass review of this, as she is currently very busy on another project. I should have some review comments ready for you soon. Sorry about the wait!

@Jake-Shadle
Copy link
Copy Markdown
Collaborator Author

No worries, thanks!

Copy link
Copy Markdown
Collaborator

@marti4d marti4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice, and it's great that you also wrote tests for it! Thanks a bunch for this, and sorry about the long wait for this review.

Most of my comments below are just minor suggestions and nitpicks -- You can probably ignore them if you don't agree; however, I have 3 concerns:

  1. I think there may be reversed logic in windows/minidump_writer.rs#230
  2. You mention that let mut user_streams = Vec::with_capacity(2); may interfere with in-process dumping. If that's the case, does it make sense that we are providing a current_process() function to allow a behavior that won't work properly?
  3. I saw your comments above, and for the record I also see the failure of the dump_external_process test with the same code. Does it make sense to disable that test until it's fixed?

WRT to the failing test, I've done a bit of investigation and it looks like if you pass std::ptr::null() in place of exc_info during the call to MiniDumpWriteDump, it works... So the issue seems to be stemming from that.

It's getting a bit late for me right now, but tomorrow I will continue investigating --It looks like it should work, so it's fairly intriguing that it doesn't.

Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread tests/windows_minidump_writer.rs
Copy link
Copy Markdown
Collaborator

@marti4d marti4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the feedback so quickly! I have a few more optional suggestions, but as far as I'm concerned this code is ready to check in once we figure out why that test is broken.

I'm investigating that right now, so hopefully we can get that resolved quickly and merge this change 😀

Comment thread tests/windows_minidump_writer.rs
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/windows/minidump_writer.rs Outdated
Comment thread src/bin/test.rs Outdated
marti4d added 2 commits April 22, 2022 12:56
This fixes the "ReadProcessMemory" failure in the MiniDumpWriteDump() call.

The root issue is that Cargo is being used to run the test executable, and
so `child.id()` returns Cargo's PID and not the PID of the test.exe
executable.

This has the test.exe pass its actual PID back to the parent so it can
be debugged properly.

Note that this doesn't fully fix the test -- There is still another error
@marti4d
Copy link
Copy Markdown
Collaborator

marti4d commented Apr 22, 2022

@Jake-Shadle I left a PR to fix the broken test on your Embark Studios fork. Once you merge that in, I think this PR should be good-to-go! 😀

Copy link
Copy Markdown
Collaborator

@marti4d marti4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gankra Hey Aria! IMO this change is good-to-go and I'm confident to merge it in at anytime.

Thanks a lot, @Jake-Shadle. This is great :)

Comment thread src/bin/test.rs Outdated
@Gankra Gankra merged commit 2474741 into rust-minidump:main Apr 26, 2022
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 this pull request may close these issues.

3 participants