【问题标题】:Thread 1 Sigabrt error xcode线程 1 Sigabrt 错误 xcode
【发布时间】:2015-11-09 00:08:15
【问题描述】:

我有一个应用程序,它显示了 RSSI 和来自 Beacon 的一些其他内容。众所周知,RSSI 通过在每秒更新的 tableView 中显示它对用户可见(非常快)。在 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;
    }

【问题讨论】:

  • 更新表格视图的速度比显示器的刷新率 (60 Hz) 快是没有意义的
  • 你能用你得到sigabrt的代码更新你的帖子吗?
  • 我已将代码添加到问题@Chris
  • sigabrt 发生在哪里?

标签: ios objective-c lldb sigabrt


【解决方案1】:

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

对于这类事情,Address Sanitizer (ASAN) 是一个很好的工具。您可以在项目的 Run Scheme 的 Diagnostics 选项卡中打开它。然后你必须进行重建才能使用它 - 所以错误必须在你拥有的代码中。但是如果你可以使用它,它非常擅长在这些错误发生时捕捉它们,这使得诊断比稍后捕捉错误的一些副作用要容易得多。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多