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

Conversation

@bdero
Copy link
Member

@bdero bdero commented Aug 9, 2021

Fix a memory leak that triggers asan traces in the codec tests.

@bdero bdero requested a review from stuartmorgan-g August 9, 2021 12:23
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

This needs a test. You can check that it's always returning the same instance for a given argument, which won't be true with the bug.

std::unique_ptr<StandardMessageCodec>>;
auto it = sInstances->find(serializer);
if (it == sInstances->end()) {
static auto sInstances = std::map<const StandardCodecSerializer*,
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g Aug 9, 2021

Choose a reason for hiding this comment

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

The missing static is obviously a mistake, but the other changes you've made here are breaking deliberate behavior and violate style: https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables

Copy link
Member Author

Choose a reason for hiding this comment

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

That destructor ordering argument makes sense, thanks for the link. Fixed and added tests. Also did the same in StandardMethodCodec, as that's leaking across tests as well.

@bdero bdero force-pushed the bdero/fix-test-leaks branch 2 times, most recently from f50c270 to 6797fda Compare August 9, 2021 20:36
@bdero bdero requested a review from stuartmorgan-g August 9, 2021 20:55
@bdero bdero force-pushed the bdero/fix-test-leaks branch from 6797fda to 84666c4 Compare August 9, 2021 21:27
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bdero bdero merged commit 2fa5f69 into flutter:master Aug 9, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 11, 2021
yx-mike added a commit to yx-mike/engine that referenced this pull request Dec 31, 2021
filmil pushed a commit to filmil/engine that referenced this pull request Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants