线程1 Sigabrt错误xcode

时间:2015-11-09 00:08:15

标签: ios objective-c lldb sigabrt

我有一个应用程序,显示一个RSSI和一些来自灯塔的东西。众所周知,用户可以通过在每秒更新的tableView(非常快)中显示RSSI来看到RSSI。在tableView中我调用了一个正在做一些事情的类。该类正在计算,计算需要几秒钟。我得到的错误是lldb。当我键入bt我得到这些信息。

* thread #1: time = 0x3d0fd, 0x0000000197c07140 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x0000000197c07140 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000197cd0ef8 libsystem_pthread.dylib`pthread_kill + 112
    frame #2: 0x0000000197b7ac18 libsystem_c.dylib`__abort + 148
    frame #3: 0x0000000197b7b494 libsystem_c.dylib`__stack_chk_fail + 224
  * frame #4: 0x00000001000eae98 ssProject`-[myClass ft:::](self=0x000000014e9320f0, _cmd="ft:::", size=2048, startRing=0, ringArray=@"2837 objects") + 1380 at myClass:173
    frame #5: 0x00000001000eb4ec ssProject `-[myClass cl::](self=0x000000014e9320f0, _cmd="cl::", allR=@"514 objects", allT=@"514 objects") + 1620 at myClass:260
    frame #6: 0x00000001000e2034 ssProject `-[TagViewController tableView:cellForRowAtIndexPath:](self=@"0 objects", _cmd="tableView:cellForRowAtIndexPath:", tableView=0x0000000148828c00, indexPath=0xc000000000000016) + 1624 at TagViewController.m:184
    frame #7: 0x00000001880ba20c UIKit`-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 688
    frame #8: 0x00000001880ba364 UIKit`-[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
    frame #9: 0x00000001880a97b8 UIKit`-[UITableView _updateVisibleCellsNow:isRecursive:] + 2440
    frame #10: 0x00000001880bef0c UIKit`-[UITableView _performWithCachedTraitCollection:] + 104
    frame #11: 0x0000000187e5722c UIKit`-[UITableView layoutSubviews] + 176
    frame #12: 0x0000000187d677ac UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 644
    frame #13: 0x0000000187566b58 QuartzCore`-[CALayer layoutSublayers] + 148
    frame #14: 0x0000000187561764 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 292
    frame #15: 0x0000000187561624 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
    frame #16: 0x0000000187560cc0 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 252
    frame #17: 0x0000000187560a08 QuartzCore`CA::Transaction::commit() + 512
    frame #18: 0x000000018755a0f8 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
    frame #19: 0x000000018278fbd0 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
    frame #20: 0x000000018278d974 CoreFoundation`__CFRunLoopDoObservers + 372
    frame #21: 0x000000018278dda4 CoreFoundation`__CFRunLoopRun + 928
    frame #22: 0x00000001826bcca0 CoreFoundation`CFRunLoopRunSpecific + 384
    frame #23: 0x000000018d8f8088 GraphicsServices`GSEventRunModal + 180
    frame #24: 0x0000000187dd4ffc UIKit`UIApplicationMain + 204
    frame #25: 0x00000001000e9680 swimsimulator`main(argc=1, argv=0x000000016fd27ae8) + 116 at main.m:14
    frame #26: 0x0000000197aea8b8 libdyld.dylib`start + 4

我希望你们中的任何人能帮助我解决这个问题。

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Tag"];

        AXABeacon *beacon = [[AXABeacon alloc] init];
        beacon = [self.bleDevices objectAtIndex:indexPath.row];

        //Definerar veriabler
        UILabel *titleLabel = (UILabel *)[cell viewWithTag:1];
        UILabel *uuidLabel = (UILabel *)[cell viewWithTag:2];
        UILabel *rssiLabel = (UILabel *)[cell viewWithTag:3];
        UILabel *majorLabel = (UILabel *)[cell viewWithTag:4];
        UILabel *minorLabel = (UILabel *)[cell viewWithTag:5];
        UILabel *statusLabel = (UILabel *)[cell viewWithTag:6];
        UILabel *lastLap = (UILabel *)[cell viewWithTag:7];
        UILabel *lastTime = (UILabel *)[cell viewWithTag:8];

        //Ger variabler ett värde
        titleLabel.text = [NSString stringWithFormat:@"%@", beacon.name];
        uuidLabel.text = [NSString stringWithFormat:@"%@", beacon.uuidString];
        rssiLabel.text = [NSString stringWithFormat:@"RSSI: %@", [beacon.rssi stringValue]];
        minorLabel.text = [NSString stringWithFormat:@"Minor: %@", beacon.minor];
        majorLabel.text = [NSString stringWithFormat:@"Major: %@", beacon.major];

        NSString *fileNameWithDate = [NSString stringWithFormat:@"%@%d.csv", beacon.uuidString, self.randNum];
        NSMutableArray *allRssis = [self getDataInArray: @"rssi":fileNameWithDate];
        NSMutableArray *allTimes2 = [self getDataInArray: @"time":fileNameWithDate];

        NSInteger bitar = 257;
        NSInteger raknBitar = bitar * self.delayCount;

        if(allRssis.count >= raknBitar){
            self.checkAlgo = true;
            NSLog(@"Här kör vi igen");
            if (self.checkAlgo == true) {
                myClass *newObject;
                newObject = [[myClass alloc] init];
                self.checkAlgo = false;
                self.delayCount = self.delayCount + 1;
                NSLog(@"%@", [newObject cl:allR :allT]);
 [result objectAtIndex:0]];
                //lastTime.text = [NSString stringWithFormat:@"Tiden (Senaste): %@", [result objectAtIndex:1]];
            }
        } else {
            NSLog(@"Antal rader: %lu", (unsigned long)allTimes2.count);
        }

        if(self.startClicked)
        {
            statusLabel.text = [NSString stringWithFormat:@"Status: Lagrar data"];
        }
        else
        {
            statusLabel.text = [NSString stringWithFormat:@"Status:"];
        }
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        //Anpassar text till storlek av box
        uuidLabel.adjustsFontSizeToFitWidth = YES;
        titleLabel.adjustsFontSizeToFitWidth = YES;

        return cell;
    }

1 个答案:

答案 0 :(得分:1)

你使用stack_chk_fail失败意味着你要覆盖堆栈中的某个变量。这种方式的工作方式是编译器在调用开始时在堆栈中插入一个保护字,当你从调用中返回时,它会检查该字是否仍然具有给定的值。它没有,所以堆栈保护机制强制中止。

对于这种事情,Address Sanitizer(ASAN)是一个很好的工具。您可以在项目的“运行方案”的“诊断”选项卡中将其打开。然后你必须进行重建才能使用它 - 所以错误必须在你拥有的代码中。但是如果你可以使用它,那么在发生这些错误时就能很好地捕获这些错误,这使得诊断比以后捕获错误的一些副作用更容易。