Skip to content

BufferedFileStreamStrategy.ReadAsync throws Arg_InvalidOperationException when EnableLLVM == true #104167

@jamescrosswell

Description

@jamescrosswell

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

.NET 8.0.0

Description

We have a customer using the Sentry SDK in their MAUI application. One piece of functionality they've built sends log files through to a Sentry server. A background task in the Sentry API is calling FileStream.ReadAsync to enable this.

If the application is compiled with the build property <EnableLLVM>true</EnableLLVM> then frequently the logs are not sent to Sentry. Trawling through the diagnostic logs, it appears the BufferedFileStreamStrategy.ReadAsync method is throwing an Arg_InvalidOperationException, but it's not clear why.

See full discussion (including the source code to an app that allows this issue to be reproduced) at:

Steps to Reproduce

Steps to reproduce described here.

Did you find any workaround?

No. The customer needs to enable EnableLLVM for performance reasons.

Relevant log output

2024-02-15 14:50:56.008  9130-9159  DOTNET                  com.companyname.sentrydebughelper    I    Debug: Android: Serializing object: { 	"reportType": "SendLogs" }
2024-02-15 14:50:56.010  9130-9209  DOTNET                  com.companyname.sentrydebughelper    I  Warning: Failed to serialize envelope item
                                                                                                    System.InvalidOperationException: Arg_InvalidOperationException
2024-02-15 14:50:56.010  9130-9209  DOTNET                  com.companyname.sentrydebughelper    I     at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1[[System.Int64, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetStatus(Int16 )
                                                                                                       at Microsoft.Win32.SafeHandles.SafeFileHandle.ThreadPoolValueTaskSource.GetStatus(Int16 )
                                                                                                       at System.IO.Strategies.BufferedFileStreamStrategy.ReadAsync(Byte[] , Int32 , Int32 , CancellationToken )
2024-02-15 14:50:56.010  9130-9209  DOTNET                  com.companyname.sentrydebughelper    I     at System.IO.FileStream.ReadAsync(Byte[] , Int32 , Int32 , CancellationToken )
                                                                                                       at Sentry.Internal.PartialStream.ReadAsync(Byte[] , Int32 , Int32 , CancellationToken )
2024-02-15 14:50:56.010  9130-9209  DOTNET                  com.companyname.sentrydebughelper    I     at System.IO.Stream.<CopyToAsync>g__Core|27_0(Stream , Stream , Int32 , CancellationToken )
                                                                                                       at Sentry.Protocol.Envelopes.EnvelopeItem.BufferPayloadAsync(IDiagnosticLogger , CancellationToken )
                                                                                                       at Sentry.Protocol.Envelopes.EnvelopeItem.SerializeAsync(Stream , IDiagnosticLogger , CancellationToken )
2024-02-15 14:50:56.010  9130-9209  DOTNET                  com.companyname.sentrydebughelper    I     at Sentry.Protocol.Envelopes.Envelope.SerializeAsync(Stream , IDiagnosticLogger , ISystemClock , CancellationToken )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions