Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bruceeelin opened this issue Aug 9, 2024 · 3 comments

Comments

@bruceeelin
Copy link

bruceeelin commented Aug 9, 2024

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

@missingems
Copy link

Same, I am facing this issue as well.

@apparition47
Copy link

apparition47 commented Apr 2, 2025

I'm seeing the same issue too; it crashes frequently.

I noticed svgnative-Xcode compiles with LibXMLParser if it's available. I switched it out for RapidXMLParser and I haven't seen any crashes so far (haven't tried ExpatXMLParser). To do this, you just need to change the file exclusions either in the Package.swift or podspec in svgnative-Xcode. svg-native-viewer will compile with whichever one of the 3 available ~XMLParser.

For example:

            exclude: ["svgnative/src/win",
                      "svgnative/src/xml/ExpatXMLParser.cpp",
-                      "svgnative/src/xml/RapidXMLParser.cpp",
+                      "svgnative/src/xml/LibXMLParser.cpp",

EDIT: opened a PR on svgnative-Xcode to make this the default.

@Eggers-CGI
Copy link

Hey, can we get an update here?
Is there a problem it will not be merged?
We are waiting for this repo to accept the Merge-Request to solve a bug with concurrency issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants