From 93d11f50dfd671c1a680da6fb8f1c4232f0290ac Mon Sep 17 00:00:00 2001 From: Anthony Stange Date: Thu, 25 Mar 2021 16:35:37 +0000 Subject: [PATCH] Don't assert while a callback is registered If an assert fails while a callback is registered and some data is delivered that attempts to invoke the callback, it'll cause a segfault since the callback is allocated on a part of the stack that's no longer valid. Bug: 183362725 Change-Id: I3a1f8fbf15c24e344fde8e5b44bb93681ef47d38 Test: Run VTS --- sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h index 82b2d25833..03ef1b8c88 100644 --- a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h +++ b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h @@ -462,6 +462,7 @@ TEST_P(SensorsHidlTest, InjectSensorEventData) { // Wait for events to be written back to the Event FMQ callback.waitForEvents(sensors, milliseconds(1000) /* timeout */); + getEnvironment()->unregisterCallback(); for (const auto& s : sensors) { auto events = callback.getEvents(s.sensorHandle); @@ -485,7 +486,6 @@ TEST_P(SensorsHidlTest, InjectSensorEventData) { ASSERT_EQ(lastEvent.u.vec3.status, injectedEvent.u.vec3.status); } - getEnvironment()->unregisterCallback(); ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL)); } @@ -603,7 +603,7 @@ void SensorsHidlTest::runFlushTest(const std::vector& sensors, b << " type=" << static_cast(sensor.type) << " name=" << sensor.name); Result flushResult = flush(sensor.sensorHandle); - ASSERT_EQ(flushResult, expectedResponse); + EXPECT_EQ(flushResult, expectedResponse); } }