Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 310d3dde authored by Anthony Stange's avatar Anthony Stange
Browse files

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
Merged-In: I3a1f8fbf15c24e344fde8e5b44bb93681ef47d38
Change-Id: I2b1895a1f5898b8971ffd820a7d619a09f12495d
Test: Run VTS
parent e7b96104
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -390,6 +390,7 @@ TEST_F(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);
@@ -409,7 +410,6 @@ TEST_F(SensorsHidlTest, InjectSensorEventData) {
        ASSERT_EQ(lastEvent.u.vec3.status, injectedEvent.u.vec3.status);
    }

    getEnvironment()->unregisterCallback();
    ASSERT_EQ(Result::OK, getSensors()->setOperationMode(OperationMode::NORMAL));
}

@@ -711,7 +711,7 @@ void SensorsHidlTest::runFlushTest(const std::vector<SensorInfo>& sensors, bool
        // Flush the sensor
        for (int32_t i = 0; i < flushCalls; i++) {
            Result flushResult = flush(sensor.sensorHandle);
            ASSERT_EQ(flushResult, expectedResponse);
            EXPECT_EQ(flushResult, expectedResponse);
        }
    }