@cratis/pi 7.101.0 → 7.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/package/corpus/harnesses/copilot/instructions/github-actions.instructions.md +17 -0
  2. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
  3. package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
  4. package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
  5. package/package/corpus/hooks/README.md +11 -1
  6. package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
  7. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
  8. package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
  9. package/package/corpus/rules/github-actions.md +17 -0
  10. package/package/corpus/rules/profiles.md +10 -1
  11. package/package/corpus/rules/pull-requests.md +2 -0
  12. package/package/corpus/rules/secrets.md +4 -0
  13. package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
  14. package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
  15. package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
  16. package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
  17. package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
  18. package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
  19. package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
  20. package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
  21. package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
  22. package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
  23. package/package/corpus/skills/binlog-generation/LICENSE +23 -0
  24. package/package/corpus/skills/binlog-generation/NOTICE +22 -0
  25. package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
  26. package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
  27. package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
  28. package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
  29. package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
  30. package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
  31. package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
  32. package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
  33. package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
  34. package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
  35. package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
  36. package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
  37. package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
  38. package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
  39. package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
  40. package/package/corpus/skills/cratis-ci-pipeline-performance/LICENSE +2 -0
  41. package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +201 -0
  42. package/package/corpus/skills/cratis-ci-pipeline-performance/references/build-once-and-shard.md +158 -0
  43. package/package/corpus/skills/cratis-ci-pipeline-performance/references/caching.md +86 -0
  44. package/package/corpus/skills/cratis-ci-pipeline-performance/references/flaky-and-hung-jobs.md +70 -0
  45. package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +67 -0
  46. package/package/corpus/skills/cratis-ci-pipeline-performance/references/required-checks-and-path-filters.md +117 -0
  47. package/package/corpus/skills/cratis-ci-pipeline-performance/references/runner-sizing-and-images.md +65 -0
  48. package/package/corpus/skills/cratis-ci-pipeline-performance/references/security-and-pinning.md +73 -0
  49. package/package/corpus/skills/cratis-ci-pipeline-performance/references/sources.md +33 -0
  50. package/package/corpus/skills/cratis-ci-pipeline-performance/references/test-setup-cost.md +82 -0
  51. package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/ci-timings.sh +356 -0
  52. package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1003.json +79 -0
  53. package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1007.json +79 -0
  54. package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1010.json +79 -0
  55. package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/runs.json +102 -0
  56. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/LICENSE +2 -0
  57. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/SKILL.md +244 -0
  58. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/docker-images.md +86 -0
  59. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/dotnet-nuget.md +87 -0
  60. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/go-jvm-python-elixir.md +83 -0
  61. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/npm-yarn.md +78 -0
  62. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/other-environments.md +60 -0
  63. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/worked-examples.md +97 -0
  64. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/cratis-local-packages.sh +778 -0
  65. package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/npm-restore-check.cjs +109 -0
  66. package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
  67. package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
  68. package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
  69. package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
  70. package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
  71. package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
  72. package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
  73. package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
  74. package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
  75. package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
  76. package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
  77. package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
  78. package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
  79. package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
  80. package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
  81. package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
  82. package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
  83. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
  84. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
  85. package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
  86. package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
  87. package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
  88. package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
  89. package/package/corpus/skills/dump-collect/LICENSE +23 -0
  90. package/package/corpus/skills/dump-collect/NOTICE +40 -0
  91. package/package/corpus/skills/dump-collect/SKILL.md +97 -0
  92. package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
  93. package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
  94. package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
  95. package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
  96. package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
  97. package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
  98. package/package/corpus/skills/extension-points/LICENSE +23 -0
  99. package/package/corpus/skills/extension-points/NOTICE +18 -0
  100. package/package/corpus/skills/extension-points/SKILL.md +248 -0
  101. package/package/corpus/skills/filter-syntax/LICENSE +23 -0
  102. package/package/corpus/skills/filter-syntax/NOTICE +17 -0
  103. package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
  104. package/package/corpus/skills/including-generated-files/LICENSE +23 -0
  105. package/package/corpus/skills/including-generated-files/NOTICE +17 -0
  106. package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
  107. package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
  108. package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
  109. package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
  110. package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
  111. package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
  112. package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
  113. package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
  114. package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
  115. package/package/corpus/skills/msbuild/LICENSE +23 -0
  116. package/package/corpus/skills/msbuild/NOTICE +55 -0
  117. package/package/corpus/skills/msbuild/SKILL.md +117 -0
  118. package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
  119. package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
  120. package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
  121. package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
  122. package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
  123. package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
  124. package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
  125. package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
  126. package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
  127. package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
  128. package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
  129. package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
  130. package/package/corpus/skills/orleans/LICENSE +21 -0
  131. package/package/corpus/skills/orleans/NOTICE +64 -0
  132. package/package/corpus/skills/orleans/SKILL.md +140 -0
  133. package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
  134. package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
  135. package/package/corpus/skills/orleans/references/examples.md +66 -0
  136. package/package/corpus/skills/orleans/references/grain-api.md +784 -0
  137. package/package/corpus/skills/orleans/references/grains.md +75 -0
  138. package/package/corpus/skills/orleans/references/hosting.md +71 -0
  139. package/package/corpus/skills/orleans/references/implementation.md +591 -0
  140. package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
  141. package/package/corpus/skills/orleans/references/patterns.md +811 -0
  142. package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
  143. package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
  144. package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
  145. package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
  146. package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
  147. package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
  148. package/package/corpus/skills/platform-detection/LICENSE +23 -0
  149. package/package/corpus/skills/platform-detection/NOTICE +17 -0
  150. package/package/corpus/skills/platform-detection/SKILL.md +230 -0
  151. package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
  152. package/package/corpus/skills/profiling/LICENSE +21 -0
  153. package/package/corpus/skills/profiling/NOTICE +50 -0
  154. package/package/corpus/skills/profiling/SKILL.md +144 -0
  155. package/package/corpus/skills/profiling/references/commands.md +439 -0
  156. package/package/corpus/skills/profiling/references/patterns.md +586 -0
  157. package/package/corpus/skills/profiling/references/profiling.md +190 -0
  158. package/package/corpus/skills/run-tests/LICENSE +23 -0
  159. package/package/corpus/skills/run-tests/NOTICE +19 -0
  160. package/package/corpus/skills/run-tests/SKILL.md +305 -0
  161. package/package/corpus/skills/target-authoring/LICENSE +23 -0
  162. package/package/corpus/skills/target-authoring/NOTICE +17 -0
  163. package/package/corpus/skills/target-authoring/SKILL.md +165 -0
  164. package/package/corpus/skills/vectorization/LICENSE +23 -0
  165. package/package/corpus/skills/vectorization/NOTICE +17 -0
  166. package/package/corpus/skills/vectorization/SKILL.md +189 -0
  167. package/package/profile-catalog.json +87 -1
  168. package/package.json +3 -2
@@ -0,0 +1,412 @@
1
+ # Container Crash Dump Collection
2
+
3
+ ## Contents
4
+
5
+ - Docker
6
+ - Kubernetes
7
+ - Verification
8
+ - Container Considerations
9
+ - Troubleshooting
10
+
11
+ | Need | Tool | Runtime | Requires |
12
+ |------|------|---------|----------|
13
+ | Automatic dump on crash (CoreCLR) | `DOTNET_DbgEnableMiniDump` env vars + `createdump` | CoreCLR | `SYS_PTRACE`, volume mount |
14
+ | Automatic dump on crash (NativeAOT, preferred) | `--ulimit core=-1` + `core_pattern` | NativeAOT | `SYS_PTRACE`, volume mount |
15
+ | Automatic dump on crash (NativeAOT, alternative) | `createdump` + `DOTNET_DbgEnableMiniDump` env vars | NativeAOT | `SYS_PTRACE`, volume mount |
16
+ | On-demand from running container | `dotnet-dump collect` (CoreCLR), `gcore` (NativeAOT) | Per-runtime | `SYS_PTRACE` |
17
+ | Copy dump out of container | `docker cp` / `kubectl cp` | Both | — |
18
+
19
+ Collecting crash dumps from .NET applications running in Docker or Kubernetes containers requires additional configuration for capabilities, storage, and environment variables.
20
+
21
+ > **Note:** The `%e`, `%p`, `%h`, `%t` format specifiers in `DOTNET_DbgMiniDumpName` require .NET 7+. On .NET 6, use a literal path instead.
22
+ >
23
+ > **Dump types** for `DOTNET_DbgMiniDumpType`: 1=Mini, 2=Heap, 3=Triage, 4=Full. Use 4 for maximum diagnostic value. NativeAOT and CoreCLR single-file apps only support full dumps (type 4).
24
+
25
+ ## Docker
26
+
27
+ ### Required Capability
28
+
29
+ The `SYS_PTRACE` capability is required for `dotnet-dump collect`, `createdump`, and `gcore` to attach to processes:
30
+
31
+ ```bash
32
+ # docker run
33
+ docker run --cap-add=SYS_PTRACE -v /tmp/dumps:/dumps myapp
34
+
35
+ # docker compose
36
+ ```
37
+
38
+ ```yaml
39
+ # docker-compose.yml
40
+ services:
41
+ myapp:
42
+ image: myapp
43
+ cap_add:
44
+ - SYS_PTRACE
45
+ volumes:
46
+ - ./dumps:/dumps
47
+ environment:
48
+ # CoreCLR automatic crash dumps
49
+ DOTNET_DbgEnableMiniDump: "1"
50
+ DOTNET_DbgMiniDumpType: "4"
51
+ DOTNET_DbgMiniDumpName: "/dumps/%e_%p_%t.dmp"
52
+ DOTNET_EnableCrashReport: "1"
53
+ ```
54
+
55
+ ### CoreCLR in Docker
56
+
57
+ Add environment variables to enable automatic crash dumps. Either in `docker run`:
58
+
59
+ ```bash
60
+ docker run --cap-add=SYS_PTRACE \
61
+ -v /tmp/dumps:/dumps \
62
+ -e DOTNET_DbgEnableMiniDump=1 \
63
+ -e DOTNET_DbgMiniDumpType=4 \
64
+ -e DOTNET_DbgMiniDumpName="/dumps/%e_%p_%t.dmp" \
65
+ -e DOTNET_EnableCrashReport=1 \
66
+ myapp
67
+ ```
68
+
69
+ Or in the Dockerfile (baked into the image):
70
+
71
+ ```dockerfile
72
+ FROM mcr.microsoft.com/dotnet/aspnet:10.0
73
+
74
+ # Configure crash dump collection
75
+ ENV DOTNET_DbgEnableMiniDump=1
76
+ ENV DOTNET_DbgMiniDumpType=4
77
+ ENV DOTNET_DbgMiniDumpName="/dumps/%e_%p_%t.dmp"
78
+ ENV DOTNET_EnableCrashReport=1
79
+
80
+ # Create dump directory
81
+ RUN mkdir -p /dumps
82
+
83
+ COPY --from=build /app .
84
+ ENTRYPOINT ["dotnet", "myapp.dll"]
85
+ ```
86
+
87
+ ### NativeAOT in Docker
88
+
89
+ Since NativeAOT only supports full dumps, OS-level core dump mechanisms are the simplest approach — no extra tooling to copy or configure.
90
+
91
+ **Preferred: OS-level core dumps:**
92
+
93
+ ```bash
94
+ docker run --cap-add=SYS_PTRACE \
95
+ --ulimit core=-1 \
96
+ -v /tmp/dumps:/dumps \
97
+ myapp
98
+ ```
99
+
100
+ **Note:** You may also need to set the core pattern inside the container. If the host's `core_pattern` pipes to `systemd-coredump`, container core dumps may not be written where expected. Override at runtime:
101
+
102
+ ```bash
103
+ docker run --cap-add=SYS_PTRACE \
104
+ --ulimit core=-1 \
105
+ # Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
106
+ --privileged \
107
+ -v /tmp/dumps:/dumps \
108
+ myapp sh -c 'echo "/dumps/core.%e.%p" > /proc/sys/kernel/core_pattern && exec ./myapp'
109
+ ```
110
+
111
+ > **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
112
+ ⚠️ `--privileged` is needed to write to `/proc/sys/kernel/core_pattern`. For production, prefer configuring the core pattern on the host instead.
113
+
114
+ **Alternative: Use createdump with DOTNET_DbgEnableMiniDump** (same env vars as CoreCLR). Copy `createdump` next to the app binary in the image:
115
+
116
+ ```dockerfile
117
+ FROM mcr.microsoft.com/dotnet/runtime-deps:10.0
118
+
119
+ # Copy createdump from the runtime (match your .NET version)
120
+ COPY --from=mcr.microsoft.com/dotnet/runtime:10.0 /usr/share/dotnet/shared/Microsoft.NETCore.App/ /tmp/runtime/
121
+ RUN find /tmp/runtime -name createdump -exec cp {} /app/ \; && rm -rf /tmp/runtime/
122
+
123
+ # Configure crash dump collection
124
+ ENV DOTNET_DbgEnableMiniDump=1
125
+ ENV DOTNET_DbgMiniDumpType=4
126
+ ENV DOTNET_DbgMiniDumpName="/dumps/%e_%p_%t.dmp"
127
+
128
+ RUN mkdir -p /dumps
129
+
130
+ COPY --from=build /app .
131
+ ENTRYPOINT ["./myapp"]
132
+ ```
133
+
134
+ For .NET 11+, use `DOTNET_DbgCreateDumpToolPath` instead of co-locating:
135
+
136
+ ```dockerfile
137
+ ENV DOTNET_DbgCreateDumpToolPath=/opt/tools/createdump
138
+ ENV DOTNET_DbgEnableMiniDump=1
139
+ ENV DOTNET_DbgMiniDumpType=4
140
+ ENV DOTNET_DbgMiniDumpName="/dumps/%e_%p_%t.dmp"
141
+ ```
142
+
143
+ Run with:
144
+ ```bash
145
+ docker run --cap-add=SYS_PTRACE \
146
+ -v /tmp/dumps:/dumps \
147
+ myapp
148
+ ```
149
+
150
+ ### On-Demand Collection in Docker
151
+
152
+ ```bash
153
+ # Find the container and process
154
+ docker exec <container> dotnet-dump ps # CoreCLR
155
+ docker exec <container> sh -c 'ps aux | grep myapp' # NativeAOT
156
+
157
+ # Collect dump (CoreCLR)
158
+ docker exec <container> dotnet-dump collect -p <pid> --output /dumps/myapp.dmp
159
+
160
+ # Collect dump (NativeAOT — requires gdb/gcore in the image)
161
+ docker exec <container> gcore -o /dumps/myapp <pid>
162
+
163
+ # Copy dump out of container (alternative to volume mount)
164
+ docker cp <container>:/dumps/myapp.dmp ./myapp.dmp
165
+ ```
166
+
167
+ ## Kubernetes
168
+
169
+ ### Pod Spec for CoreCLR
170
+
171
+ ```yaml
172
+ apiVersion: v1
173
+ kind: Pod
174
+ metadata:
175
+ name: myapp
176
+ spec:
177
+ containers:
178
+ - name: myapp
179
+ image: myapp:latest
180
+ securityContext:
181
+ capabilities:
182
+ add: ["SYS_PTRACE"]
183
+ env:
184
+ - name: DOTNET_DbgEnableMiniDump
185
+ value: "1"
186
+ - name: DOTNET_DbgMiniDumpType
187
+ value: "4"
188
+ - name: DOTNET_DbgMiniDumpName
189
+ value: "/dumps/%e_%p_%t.dmp"
190
+ - name: DOTNET_EnableCrashReport
191
+ value: "1"
192
+ volumeMounts:
193
+ - name: dumps
194
+ mountPath: /dumps
195
+ volumes:
196
+ - name: dumps
197
+ emptyDir:
198
+ sizeLimit: 5Gi # Adjust based on expected dump size
199
+ ```
200
+
201
+ ### Pod Spec for NativeAOT
202
+
203
+ **Preferred: OS-level core dumps** (simplest — no extra tooling needed):
204
+
205
+ ```yaml
206
+ apiVersion: v1
207
+ kind: Pod
208
+ metadata:
209
+ name: myapp-nativeaot
210
+ spec:
211
+ containers:
212
+ - name: myapp
213
+ image: myapp:latest
214
+ securityContext:
215
+ capabilities:
216
+ add: ["SYS_PTRACE"]
217
+ command: ["/bin/sh", "-c"]
218
+ args: ["ulimit -c unlimited && exec ./myapp"]
219
+ volumeMounts:
220
+ - name: dumps
221
+ mountPath: /dumps
222
+ volumes:
223
+ - name: dumps
224
+ emptyDir:
225
+ sizeLimit: 10Gi
226
+ ```
227
+
228
+ **Alternative: Use createdump** (bundled in the image next to the app, or via `DOTNET_DbgCreateDumpToolPath` on .NET 11+):
229
+
230
+ ```yaml
231
+ apiVersion: v1
232
+ kind: Pod
233
+ metadata:
234
+ name: myapp-nativeaot
235
+ spec:
236
+ containers:
237
+ - name: myapp
238
+ image: myapp:latest
239
+ securityContext:
240
+ capabilities:
241
+ add: ["SYS_PTRACE"]
242
+ env:
243
+ - name: DOTNET_DbgEnableMiniDump
244
+ value: "1"
245
+ - name: DOTNET_DbgMiniDumpType
246
+ value: "4"
247
+ - name: DOTNET_DbgMiniDumpName
248
+ value: "/dumps/%e_%p_%t.dmp"
249
+ # .NET 11+ only — uncomment if createdump is not next to the binary:
250
+ # - name: DOTNET_DbgCreateDumpToolPath
251
+ # value: "/opt/tools/createdump"
252
+ volumeMounts:
253
+ - name: dumps
254
+ mountPath: /dumps
255
+ volumes:
256
+ - name: dumps
257
+ emptyDir:
258
+ sizeLimit: 5Gi
259
+ ```
260
+
261
+ ### Using a Persistent Volume for Dumps
262
+
263
+ For production, use a PersistentVolumeClaim instead of `emptyDir` so dumps survive pod restarts:
264
+
265
+ ```yaml
266
+ volumes:
267
+ - name: dumps
268
+ persistentVolumeClaim:
269
+ claimName: dump-storage
270
+
271
+ ---
272
+ apiVersion: v1
273
+ kind: PersistentVolumeClaim
274
+ metadata:
275
+ name: dump-storage
276
+ spec:
277
+ accessModes: ["ReadWriteOnce"]
278
+ resources:
279
+ requests:
280
+ storage: 20Gi
281
+ ```
282
+
283
+ ### On-Demand Collection in Kubernetes
284
+
285
+ ```bash
286
+ # Find the pod and process
287
+ kubectl exec <pod> -- dotnet-dump ps # CoreCLR
288
+ kubectl exec <pod> -- sh -c 'ps aux | grep myapp' # NativeAOT
289
+
290
+ # Collect dump
291
+ kubectl exec <pod> -- dotnet-dump collect -p <pid> --output /dumps/myapp.dmp
292
+
293
+ # Copy dump out of the pod
294
+ kubectl cp <pod>:/dumps/myapp.dmp ./myapp.dmp
295
+ ```
296
+
297
+ ### Deployment-Level Configuration
298
+
299
+ To apply dump collection to all pods in a Deployment:
300
+
301
+ ```yaml
302
+ apiVersion: apps/v1
303
+ kind: Deployment
304
+ metadata:
305
+ name: myapp
306
+ spec:
307
+ template:
308
+ spec:
309
+ containers:
310
+ - name: myapp
311
+ image: myapp:latest
312
+ securityContext:
313
+ capabilities:
314
+ add: ["SYS_PTRACE"]
315
+ env:
316
+ - name: DOTNET_DbgEnableMiniDump
317
+ value: "1"
318
+ - name: DOTNET_DbgMiniDumpType
319
+ value: "4"
320
+ - name: DOTNET_DbgMiniDumpName
321
+ value: "/dumps/%e_%p_%t.dmp"
322
+ volumeMounts:
323
+ - name: dumps
324
+ mountPath: /dumps
325
+ volumes:
326
+ - name: dumps
327
+ emptyDir:
328
+ sizeLimit: 5Gi
329
+ ```
330
+
331
+ ## Verification
332
+
333
+ **Docker:**
334
+
335
+ ```bash
336
+ # Check env vars inside the container
337
+ docker exec <container> env | grep DOTNET_Dbg
338
+
339
+ # Check dump directory exists and is writable
340
+ docker exec <container> ls -la /dumps/
341
+
342
+ # Check createdump is available (NativeAOT)
343
+ docker exec <container> ls -la /app/createdump 2>/dev/null || echo "createdump not co-located"
344
+
345
+ # After a crash, check for dump files
346
+ docker exec <container> sh -c 'ls -la /dumps/*.dmp' 2>/dev/null
347
+ # Or from the host via volume mount:
348
+ ls -la /tmp/dumps/*.dmp
349
+ ```
350
+
351
+ **Kubernetes:**
352
+
353
+ ```bash
354
+ # Check env vars
355
+ kubectl exec <pod> -- env | grep DOTNET_Dbg
356
+
357
+ # Check dump directory
358
+ kubectl exec <pod> -- ls -la /dumps/
359
+
360
+ # After a crash, list dumps
361
+ kubectl exec <pod> -- sh -c 'ls -la /dumps/*.dmp' 2>/dev/null
362
+
363
+ # Copy dumps out for inspection
364
+ kubectl cp <pod>:/dumps/ ./dumps/
365
+ ```
366
+
367
+ ## Container Considerations
368
+
369
+ ### Non-Root Users
370
+
371
+ If your container runs as a non-root user, ensure the dump directory is writable:
372
+
373
+ ```dockerfile
374
+ RUN mkdir -p /dumps && chown -R app:app /dumps
375
+ USER app
376
+ ```
377
+
378
+ For Kubernetes, use an init container or `securityContext.fsGroup`:
379
+
380
+ ```yaml
381
+ securityContext:
382
+ runAsNonRoot: true
383
+ runAsUser: 1000
384
+ fsGroup: 1000 # matches the app user's group
385
+ ```
386
+
387
+ When using `runAsNonRoot: true`, the dump directory must be writable by the non-root user. Use `fsGroup` to grant group write access to the mounted volume, or set permissions in the Dockerfile.
388
+
389
+ ### Alpine / musl-Based Images
390
+
391
+ `createdump`, `dotnet-dump`, and CoreCLR automatic crash dumps all work on the supported .NET Alpine images. No special configuration is needed beyond the standard setup described above.
392
+
393
+ ### SELinux / AppArmor
394
+
395
+ On hosts with SELinux or AppArmor, `SYS_PTRACE` alone may not be sufficient:
396
+
397
+ - **SELinux**: The container may need `--security-opt label=disable` or an appropriate SELinux policy allowing ptrace
398
+ - **AppArmor**: Use `--security-opt apparmor=unconfined` for debugging, or create a custom profile that allows ptrace
399
+
400
+ ⚠️ Disabling security modules is acceptable for debugging but should not be used in production.
401
+
402
+ ## Troubleshooting
403
+
404
+ > **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
405
+
406
+ | Problem | Cause | Fix |
407
+ |---------|-------|-----|
408
+ | `dotnet-dump collect` fails with "permission denied" | Missing `SYS_PTRACE` capability | Add `SYS_PTRACE` to securityContext / cap_add |
409
+ | Dump file not created on crash | Dump directory doesn't exist | Ensure `/dumps` directory exists in the image or init container |
410
+ | Core dump goes to wrong location | Host `core_pattern` overrides container | Configure `core_pattern` on the host or use `--privileged` |
411
+ | Dump file is 0 bytes | Disk space exhausted | Increase `emptyDir.sizeLimit` or PVC size |
412
+ | `createdump` not found in container | Minimal runtime image | For CoreCLR: use `dotnet-dump collect` instead. For NativeAOT: copy `createdump` from the runtime image (see NativeAOT in Docker section) or use the full SDK image |
@@ -0,0 +1,108 @@
1
+ # CoreCLR Crash Dump Collection
2
+
3
+ ## Contents
4
+
5
+ - Automatic Crash Dumps (All Platforms)
6
+ - On-Demand Dump Collection
7
+ - Verification
8
+
9
+ | Need | Tool | Platforms |
10
+ |------|------|-----------|
11
+ | Automatic dump on crash | `DOTNET_DbgEnableMiniDump` env vars | All |
12
+ | On-demand from running process | `dotnet-dump collect` (recommended) | All |
13
+ | On-demand via OS tools | `gcore` (Linux) | Linux |
14
+
15
+ ## Automatic Crash Dumps (All Platforms)
16
+
17
+ CoreCLR has built-in crash dump support via environment variables. Set these before launching the app:
18
+
19
+ ```bash
20
+ # Enable crash dumps (required)
21
+ export DOTNET_DbgEnableMiniDump=1
22
+
23
+ # Dump type: 1=Mini, 2=Heap, 3=Triage, 4=Full
24
+ # Use 4 (Full) for maximum diagnostic value, 1 (Mini) for smaller files
25
+ export DOTNET_DbgMiniDumpType=4
26
+
27
+ # Output path — supports format specifiers (.NET 7+):
28
+ # %p = PID, %e = process name, %h = hostname, %t = timestamp
29
+ export DOTNET_DbgMiniDumpName=/tmp/dumps/%e_%p_%t.dmp
30
+
31
+ # Optional: generate a JSON crash report alongside the dump
32
+ export DOTNET_EnableCrashReport=1
33
+
34
+ # Optional: diagnostics if dump creation itself fails
35
+ export DOTNET_CreateDumpDiagnostics=1
36
+ ```
37
+
38
+ **On Windows (PowerShell):**
39
+ ```powershell
40
+ $env:DOTNET_DbgEnableMiniDump = "1"
41
+ $env:DOTNET_DbgMiniDumpType = "4"
42
+ $env:DOTNET_DbgMiniDumpName = "C:\dumps\%e_%p_%t.dmp"
43
+ $env:DOTNET_EnableCrashReport = "1"
44
+ ```
45
+
46
+ ### Dump Type Reference
47
+
48
+ | Value | Type | Size | Use When |
49
+ |-------|------|------|----------|
50
+ | 1 | Mini | Small | Stack traces only, minimal disk usage |
51
+ | 2 | Heap | Large | Need to inspect managed heap objects |
52
+ | 3 | Triage | Small | The same as mini, but redacts known file paths |
53
+ | 4 | Full | Largest | Full process memory, maximum diagnostic value |
54
+
55
+ ### Important Notes
56
+
57
+ - The dump output directory must exist before the crash — CoreCLR will not create it.
58
+ - Format specifiers (`%p`, `%e`, `%h`, `%t`) require .NET 7+. On .NET 6, use a literal path.
59
+ - The legacy `COMPlus_` prefix (e.g., `COMPlus_DbgEnableMiniDump`) still works but `DOTNET_` is preferred for .NET 6+.
60
+ - Single-file published apps only support full dumps (`DOTNET_DbgMiniDumpType=4`), same as NativeAOT.
61
+
62
+ ## On-Demand Dump Collection
63
+
64
+ ### Using dotnet-dump (Recommended)
65
+
66
+ ```bash
67
+ # Install (one-time, requires .NET SDK)
68
+ # Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
69
+ dotnet tool install -g dotnet-dump
70
+
71
+ # Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
72
+ # Without the SDK, download directly from https://github.com/dotnet/diagnostics/releases
73
+
74
+ # List .NET processes
75
+ dotnet-dump ps
76
+
77
+ # Collect a dump from a running process
78
+ dotnet-dump collect -p <pid>
79
+
80
+ # Specify dump type and output path
81
+ dotnet-dump collect -p <pid> --type Full --output /tmp/dumps/myapp.dmp
82
+ ```
83
+
84
+ **Supported `--type` values:** `Full`, `Heap`, `Mini`
85
+
86
+ ### Using gcore (Linux Only)
87
+
88
+ ```bash
89
+ # Requires gdb installed
90
+ gcore -o /tmp/dumps/myapp <pid>
91
+ # Produces /tmp/dumps/myapp.<pid>
92
+ ```
93
+
94
+ ## Verification
95
+
96
+ After enabling crash dumps, verify the configuration:
97
+
98
+ ```bash
99
+ # Check env vars are set
100
+ env | grep DOTNET_Dbg
101
+ env | grep DOTNET_EnableCrashReport
102
+
103
+ # Ensure dump directory exists and is writable
104
+ ls -la /tmp/dumps/
105
+
106
+ # After a crash, check for dump files
107
+ ls -la /tmp/dumps/*.dmp
108
+ ```