Prevent 'use after free' by waiting for all queued tasks to be processed.
Sometimes, a task bound to VideoSendStreamTest was called
after the underlying object had been destructed:
1. |test| goes out of scope.
2. There might still have been a task in fixture's queue,
setup by OnSendRtp (capturing [this]) and invoked before
the destruction of the fixture.
This CL uses the same workaround than BandwidthStatsTest:
block until all posted tasks are processed.
This fixes the following flaky tests:
* VideoSendStreamTest.ChangingNetworkRoute
* VideoSendStreamTest.RespectsMinTransmitBitrate*
Bug: webrtc:11156
Change-Id: I229c96d2abbbb60b43e9d9f62ad112507a21fe48
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/163984
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Yves Gerey <yvesg@google.com>
Cr-Commit-Position: refs/heads/master@{#30152}
This commit is contained in:
parent
e8d54b924d
commit
c33e4910c5
@ -1711,6 +1711,12 @@ TEST_F(VideoSendStreamTest, ChangingNetworkRoute) {
|
||||
extensions_.Register<TransportSequenceNumber>(kExtensionId);
|
||||
}
|
||||
|
||||
~ChangingNetworkRouteTest() {
|
||||
// Block until all already posted tasks run to avoid 'use after free'
|
||||
// when such task accesses |this|.
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [] {});
|
||||
}
|
||||
|
||||
void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
|
||||
RTC_DCHECK_RUN_ON(&task_queue_thread_);
|
||||
RTC_DCHECK(!call_);
|
||||
@ -1896,6 +1902,12 @@ class MaxPaddingSetTest : public test::SendTest {
|
||||
task_queue_thread_.Detach();
|
||||
}
|
||||
|
||||
~MaxPaddingSetTest() {
|
||||
// Block until all already posted tasks run to avoid 'use after free'
|
||||
// when such task accesses |this|.
|
||||
SendTask(RTC_FROM_HERE, task_queue_, [] {});
|
||||
}
|
||||
|
||||
void ModifyVideoConfigs(
|
||||
VideoSendStream::Config* send_config,
|
||||
std::vector<VideoReceiveStream::Config>* receive_configs,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user