trunks unit tests are flaky: WeakPtrs must be invalidated on the same sequenced thread. |
|||||||||
Issue descriptionTrunk unittest is failing https://uberchromegw.corp.google.com/i/chromeos/builders/reef-paladin/builds/1219
,
Jan 24 2017
,
Jan 24 2017
Issue 681254 has been merged into this issue.
,
Jan 24 2017
Occasionally BackgroundTransceiverTest.Synchronous unit test crashes on systems where trunksd is built (reef, gru, ...) with the following error: FATAL:weak_ptr.cc(20)] Check failed: sequence_checker_.CalledOnValidSequencedThread() || HasOneRef(). WeakPtrs must be invalidated on the same sequenced thread.
,
Jan 24 2017
Apparently, this is a rarely happening race condition: We return from BackgroundCommandTransceiver::SendCommandAndWait() and then from run_loop.RunUntilIdle() in the unit test as soon as the response_ready event is signaled. However, the SendCommandTask on test_thread_ may still be running and this holding base::WeakPtr<BackgroundCommandTransceiver> after signaling the event. If the caller (BackgroundCommandTransciever::task_runner_) is immediately woken up inside event->Signal(), SendCommandTask may still be running after run_loop.RunUntilIdle() and at the end if the unit test. And then, if SendCommandTask is still running by the time we finish the test, the background_transceiver destructor will start with destructing the transciever's internal weak_factory_, which still holds a pointer used by SendCommandTask. Hence the error. This condition can easily be replicated by adding sleep after event->Signal() to the end of AssignAndSignal() in background_command_transceiver.cc.
,
Jan 24 2017
Adding test_thread_.Stop() to the end of BackgroundTransceiverTest.Synchronous resolves the issue. However, needs to be investigated if in real-life usage scenarios (aosp/system/tpm/trunks/trunksd.cc, platform2/chaps/tpm2_utility_impl.cc) the underlying transcever threads are properly stopped. Or, it is needed to rework BackgroundCommandTransceiver to use something like PostTaskAndReplyWithResult instead of homegrown reply handling.
,
Jan 24 2017
- For chapsd, TPM2UtilityImpl is constructed from tpm_background_thread.task_runner() and passes it to BackgroundCommandTransceiver. Stop() is called for tpm_background_thread in chapsd.cc, so we are ok. - For trunksd, BackgroundCommandTransceiver is constructed with background_thread.task_runner(), and background_thread is not stopped before destructing background_transceiver. So, this race is possible.
,
Jan 31 2017
For trunksd, the daemon shutdown logic is being reviewed in issue 687018 . At this moment, there's no issue with WeakPtrs, but it will need to be checked again after fixing that issue with shutdown logic.
,
Feb 1 2017
The CL https://chromium-review.googlesource.com/#/c/431503/ has actually landed, just not reflected here. Removing blockedon issue 687018 - no WeakPtr issues observed fro trunksd after adding proper shutdown.
,
Apr 17 2017
,
May 30 2017
,
Aug 1 2017
,
Oct 14 2017
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by apronin@chromium.org
, Jan 23 2017