Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jason-simmons
Copy link
Member

Tonic's DartCallConstructor calls Dart_GetNativeArgument based on the
indices of the arguments in the native function. If the argument
count of the native function does not match that of the peer Dart
function, then this will result in failing Dart_GetNativeArgument calls.
The Dart runtime will then do potentially expensive work to construct
an error object that will be ignored.

@jason-simmons jason-simmons requested a review from dnfield April 20, 2022 00:30
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way we can test this?

@jason-simmons
Copy link
Member Author

Not sure what sort of test would catch this. The error returned by Dart_GetNativeArgument is hidden inside Tonic, which is why this was not discovered until now.

Tonic contains many Dart API calls without checks for errors. This has been an issue in Tonic since day one, but we don't currently have a strategy for replacing Tonic or fixing its error handling.

@dnfield
Copy link
Contributor

dnfield commented Apr 20, 2022

Can we make the tonic error fatal in this case? That should fail existing tests but pass with this change

…::NewError calls

Tonic's DartCallConstructor calls Dart_GetNativeArgument based on the
indices of the arguments in the native function.  If the argument
count of the native function does not match that of the peer Dart
function, then this will result in failing Dart_GetNativeArgument calls.
The Dart runtime will then do potentially expensive work to construct
an error object that will be ignored.
@jason-simmons jason-simmons force-pushed the path_dart_ctor_signature branch from 07a89f9 to 3aea6e1 Compare April 20, 2022 01:08
@jason-simmons
Copy link
Member Author

Added an assert to the DartConverter<Dart_Handle>::FromArguments code path that the CanvasPath constructor was flowing through.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm but will need a test exemption from @Hixie

@Hixie
Copy link
Contributor

Hixie commented Apr 20, 2022

test-exempt: optimization

@dnfield
Copy link
Contributor

dnfield commented Apr 20, 2022

@Hixie fwiw I think this should count as a test. The dcheck added would cause test failures without the compensating change. It's just not directly touching a file with test in the name.

@dnfield
Copy link
Contributor

dnfield commented Apr 20, 2022

(accurately detecting this as a test would be very difficult by bot though)

@jason-simmons jason-simmons added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 20, 2022
@fluttergithubbot fluttergithubbot merged commit a9dafdb into flutter:main Apr 20, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 20, 2022
justinmc pushed a commit to justinmc/engine that referenced this pull request Apr 20, 2022
CaseyHillers pushed a commit to CaseyHillers/engine that referenced this pull request Apr 26, 2022
CaseyHillers pushed a commit that referenced this pull request Apr 26, 2022
…2929)

* 'Update Dart SDK to e5fa9de'

* Fix the CanvasPath::CreateNew signature to avoid unnecessary Dart API::NewError calls (#32791)

* Update license hash

Co-authored-by: Jason Simmons <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants