You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A downstream Avalonia app (XerahS) crashed on macOS after the user opened a file via IStorageProvider.OpenFilePickerAsync. This appears to be the same native lifetime bug fixed by #21104 / #21102, but this crash happened after selecting a file rather than canceling the picker.
I inspected the local Avalonia source and the crash lines up with the 12.0.0 implementation in native/Avalonia.Native/src/OSX/StorageProvider.mm: the async NSOpenPanel completion block captured and later dereferenced the raw IAvnSystemDialogEvents* events pointer. In current master and 12.0.2, the same code wraps that pointer in ComPtr<IAvnSystemDialogEvents> ownedEvents(events) before starting the native picker, and the block calls ownedEvents->OnCompleted(...) instead. That matches the suspected use-after-free / callback lifetime failure.
If #21104 is intended to cover selection as well as cancel, this can be closed as fixed in 12.0.2. I am filing this to provide an additional real-world crash report with the selection path and stack.
To Reproduce
Observed downstream flow:
App uses Avalonia 12.0.0 on macOS.
User invokes a menu command that calls OpenFilePickerAsync with roughly:
varfiles=awaittopLevel.StorageProvider.OpenFilePickerAsync(newFilePickerOpenOptions{Title="Select File to Upload",AllowMultiple=false,SuggestedStartLocation=awaittopLevel.StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Desktop)});
User selects a file in the native macOS file picker.
App terminates with EXC_BAD_ACCESS in libAvaloniaNative.dylib.
Expected behavior
Selecting a file should complete the task and return the selected IStorageFile without terminating the process.
Actual behavior
The app crashed in the native picker completion callback before downstream upload code could run.
Describe the bug
A downstream Avalonia app (XerahS) crashed on macOS after the user opened a file via
IStorageProvider.OpenFilePickerAsync. This appears to be the same native lifetime bug fixed by #21104 / #21102, but this crash happened after selecting a file rather than canceling the picker.I inspected the local Avalonia source and the crash lines up with the
12.0.0implementation innative/Avalonia.Native/src/OSX/StorageProvider.mm: the asyncNSOpenPanelcompletion block captured and later dereferenced the rawIAvnSystemDialogEvents* eventspointer. In currentmasterand12.0.2, the same code wraps that pointer inComPtr<IAvnSystemDialogEvents> ownedEvents(events)before starting the native picker, and the block callsownedEvents->OnCompleted(...)instead. That matches the suspected use-after-free / callback lifetime failure.If #21104 is intended to cover selection as well as cancel, this can be closed as fixed in
12.0.2. I am filing this to provide an additional real-world crash report with the selection path and stack.To Reproduce
Observed downstream flow:
12.0.0on macOS.OpenFilePickerAsyncwith roughly:EXC_BAD_ACCESSinlibAvaloniaNative.dylib.Expected behavior
Selecting a file should complete the task and return the selected
IStorageFilewithout terminating the process.Actual behavior
The app crashed in the native picker completion callback before downstream upload code could run.
Top stack frames from the macOS crash report:
The faulting instruction corresponds to the old
events->OnCompleted(uriStrings)callback path inStorageProvider::OpenFileDialog.Avalonia version
12.0.0
OS
macOS 26.5 (25F5068a), Intel x64 process
Additional context
Downstream crash app details:
0.22.170libAvaloniaNative.dylibfrom Avalonia12.0.0Local source comparison:
12.0.0:StorageProvider::OpenFileDialogcaptures rawIAvnSystemDialogEvents* eventsin the async block.12.0.2/master: Fix macOS file pickers native crash #21104 changes the folder, open-file, and save-file picker paths to keepeventsalive withComPtr<IAvnSystemDialogEvents> ownedEvents(events).