Commit c507305
Defer DOTNET_DbgEnableMiniDump error message until dump creation (#122986)
# Description
The error message "DOTNET_DbgEnableMiniDump is set and the createdump
binary does not exist" was being printed during runtime initialization,
even when no dump would be created. This prevented setting the
environment variable in crossgen scenarios where createdump isn't
shipped.
**Changes:**
- Removed file existence check (`stat()`) during initialization in
`PalCreateDumpInitialize()` to avoid unnecessary file system operations
- Detect missing createdump binary when `execv()` returns `ENOENT` error
in `CreateCrashDump()`
- Print specific error message only when actually attempting to execute
the missing binary
- Error now appears only when dump creation is attempted (either via
crash or explicit API call), not during initialization
# Customer Impact
Customers using crossgen tooling cannot set `DOTNET_DbgEnableMiniDump`
without spurious error messages during builds. This affects debugging
workflows in environments where dump generation is conditionally needed.
# Regression
No. This is an existing issue with the environment variable handling.
# Testing
Built NativeAOT runtime successfully with changes. Verified:
- No initialization errors when createdump missing
- Error message appears when attempting to execute missing createdump
binary
- No change in behavior when createdump exists
- No unnecessary file system checks during initialization
# Risk
Low. Changes eliminate unnecessary file system checks during
initialization and defer error detection to the point where the binary
is actually needed (execv call). The actual dump creation logic and all
success paths remain unchanged. Error messages now appear only when
dumps are actually attempted, preventing spurious warnings during
initialization.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Hard to use `DOTNET_DbgEnableMiniDump` when crossgen is
involved somewhere in the build</issue_title>
>
<issue_description>https://github.com/dotnet/runtime/blob/242f7b23752599f22157268de41fee91cb97ef6c/src/coreclr/nativeaot/Runtime/unix/PalCreateDump.cpp#L627
>
> This line runs ahead-of-time in the non failure case when setting the
`DOTNET_DbgEnableMiniDump ` env var. The Crossgen2 pack currently
doesn't ship createdump and therefore this line always raises an error
when the env var is set.
>
> This isn't great as it means that you can't set
`DOTNET_DbgEnableMiniDump` if crossgen is involved. I.e. when building
the runtime repo.
>
> cc @hoyosjs </issue_description>
>
> <agent_instructions>Instead of having fprintf(stderr,
"DOTNET_DbgEnableMiniDump is set and the createdump binary does not
exist: %s\n", program); in PalCreateDumpInitialize in PalCreateDump.cpp,
we should instead output it in BuildCreateDumpCommandLine inside the if
(g_szCreateDumpPath == nullptr || g_ppidarg == nullptr)
block</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #122982
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: steveisok <[email protected]>
Co-authored-by: noahfalk <[email protected]>1 parent 53653bd commit c507305
1 file changed
+8
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
275 | 282 | | |
276 | 283 | | |
277 | 284 | | |
| |||
621 | 628 | | |
622 | 629 | | |
623 | 630 | | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| |||
0 commit comments