-
-
Notifications
You must be signed in to change notification settings - Fork 226
fix: respect SentryNative=false at runtime
#4220
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
Conversation
-p:SentryNative=false at runtimeSentryNative=false at runtime
|
The sentry-dotnet/src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets Lines 12 to 18 in b97aec8
Subsequently, when the runtime host configuration option was undefined at runtime, it would default to sentry-dotnet/src/Sentry/Platforms/Native/SentryNative.cs Lines 10 to 20 in b97aec8
Manual steps for reproducing the problem: $ dotnet new console -o HelloWorld --aot
[...]
$ cd HelloWorld/
$ dotnet add package Sentry -v 5.8.0
[...]
$ cat > Program.cs <<'EOF'
SentrySdk.Init(options =>
{
options.Dsn = "https://[email protected]/42";
options.Debug = true;
});
Console.WriteLine("Hello, Sentry!");
EOF
$ dotnet publish -p:SentryNative=false
Restore complete (0.3s)
HelloWorld succeeded (10.0s) → bin/Release/net9.0/linux-x64/publish/
Build succeeded in 10.5s
Workload updates are available. Run `dotnet workload list` for more information.
$ ./bin/Release/net9.0/linux-x64/publish/HelloWorld
Debug: Logging enabled with ConsoleDiagnosticLogger and min level: Debug
Warning: Sentry option 'Debug' is set to true while Environment is production. Be aware this can cause performance degradation and is not advised. See https://docs.sentry.io/platforms/dotnet/configuration/diagnostic-logger for more information
Debug: This looks like a Native AOT application build.
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:
sentry-native.so: cannot open shared object file: No such file or directory
libsentry-native.so: cannot open shared object file: No such file or directory
sentry-native: cannot open shared object file: No such file or directory
libsentry-native: cannot open shared object file: 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) + 0x190
at Sentry.SentrySdk.Init(Action`1) + 0x3a
at Program.<Main>$(String[] args) + 0x51
Aborted (core dumped)runtimeconfig.json (SentryNative=true => "Sentry.Native.IsEnabled": true)$ dotnet publish -p:SentryNative=true
Restore complete (0.2s)
HelloWorld succeeded (8.6s) → bin/Release/net9.0/linux-x64/publish/
Build succeeded in 8.9s
Workload updates are available. Run `dotnet workload list` for more information.
$ cat ./bin/Release/net9.0/linux-x64/HelloWorld.runtimeconfig.json{
"runtimeOptions": {
"tfm": "net9.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "9.0.4"
}
],
"configProperties": {
"Sentry.Native.IsEnabled": true,
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.ComponentModel.DefaultValueAttribute.IsSupported": false,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported": false,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": true,
"System.Globalization.PredefinedCulturesOnly": true,
"System.Net.Security.UseManagedNtlm": false,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": false,
"System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported": false,
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": false,
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": false,
"System.Runtime.InteropServices.EnableCppCLIHostActivation": false,
"System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false,
"System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault": false,
"System.Threading.Thread.EnableAutoreleasePool": false,
"System.Linq.Expressions.CanEmitObjectArrayDelegate": false
}
}
}runtimeconfig.json (SentryNative=false => N/A)$ dotnet publish -p:SentryNative=false
Restore complete (0.2s)
HelloWorld succeeded (8.3s) → bin/Release/net9.0/linux-x64/publish/
Build succeeded in 8.6s
Workload updates are available. Run `dotnet workload list` for more information.
$ cat ./bin/Release/net9.0/linux-x64/HelloWorld.runtimeconfig.json{
"runtimeOptions": {
"tfm": "net9.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "9.0.4"
}
],
"configProperties": {
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.ComponentModel.DefaultValueAttribute.IsSupported": false,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported": false,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": true,
"System.Globalization.PredefinedCulturesOnly": true,
"System.Net.Security.UseManagedNtlm": false,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": false,
"System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported": false,
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": false,
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": false,
"System.Runtime.InteropServices.EnableCppCLIHostActivation": false,
"System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false,
"System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault": false,
"System.Threading.Thread.EnableAutoreleasePool": false,
"System.Linq.Expressions.CanEmitObjectArrayDelegate": false
}
}
} |
ccb7e24 to
d33c54a
Compare
d33c54a to
a8fbd22
Compare
This PR fixes the problem that
<SentryNative>false</SentryNative>results inSentry.Native.IsEnabled=trueat runtime, as it came up in: