KissXML icon indicating copy to clipboard operation
KissXML copied to clipboard

DDXMLNode crash (compactXMLString -> XMLStringWithOptions)

Open vladimirkolbas opened this issue 7 years ago • 2 comments

We're seing a crash that isn't manually reproducible, but does occur somewhat frequently reported by Fabric (so guessing it's easier to trigger in release mode with optimizations).

File involved is DDXMLNode.m, line 1187:

CFStringTrimWhitespace((__bridge CFMutableStringRef)xmlString); crashing with

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

We believe it's occuring when sending an initial presence to the stream

xmppStream.send(XMPPPresence())

We're guessing the allocated XMPPresence goes out of scope and in some cases accessing the pointer will lead to accessing the deallocated memory.

We've just tried assigning the sent presence to a local variable to keep it alive for a longer time to see if that will solve the problem, but will need more time to see if the number of crashes decreases or drops to zero.

We believe the sent stanza is similar to this one, looks valid:

<presence><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="HmCrMVXR466Cmi5/TS/7FP+cYrE="></c><x xmlns="vcard-temp:x:update"><photo>f4c1fc071a8a13571cf32cdc3fd52a606544495e</photo></x></presence>

Do you have any better suggenstions how to evade this crash?

Screenshot of the log from Fabric attached below:

screen shot 2018-06-26 at 10 44 54

vladimirkolbas avatar Jun 26 '18 09:06 vladimirkolbas

@vladimirkolbas Hi bro. I have encountered the same problem in my project. Does your problem have been fixed by the above solution?

yxzhaoo avatar Nov 07 '18 03:11 yxzhaoo

@zyx449678686 Hey, sorry for the late reply, missed your comment. Can't say for sure as I've seen several crashes since, but only a few. Used to be a much bigger number before, so it's a big improvement if not a complete fix.

vladimirkolbas avatar Mar 04 '19 14:03 vladimirkolbas