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

Commit f166d9b5 authored by Jason Sams's avatar Jason Sams
Browse files

Add object validity checking.

Change-Id: I2613e87b09a6e560f0381d4ed620d60a10bc30e4
parent 3cfc508f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ static void computeGaussianWeights() {


static void copyInput() {
    RS_DEBUG_MARKER;
    rs_allocation ain = rsGetAllocation(InPixel);
    uint32_t dimx = rsAllocationGetDimX(ain);
    uint32_t dimy = rsAllocationGetDimY(ain);
@@ -74,7 +73,6 @@ static void copyInput() {
            ScratchPixel1[x + y * dimx] = convert_float4(InPixel[x + y * dimx]);
        }
    }
    RS_DEBUG_MARKER;
}

void filter() {
+11 −5
Original line number Diff line number Diff line
@@ -282,14 +282,14 @@ void * Context::threadProc(void *vrsc)
     rsc->props.mLogShadersUniforms = getProp("debug.rs.shader.uniforms");
     rsc->props.mLogVisual = getProp("debug.rs.visual");

     ScriptTLSStruct *tlsStruct = new ScriptTLSStruct;
     if (!tlsStruct) {
     rsc->mTlsStruct = new ScriptTLSStruct;
     if (!rsc->mTlsStruct) {
         LOGE("Error allocating tls storage");
         return NULL;
     }
     tlsStruct->mContext = rsc;
     tlsStruct->mScript = NULL;
     int status = pthread_setspecific(rsc->gThreadTLSKey, tlsStruct);
     rsc->mTlsStruct->mContext = rsc;
     rsc->mTlsStruct->mScript = NULL;
     int status = pthread_setspecific(rsc->gThreadTLSKey, rsc->mTlsStruct);
     if (status) {
         LOGE("pthread_setspecific %i", status);
     }
@@ -361,6 +361,7 @@ void * Context::threadProc(void *vrsc)
         rsc->deinitEGL();
         pthread_mutex_unlock(&gInitMutex);
     }
     delete rsc->mTlsStruct;

     LOGV("%p, RS Thread exited", rsc);
     return NULL;
@@ -387,6 +388,11 @@ void * Context::helperThreadProc(void *vrsc)
#endif

     setpriority(PRIO_PROCESS, rsc->mWorkers.mNativeThreadId[idx], rsc->mThreadPriority);
     int status = pthread_setspecific(rsc->gThreadTLSKey, rsc->mTlsStruct);
     if (status) {
         LOGE("pthread_setspecific %i", status);
     }

     while(rsc->mRunning) {
         rsc->mWorkers.mLaunchSignals[idx].wait();
         if (rsc->mWorkers.mLaunchCallback) {
+19 −0
Original line number Diff line number Diff line
@@ -49,6 +49,24 @@ namespace android {

namespace renderscript {

#if 0
#define CHECK_OBJ(o) { \
    GET_TLS(); \
    if(!ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
    } \
}
#define CHECK_OBJ_OR_NULL(o) { \
    GET_TLS(); \
    if(o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
    } \
}
#else
#define CHECK_OBJ(o)
#define CHECK_OBJ_OR_NULL(o)
#endif

class Context
{
public:
@@ -64,6 +82,7 @@ public:
        Context * mContext;
        Script * mScript;
    };
    ScriptTLSStruct *mTlsStruct;

    typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);

+12 −0
Original line number Diff line number Diff line
@@ -195,3 +195,15 @@ void ObjectBase::dumpAll(Context *rsc)
    }
}

bool ObjectBase::isValid(const Context *rsc, const ObjectBase *obj)
{
    const ObjectBase * o = rsc->mObjHead;
    while (o) {
        if (o == obj) {
            return true;
        }
        o = o->mNext;
    }
    return false;
}
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public:
    virtual void serialize(OStream *stream) const = 0;
    virtual RsA3DClassID getClassId() const = 0;

    static bool isValid(const Context *rsc, const ObjectBase *obj);

protected:
    const char *mAllocFile;
    uint32_t mAllocLine;
Loading