标签: exc-bad-access

为什么我的cocoa程序在启动时会获得EXC_BAD_ACCESS?

在加载我的cocoa应用程序期间,我的程序崩溃了一些消息EXC_BAD_ACCESS.堆栈跟踪没有帮助.有关我如何找到问题的任何线索?

macos cocoa exc-bad-access

3
推荐指数
1
解决办法
1万
查看次数

无效时,NSTimer在Iphone上与EXC_BAD_ACCESS崩溃

我在我的应用程序中设置了两个计时器,每隔几秒重复一次.除非是时间使计时器无效,否则一切正常.当手机被锁定时,我想让这些计时器无效,然后在手机解锁时重新创建它们.

我使用通知来实现何时无效/创建计时器.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify_didBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify_willResigneActive:) name:UIApplicationWillResignActiveNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

这是notify_didBecomeActive方法包含的内容:

clockTicker = [[NSTimer scheduledTimerWithTimeInterval: 1  
                                            target: self  
                                          selector: @selector(showActivity)  
                                          userInfo: nil  
                                           repeats: YES] retain];

alarmTicker = [[NSTimer scheduledTimerWithTimeInterval: CONST_ALARMTIMER  
                                               target: self  
                                             selector: @selector(checkAndLaunchAlarm)  
                                             userInfo: nil  
                                              repeats: YES] retain];
Run Code Online (Sandbox Code Playgroud)

这个notify_willResigneActive方法包含:

if (alarmTicker) {
    [alarmTicker invalidate];
    [alarmTicker release];
    alarmTicker = NULL;
}

if (clockTicker) {
    [clockTicker invalidate];
    [clockTicker release];
    clockTicker = NULL;
}
Run Code Online (Sandbox Code Playgroud)

问题是,当我在第二个计时器上调试这个无效时,我得到了错误.奇怪的是,如果我切换定时器的命令(比如首先使clockTicker失效)..我仍然在第二个定时器上得到错误.

我能做错什么?

谢谢,莱昂纳多

iphone exc-bad-access objective-c nstimer ios

3
推荐指数
1
解决办法
6236
查看次数

main.m中的EXC_BAD_ACCESS

突然,我在这一行得到了EXC_BAD_ACCESS:

int retVal = UIApplicationMain(argc, argv, nil, nil);
Run Code Online (Sandbox Code Playgroud)

这是代码:

int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
Run Code Online (Sandbox Code Playgroud)

我甚至不知道从哪里开始看?

有人可以帮忙吗?

iphone exc-bad-access objective-c

3
推荐指数
1
解决办法
2802
查看次数

执行错误访问NSString

individualPercUpdated被称为上UIControlEventEditingDidEndcheckInitialValue被callled上UIControlEventEditingDidBegin.if(!([initialValue isEqualToString:textField.text]))通过发出警告Exec Bad Access,我的程序崩溃了

- (void)viewDidLoad
{
    [super viewDidLoad];
    initialValue=[[NSString alloc] init];
}

-(void) individualPercUpdated:(UITextField *)textField{

    if(initialValue!=nil){
        if(!([initialValue isEqualToString:textField.text])){
            initialValue=textField.text;
            NSLog(@"%@",textField.text);
        }
    }

    else{
        NSLog(@"%@",textField.text);
    }
}

-(void) checkInitialValue:(UITextField *)textField{
        initialValue=textField.text;
    }

}
Run Code Online (Sandbox Code Playgroud)

iphone exc-bad-access nsstring uitextfield ios

3
推荐指数
1
解决办法
1057
查看次数

我根据此崩溃报告在哪里开始查看?

我仍然是崩溃报告分析的新手,可以使用一些帮助来追踪我的问题.这是有问题的报告的一部分.

Incident Identifier: 5D510334-3888-40A6-A7C1-5AE1109BFDD4
CrashReporter Key:   b4cfc1c63d61ef3f17a53e0732f05ad768cad375
Hardware Model:      iPhone4,1
Process:         WxT [1263]
Path:            /var/mobile/Applications/E7B24747-F168-4E23-99F9-89DC23A8531C/WxT.app/WxT
Identifier:      WxT
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-11-07 21:35:25.723 -0600
OS Version:      iOS 6.0.1 (10A523)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000020
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   MapKit                          0x318325d2 _contains(objc_object*, MKQuadTrieNode*) + 10
1   MapKit                          0x318325c0 -[MKQuadTrie contains:] + 20
2   MapKit                          0x3184411c -[MKAnnotationContainerView addAnnotation:] …
Run Code Online (Sandbox Code Playgroud)

exc-bad-access crash-reports ios

3
推荐指数
1
解决办法
1788
查看次数

[NSKeyedUnarchiver unarchiveObjectWithData:]上的EXC_BAD_ACCESS;

我设定赏金后找到了答案.如果有人对我的方法有一些有用的评论(我不知道它是否是'正确的'解决方案)他/她可以获得赏金.如果您打算回答我的问题,请发表评论,以便我可以改进未来的问题.

我目前正在学习Objective-C和本书Cocoa Programming For Mac OS X,它在第10章介绍了归档.I(AFAIK)确实完成了作者要我做的事情,但是当打开一个文件并因此取消归档时,应用程序就崩溃了:

array = [NSKeyedUnarchiver unarchiveObjectWithData:data];
Run Code Online (Sandbox Code Playgroud)

它说GDB received signal: EXC_BAD_ACCESS.我只是在访问一个超出界限的数组插槽时遇到过这种情况,我相信没有这样做.我最好的猜测是,Cocoa场景背后的东西出了问题,间接由我引起.这可能是什么?
正如我所说,我目前正在学习Objective-C(但我知道Java),所以不要指望我知道每一个模糊的语言特性.

文件打开方法(MyDocument.m):

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
    NSMutableArray *array = nil;
    NSLog(@"data is %@", data);

    @try {
        array = [NSKeyedUnarchiver unarchiveObjectWithData:data]; // line of the EXC_BAD_ACCESS
    }
    @catch (NSException * e) {
        if (outError) {
            NSDictionary *d = [NSDictionary dictionaryWithObject:@"The data is corrupted." forKey:NSLocalizedFailureReasonErrorKey];
            *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:d];
        }
        return NO;
    } …
Run Code Online (Sandbox Code Playgroud)

file-io exc-bad-access objective-c

3
推荐指数
1
解决办法
6307
查看次数

尝试从子托管上下文保存到父级时的EXC_BAD_ACCESS

我有一个EXC_BAD_ACCESS杀了我.我看不出它来自哪里.

ARC代码.SymptomRating是一个托管对象,当然:

__block DPLSymptomRating *rating;
self.editMOC = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];  // retained: strong

NSManagedObjectContext *moc = self.editMOC; //editSymptom.managedObjectContext;

[moc performBlockAndWait:^{
    NSError __autoreleasing *error = nil;
    moc.parentContext = DPLPersonalHxDataStore.shared.managedObjectContext;

    rating = [NSEntityDescription insertNewObjectForEntityForName:@"SymptomRating" inManagedObjectContext:moc];
    [moc assignObject:rating toPersistentStore:[NSPersistentStore MR_defaultPersistentStore]];

    rating.ratingCode = @101;
    rating.symptomCode = 1;
    rating.displayName = @"debug";
    NSAssert(rating!=nil, @"Cannot edit nil rating");
    NSAssert(rating.managedObjectContext==moc, @"");
    NSLog(@"validates for insert: %@", [rating validateForInsert:&error]?@"true":@"false");
    NSAssert(error==nil,@"");
    NSLog(@"inserted objects: %@", moc.insertedObjects);    // 1 object, from above
    NSLog(@"updated objects: %@", moc.updatedObjects);      // empty
    NSLog(@"deleted objects: %@", moc.deletedObjects);      // …
Run Code Online (Sandbox Code Playgroud)

exc-bad-access core-data automatic-ref-counting

3
推荐指数
1
解决办法
2594
查看次数

线程1:EXC_BAD_ACCESS(代码= 1,地址= 0xf1759018)

所以我收到了这个错误(如下图所示).当我收到此错误时发生的事情是通过我的核心数据数据库,并根据我收集的电池统计数据平均结果.这工作正常,直到我休息,然后回来,插入它,它开始得到这个错误.我有一个异常断点,但除了图像中的崩溃之外,它仍然没有显示任何其他内容.

谁知道我应该怎么做?

xcode版本5.0

让我知道我是否可以发布任何其他有助于弄清楚导致这种情况的原因!

这是错误

xcode runtime-error exc-bad-access ios

3
推荐指数
1
解决办法
5480
查看次数

NSManagedObject在Swift中实现协议的EXC_BAD_ACCESS错误

我有以下两种方法:

func isAuthenticated() -> Bool {
    var currentUser: CurrentUser? = self.getCurrentUser()

    if currentUser == nil {
        return false
    }

    self.token = getUserToken(currentUser!.username)
    if self.token == nil {
        return false
    }

    if !tokenIsValidForUser(self.token!, user: currentUser!) {
        return false
    }

    return true
}

func tokenIsValidForUser(token: AuthenticationToken, user: UserObject) -> Bool {
    if token.username != user.username {
        return false
    }

    return true
}
Run Code Online (Sandbox Code Playgroud)

当我调用时isAuthenticated(),它在tokenIsValidForUser()with 的第一行失败EXC_BAD_ACCESS,显然是在CurrentUser对象上.

我的理解是,当对象不再存在时,你会遇到这种错误,但我无法理解为什么会出现这种情况.

对象类型CurrentUser声明为:

protocol UserObject {
    var username: String { get set } …
Run Code Online (Sandbox Code Playgroud)

protocols exc-bad-access core-data ios swift

3
推荐指数
1
解决办法
1690
查看次数

C++ sort lambda比较器EXC_BAD_ACCESS

我遇到了这个奇怪的问题,以下代码抛出EXC_BAD_ACCESS错误.

using T = pair<int, bool>;
sort(vp.begin(), vp.end(), [](const T& a, const T& b) {
    return (a.first < b.first) || ((a.first == b.first) && a.second);
});
Run Code Online (Sandbox Code Playgroud)

如果我跑:

using T = pair<int, bool>;
sort(vp.begin(), vp.end(), [](const T& a, const T& b) {
    return (a.first < b.first);
});
Run Code Online (Sandbox Code Playgroud)

有用.如果我减少数据大小,它也可以.我很好奇是什么((a.first == b.first) && a.second)导致了这个错误?完整的数据源代码如下:https://pastebin.com/r7muQhu7

我的环境:

Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Run Code Online (Sandbox Code Playgroud)

c++ lambda exc-bad-access c++11

3
推荐指数
1
解决办法
153
查看次数