Crash when fRefCnt.fetch_add

16 views
Skip to first unread message

l1 shu

unread,
Apr 25, 2021, 6:26:36 AMApr 25
to skia-discuss
Hi team, I got an error:
crash.png

the final call is `__c11_atomic_fetch_add`, I don't know where the problem is, can someone help me point out my question? Thanks

l1 shu

unread,
Apr 25, 2021, 10:35:16 PMApr 25
to skia-discuss
More information is:

When I return an sk_sp<SkShader>  object, It enters the skia internal logic

1. return sk_sp<SkShader>
2.  sk_sp<T>& operator=(sk_sp<T>&& that) {
         this->reset(that.release());
         return *this;
      }

3. void reset(T* ptr = nullptr) {
         T* oldPtr = fPtr;
         fPtr = ptr;
         SkSafeUnref(oldPtr);
     }

4. template <typename T> static inline void SkSafeUnref(T* obj) {
         if (obj) {
             obj->unref();
         }
     }

5. void unref() const {
         if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) {
             this->internal_dispose();
         }
     }

6. Unfortunately crash...

l1 shu

unread,
Apr 26, 2021, 7:34:28 AMApr 26
to skia-discuss
Ignore the discussion, I figure it out
Reply all
Reply to author
Forward
0 new messages