Description
On Native AOT, SentrySdk.InitHub resolves the environment before it initialises sentry-native, but not the release (resolve, init). CFunctions passes a release to sentry-native only when SentryOptions.Release is set (source), and IScopeObserver has no way to set one afterwards.
sentry-native falls back to the SENTRY_RELEASE environment variable by itself (source). What it never receives is the .NET SDK's default release, which is the entry assembly's name@version from SettingLocator.GetRelease.
Impact
Suppose an app sets neither SentryOptions.Release nor SENTRY_RELEASE:
- Managed events carry
name@version.
- Every native crash, for the lifetime of the process, arrives with no release, so it isn't attributed to any release.
Expected
sentry-native is initialised with the same release that managed events use.
Notes
The fix should be limited to the Native path; resolving the release earlier for every platform isn't safe.
Found while designing #5197, which would also fix this by resolving the release once, before native init.
Description
On Native AOT,
SentrySdk.InitHubresolves the environment before it initialises sentry-native, but not the release (resolve, init).CFunctionspasses a release to sentry-native only whenSentryOptions.Releaseis set (source), andIScopeObserverhas no way to set one afterwards.sentry-native falls back to the
SENTRY_RELEASEenvironment variable by itself (source). What it never receives is the .NET SDK's default release, which is the entry assembly'sname@versionfromSettingLocator.GetRelease.Impact
Suppose an app sets neither
SentryOptions.ReleasenorSENTRY_RELEASE:name@version.Expected
sentry-native is initialised with the same release that managed events use.
Notes
The fix should be limited to the Native path; resolving the release earlier for every platform isn't safe.
options.Release ??= GetDefaultReleaseString()during their own init (Android, Cocoa).package@version+builddefault with the assembly-based one. Cursor Bugbot flagged exactly this on fix: fetch default attributes fromScopefirst #5376.Found while designing #5197, which would also fix this by resolving the release once, before native init.