Skip to content

fuzz: avoid leaking time system singleton.#5850

Merged
jmarantz merged 4 commits intoenvoyproxy:masterfrom
htuch:fuzz-leak-singleton
Feb 6, 2019
Merged

fuzz: avoid leaking time system singleton.#5850
jmarantz merged 4 commits intoenvoyproxy:masterfrom
htuch:fuzz-leak-singleton

Conversation

@htuch
Copy link
Member

@htuch htuch commented Feb 5, 2019

Previously we were seeing:

FAIL: Active singletons exist:
Unexpected active singleton: N5Envoy5Event25SingletonTimeSystemHelperE

at the end of each fuzz test.

Risk level: Low
Testing: bazel test //test/common/access_log:access_log_formatter_fuzz_test --test_output=streamed
--test_arg="-l trace" -c dbg --config=clang-asan --test_output=all

Signed-off-by: Harvey Tuch htuch@google.com

Previously we were seeing:

FAIL: Active singletons exist:
Unexpected active singleton: N5Envoy5Event25SingletonTimeSystemHelperE

at the end of each fuzz test.

Risk level: Low
Testing: bazel test //test/common/access_log:access_log_formatter_fuzz_test  --test_output=streamed
--test_arg="-l trace" -c dbg --config=clang-asan --test_output=all

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch requested a review from jmarantz February 5, 2019 20:31
Copy link
Member Author

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Q: should we RELEASE_ASSERT on TestBase::checkSingletonQuiescensce? The reason we didn't catch it is this is a soft fail today.

}
// Cleanup before we jump into the tests, the test API creates a singleton time system that we
// don't want to leak into gtest.
api.reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

This works. You could also put the entire stanza above into a helper function or a scope.

jmarantz
jmarantz previously approved these changes Feb 5, 2019
Signed-off-by: Harvey Tuch <htuch@google.com>
public:
~TestBaseWithParam() { TestBase::checkSingletonQuiescensce(); }
~TestBaseWithParam() {
RELEASE_ASSERT(TestBase::checkSingletonQuiescensce(), "active singletons exist");
Copy link
Contributor

Choose a reason for hiding this comment

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

OK this is good...I was thinking about ASSERT_TRUE(...) or EXPECT_TRUE(...) here so that further tests would continue to run. But maybe it's hard to reason about more tests when there are leaks in the current one.

jmarantz
jmarantz previously approved these changes Feb 5, 2019
Signed-off-by: Harvey Tuch <htuch@google.com>
Envoy::test_corpus_.emplace_back(arg);
// Ensure we cleanup API resources before we jump into the tests, the test API creates a singleton
// time system that we don't want to leak into gtest.
{
Copy link
Contributor

Choose a reason for hiding this comment

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

can you sink stats_store too?

Signed-off-by: Harvey Tuch <htuch@google.com>
@jmarantz jmarantz merged commit cfd8fab into envoyproxy:master Feb 6, 2019
@htuch htuch deleted the fuzz-leak-singleton branch February 6, 2019 15:20
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
* fuzz: avoid leaking time system singleton.

Previously we were seeing:

FAIL: Active singletons exist:
Unexpected active singleton: N5Envoy5Event25SingletonTimeSystemHelperE

at the end of each fuzz test.

Risk level: Low
Testing: bazel test //test/common/access_log:access_log_formatter_fuzz_test  --test_output=streamed
--test_arg="-l trace" -c dbg --config=clang-asan --test_output=all

Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants