I have read the code, and compiled this code in release mode, and I still do not understand why calling data->unref() breaks everything.
auto outputStream = new SkDynamicMemoryWStream();
std::unique_ptr<SkCanvas> svgCanvas = SkSVGCanvas::Make(SkRect::MakeWH(200, 200), outputStream, SkSVGCanvas::kConvertTextToPaths_Flag);
// drawing..
delete svgCanvas.release();
auto data = outputStream->detachAsData();
delete outputStream;
data->unref();
As I can see there is a check which looks at current ref count and calls delete only if it is 1, which means if I call unref myself, the subsequent unref by sk_sp's destructor will not call delete second time. What am I missing?
The error is still this "malloc(): unaligned tcache chunk detected"
void unref() const {
if (1 == fRefCnt.fetch_add(-1, std::memory_order_acq_rel)) {
// restore the 1 for our destructor's assert
SkDEBUGCODE(fRefCnt.store(1, std::memory_order_relaxed));
delete (const Derived*)this;
}
}
суббота, 16 марта 2024 г. в 12:25:10 UTC+3, Данил Буланов: