-
Notifications
You must be signed in to change notification settings - Fork 275
Microsoft.Testing.Extensions.HangDump does not work on macOS or Linux in native AOT mode #3097
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
Comments
@MarcoRossignoli I think it's another bug of pipe name under non-windows, could you check it please? |
Thanks @martincostello for reporting it, I'll check the length name issue, anyway I don't know if hang/crash works for native aot version. @brianrob @tommcdon we're using the environment variable for the crash dump https://learn.microsoft.com/en-us/dotnet/core/diagnostics/collect-dumps-crash and the |
Sorry I totally forgot about this ticket, will work on it this week! |
@martincostello Would you be able to test the fix from our preview feed? I tried cloning your repo to test it out but running
|
I can try it out tomorrow, but these are the dependency steps the CI runs to install the tooling that native AoT needs on linux: https://github.com/martincostello/alexa-london-travel/blob/9a799b548274c270f8dc61417265d04e5cc19a9d/.github/workflows/build.yml#L65-L74 |
It's ok, I can reproduce the error with these lines :) Thanks @martincostello <3 |
We fixed the length issue of the pipe but looks like there is still an issue. We haven't yet validated if hang dump is working well in Native AOT mode so for now the only recommendation would be to not use it for NAOT We will work on adding tests for it on our next iteration and will post-back the resutls. |
The reason I found this bug in the the first place was I was specifically trying to diagnose a hang that is only happening to me in native AoT 😅 |
We're waiting some internal info on how to support hang/crash in native aot mode. We'll let you know soon as possible. |
@martincostello do you mean that if you run test in "normal mode" everything is good but if you try with native aot it's hanging? |
Sorry for the delayed response! Environment variable enabled crash dumps and In .NET 8, using
|
Exactly that. |
@martincostello - if you publish the tests for AOT do you get any trim/AOT warnings? |
Those are not warnings - just info messages. It seems there are no warnings, unless they're suppressed by something. |
@vitek-karas I haven't seen any warning when building locally. I will double check the configuration to ensure the analyzers are enabled correctly. |
@martincostello Hi martin, for debugging Native AOT apps in particular, you might find native tooling better. For instance, you could use GDB or LLDB to attach to the running process and dump the stack directly. As long as symbols are on the machine, you shouldn't need any special technology to do basic investigations. The native compiler should be able to understand the native code. |
Specifically I only seem to get the hangs in the native AoT tests themselves. The AoT application itself is fine, and I don't get the hangs in normal xunit tests, or on Windows or macOS under native AoT. It seems to be exclusively my native AoT tests on Linux, and then only sometimes (and those tests are 99% copy-paste from existing non-AoT tests for xunit). It's mostly just a minor annoyance (a few retries and it'll go away), but I'd like to get to the bottom of it to know if it's an issue in my code, or in the native AoT test SDK itself. Using the built-in tooling seemed like the easiest way to grab a file to inspect to find what was hanging from my CI (which is where I experience the issue), but that ultimately lead me to opening this issue as I fell at the first hurdle. |
I assume your Native aot tests are also Native aot? Or are they regular coreclr? |
They use the native AoT support in MSTest.TestFramework. |
Got it. Yup, in that case I would recommend trying to attach with LLDB or GDB. While the |
I might try that, but I'll have to learn LLDB/GDB as I've never used them before. That depends on me being able to reproduce it locally - if it only happens in CI then that's basically a non-starter. |
Agreed. I’ll leave this issue open. Unfortunately the person who worked on createdump support with Native aot is out on vacation right now, so it might be a bit before we have a more detailed fix. |
OK, I've investigated and have some more information. There may be multiple ways that the runtime creates dump files (I haven't surveyed all the possible options) but one is a program called What I'm unclear on is: how does the |
As reported here #3097 (comment) we use the env vars for the crash dump and the package |
OK, I managed to investigate the current state and get a dump out of Here are the requirements:
What I think we need to improve on the Native AOT side is error messages. There's no indication what the cause of some of these failures are. |
Might also need to set dotnet-dump could be used to collect dumps as well. lldb , together with the symbol file, can be used to analyze the dumps collected. |
Trying to follow the steps above to use dotnet-dump to generate a dump to see where the hang is coming from, and I keep getting the following error: > dotnet dump collect -p 27454
Writing full to /home/martin/core_20240806_094936
Write dump failed - HRESULT: 0x80004005. I've tried making every If I try and use |
Playing around in GitHub Actions, I found a clue that's gotten generation working there. When I set
If I manually copy the file from |
The tips got me far enough that I think I root-caused the deadlock as described in #3485, which I've now been able to create a workaround for in my project. The documentation for trying to do this with a native AoT app certainly needs some TLC for those unfamiliar with tools such as lldb (which is how I eventually got hold of the stacks) 😅. |
Describe the bug
Following this tip #3095 (comment) I added the Microsoft.Testing.Extensions.HangDump package to a native AoT test project of mine to try and diagnose a hanging test (which in my case I can only repro on Linux).
Upon making the changes martincostello/alexa-london-travel#1298 and running the CI, the tests fail with a unique exception message each on macOS and Linux as shown below. I can also repo this outside of GitHub Actions CI with WSL.
macOS
Linux
Steps To Reproduce
./build.ps1
in the root of the repository.Expected behavior
Either:
Actual behavior
The process exits with an error of either
ArgumentOutOfRangeException
on macOS orIOException
on Linux.Additional context
In case it was an issue with the file name I was providing, I tried not specifying a file name at all in the hope of it having a default like
dotnet test
does. In that case, a different failure is observed:The text was updated successfully, but these errors were encountered: