プロセスの起動に失敗の対応 - #2548
Merged
Merged
Conversation
|
Contributor
This was referenced Jul 24, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




新しいウィンドウを開くと「プロセスの起動に失敗しました」が表示される不具合を修正
PR 対象
アプリ(サクラエディタ本体)
カテゴリ
不具合修正
関連 issue / PR
PR の背景
タブバーを表示し「ウィンドウをまとめて表示」を有効にしている環境で、既存のエディタから「新しいウィンドウを開く」を実行すると、新しいウィンドウ自体は開くにもかかわらず、操作から約15秒後に「プロセスの起動に失敗しました。」のエラーダイアログが表示される。
WaitForMultipleObjectsの戻り値は 258(WAIT_TIMEOUT)本症状は #2545 にて報告されている。当初
CControlTray::OpenNewEditorのCREATE_SUSPENDED順序不整合が原因と推測したが、PR #2546 で修正された内容を適用しても症状が再発することを確認。以下、実測に基づく原因解析と修正内容です。
原因
CEditWnd::_AdjustInMonitor(sakura_core/window/CEditWnd.cpp)内で、他プロセスのウィンドウに対して同期版ShowWindowを呼び出している箇所が真の原因である。デッドロックのメカニズム
CControlTray::OpenNewEditor内で子プロセスを起動後、WaitForMultipleObjects(hEvent, hProcess, 15000)に入る。この時点で親の UI スレッドはメッセージポンプを停止して待機しているCEditWnd::_AdjustInMonitorにてsTabGroupInfo.hwndTop(= タブグループの現在の先頭ウィンドウ = 親エディタのウィンドウ)に対し::ShowWindow(hwndTop, SW_HIDE)を発行するShowWindowは内部で cross-threadSendMessage(WM_SHOWWINDOW)として処理され、受信側スレッドが WndProc から return するまで送信元を無期限ブロックするWaitForMultipleObjectsがタイムアウト(戻り値 258)し、「プロセスの起動に失敗しました。」を表示。親がポンプ再開後、子のShowWindowがようやく戻り、子は残りの初期化を完走してウィンドウが可視化されるこれで観測されているすべての現象(操作の約15秒後にエラー・ウィンドウは開く・子は exit 0・タブまとめ設定時のみ発生・タイミング依存)が矛盾なく説明できる。
診断根拠
wWinMain → CProcess::Run → CNormalProcess::InitializeProcess → CEditApp::Create → CEditWnd::Create → CEditWnd::_AdjustInMonitor → win32u syscallxxxSendNotifyMessage/xxxWindowEvent/Wow64KiUserCallbackDispatcherが並び、cross-thread メッセージ配信待ちであることと整合ShowWindowAsyncへ置換したビルドで症状が再発しないことを確認修正内容
::ShowWindowを::ShowWindowAsyncへ変更する。ShowWindowAsyncは内部的にPostMessage(WM_SHOWWINDOW)相当の実装で、受信側の応答を待たずに即座にリターンする。これにより送信元(子)は同期待機しなくなり、デッドロックが解消。変更対象ファイル
sakura_core/window/CEditWnd.cppのCEditWnd::_AdjustInMonitor仕様・動作説明
修正前後の動作比較
ShowWindow)ShowWindowAsync)WaitForMultipleObjects(15秒)でメッセージポンプ停止::ShowWindow(hwndTop, SW_HIDE)::ShowWindowAsync(hwndTop, SW_HIDE)SendMessage(WM_SHOWWINDOW)。親の WndProc 応答まで送信元を無期限ブロックPostMessage(WM_SHOWWINDOW)。親のキューに積むだけで即座にリターンInitializeProcessのスコープ終了時に初期化完了イベントをシグナルユーザーから見える結果
PR の影響範囲
CEditWnd::_AdjustInMonitor内の1行のみsTabGroupInfo.hwndTopが有効、の条件下でのみ通る箇所。それ以外の起動経路(初回起動・タブ分離設定・タブバー非表示設定)には影響しないテスト内容
以下を修正ビルドで確認済み。