Skip to content

Adding proper exiting and cleanup logic for singlefile createdump #117286

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rcj1
Copy link
Contributor

@rcj1 rcj1 commented Jul 3, 2025

Closes dotnet/diagnostics#5245

This PR adds the proper exiting and cleanup logic for singlefile createdump. The exit() in the createdump child process ensures that the proper error messages are visible on the console and that said child processes do not accumulate in the system. This also necessitates a way to determine whether we are in the child process, before running destructors that unlink the diagnostics server socket (inherited from the parent and still needed by the parent). The code that would have ultimately been called on exit() is available here:

ds_ipc_close (port->ipc, is_shutdown, callback);

This logic is handled by g_ContinueCleanup which is set to true by default and set to false if we are in the child.

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 18:33
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 3, 2025
@rcj1 rcj1 requested a review from hoyosjs July 3, 2025 18:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that the singlefile createdump child process exits cleanly without disturbing the parent’s diagnostic server socket.

  • Introduces g_ContinueCleanup to skip cleanup in the forked child
  • Guards PROCNotifyProcessShutdown with the new flag
  • In the child branch of PROCCreateCrashDump, captures the callback’s return value, disables cleanup, and calls exit(...)
Comments suppressed due to low confidence (2)

src/coreclr/pal/src/thread/process.cpp:2266

  • The new child‐process exit and cleanup gating behavior aren’t covered by existing tests. It would be valuable to add or update tests that fork and verify the child exits and the parent cleanup still runs.
            exit(callbackResult);

src/coreclr/pal/src/thread/process.cpp:218

  • The global flag g_ContinueCleanup is accessed in both the normal and signal‐shutdown paths; consider making it volatile or using an atomic type to ensure thread‐safe reads and writes.
bool g_ContinueCleanup = true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotnet-dump collect silently fails if the user running the process does not have permission to write
1 participant