-
Notifications
You must be signed in to change notification settings - Fork 162
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
[Fuzi 0.1.1, iOS9, Swift 2] XMLElement.firstChild(...) crash: "libswiftCore.dylib`_swift_abortRetainUnowned:", "attempted to retain deallocated object". #1
Comments
@razvandub Hello thanks for the feedback. The reason why this happens is that an XMLElement holds a weak reference to the document and in your code there is no strong reference to the document and it is released after you get the root element. Changing your code to this will resolve your issue
|
Thanks @cezheng, I'll do that for now. Could you please update the readme to make this explicit since Fuzi's mem management is not intuitive and also because this was not the case with 0.1.0? Thanks. |
@razvandub Sorry about that. I was changing this in 0.1.1 to resolve a reference loop between root & document making the document instances never released in 0.1.0, but didn't realized that might be dangerous if users are not properly guided. I appreciate your feedback. I will put some thoughts on how to make your code not crash first. If I can't come up with a way of doing that I will update the README |
No problem @cezheng, thanks. |
@cezheng Why do you use |
@stepanhruda There're 2 reasons I don't use weak
So currently, the proper way to use this library is to keep a strong reference on the document rather than the element. If you have any thoughts on improving this, I will appreciate it if you could share your thoughts or even a PR |
Fix for Xcode16: safe way to create UnsafeBufferPointer
Input:
Code:
Crash:
(lldb) bt
_swift_abortRetainUnowned + 15 frame #1: 0x0000000108b18986 libswiftCore.dylib
swift_retainUnowned + 38frame Accessing parents children #2: 0x0000000105a2398b Fuzi`Fuzi.XMLElement.firstChild (tag="Body", ns=nil, self=0x00007fcf91e50290)(tag : Swift.String, inNamespace : Swift.Optional<Swift.String>) -> Swift.Optional<Fuzi.XMLElement> + 411 at Element.swift:81
...
The text was updated successfully, but these errors were encountered: