SDWebImage/SDWebImageSVGNativeCoder

Bug: app crashed at ~LibXMLDocument because of xmlFreeDoc be called multiple times

Opened this issue · 1 comments

Version:

  • svgNativeCoder: 0.2.0
  • SDWebImage: 5.19.1

Crashed iOS Version:
17.5, 17.6, 16.7, etc

Recently, we enabled the svg image loading feature in the app to be used with SDWebImage, which we introduced in the AppDelegate using this method:

SDImageSVGNativeCoder *SVGCoder = [SDImageSVGNativeCoder sharedCoder];
[[SDImageCodersManager sharedManager] addCoder:SVGCoder];

When using it, it is the same as loading a normal image, and there is no superfluous operation.
We've been running the online app for a week, and some users have crashes, and the stack monitored by Firebase looks like this:

image image image

This happens because the pointer is released multiple times during ~libXMLDocument(), and this bug can be replicated by adding the following code when debugging:

~LibXMLDocument()
{
    xmlFreeDoc(mDocument);
    xmlFreeDoc(mDocument); //  new added
    xmlCleanupParser();
}

I can't analyze under what scenario this crash occurs and why the pointer is released multiple times, I hope you can help look at the specific problem, thank you very much for your help

Same, I am facing this issue as well.