【Mac】Terminal が起動直後にクラッシュ！ウィンドウ復元情報を削除して解決した話

## はじめに

ある日、いつも通りTerminalからAmazon Qを呼び出し、チャットしていたら…

> 「Terminalが突然クラッシュして起動できない！」

という事態に遭遇しました。

再起動してもダメ、なにかのバグか？と思いきや、意外とシンプルな原因＆対処法で解決できたので、備忘録としてQiitaに残しておきます。  
同じ症状で困っている人の助けになれば幸いです！

## 環境

- MacBook Air M3
- macOS Sonoma 14.4.1

## エラー
```
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Terminal [1024]
Path:                  /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
Identifier:            com.apple.Terminal
Version:               2.14 (453)
Build Info:            Terminal-453000000000000~569
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2025-06-08 00:50:23.1925 +0900
OS Version:            macOS 14.4.1 (23E224)
Report Version:        12
Anonymous UUID:        4A9E9716-D344-F0A7-8771-7DAA9A04AE39


Time Awake Since Boot: 190 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00005fffffffffff
Exception Codes:       0x0000000000000001, 0x00005fffffffffff

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [1024]

VM Region Info: 0x5fffffffffff is not in any region.  Bytes after previous region: 105072079929344  Bytes before following region: 1
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)        1000000000-7000000000   [384.0G] ---/--- SM=NUL  reserved VM address space (unallocated)
--->  GAP OF 0x5f9000000000 BYTES
      MALLOC_NANO              600000000000-600020000000 [512.0M] rw-/rwx SM=PRV  

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_platform.dylib      	       0x18f59f3c0 _platform_memmove + 544
1   Terminal                      	       0x1009237e8 0x100900000 + 145384
2   Terminal                      	       0x1009236dc 0x100900000 + 145116
3   Terminal                      	       0x10092c2e0 0x100900000 + 180960
4   Terminal                      	       0x10092c1d4 0x100900000 + 180692
5   Terminal                      	       0x100944b88 0x100900000 + 281480
6   Terminal                      	       0x1009436b4 0x100900000 + 276148
7   AppKit                        	       0x192eabe24 -[NSApplication(NSPersistentUIRestorationSupport) restoreWindowWithIdentifier:state:completionHandler:] + 368
8   AppKit                        	       0x192eab700 -[NSApplication(NSPersistentUIRestorationSupport) _restoreWindowWithRestoration:completionHandler:] + 604
9   AppKit                        	       0x193c4dca8 -[NSPersistentUIRestorer restoreStateFromRecords:usingDelegate:requireSecureCoding:completionHandler:] + 1608
10  AppKit                        	       0x193609914 -[NSPersistentUIManager restoreAllPersistentStateWithFullFidelity:completionHandler:] + 588
11  AppKit                        	       0x1932e7bc4 -[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:withFullFidelity:completionHandler:] + 396
12  AppKit                        	       0x192eaa66c -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 496
13  AppKit                        	       0x192eaa270 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 492
14  Foundation                    	       0x190755914 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 316
15  Foundation                    	       0x190755708 _NSAppleEventManagerGenericHandler + 80
16  AE                            	       0x1966669c4 0x19665b000 + 47556
17  AE                            	       0x1966662ec 0x19665b000 + 45804
18  AE                            	       0x19665f8a8 aeProcessAppleEvent + 488
19  HIToolbox                     	       0x199df6e90 AEProcessAppleEvent + 68
20  AppKit                        	       0x192ea4c7c _DPSNextEvent + 1440
21  AppKit                        	       0x193696dec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
22  AppKit                        	       0x192e97cb8 -[NSApplication run] + 476
23  AppKit                        	       0x192e6ef54 NSApplicationMain + 880
24  dyld                          	       0x18f1e60e0 start + 2360

Thread 1:
0   libsystem_pthread.dylib       	       0x18f569d20 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	       0x18f569d20 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x18f569d20 start_wqthread + 0

Thread 4:: com.apple.terminal.low-disk-space-handler
0   libsystem_kernel.dylib        	       0x18f534340 kevent + 8
1   Terminal                      	       0x100905a04 0x100900000 + 23044
2   Foundation                    	       0x190778520 __NSThread__start__ + 716
3   libsystem_pthread.dylib       	       0x18f56ef94 _pthread_start + 136
4   libsystem_pthread.dylib       	       0x18f569d34 thread_start + 8

Thread 5:
0   libsystem_pthread.dylib       	       0x18f569d20 start_wqthread + 0

Thread 6:: com.apple.terminal.sigchld-handler
0   libsystem_kernel.dylib        	       0x18f52edb4 read + 8
1   Terminal                      	       0x10090da98 0x100900000 + 55960
2   Foundation                    	       0x190778520 __NSThread__start__ + 716
3   libsystem_pthread.dylib       	       0x18f56ef94 _pthread_start + 136
4   libsystem_pthread.dylib       	       0x18f569d34 thread_start + 8

Thread 7:: com.apple.terminal.tty-io
0   libsystem_kernel.dylib        	       0x18f539358 __select + 8
1   Terminal                      	       0x10090eb58 0x100900000 + 60248
2   Foundation                    	       0x190778520 __NSThread__start__ + 716
3   libsystem_pthread.dylib       	       0x18f56ef94 _pthread_start + 136
4   libsystem_pthread.dylib       	       0x18f569d34 thread_start + 8


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000060000190f214   x1: 0x000060000000001f   x2: 0xfffffffffe6f0dec   x3: 0x0000600000000020
    x4: 0x000060000190f212   x5: 0x0000000000000012   x6: 0x0000000000000002   x7: 0x0000000000000003
    x8: 0xfffffffffffffffe   x9: 0x0000000000000001  x10: 0x000060000190f210  x11: 0x0000000000000001
   x12: 0x0000000000000001  x13: 0x0000000000000001  x14: 0x0000000000000001  x15: 0x0000600000f353e0
   x16: 0x260100018f59f1a0  x17: 0x00000001009c4690  x18: 0x0000000000000000  x19: 0x0000000000000003
   x20: 0x000060000257f600  x21: 0x0000000000000001  x22: 0x000060000080ee70  x23: 0x000000016f4fe2d0
   x24: 0x0000000000000002  x25: 0x0000000000000001  x26: 0x0000000000000001  x27: 0x0000600000f34720
   x28: 0x0000000000000017   fp: 0x000000016f4fe240   lr: 0x00000001009237e8
    sp: 0x000000016f4fe220   pc: 0x000000018f59f3c0 cpsr: 0xa0001000
   far: 0x00005fffffffffff  esr: 0x92000005 (Data Abort) byte read Translation fault

Binary Images:
       0x100cf4000 -        0x100cfffff libobjc-trampolines.dylib (*) <e8a1b184-0349-3c61-a119-6543eb038317> /usr/lib/libobjc-trampolines.dylib
       0x100900000 -        0x1009c3fff com.apple.Terminal (2.14) <73d4892b-cea7-333a-8cc0-e6ffb1a2e655> /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
       0x18f59b000 -        0x18f5a2fe7 libsystem_platform.dylib (*) <031f3e8c-5227-3138-a444-68174c1c28cf> /usr/lib/system/libsystem_platform.dylib
       0x192e6a000 -        0x1941a6fff com.apple.AppKit (6.9) <8b85317d-d56a-3370-8b78-da6c1d0fb53c> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x190724000 -        0x191381fff com.apple.Foundation (6.9) <1b93a4d2-db73-3f3b-a726-c8eacc5128e0> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x19665b000 -        0x1966ceff7 com.apple.AE (944) <1885b57c-7ef6-3921-ba18-0de48c174133> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
       0x199db4000 -        0x19a077fff com.apple.HIToolbox (2.1.1) <c315e2a3-3fd1-3a2b-b205-b8b492b0f506> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
       0x18f1e0000 -        0x18f2689db dyld (*) <f6dd3ec2-85a4-3ab1-8486-b189cd980ebe> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x18f568000 -        0x18f574fff libsystem_pthread.dylib (*) <45239f06-cc53-36d0-9933-7776ac7ea2fa> /usr/lib/system/libsystem_pthread.dylib
       0x18f52d000 -        0x18f567ffb libsystem_kernel.dylib (*) <2a91fd2c-4cef-3211-a025-7a1c0a8c2db5> /usr/lib/system/libsystem_kernel.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=833.8M resident=0K(0%) swapped_out_or_unallocated=833.8M(100%)
Writable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               128K        1 
Activity Tracing                   256K        1 
CG image                           544K        2 
ColorSync                          576K       27 
CoreAnimation                      448K       28 
CoreGraphics                        32K        2 
CoreServices                        32K        1 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                             1.1G       44 
MALLOC guard page                  192K       12 
STACK GUARD                       56.1M        8 
Stack                             11.7M        8 
VM_ALLOCATE                        112K        7 
__AUTH                             968K      212 
__AUTH_CONST                      16.1M      377 
__CTF                               824        1 
__DATA                            3898K      364 
__DATA_CONST                      18.6M      380 
__DATA_DIRTY                       921K      115 
__FONT_DATA                          4K        1 
__LINKEDIT                       525.5M        3 
__OBJC_RO                         71.7M        1 
__OBJC_RW                         2195K        1 
__TEXT                           308.4M      395 
dyld private memory                272K        1 
mapped file                      199.6M       56 
shared memory                      848K       13 
===========                     =======  ======= 
TOTAL                              2.3G     2063 
```

## 原因：Terminalの「復元情報」が壊れていた

Terminalには、前回開いていたウィンドウの状態を記憶して「自動復元」する機能があります。  
しかしこの復元データが破損してしまうと、起動時にクラッシュすることがあります。
自動復元機能はOFFにすることもできますが、私の場合はONにしていました。


## 対処法：ウィンドウ復元情報のリセット

以下の手順で、Terminal の復元データを削除することで解決しました。

### 手順

1. Finder を開く  
2. メニューバーから「移動」>「フォルダへ移動...」を選択  
3. 以下のパスを入力して Enter：
   ```
   ~/Library/Saved Application State/com.apple.Terminal.savedState
   ```
4. 開いたフォルダ内のファイルをすべて削除  
   ※ このとき **Terminal は終了しておくこと！**
5. Terminal を再起動

## 結果

無事にTerminalが起動するようになりました！  
復元情報が原因とは気付きにくいですが、Macでは意外とよくあるようです。