Instructions icon indicating copy to clipboard operation
Instructions copied to clipboard

Crash with error: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7fff86533e38)

Open vivek4292 opened this issue 6 years ago • 6 comments

Describe the bug When I was using 1.2.0 and Xcode 10.2 it was working fine. As I switched to Xcode 11.2 and 1.4.0 version of Instruction. I found a crash while assigning a delegate to CoachMarksController instance.

To Reproduce Assign a delegate to an instance of CoachMarksController. In Xcode 11.2

Expected behavior It should display coach mark views smoothly.

Screenshots Screenshot 2019-11-12 at 5 40 40 PM

Environment:

  • Xcode: 11.2
  • Device: e.g. iPad 9.7- inch
  • iOS version: 13.2
  • Dependency Manager: Carthage

vivek4292 avatar Nov 12 '19 12:11 vivek4292

Hey @vivek4292, thanks for reporting the issue. I'm unable to reproduce it, would you be able to provide a sample project demonstrating the crash?

ephread avatar Nov 22 '19 21:11 ephread

Hey, @ephread thanks for the response. I tried this in a separate project with the same environment and it is working fine. But it's still not working in my project. Screenshot 2019-11-27 at 5 58 45 PM In the above screenshot: I'm instantiating an object of CoachMarksController() and passing to a class-level variable. In the next line, you can see I'm assigning a data source to it. At that moment I checked if its reference is available in memory, I found It was available(see console). When I move to the next line, I found its data source was nil. Datasource was not assigned. Moreover, when I checked its memory reference (see console). It was missing and showing error:

"error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x6). The process has been returned to the state before expression evaluation".

The moment I released the breakpoint, the app got crashed on the same line (like the previous screenshot). Please help.

vivek4292 avatar Nov 27 '19 13:11 vivek4292

I'm instantiating an object of CoachMarksController() and passing to a class-level variable. In the next line, you can see I'm assigning a data source to it.

This may be a trivial question, but how and where is coacher declared? Asking because it looks a lot like an object that is released too soon.

ephread avatar Dec 01 '19 06:12 ephread

@ephread Yeah it's a trivial question but I can understand in such case anyone can think of this possible reason. Agreed, it looks like an object is getting released soon. At first, I declared coacher at class level as lazy. Screenshot 2019-12-02 at 12 17 16 PM It was instantiated on first use(not in ViewDidLoad) and it was working fine till I was using Xcode 11.1 When I migrated this to Xcode 11.2.1 It started causing a crash. My thoughts were the same about releasing the object soon so I tried not to use lazy, instantiating in ViedDidLoad(), even instantiate a fresh object in ViewDidLoad() and not using a class-level variable. Screenshot 2019-12-02 at 12 21 45 PM

But the crash is still there.

vivek4292 avatar Dec 02 '19 06:12 vivek4292

I had the same problem with a project I am working on, I solve it by moving the code that was causing the bug to the main queue since that code was directly related to UI. this was in Xcode 13.

kadm91 avatar Jun 29 '22 06:06 kadm91

How do you move the code to main queue? where do I find the main queue?

tru110799 avatar Apr 26 '23 15:04 tru110799