Skip to content

[pigeon] C++ generated code doesn't handle null arguments of custom class type #149174

@russellwheatley

Description

@russellwheatley

Steps to reproduce

I have a reproduction repo here.

Code uses url launcher windows package. I essentially updated the messages/pigeon.dart and regenerated the code.

This is the update

In a nutshell, if an arg is nullable, and null is passed, it will crash the app. Here is where it crashes in the code. Essentially, when it tries to parse the nullable value.

I have instructions in the README of the reproduction repo, but here they are for completeness:

  1. Run flutter build windows --debug in example/
  2. Open app on Visual Studio by opening the solution in example/build/windows/x64/runner/runner.sln
  3. Put two break points on these lines. Note that it gets to the first line but will crash before getting to the second line.

This issue was found when implementing this feature on FlutterFire: https://github.com/firebase/flutterfire/pull/12825/files#diff-ad8aa9e593097c77254420c5c93cccbba4478ba947392296a18cceddc6068d85R4028-R4037

Expected results

Not to crash when passing null as nullable argument.

Actual results

Crashes in Pigeon generated code on this line

Code sample

Code sample

https://github.com/russellwheatley/pigeon_bug_windows/blob/master/README.md

Screenshots or Video

Screenshots / Video demonstration

image

Logs

Logs

None.

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3593], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3)
[!] Android Studio (not installed)
[√] VS Code (version 1.89.1)
[√] Connected device (3 available)
[√] Network resources

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolep: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.platform-windowsBuilding on or for Windows specificallyteam-ecosystemOwned by Ecosystem team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions