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

Create a createdump static library for single-file dump generation #84864

Merged
merged 7 commits into from
May 10, 2023

Conversation

mikem8361
Copy link
Member

A "createdump_static" lib is now built that is linked into the single-file host and in the future can be linked into a Native AOT host/app going forward. For single-file apps most of the same unhandled exception or crash dump generation code is the same (same env vars, most of all the PAL code is the same) except where createdump executable was execve, a callback invokes (set by the host) the static createdump lib entry point.

File full dumps are generated (which currently are very large under MacOS) but the user can put the DAC side-by-side with their app and the smaller heap or mini dumps can be generated. The SDK could give an option to publish the DAC SXS for a single-file app.

@ghost
Copy link

ghost commented Apr 14, 2023

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

A "createdump_static" lib is now built that is linked into the single-file host and in the future can be linked into a Native AOT host/app going forward. For single-file apps most of the same unhandled exception or crash dump generation code is the same (same env vars, most of all the PAL code is the same) except where createdump executable was execve, a callback invokes (set by the host) the static createdump lib entry point.

File full dumps are generated (which currently are very large under MacOS) but the user can put the DAC side-by-side with their app and the smaller heap or mini dumps can be generated. The SDK could give an option to publish the DAC SXS for a single-file app.

Author: mikem8361
Assignees: mikem8361
Labels:

area-Diagnostics-coreclr

Milestone: -

@mikem8361
Copy link
Member Author

/cc: @LakshanF

@mikem8361
Copy link
Member Author

This change adds only 125KB to the singlefilehost on Linux x64.

@mikem8361 mikem8361 requested a review from VSadov April 17, 2023 23:25
@mikem8361 mikem8361 changed the title Create a createdump static library for single-file and native AOT dump generation Create a createdump static library for single-file dump generation Apr 17, 2023
@mikem8361
Copy link
Member Author

Code review ping.

@tmds
Copy link
Member

tmds commented Apr 24, 2023

@mikem8361 does this add into the single file host the ability to create a dump?
Is there a way to request a running single file host to create a dump of itself?

@mikem8361
Copy link
Member Author

It should end up working like regular app (with createdump/DAC side-by-side), where the Microsoft.Diagnostics.NETCore.Client WriteDump API can generate core dumps of the process. Calling the API on itself isn't well tested but should work I think.

@mikem8361
Copy link
Member Author

@hoyosjs - ping.

src/coreclr/debug/createdump/crashinfo.cpp Outdated Show resolved Hide resolved
src/coreclr/debug/createdump/crashinfo.cpp Outdated Show resolved Hide resolved
src/coreclr/debug/createdump/crashinfo.cpp Show resolved Hide resolved
src/coreclr/debug/createdump/crashinfounix.cpp Outdated Show resolved Hide resolved
src/coreclr/pal/inc/pal.h Show resolved Hide resolved
src/coreclr/pal/src/thread/process.cpp Show resolved Hide resolved
src/coreclr/debug/createdump/createdumpunix.cpp Outdated Show resolved Hide resolved
src/coreclr/debug/createdump/crashinfo.cpp Outdated Show resolved Hide resolved
@tmds
Copy link
Member

tmds commented May 9, 2023

It should end up working like regular app (with createdump/DAC side-by-side), where the Microsoft.Diagnostics.NETCore.Client WriteDump API can generate core dumps of the process. Calling the API on itself isn't well tested but should work I think.

It would be nice if on Unix the dump could be requested by sending a signal (like SIGQUIT) to the process without requiring additional libraries/tooling. Do you think it's worth opening an issue for?

Note that Mono has a thread dump feature via SIGQUIT:

MONO_SIG_HANDLER_FUNC (static, sigquit_signal_handler)
{
mono_threads_request_thread_dump ();

mikem8361 and others added 6 commits May 9, 2023 09:53
…p generation

A "createdump_static" lib is now built that is linked into the single-file host and
in the future can be linked into a Native AOT host/app going forward. For single-file
apps most of the same unhandled exception or crash dump generation code is the same
(same env vars, most of all the PAL code is the same) except where createdump executable
was execve, a callback invokes (set by the host) the static createdump lib entry point.

File full dumps are generated (which currently are very large under MacOS) but the user
can put the DAC side-by-side with their app and the smaller heap or mini dumps can be
generated. The SDK could give an option to publish the DAC SXS for a single-file app.
@mikem8361
Copy link
Member Author

@tmds, enabling SIGQUIT to generate dumps would be a feature requiring an new issue. This is complicated by the fact the runtime handles SIGQUIT to do some cleanup.

@tommcdon
Copy link
Member

Fixed #68676

@ghost ghost locked as resolved and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants