-
Notifications
You must be signed in to change notification settings - Fork 793
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
AOT compiled app throws System.PlatformNotSupportedException #5358
Comments
@Yun-Ting Could you take a look? |
Hi @kedare, I cloned the code you shared: https://github.com/kedare/dotnet-otel-bug/tree/main and the issue did not repro in my machine. But I do see this warning emitted with your code: Could you try whether updating L36 to be |
I fixed the null safety but the issue still happens 100% of the time, I will try to make a Dockerfile to make it easier to reproduce |
Hmm somehow I can't reproduce it with this sample project with Docker but it does with our full project. Is there a way to get more information from the stacktrace from the full project about what could cause this so I can try to reproduce it on the minimal project ?
It would be related to the activity start ? Or to something happening inside the activity ? |
Hello there! We encountered this as well recently. I believe this is coming from the #if NET6_0_OR_GREATER || NETFRAMEWORK
this.fnGetExceptionPointers = Marshal.GetExceptionPointers;
#else For AOT, this currently is not supported. https://github.com/dotnet/runtime/blob/cd850233414468a8ffe84fc8fa05a36d0b3b1316/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs#L225
I'm currently noodling on ways around this, but, honestly, not comfortable enough with the pointer accessors yet to recommend a solution or submit a PR. Hoping to be able to do either of those over the next few days though. Cheers! |
@kedare As @Tesouro-Chris pointed, it looks like @eerhardt @vitek-karas Would you have any inputs for this issue? We probably need to annotate this method. |
I was thinking the same thing. But annotating it with "RequiresDynamicCode" seems a bit confusing, since it doesn't really require "dynamic code". Are there other ways to know if an exception is currently being handled? It would probably be best to guard this and not call it when |
Yeah, the right thing would be something along the lines of IsSehInteropSupported or something like that. This doesn't have to do with the ability to JIT new code at runtime, but how exceptions are implemented. CoreCLR implements exceptions on top of SEH because of C++/CLI. I think we could make this return null based on the conversation in dotnet/runtime#26620. Some additional conversation at dotnet/runtime#75669 (comment). Cc-ing people involved in those: @AaronRobinsonMSFT @jkoritzinsky @jkotas |
Returning null won't make opentelemetry-dotnet/src/OpenTelemetry/Trace/ExceptionProcessor.cs Lines 42 to 77 in af2b551
I think the proper fix would be to introduce APIs that allow tracking exceptions in flight. We have |
I'm going to remove the bug label here and close this as resolved. The issue isn't part of OpenTelemetry, or one we are going to fix. It requires upstream fixes in the runtime to make that happen. Sorry we don't have a better answer for you. If anyone thinks that there's something that the Otel .NET library can do, please do comment and we can open an issue for tracking that work. |
What is this PR #5374 then? |
Reopened. My perception was that it wasn't a fix, just making a different, potentially better, error message. If you think it's worth keeping this open while we add a better error message, or I've misunderstood, then I don't mind it being open. |
I think we should keep this open, as there is an open PR trying to address this. If we conclude in the PR that this is not something OTel .NET can fix, then yes, we can close. |
No worry, thank you for your help :) |
Are you happy, with that PR merged, that we close this? |
Yes that should be good, thank you for your help |
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g.
OpenTelemetry 1.0.2
):OpenTelemetry 1.7.0
OpenTelemetry.Exporter.OpenTelemetryProtocol 1.7.0
Runtime version (e.g.
net462
,net48
,netcoreapp3.1
,net6.0
etc. You canfind this information from the
*.csproj
file):net8.0
Symptom
When compiling with PublishAot=true, I get an
System.PlatformNotSupportedException
from an unknown origin in the codeWhat is the expected behavior?
App should output without error
What is the actual behavior?
The application would throw an exception at startup:
Reproduce
Code in : https://github.com/kedare/dotnet-otel-bug/
Try without AOT, it should work fine :
Try with AOT, it should throw the exception after the
pre otel
console outputAdditional Context
Tested in MacOs (build to Mac binary)
Tested inside docker (build to Linux binary)
I first though the issue was from the
AddSource("*")
as then I remove it the issue is gone but I guess it's just because then it's not gathering any trace and not hitting the part of the opentelemetry code that triggers this issue)The text was updated successfully, but these errors were encountered: