簡體   English   中英

調試EXC_BAD_ACCESS-Objective-C-Xcode 8.0

[英]Debugging a EXC_BAD_ACCESS - Objective-C - Xcode 8.0

我是Objective-C領域的新手,遇到EXC_BAD_ACCESS。 我知道在stackoverflow上有很多論壇和相關內容-但是我仍然無法找到崩潰源。

我有游戲代碼,退出關卡和承租人時,應用崩潰。 這是我經過努力嘗試的步驟,可以找到崩潰的源以及顯示的內容:

圖片1 在此處輸入圖片說明

以下分別是相關的消息:

圖片2: 在此處輸入圖片說明

圖片3: 在此處輸入圖片說明

圖片4: 在此處輸入圖片說明

圖片5: 在此處輸入圖片說明

圖片6: 在此處輸入圖片說明

我已啟用NSZombies並在應用程序崩潰時獲取此日志:

Journey[76657:4493989] *** -[UILabel isKindOfClass:]: message sent to deallocated instance 0x60030b4d0d80. 

我查過這類錯誤,但仍不確定如何閱讀。 接下來我嘗試了:

(lldb) command script import lldb.macosx.heap
"malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help.
(lldb) malloc_info --stack-history 0x60030b4d0d80

我讀到這將幫助我確定代碼中可能發生崩潰的確切行,但是輸出似乎與我的代碼不匹配:

2016-11-02 19:47:47.338190 Casino Journey[76657:4498737] [] nw_socket_handle_socket_event Event mask: 0x4
2016-11-02 19:47:47.339741 Casino Journey[76657:4494204] [] tcp_connection_cancel 17
2016-11-02 19:47:47.346972 Casino Journey[76657:4498737] [] nw_socket_handle_socket_event Socket received WRITE_CLOSE event
2016-11-02 19:47:47.351492 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17 live.chartboost.com:443 ready resolver (satisfied)]
2016-11-02 19:47:47.358787 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.1 54.236.125.98:443 ready socket-flow (satisfied)]
2016-11-02 19:47:47.366406 Casino Journey[76657:4498737] [] __nw_socket_service_writes_block_invoke sendmsg(fd 13, 31 bytes): socket has been closed
2016-11-02 19:47:47.370392 Casino Journey[76657:4498737] [] nw_endpoint_flow_protocol_error [17.1 54.236.125.98:443 cancelled socket-flow (null)] Socket protocol sent error: [32] Broken pipe
2016-11-02 19:47:47.373586 Casino Journey[76657:4498737] [] nw_endpoint_flow_protocol_disconnected [17.1 54.236.125.98:443 cancelled socket-flow (null)] Output protocol disconnected
2016-11-02 19:47:47.376552 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.2 107.23.51.227:443 initial path (null)]
2016-11-02 19:47:47.380708 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.3 54.85.200.4:443 initial path (null)]
2016-11-02 19:47:47.383242 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.4 54.86.68.178:443 initial path (null)]
2016-11-02 19:47:47.385251 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.5 54.85.112.211:443 initial path (null)]
2016-11-02 19:47:47.387182 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.6 107.23.150.89:443 initial path (null)]
2016-11-02 19:47:47.388414 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.7 107.21.6.246:443 initial path (null)]
2016-11-02 19:47:47.389678 Casino Journey[76657:4498737] [] nw_endpoint_handler_cancel [17.8 54.210.97.43:443 initial path (null)]
2016-11-02 19:47:47.394671 Casino Journey[76657:4498737] [] nw_resolver_cancel_on_queue 0x6005eb89df70
2016-11-02 19:47:47.399258 Casino Journey[76657:4498737] [] -[NWConcrete_tcp_connection dealloc] 17
GuardMalloc[Casino Journey-76657]: Attempting excessively large memory allocation:  268435456 bytes
GuardMalloc[Casino Journey-76657]: If you really wanted to allocate so much memory, launch your executable with the environment variable MALLOC_PERMIT_INSANE_REQUESTS set to any value to circumvent this check.
GuardMalloc[Casino Journey-76657]: Explicitly trapping into debugger!!!
0x000060030b4d0d80: malloc(   640) -> 0x60030b4d0d80 _NSZombie_UILabel
error: expression failed "
typedef int kern_return_t;
typedef unsigned task_t;
#define MAX_FRAMES 128
#define MAX_HISTORY 16
typedef struct mach_stack_logging_record_t {
    uint32_t type_flags;
    uint64_t stack_identifier;
    uint64_t argument;
    uint64_t address;
} mach_stack_logging_record_t;
typedef void (*enumerate_callback_t)(mach_stack_logging_record_t, void *);
typedef struct malloc_stack_entry {
    uint64_t address;
    uint64_t argument;
    uint32_t type_flags;
    uint32_t num_frames;
    uint64_t frames[MAX_FRAMES];
    kern_return_t frames_err;    
} malloc_stack_entry;
typedef struct $malloc_stack_history {
    task_t task;
    unsigned idx;
    malloc_stack_entry entries[MAX_HISTORY];
} $malloc_stack_history;
$malloc_stack_history info = { (task_t)mach_task_self(), 0 };
uint32_t max_stack_frames = MAX_FRAMES;
enumerate_callback_t callback = [] (mach_stack_logging_record_t stack_record, void *baton) -> void {
    $malloc_stack_history *info = ($malloc_stack_history *)baton;
    if (info->idx < MAX_HISTORY) {
        malloc_stack_entry *stack_entry = &(info->entries[info->idx]);
        stack_entry->address = stack_record.address;
        stack_entry->type_flags = stack_record.type_flags;
        stack_entry->argument = stack_record.argument;
        stack_entry->num_frames = 0;
        stack_entry->frames[0] = 0;
        stack_entry->frames_err = (kern_return_t)__mach_stack_logging_frames_for_uniqued_stack (
            info->task, 
            stack_record.stack_identifier,
            stack_entry->frames,
            (uint32_t)MAX_FRAMES,
            &stack_entry->num_frames);
        // Terminate the frames with zero if there is room
        if (stack_entry->num_frames < MAX_FRAMES)
            stack_entry->frames[stack_entry->num_frames] = 0; 
    }
    ++info->idx;
};
(kern_return_t)__mach_stack_logging_enumerate_records (info.task, (uint64_t)0x60030b4d0d80, callback, &info);
info" => error: error: Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0).
The process has been returned to the state before expression evaluation.

如果有人可以幫助我確定此錯誤的可能原因,我將不勝感激! 嘗試調試此類錯誤時,通常會有任何幫助或注釋。

我也在使用xcode的最新版本:8.0版

編輯:我正在添加BaseViewController的代碼-我的確知道這可能很難閱讀並且很復雜,實際代碼中有很多文件:

//
//
//

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
#import "PHPublisherContentRequest.h"
#import <Foundation/Foundation.h>
#import "PHAPIRequest.h"
#import "PHContentView.h"
#import "AppController.h"
#import "Define.h"

@interface BaseViewController : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver, PHAPIRequestDelegate, PHPublisherContentRequestDelegate> {

    IBOutlet UIActivityIndicatorView *activityIndicator;
    BaseViewController *superClassDelegate;
}

- (void)exitIAP;
-(void) buyProductWithIdentifier:(NSString *) productIdentifier;
-(void) sendVgpCallToPlayHavenForPlacement:(NSString *) placementTag;


@end

我是Objective-C領域的新手

歡迎使用Objective-C。 這是您將獲得的最佳建議:

使用弧!

真。 編譯器知道更多關於內存管理比你做的。 使用ARC並丟失所有這些保留,釋放和取消分配。 現在做。

請檢查以下事項:-

  1. 前往目標
  2. 選擇構建階段
  3. 選擇編譯源
  4. 選擇您的文件/類名
  5. 雙擊編譯器標志

-fno-objc-arc框中輸入一個單詞

輸入-fno-objc-arc之后,請清理並構建您的應用程序。

正如@ New16所說,變量應在設置為nil之前釋放。

如果我是你,我將在BaseViewController查看UILabel

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM