[Bug]: Crash in finaliser if RealmObject
implementation throws in object initialisation
#3045
Labels
RealmObject
implementation throws in object initialisation
#3045
What happened?
Regressed in 2d2f595#diff-ffe0558165702693f2ba96b95df2b7f6bf559ca7a2ef344e9cab6af24f75f6ae (due to missing null check).
This is a bit of a caveat with NRT and pre-constructor time crashes. We get around similar issues by using a helper method to check for null (https://github.com/ppy/osu-framework/blob/7fea93e6f5a30d5a47e2bd609fe1cf7ef45c507d/osu.Framework/Extensions/ObjectExtensions/ObjectExtensions.cs#L30-L33, usage: https://github.com/ppy/osu-framework/blob/3a9acd01eac691fcbea0163038743a05bb0ba41d/osu.Framework/IO/Stores/RawCachingGlyphStore.cs#L178). Another way would be to make the
_accessor
nullableWith the sample code included below, a crash is observed which can halt an application that is not manually handling all unobserved exceptions:
JetBrains.Rider-EAP.2022-10-05.at.07.58.44.mp4
Repro steps
Version
10.16.0
What SDK flavour are you using?
Local Database only
What type of application is this?
Console/Server
Client OS and version
n/a
Code snippets
Stacktrace of the exception/crash you're getting
Relevant log output
No response
The text was updated successfully, but these errors were encountered: