Getting strange debugger message: Assertion failed: (cls), function getName: what is this?

前端 未结 6 813
一生所求
一生所求 2021-02-01 17:47

Since I upgraded from Xcode 3.2.3 to 3.2.4 and iOS 4.0.1 to iOS 4.1 SDK, when I set a breakpoint in my code and single-step over instructions, at each step, the debugger will sp

相关标签:
6条回答
  • 2021-02-01 17:57

    I also have the same problem; I don't have a solution but I'm able to work around it. In short, I suggest you add more breakpoints...

    I noticed in the call stack that it's actually the debugger that is misbehaving. The function gdb_class_getClass calls getName, presumedly this is passing NULL instead of (say) MyClass. The code that I'm trying to debug is a method of MyClass. So, thinking that the debugger has a problem with MyClass, I set a breakpoint at a line outside of any code of MyClass (ie the line that calls the method on MyClass) and hit continue when the program breaks. This seems to resolve the problem in my case. (Note that auto-continue doesn't work.)

    To be clear:

    //Set breakpoint here
    [myClassInstance buggyMethod];
    

    My buggyMethod is actually in another file:

    ...
    -(void)buggyMethod {
        //This is where I set my 'real' breakpoint
    

    Hope that helps.

    0 讨论(0)
  • 2021-02-01 17:59

    I ran into this - and here's the reason mine happened: I had used +localizedStringFromDate:dateStyle:timeStyle: in my code. Worked fine on the iPhone, but it's not available pre-4.0 SDK, so it coughed on the iPad. See if you're calling some routine that's either no longer available in the SDK, or available only in later versions. Frankly, I can't wait for 4.1 on the iPad!

    -Owen

    0 讨论(0)
  • 2021-02-01 18:12

    I had this problem when I was running on simulator "iPad 3.2 simulator". This problem disappeared when I switched the simulator to "iPad 4.3 simulator"

    0 讨论(0)
  • 2021-02-01 18:14

    I'm also having this problem, in an iPad app originally written in Xcode 3.2.4 using the iOS 3.2 SDK, now being debugged in Xcode 3.2.5 using the 4.2 SDK, but only when I set the simulator to the 3.2 iOS Deployment Target (so I can run in the 3.2 simulator). Every stop at a breakpoint in the debugger, I get this assert repeated eight times. Single-stepping over a line gets two more.

    What I can't understand is I haven't added any code to the project since I last run it in Xcode 3.2.4 and iOS SDK 3.2, so I can't have added any calls that were not present in that SDK or else it wouldn't have compiled.

    Until someone finds an answer to this, I think the only workaround (so I can continue debugging my code in a 3.2 environment) is to reinstall Xcode 3.2.4 and use the 3.2 SDK and simulator.

    0 讨论(0)
  • 2021-02-01 18:17

    I'm having a similar problem, but mine is with creating a custom view with Core Text in it. As soon as my view's drawRect calls the line

    CTFontRef titleFont = CTFontCreateWithName(CFSTR("Baskerville"), 40.0f, NULL); 
    

    It hangs the app, whether in the simulator or on the device. Bizarrely, I can rectify this by alloc-initing another UIKit text component in the View Controller's viewDidLoad method... I don't even have to add it as a subview. It's like it needs some common text elements loaded before Core Text can load in fonts.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];        
    }
    

    Weird.

    0 讨论(0)
  • 2021-02-01 18:19

    I have exactly the same issue. I know it's not the complete answer but here's what I could find.

    The relevant function getName looks like this:

    /***********************************************************************
    * getName
    * fixme
    * Locking: runtimeLock must be held by the caller
    **********************************************************************/
    static const char *
    getName(struct class_t *cls)
    {
        // fixme hack rwlock_assert_writing(&runtimeLock);
        assert(cls);
    
        if (isRealized(cls)) {
            return cls->data->ro->name;
        } else {
            return ((const struct class_ro_t *)cls->data)->name;
        }
    }
    

    So gdb is complaining that the assertion assert(cls) is failing. Which means that getName somehow gets a NULL pointer as an argument.

    Which is kinda funny, where could we be asking for the name of a NULL class?

    Hope this helps...

    0 讨论(0)
提交回复
热议问题