Skip to content

Errors with sentry-native launching with Sentry.AspNetCore on Dockerized Native AOT builds on Linux #4127

@ionite34

Description

@ionite34

Package

Sentry

.NET Flavor

.NET

.NET Version

9.0.201

OS

Linux

OS Version

alpine 3.21

Development Environment

Other

SDK Version

5.5.1

Self-Hosted Sentry Version

No response

Workload Versions

N/A

UseSentry or SentrySdk.Init call

N/A

Steps to Reproduce

  1. Using any minimal api AOT example, such as:
var builder = WebApplication.CreateSlimBuilder(args);

builder.Services.AddSentry();

var app = builder.Build();

api.MapGet("test", () => "Test Ok");

await app.RunAsync();
  1. Building with this Dockerfile:
FROM mcr.microsoft.com/dotnet/nightly/sdk:9.0.201-alpine3.21-aot AS build
WORKDIR /src

COPY --link . .
RUN dotnet publish -c Release -a linux-musl-x64 -o /app ./Project/Project.csproj
RUN rm /app/*.dbg /app/*.Development.json

FROM mcr.microsoft.com/dotnet/nightly/runtime-deps:9.0.3-alpine3.21-aot AS final
USER $APP_UID
EXPOSE 8080
EXPOSE 8081
ENV ASPNETCORE_URLS=http://+:8080

WORKDIR /app
COPY --link --from=build /app .
ENTRYPOINT ["./Project"]

Expected Result

Should be able to launch normally

Actual Result

Upon hitting endpoints we'll get a 500 error with:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'sentry-native' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 

Error loading shared library sentry-native.so: No such file or directory
Error loading shared library libsentry-native.so: No such file or directory
Error loading shared library sentry-native: No such file or directory
Error loading shared library libsentry-native: No such file or directory

   at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x46
   at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell*) + 0x139
   at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell*) + 0x35
   at Sentry.Native.C.sentry_options_new() + 0x1f
   at Sentry.Native.C.Init(SentryOptions) + 0x1f
   at Sentry.SentrySdk.InitNativeSdk(SentryOptions) + 0x2d
   at Sentry.SentrySdk.InitHub(SentryOptions) + 0x185
   at Sentry.SentrySdk.Init(Action`1) + 0x3a
   at Program.<<Main>$>d__0.MoveNext() + 0xde

Might be related to #4116 and #4102

An option to disable this sentry-native usage might be helpful for now since this is a blocker for us deploying Sentry at all on our Native AOT containers just for request exceptions logging and traces.

We're currently using https://www.nuget.org/packages/Microsoft.ApplicationInsights.aspnetcore on these containers, and despite build time trim warnings it still works fine so far in regards to capturing exceptions and traces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingNative

    Projects

    Status

    Done

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions