3 ms·
I was a little disappointed that we didn't get a resolution here, but it's interesting to see a little more of ARC under the hood: "It isn't clear why those re
by mmastrac 12y ago
I was a little disappointed that we didn't get a resolution here, but it's interesting to see a little more of ARC under the hood:
"It isn't clear why those retains/releases were crashing, all the objects involved looked OK in the debugger, but at least we will no longer be puzzled by code that can't possibly crash...crashing, and therefore have a better chance of actually debugging it."
- e28eta 12y agoI'd be surprised if suppressing the crash actually makes this easier to debug. I'd much prefer to debug with the crash in place, than to try to determine what's wrong later in the execution of the program when the bug has had the opportunity to spread. I'm also not very impressed with trotting out the assembly without using it to diagnose the crash. Particularly not if it's being used to disparage ARC (wrongly, I believe).
- mikeash 12y agoIt's pretty weak. He doesn't tell us which line of assembly actually crashes, nor (presuming it's one of the calls to objc_storeStrong) what object is being manipulated when it crashes. There's no point in looking at your assembly code unless you're going to actually use it to investigate what's going on.
- peterkelly 12y agoI was also expecting to see an explanation of why the crash was occurring, given the build-up. Here's my theory: One or both of the parameters were passed in from unsafe references, and the objects had been deallocated. According to a simple reading of the code, you would not expect this to be a problem, because the method doesn't attempt to access either of them (it's equivalent to passing an invalid pointer to a C function, and then not accessing it). However ARC subtly changes the semantics of the language. Strictly speaking, the parameters are supposed to be valid, as ARC adds retain/release calls for them (the fact that those are normally optimised away is purely that - an optimisation). So the bug here was that invalid pointers were being passed to a method which does actually use them (albeit non-obviously). As soon as retain was called on the invalid pointer, it ended up accessing or calling to some arbitrary location in memory, hence the crash.