Repository navigation
Description
Description
We're a MSFT internal team using dotnet on linux in AKS. We're onboarded to Azure Watson and some of our teams are looking to migrate to distroless containers for our applications. We have noticed that collecting core dumps on crashes does not work correctly unless we start dotnet inside a shell script, aka this doesn't generate the correct core dumps:
ENTRYPOINT ["dotnet", "MyApp.dll"]however this does:
ENTRYPOINT ["/bin/bash", "start.sh"]where start.sh is a small wrapper that forwards signals and calls dotnet itself.
We're expecting 2 core dumps to be taken:
- One by dotnet using createdump
- One by the kernel itself
However, if we don't run with a shell, we typically see 0 dumps when the app crashes (we do occasionally see 1 dump, which is weird).
Reproduction Steps
The app code seems to be irrelevant, anything that crashes the process seems to work:
namespace MyApplication {
using System;
using System.Threading;
public class Program
{
public static void Main(string[] args)
{
Thread.Sleep(5000);
throw new Exception("Crashed on startup");
}
}
} Then a dockerfile like this one:
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim
ARG source=./
WORKDIR /app
# This is just the result of `dotnet publish`
COPY $source .
ENTRYPOINT ["dotnet", "MyApplication.dll"]We then deploy it to AKS in a pod with COMPlus_DbgEnableMiniDump=1 and COMPlus_DbgMiniDumpType=4, and the azure-watson agent running on the node.
Expected behavior
createdump takes a dump of the managed heap and the watson agent finds it and uploads it to the portal.
Actual behavior
Generally, no dump appears. Occassionally, a dump will show up without symbols. One thing that is a little notable is that these dumps typically are in a SIGSEGV bucket, whereas dumps that come from containers running from a shell are almost always in a SIGABRT bucket.
Regression?
n/a
Known Workarounds
As mentioned above. The issues only comes up if we are running dotnet as the entrypoint in our container. If the entrypoint is a bash script that starts dotnet. Everything works as expected, and our core dumps are properly taken and uploaded. We haven't tried other shells or init exe's
Configuration
We're using mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim and I believe we've seen this with the aspnet version as well.
Host OS : Ubuntu 18.04.6 LTS
Kernel version: 5.4.0-1078-azure
Arch: x64
Other information
No response
Activity
hoyosjs commentedon May 16, 2022
Is there any particular user you're using for this? Also, what's the CRI implementation and OCI runtime? Is it containerd/runc? Under regular docker it works fine, so my first hunch is any access issues - potentially because the user isn't PTRACE enabled or because the seccomp profile disallows it.
peter-glotfelty commentedon May 16, 2022
Hello @hoyosjs, the app runs as the default user in the mcr image which I assume is root. We're using containerd + runc:
peter-glotfelty commentedon May 25, 2022
Did a little more investigating of this issue:
Adding PTRACE to the container spec doesn't change anything as best I can tell.
I notice that if dotnet is not running in a shell, it looks like it runs createdump twice (we don't get either though 😔):
However, if it crashes in a start.sh script, it only prints that code out once.
This might be a logging issue and nothing else, but it seems like it's maybe worth mentioning.
mikem8361 commentedon Jul 12, 2022
Are you exporting COMPlus_DbgMiniDumpName? Is
/watson/cores/<process-name>-1the actually core dump file path? Or was it edited to remove the actual process name?Not sure why createdump is being run twice for the same process.
FYI, the
/app/start.sh: line 19: 7 Aborted (core dumped) dotnet <process>.dllmessage is from enable system core dumps.2 remaining items
mikem8361 commentedon Jul 13, 2022
The reason I'm asking is that maybe the coredump isn't being written because of some invalid char in the name or path, but Linux has very few invalid file name chars and it should fail to open. I didn't see where that doc recommended the () in the name. Could you try a simpler file name (no ())? You may want to use
%efor process id instead of%d(this is supported for backwards compatibility).I did see this:
mikem8361 commentedon Jul 13, 2022
Oops, I didn't see what CONTAINER_NAME_SEPARATOR was defined to ().
peter-glotfelty commentedon Jul 15, 2022
We can definitely switch to %e as part of general housekeeping. I think we onboarded when most of our services were still on 3.1, and the guidance may have been different.
Just to check nothing weird was happening with the names, I changed
()to__, and I still see the issue so I don't think it's the naming convention.mikem8361 commentedon Jul 15, 2022
If you are still on 3.1 (I assumed 6.0), then you should continue use %d.
Later .NET Core versions do have better diagnostic logging. The only thing I can come up with on this containerd/runc issue, is that the createdump process doesn't have sufficient permissions to write the dump to the target directory even though the dump open/writes don't fail. I'm grasping at straws here because I don't know this container stuff.
peter-glotfelty commentedon Jul 15, 2022
We are on 6.0 now. (Sorry for the confusion)
I'm also not sure what else we can add. I added the
COMPlus_CreateDumpDiagnosticsand created a few more dumps; I'll attach the logs below, but I don't think there's a smoking gun there either. Interesting-ish snippetscreatedumplogs-without-errors.txt
createdumplogs-with-errors.txt
tommcdon commentedon Nov 2, 2022
Hi @peter-glotfelty sorry for the delay on this issue. It seems there are two issues in this issue:
createdump(presumably this is because the right env variables are not set?)peter-glotfelty commentedon Nov 8, 2022
Not quite, I only see this behavior when the container is running without a shell. Basically, it's another symptom we see in addition to your first bullet point so I suspect they are related.
Our startup script is pretty simple:
hoyosjs commentedon Jan 24, 2023
@peter-glotfelty
I tried reproing this under AKS on an Ubuntu node with the following settings:
Container recipe:
Container spec:
And I get:
With a dotnet entry point. So somethings seems to be different. I couldn't use mariner since I'd have to use a DaemonSet to work around dotnet/diagnostics#3423. The AKS team is working on deploying the containerd fix now. Do you think it could be related to that?
mikem8361 commentedon Feb 10, 2023
No longer repro.