Skip to content

Conversation

@staticfloat
Copy link
Member

Attempting to call MiniDumpWriteDump() to get crash dumps on windows when SIGQUIT is passed.

@DilumAluthge
Copy link
Member

Would it be worth upstreaming this?

@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch from 90dc9b6 to 64105e8 Compare November 14, 2022 19:15
@staticfloat
Copy link
Member Author

I could not, for the life of me, get WER to generate a dump file. I could generate .wer files, and they claimed to have heap dumps attached, but I could never find where they were. I have reverted to using MiniDumpWriteDump(), which is confirmed working. The next question is; do we want to provide a configuration mechanism? I think I have chosen sane defaults for most things, but perhaps we want to be able to customize the directory the dumps are written out to, the kind of dump that is generated, the filename of the dump, etc...?

@staticfloat
Copy link
Member Author

For the record, the way I confirmed this is working was to build Julia with this patched libuv, then run:

p = run(`$(Base.julia_cmd()) -e "sleep(10)"`; wait=false)
sleep(1)
kill(p, Base.SIGQUIT)

The generated .dmp file is then openable in windbg.

One downside to not using WER is that we don't get a unified dump collection mechanism for both SIGQUIT-initiated dumps as well as segfault-initiated dumps. I'd really like to be able to do both, but I just haven't been able to get them to work. :(

@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch 4 times, most recently from 3d01890 to 9d4a5bd Compare November 17, 2022 01:40
staticfloat added a commit to JuliaLang/julia that referenced this pull request Nov 17, 2022
This commit provides two pieces; first, it enables building libuv with
`SIGQUIT` support on Windows (useful for [0]), and second it enables
coredumping when exceptions are hit, after our exception handler has
finished printing out a backtrace.  This is useful for using WER to
create dump files when we segfault, etc...

This commit requires libuv PRs [1] and [2] to properly function.

[0] #45864
[1] JuliaLang/libuv#30
[2] JuliaLang/libuv#31
@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch from db5b0ba to bfb68de Compare November 17, 2022 23:26
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Can you submit this upstream to v1.x also?

@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch 4 times, most recently from e09b534 to 906824c Compare November 29, 2022 22:01
@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch from 906824c to 6fe5518 Compare November 29, 2022 22:38
@staticfloat
Copy link
Member Author

@vtjnash could you review once more, and if it's good, I'll submit to upstream on the v1.x branch.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

basically just commenting on a lot of style nits for libuv-style, but otherwise SGTM

This commit adds the ability to dump core when sending the `SIGQUIT`
signal on Windows.  The change reads in the current registry setting for
local dumps, and attempts to write out to that location before killing
the process.  See [0] for registry and pathing details. This behavior
mimics that of the dumps created by the typical Windows
Error Reporting mechanism.

[0] https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
@staticfloat staticfloat force-pushed the sf/sigquit_on_windows branch from 6fe5518 to 962eb03 Compare November 30, 2022 19:19
@staticfloat
Copy link
Member Author

Upstream patch submitted here: libuv#3840

@staticfloat
Copy link
Member Author

@vtjnash there have been a few times recently where this kind of support would have been helpful. What do we think; should I bump the upstream PR?

@vtjnash
Copy link
Member

vtjnash commented Apr 27, 2023

Yeah, go ahead and bump it and I will try to find time (hah)

@staticfloat
Copy link
Member Author

Now that upstream has been merged, what do we do here?

@vtjnash vtjnash closed this May 23, 2023
@vtjnash vtjnash deleted the sf/sigquit_on_windows branch May 23, 2023 13:57
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