naptics / PlainPing

a very plain ping interface in swift
MIT License
58 stars 21 forks source link

Crash on assert( CFSocketGetSocketFlags(self.socket) & kCFSocketCloseOnInvalidate ) before RunLoop #28

Closed nneuberger1 closed 3 years ago

nneuberger1 commented 4 years ago

We're seeing some sporadic crashes in the following line:

https://github.com/naptics/PlainPing/blob/917c2de5f61902f51b1644211701feb7e2269ca3/Pod/Classes/SimplePing.m#L630

Assertion failed: (CFSocketGetSocketFlags(self.socket) & kCFSocketCloseOnInvalidate), function -[SimplePing startWithHostAddress], file /opt/atlassian/bamboo-agent-home/xml-data/build-dir/IOS-KIAORCPNI-JOB1/Pods/PlainPing/Pod/Classes/SimplePing.m, line 630.

Based on some of our research, the kCFSocketCloseOnInvalidate https://developer.apple.com/documentation/corefoundation/kcfsocketcloseoninvalidate

We ended up creating a branch and checking state of both and returning a "didFailWithError instead."

I don't have a huge amount of socket experience so I don't know why it would be failing originally. My best guess is that the self.socket may be NULL. Or perhaps the kCFSocketCloseOnInvalidate is becoming false.

I'll get a pull request to get others thoughts on it. It's initially working for us but haven't fully validated on new errors yet coming from our PR code.

nneuberger1 commented 4 years ago

Here's the Pull Request.

https://github.com/naptics/PlainPing/pull/29