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

Commit a925d0d5 authored by Ravneet's avatar Ravneet
Browse files

Camera: Remove tid and pid from abort message

- Remove pid and tid from abort message
so it can be used to dupe watchdog bugs
that were triggered by the same call
- Monitor function name with std::string
to prevent any use-after-free issue

Bug: 279520262
Test: Tested manually
Change-Id: I0d6d11544caf68353afdbf4aa6ba6bfa086b36d4
parent ba581eb1
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -43,8 +43,7 @@ bool CameraServiceWatchdog::threadLoop()
            mTidMap[currentThreadId].cycles++;

            if (mTidMap[currentThreadId].cycles >= mMaxCycles) {
                std::string abortMessage = getAbortMessage(getpid(), currentThreadId,
                        mTidMap[currentThreadId].functionName);
                std::string abortMessage = getAbortMessage(mTidMap[currentThreadId].functionName);
                android_set_abort_message(abortMessage.c_str());
                ALOGW("CameraServiceWatchdog triggering abort for pid: %d tid: %d", getpid(),
                        currentThreadId);
@@ -60,10 +59,9 @@ bool CameraServiceWatchdog::threadLoop()
    return true;
}

std::string CameraServiceWatchdog::getAbortMessage(int pid, int tid, const char* functionName) {
std::string CameraServiceWatchdog::getAbortMessage(const std::string& functionName) {
    std::string res = "CameraServiceWatchdog triggering abort during "
            + std::string(functionName) + " | pid: " + std::to_string(pid)
            + " tid: " + std::to_string(tid);
            + functionName;
    return res;
}

+2 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class CameraServiceWatchdog : public Thread {

struct MonitoredFunction {
    uint32_t cycles;
    const char* functionName;
    std::string functionName;
};

public:
@@ -144,7 +144,7 @@ private:
     */
    void stop(uint32_t tid);

    std::string getAbortMessage(int pid, int tid, const char* functionName);
    std::string getAbortMessage(const std::string& functionName);

    virtual bool    threadLoop();