Skip to content

[cloud_firestore]: Using DocumentReference as query value or field write value systematically causes a crash on Windows #18028

@thearaks

Description

@thearaks

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Database

Which platforms are affected?

Windows

Description

When using a DocumentReference as value in a query where clause or in a write operation's field value the application terminates because of a native crash on Windows using cloud_firestore 6.1.2.

Expand Flutter doctor snippet
[√] Flutter (Channel stable, 3.41.1, on Microsoft Windows [Versione 10.0.26200.6725], locale it-IT)
[√] Windows Version (11 Home 64 bit, 25H2, 2009)
[X] Android toolchain - develop for Android devices
    X cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.3.0)
[√] Connected device (3 available)
[√] Network resources

(I don't build the Android platform on this computer)

Reproducing the issue

Querying a collection:

final ref = FirebaseFirestore.instance.collection('collectionA').doc('docA');
final subscription = FirebaseFirestore.instance
  .collection('collectionB')
  .where('entityRef', isEqualTo: ref)
  .snapshots()
  .listen((snap) => ...);

Or updating a document:

final ref = FirebaseFirestore.instance.collection('collectionA').doc('docA');
final firestoreData = <String, dynamic>{
  'entityRef': ref
};
FirebaseFirestore.instance.collection('collectionB').doc('docB').set(firestoreData);

Causes a native unhandled exception:

Eccezione non gestita in 0x00007FF6CB27E0DB in fpa.exe: È stato passato un parametro non valido a una funzione che considera errori irreversibili i parametri non validi.

Firebase Core version

4.4.0

Flutter Version

3.41.1

Relevant Log Output

Stack trace:

>   fpa.exe!std::bad_variant_access::_Doraise() Riga 411    C++
    fpa.exe!stdext::exception::_Raise() Riga 117    C++
    fpa.exe!std::_Throw_bad_variant_access() Riga 417   C++
    fpa.exe!std::get<3,std::monostate,bool,int,__int64,double,std::string,std::vector<unsigned char,std::allocator<unsigned char>>,std::vector<int,std::allocator<int>>,std::vector<__int64,std::allocator<__int64>>,std::vector<double,std::allocator<double>>,std::vector<flutter::EncodableValue,std::allocator<flutter::EncodableValue>>,std::map<flutter::EncodableValue,flutter::EncodableValue,std::less<flutter::EncodableValue>,std::allocator<std::pair<flutter::EncodableValue const ,flutter::EncodableValue>>>,flutter::CustomEncodableValue,std::vector<float,std::allocator<float>>>(std::variant<std::monostate,bool,int,__int64,double,std::string,std::vector<unsigned char,std::allocator<unsigned char>>,std::vector<int,std::allocator<int>>,std::vector<__int64,std::allocator<__int64>>,std::vector<double,std::allocator<double>>,std::vector<flutter::EncodableValue,std::allocator<flutter::EncodableValue>>,std::map<flutter::EncodableValue,flutter::EncodableValue,std::less<flutter::EncodableValue>,std::allocator<std::pair<flutter::EncodableValue const ,flutter::EncodableValue>>>,flutter::CustomEncodableValue,std::vector<float,std::allocator<float>>> & _Var) Riga 1167 C++
    fpa.exe!std::get<__int64,std::monostate,bool,int,__int64,double,std::string,std::vector<unsigned char,std::allocator<unsigned char>>,std::vector<int,std::allocator<int>>,std::vector<__int64,std::allocator<__int64>>,std::vector<double,std::allocator<double>>,std::vector<flutter::EncodableValue,std::allocator<flutter::EncodableValue>>,std::map<flutter::EncodableValue,flutter::EncodableValue,std::less<flutter::EncodableValue>,std::allocator<std::pair<flutter::EncodableValue const ,flutter::EncodableValue>>>,flutter::CustomEncodableValue,std::vector<float,std::allocator<float>>>(std::variant<std::monostate,bool,int,__int64,double,std::string,std::vector<unsigned char,std::allocator<unsigned char>>,std::vector<int,std::allocator<int>>,std::vector<__int64,std::allocator<__int64>>,std::vector<double,std::allocator<double>>,std::vector<flutter::EncodableValue,std::allocator<flutter::EncodableValue>>,std::map<flutter::EncodableValue,flutter::EncodableValue,std::less<flutter::EncodableValue>,std::allocator<std::pair<flutter::EncodableValue const ,flutter::EncodableValue>>>,flutter::CustomEncodableValue,std::vector<float,std::allocator<float>>> & _Var) Riga 1210   C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 266   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 210   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 110   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!flutter::StandardCodecSerializer::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 215  C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 299   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!flutter::StandardCodecSerializer::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 206  C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 299   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!flutter::StandardCodecSerializer::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 206  C++
    fpa.exe!cloud_firestore_windows::FirestoreCodec::ReadValueOfType(unsigned char type, flutter::ByteStreamReader * stream) Riga 299   C++
    [Codice esterno]    
    fpa.exe!flutter::StandardCodecSerializer::ReadValue(flutter::ByteStreamReader * stream) Riga 95 C++
    fpa.exe!flutter::StandardMessageCodec::DecodeMessageInternal(const unsigned char * binary_message, const unsigned __int64 message_size) Riga 326    C++
    fpa.exe!flutter::MessageCodec<flutter::EncodableValue>::DecodeMessage(const unsigned char * binary_message, const unsigned __int64 message_size) Riga 31    C++
    fpa.exe!flutter::BasicMessageChannel<flutter::EncodableValue>::SetMessageHandler::__l2::<lambda>(const unsigned char * binary_message, const unsigned __int64 binary_message_size, const std::function<void __cdecl(unsigned char const *,unsigned __int64)> & binary_reply) Riga 105   C++
    [Codice esterno]    
    fpa.exe!flutter::`anonymous namespace'::ForwardToHandler(FlutterDesktopMessenger * messenger, const FlutterDesktopMessage * message, void * user_data) Riga 76  C++
    [Codice esterno]    
    fpa.exe!wWinMain(HINSTANCE__ * instance, HINSTANCE__ * prev, wchar_t * command_line, int show_command) Riga 38  C++
    [Codice esterno]

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.11.0
Flutter SDK 3.41.1
fpa 3.1.0+113

dependencies:
- ambilytics 1.2.0 [flutter http firebase_analytics firebase_core shared_preferences uuid]
- auto_size_text 3.0.0 [flutter]
- built_collection 5.1.1
- built_value 8.12.3 [built_collection collection fixnum meta]
- cached_network_image 3.4.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- cloud_firestore 6.1.2 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- collection 1.19.1
- easy_debounce 2.0.3
- extended_nested_scroll_view 6.2.1 [flutter visibility_detector]
- firebase_analytics 12.1.2 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 6.1.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_remote_config 6.1.4 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_animate 4.5.2 [flutter flutter_shaders]
- flutter_html 3.0.0 [html csslib collection list_counter flutter]
- flutter_localizations 0.0.0 [flutter intl path]
- from_css_color 2.0.0 [flutter]
- google_fonts 6.3.3 [crypto flutter http path_provider]
- intl 0.20.2 [clock meta path]
- material_table_view 5.5.2 [flutter sliver_passthrough]
- math_expressions 3.1.0 [petitparser vector_math]
- mockito 5.6.3 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api]
- package_info_plus 9.0.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- page_transition 2.2.1 [flutter]
- photo_view 0.15.0 [flutter]
- provider 6.1.5+1 [collection flutter nested]
- rxdart 0.28.0
- shared_preferences 2.5.4 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- sliver_tools 0.2.12 [flutter]
- smooth_page_indicator 1.2.1 [flutter]
- substring_highlight 1.0.33 [flutter]
- to_csv 6.0.1 [flutter flutter_lints intl csv universal_html file_saver share_plus path path_provider]
- tuple 2.0.2
- url_launcher 6.3.2 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]

dev dependencies:
- analyzer 8.4.1 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- build_runner 2.11.1 [analyzer args async build build_config build_daemon built_collection built_value code_builder collection convert crypto dart_style glob graphs http_multi_server io json_annotation logging meta mime package_config path pool pub_semver shelf shelf_web_socket stream_transform watcher web_socket_channel yaml]
- built_value_generator 8.12.2 [analyzer build build_config built_collection built_value collection source_gen]
- flutter_launcher_icons 0.14.4 [args checked_yaml cli_util image json_annotation path yaml]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing collection meta stream_channel]
- msix 3.16.13 [args yaml path package_config get_it image pub_semver console cli_util]

dependency overrides:
- share_plus 12.0.1 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi web win32]

transitive dependencies:
- _fe_analyzer_shared 91.0.0 [meta]
- _flutterfire_internals 1.3.66 [collection firebase_core firebase_core_platform_interface flutter meta]
- archive 4.0.9 [path posix]
- args 2.7.0
- async 2.13.0 [collection meta]
- boolean_selector 2.1.2 [source_span string_scanner]
- build 4.0.4 [analyzer crypto glob logging package_config path]
- build_config 1.2.0 [checked_yaml json_annotation path pubspec_parse]
- build_daemon 4.1.1 [built_collection built_value crypto http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- cached_network_image_platform_interface 4.1.1 [flutter flutter_cache_manager]
- cached_network_image_web 1.3.1 [cached_network_image_platform_interface flutter flutter_cache_manager web]
- characters 1.4.1
- charcode 1.4.0
- checked_yaml 2.0.4 [json_annotation source_span yaml]
- cli_util 0.4.2 [meta path]
- clock 1.1.2
- cloud_firestore_platform_interface 7.0.6 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 5.1.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- code_assets 1.0.0 [collection hooks]
- code_builder 4.11.1 [built_collection built_value collection matcher meta]
- console 4.1.0 [vector_math]
- convert 3.1.2 [typed_data]
- cross_file 0.3.5+2 [meta web]
- crypto 3.0.7 [typed_data]
- csslib 1.0.2 [source_span]
- csv 6.0.0
- dart_style 3.1.3 [analyzer args collection package_config path pub_semver source_span yaml]
- dio 5.9.1 [async collection http_parser meta mime path dio_web_adapter]
- dio_web_adapter 2.1.1 [dio http_parser meta web]
- fake_async 1.3.3 [clock collection]
- ffi 2.2.0
- file 7.0.1 [meta path]
- file_saver 0.3.1 [collection dio flutter flutter_web_plugins path_provider path_provider_linux path_provider_windows web]
- firebase_analytics_platform_interface 5.0.6 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.6.1+2 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_auth_platform_interface 8.1.6 [_flutterfire_internals collection firebase_core flutter http meta plugin_platform_interface]
- firebase_auth_web 6.1.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core 4.4.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 6.0.2 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 3.4.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_remote_config_platform_interface 2.0.7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_web 1.10.3 [_flutterfire_internals firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins]
- fixnum 1.1.1
- flutter_cache_manager 3.4.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_lints 6.0.0 [lints]
- flutter_shaders 0.1.3 [flutter vector_math]
- flutter_web_plugins 0.0.0 [flutter]
- get_it 9.2.0 [async collection meta]
- glob 2.1.3 [async collection file path string_scanner]
- graphs 2.3.2 [collection]
- hooks 1.0.1 [collection crypto logging meta pub_semver yaml]
- html 0.15.6 [csslib source_span]
- http 1.6.0 [async http_parser meta web]
- http_multi_server 3.2.2 [async]
- http_parser 4.1.2 [collection source_span string_scanner typed_data]
- image 4.8.0 [archive meta xml]
- io 1.0.5 [meta path string_scanner]
- json_annotation 4.10.0 [meta]
- leak_tracker 11.0.2 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.10 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.2 [leak_tracker matcher meta]
- lints 6.1.0
- list_counter 1.0.2
- logging 1.3.0
- matcher 0.12.18 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.13.0 [collection]
- meta 1.17.0
- mime 2.0.0
- native_toolchain_c 0.17.4 [code_assets glob hooks logging meta pub_semver]
- nested 1.0.0 [flutter]
- objective_c 9.3.0 [code_assets collection ffi hooks logging native_toolchain_c pub_semver]
- octo_image 2.1.0 [flutter]
- package_config 2.2.0 [path]
- package_info_plus_platform_interface 3.2.1 [flutter meta plugin_platform_interface]
- path 1.9.1
- path_provider 2.1.5 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.22 [flutter path_provider_platform_interface]
- path_provider_foundation 2.6.0 [ffi flutter objective_c path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- petitparser 7.0.2 [meta collection]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- pool 1.5.2 [async stack_trace]
- posix 6.0.3 [ffi meta path]
- pub_semver 2.2.0 [collection]
- pubspec_parse 1.5.0 [checked_yaml collection json_annotation pub_semver yaml]
- share_plus_platform_interface 6.1.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences_android 2.4.20 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.6 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.3 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.4.2 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 3.0.0 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.0
- sliver_passthrough 1.0.0 [flutter]
- source_gen 4.2.0 [analyzer async build dart_style glob path pub_semver source_span yaml]
- source_span 1.10.2 [collection path term_glyph]
- sqflite 2.4.2 [flutter sqflite_android sqflite_darwin sqflite_platform_interface sqflite_common path]
- sqflite_android 2.4.2+2 [flutter sqflite_common path sqflite_platform_interface]
- sqflite_common 2.5.6 [synchronized path meta]
- sqflite_darwin 2.4.2 [flutter sqflite_platform_interface meta sqflite_common path]
- sqflite_platform_interface 2.4.0 [flutter platform sqflite_common plugin_platform_interface meta]
- stack_trace 1.12.1 [path]
- stream_channel 2.1.4 [async]
- stream_transform 2.1.1
- string_scanner 1.4.1 [source_span]
- synchronized 3.4.0
- term_glyph 1.2.2
- test_api 0.7.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.4.0 [collection]
- universal_html 2.3.0 [async csslib charcode collection html meta source_span typed_data universal_io]
- universal_io 2.3.1 [collection meta typed_data]
- url_launcher_android 6.3.28 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.4.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.2 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.5 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.4.2 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.5 [flutter url_launcher_platform_interface]
- uuid 4.5.2 [crypto meta fixnum]
- vector_math 2.2.0
- visibility_detector 0.4.0+2 [flutter]
- vm_service 15.0.2
- watcher 1.2.1 [async path]
- web 1.1.1
- web_socket 1.0.1 [web]
- web_socket_channel 3.0.3 [async crypto stream_channel web web_socket]
- win32 5.15.0 [ffi]
- xdg_directories 1.1.0 [meta path]
- xml 6.6.1 [collection meta petitparser]
- yaml 3.1.3 [collection source_span string_scanner]

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions