- [NSRecursiveLock dealloc]:锁定理解堆栈跟踪和ios调试

时间:2014-01-15 21:46:28

标签: ios objective-c xcode stack-trace

我的代码中出现以下错误,但很难找到原因。

-[NSRecursiveLock dealloc]: lock (<NSRecursiveLock: 0x1e559730> '(null)') deallocated while still in use
Break on _NSLockError() to debug.

所以,我在NSLock Error上设置了一个断点。这是堆栈跟踪。

frame #0: 0x327e5288 Foundation`_NSLockError
frame #1: 0x327e6258 Foundation`-[NSRecursiveLock dealloc] + 108
frame #2: 0x327478ba ExternalAccessory`-[EAInputStream dealloc] + 122
frame #3: 0x32748420 ExternalAccessory`-[EAInputStream _streamEventTrigger] + 448
frame #4: 0x31ebf682 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #5: 0x31ebeee8 CoreFoundation`__CFRunLoopDoSources0 + 212
frame #6: 0x31ebdcb6 CoreFoundation`__CFRunLoopRun + 646
frame #7: 0x31e30ebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #8: 0x31e30d48 CoreFoundation`CFRunLoopRunInMode + 104
frame #9: 0x359e32ea GraphicsServices`GSEventRunModal + 74
frame #10: 0x33d46300 UIKit`UIApplicationMain + 1120
frame #11: 0x0009e93e Checkout`main(argc=1, argv=0x2fd6ad20) + 174 at main.mm:15
frame #12: 0x39fa1b20 libdyld.dylib`start + 4

NSRecursiveLock Deallocated是一个类似的帖子,他在那里解决了他更新Xcode的问题,但这对我来说不起作用=(。我在90%的时间内得到此错误,10%正常工作

我在VC中的.h文件有问题......

#import <UIKit/UIKit.h>
#import "SignalR.h"
#import "ClientInterface.h"

@class POS;
@interface SignalRVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>

@property (nonatomic, strong) NSString *stringFromScan;

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSMutableArray *data;
@property (weak, nonatomic) IBOutlet UILabel *errorLabel;

@property (strong, nonatomic, readwrite) SRHubConnection *connection;
@property (strong, nonatomic, readwrite) SRHubProxy *hub;
@property (strong, nonatomic) UIBarButtonItem *backBarButton;
@property (nonatomic, strong) NSMutableArray *registeredUpcs;
-(void)initConnection;

@end

我的.m文件在崩溃之前通过viewDidLoad ...

@interface SignalRVC ()
@property (strong,nonatomic) POS *myPOS;

@property (nonatomic, strong) NSString *qrLocation;
@property (nonatomic, strong) NSString *qrStation;
@property (nonatomic, strong) NSString *RPHost;
@property (nonatomic, strong) NSString *RPPort;

@property (nonatomic, strong) NSString *registeredUpc;
@property (nonatomic, strong) NSString *thumbnail;
@property (nonatomic, strong) NSString *productName;
@property (nonatomic, strong) NSString *color;
@property (nonatomic, strong) NSString *alu;
@property (nonatomic, strong) NSString *size;
@property (nonatomic, strong) NSString *upc;
@property (nonatomic, strong) NSDictionary *itemSpecs;

@property (weak, nonatomic) IBOutlet UIButton *checkoutButton;
@property (weak, nonatomic) IBOutlet UILabel *employeeLabel;

@end

@implementation SignalRVC

-(void)viewWillDisappear:(BOOL)animated{
    [_myPOS closeConnection];
    self.navigationController.toolbarHidden = YES;
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;

    NSData *dataFromQR = [self.stringFromScan dataUsingEncoding:NSUTF8StringEncoding];

    NSDictionary *jsonQR = [NSJSONSerialization JSONObjectWithData:dataFromQR options:NSJSONReadingMutableContainers error:nil];

    self.qrLocation = [jsonQR valueForKey:@"loc"];
    self.qrStation = [jsonQR valueForKey:@"id"];
    self.host = [jsonQR valueForKey:@"host"];
    self.port = [jsonQR valueForKey:@"port"];
}
- (void)viewDidLoad{
    [super viewDidLoad];

    //self.tableView.layer.cornerRadius = 10;

    if(!_myPOS){
        _myPOS = [[POS alloc] init];
    }
    _myPOS.mySignalRVC = self;

}

什么是堆栈跟踪告诉我,我该怎样做才能更好地理解问题?

唯一具有NSRecursiveLock类的地方是AFJSONRequestOperation.m和AFURLConnectionOperation.m文件,作为SignalR的一部分包含在内,但断点永远不会在这些类中被触发......

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

从堆栈跟踪中看起来EAInputStream类型的对象拥有锁定对象,并且在锁定仍然有效时它将被释放。快速谷歌搜索显示EAInputStream是一个github框架。您是否添加了它,或者它是否与您正在使用的另一个框架一起出现?