@cratis/pi 7.102.0 → 7.103.1
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.
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
- package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
- package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
- package/package/corpus/hooks/README.md +11 -1
- package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
- package/package/corpus/rules/profiles.md +10 -1
- package/package/corpus/rules/pull-requests.md +2 -0
- package/package/corpus/rules/secrets.md +4 -0
- package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
- package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
- package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
- package/package/corpus/skills/binlog-generation/LICENSE +23 -0
- package/package/corpus/skills/binlog-generation/NOTICE +22 -0
- package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
- package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
- package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
- package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
- package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
- package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
- package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
- package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
- package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
- package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
- package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
- package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
- package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
- package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
- package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +26 -1
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +17 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +17 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +8 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet-example.md +1 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/fast-path.md +7 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +1 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +40 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/response-continuations.md +1 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/worked-flow.md +1 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +3 -2
- package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
- package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
- package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
- package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
- package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
- package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
- package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
- package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
- package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
- package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
- package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
- package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
- package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
- package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
- package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
- package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
- package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
- package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
- package/package/corpus/skills/dump-collect/LICENSE +23 -0
- package/package/corpus/skills/dump-collect/NOTICE +40 -0
- package/package/corpus/skills/dump-collect/SKILL.md +97 -0
- package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
- package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
- package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
- package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
- package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
- package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
- package/package/corpus/skills/extension-points/LICENSE +23 -0
- package/package/corpus/skills/extension-points/NOTICE +18 -0
- package/package/corpus/skills/extension-points/SKILL.md +248 -0
- package/package/corpus/skills/filter-syntax/LICENSE +23 -0
- package/package/corpus/skills/filter-syntax/NOTICE +17 -0
- package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
- package/package/corpus/skills/including-generated-files/LICENSE +23 -0
- package/package/corpus/skills/including-generated-files/NOTICE +17 -0
- package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
- package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
- package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
- package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
- package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
- package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
- package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
- package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
- package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
- package/package/corpus/skills/msbuild/LICENSE +23 -0
- package/package/corpus/skills/msbuild/NOTICE +55 -0
- package/package/corpus/skills/msbuild/SKILL.md +117 -0
- package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
- package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
- package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
- package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
- package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
- package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
- package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
- package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
- package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
- package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
- package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
- package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
- package/package/corpus/skills/orleans/LICENSE +21 -0
- package/package/corpus/skills/orleans/NOTICE +64 -0
- package/package/corpus/skills/orleans/SKILL.md +140 -0
- package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
- package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
- package/package/corpus/skills/orleans/references/examples.md +66 -0
- package/package/corpus/skills/orleans/references/grain-api.md +784 -0
- package/package/corpus/skills/orleans/references/grains.md +75 -0
- package/package/corpus/skills/orleans/references/hosting.md +71 -0
- package/package/corpus/skills/orleans/references/implementation.md +591 -0
- package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
- package/package/corpus/skills/orleans/references/patterns.md +811 -0
- package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
- package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
- package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
- package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
- package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
- package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
- package/package/corpus/skills/platform-detection/LICENSE +23 -0
- package/package/corpus/skills/platform-detection/NOTICE +17 -0
- package/package/corpus/skills/platform-detection/SKILL.md +230 -0
- package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
- package/package/corpus/skills/profiling/LICENSE +21 -0
- package/package/corpus/skills/profiling/NOTICE +50 -0
- package/package/corpus/skills/profiling/SKILL.md +144 -0
- package/package/corpus/skills/profiling/references/commands.md +439 -0
- package/package/corpus/skills/profiling/references/patterns.md +586 -0
- package/package/corpus/skills/profiling/references/profiling.md +190 -0
- package/package/corpus/skills/run-tests/LICENSE +23 -0
- package/package/corpus/skills/run-tests/NOTICE +19 -0
- package/package/corpus/skills/run-tests/SKILL.md +305 -0
- package/package/corpus/skills/target-authoring/LICENSE +23 -0
- package/package/corpus/skills/target-authoring/NOTICE +17 -0
- package/package/corpus/skills/target-authoring/SKILL.md +165 -0
- package/package/corpus/skills/vectorization/LICENSE +23 -0
- package/package/corpus/skills/vectorization/NOTICE +17 -0
- package/package/corpus/skills/vectorization/SKILL.md +189 -0
- package/package/profile-catalog.json +85 -1
- package/package.json +1 -1
|
@@ -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
|
+
```
|