1


(1) ビルド フォルダーのクリーニング、
(2) シミュレーターと iPhone からのアプリの削除、
(3) 再起動、 (4) NSZombieEnabled の有効化を試し
ましたが、何もしていないようです。
(5) デバッガ lldb と gdb
(6) と gaurd malloc を使用

私はxcode 4.3.2を持っています。このバグは、シミュレーターと私の iPhone の両方で発生します。(シミュレーターではEXC_BAD_INSTRUCTION code=i386 subcode=0x0、デバイスでは と表示され ます。2 つのクラッシュ ログを次に示しますEXC_BREAKPOINT (SIGTRAP)

http://pastie.org/3941419

http://pastie.org/3941427

ログには次のように出力されます。

Trace/BPT trap: 5
Segmentation fault: 11

クラッシュでわかるように、ViewController へのトレースバックはありません。質問する前にたくさんのグーグル検索を行いましたが(リンク)、このエラーを抱えている他の多くの人(リンク) は、アプリへのトレースバックを持っています。このアプリの一般的な原因は何ですか? どこからバグを探す必要がありますか? 再現するためにできることは1つもありません。コードの一部を10回実行するだけで、少なくとも1回はクラッシュします。ありがとう!

編集:いくつかのコードがあります

outputPipe = [[NSPipe alloc] init];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getDataOut:) name:NSFileHandleReadToEndOfFileCompletionNotification object:[outputPipe fileHandleForReading]];

[[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[outputPipe fileHandleForReading]];

コードの後半で outputPipe をリリースします。

編集 2: [NSPipe パイプ] の変更; [[NSPipe alloc] init] に; 修正しませんでした。

オブザーバーを切り替えるコード:

 buttondone.title=@"Done";
    //dlog(@"last output notification inbound");
    stdoutisdone=YES;

    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadCompletionNotification object:[outputPipe fileHandleForReading]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getDataOut:) name:NSFileHandleReadToEndOfFileCompletionNotification object:[outputPipe fileHandleForReading]];

    [[outputPipe fileHandleForReading] readToEndOfFileInBackgroundAndNotify];
4

1 に答える 1

0

2 番目の NSFileHandle メソッドの呼び出しを削除して解決しました。したがって、これの代わりに:

 [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadCompletionNotification object:[outputPipe fileHandleForReading]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getDataOut:) name:NSFileHandleReadToEndOfFileCompletionNotification object:[outputPipe fileHandleForReading]];

[[outputPipe fileHandleForReading] readToEndOfFileInBackgroundAndNotify];

私はこれを使用します:

NSString * output=[[outputPipe fileHandleForReading] readToEndOfFile];

readInBackgroundAndNotifyタスクの終了後に 1 回または 2 回呼び出すことで、UI の遅延が少し発生します。誰かがより良い解決策を持っている場合、私はあなたのものを答えとしてマークします。

于 2012-05-27T18:32:43.323 に答える