2016-11-03 13 views
1

私はobjective-cレルムに新しく、EXC_BAD_ACCESSに遭遇しています。私はstackoverflowに多くのフォーラムと関連コンテンツがあることを知っています - しかし、私はまだ私のクラッシュのソースを見つけることができませんでした。EXC_BAD_ACCESS-Objective-C-Xcode 8.0のデバッグ

ゲームにコードがあり、レベルを終了して借りたときにアプリがクラッシュします。ここで私がしようとする競争、クラッシュの原因と表示されるコンテンツの場所に位置している手順は次のとおりです。

画像1: ここenter image description here

はそれぞれ、関連するメッセージです:

画像2 : enter image description here

画像3: enter image description here

画像4: enter image description here

画像5: enter image description here

画像6: enter image description here

私は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

EDIT: 私は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 
+1

2番目のイメージでは、リリースを一番上に移動し、それを 'nil'に設定します。あなたは 'BaseViewController'ヘッダファイルを表示できますか?コードを理解するのは難しいです。 –

+0

ご意見ありがとうございます - 私はコードが読みにくいことを理解しています - BaseViewControllerの内容を追加しました - あなたの提案は、 'dealloc'を一番上に移動して' nil'に設定することです。 - それが役に立ったらコードを送ることもできます。 – RDizzl3

+0

'dealloc'は最後の呼び出しでなければなりません。 'release'メソッド呼び出しを' nil'に設定してから 'dealloc'を呼び出す必要があります。同時に、適切でない 'superClassDelegate'をリリースする必要があります。あなたは 'delegate'を定義する方法をチェックする必要があります。 –

答えて

2

私はObjective-Cのレルム

に新しいです

Objective-Cへようこそ。ここであなたが今まで買ってあげる最高のアドバイスです:

使用ARCは!!!

本当に。コンパイラは、のほうがメモリ管理について多くのことをあなたよりも多く知っています()。 ARCを使用して、それらの保持、リリース、およびdeallocをすべて失います。今やれ。

+1

Objective-Cをスキップして、Swiftを習得してください。しかし、私はそれを主張しません。あなたはObjective-Cに固執したいと思います。しかし、私はあなたがARCを使用することを主張します。 – matt

1

@ New16によると、変数はnilに設定する前に解放する必要があります。

私があなたの場合は、BaseViewControllerUILabelと表示されます。

2

物事の下に一度確認してください: -

  1. 選択はフェーズを構築するターゲットに行く
  2. 選択ソースをコンパイル
  3. ファイル/クラス名を選択し
  4. コンパイラフラグを上
  5. ダブルクリック

ボックスに1語入力-fno-objc-arc

-fno-objc-arcを一度クリーニングした後に&アプリケーションをビルドします。

関連する問題