[PR #12825] Try to silently fall back to a local monarch #29257

Open
opened 2026-01-31 09:33:46 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/12825

State: closed
Merged: Yes


This is a crazy idea Dustin and I had.

we can't repro this at will. But we kinda have an idea of where the deref is. We don't know if the small patch (throw, and try again) will fix it. We're sure that the "just fall back to an isolated monarch" will work. I'd almost rather take a build testing the small patch first, to see if that works

This might seem crazy
in 1.12, isolated monarch. In 1.13, "small patch". In 1.14, we can wait and see

UPDATED DESCRIPTION

From the stack we think that the monarch may be null in an inlined call to _areWeTheKing. So, our really silly solution is two parts:

  • on preview, we're gonna just throw an exception and try it again. All the callers of _createMonarchAndCallbacks catch exceptions here, but they can't catch an A/V (this isn't Java). Hopefully, we should be able to try again until we find ourselves. The worry is that there's something else funky, preventing COM from EVER giving us a monarch. If that's the case, this solution will HANG the terminal on startup.
  • On release, we're just gonna fall back to a in-proc Monarch. This is definitely torn state - this window won't be able to communicate with other windows, but theoretically other windows could communicate with this process (though, they won't be talking with the fallback monarch instance). This is a bigger hammer - it'll definitely prevent us from exploding. but it's torn.

We don't have the runway to test the preview one, then submit the Release one if the Preview one doesn't work. So we're just gonna commit the big hammer to the OS now, and test the small hammer in the preview builds. If the preview version of the fix works, we'll just enable that for all 1.13+ builds, and get rid of the big hammer.

Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/12825 **State:** closed **Merged:** Yes --- This is a crazy idea Dustin and I had. > we can't repro this at will. But we kinda have an idea of where the deref is. We don't know if the small patch (throw, and try again) will fix it. We're sure that the "just fall back to an isolated monarch" will work. I'd almost rather take a build testing the small patch first, to see if that works > This might seem crazy > in 1.12, isolated monarch. In 1.13, "small patch". In 1.14, we can wait and see ### UPDATED DESCRIPTION From the stack we think that the monarch may be null in an inlined call to _areWeTheKing. So, our really silly solution is two parts: * on preview, we're gonna just throw an exception and try it again. All the callers of _createMonarchAndCallbacks catch exceptions here, but they can't catch an A/V (this isn't Java). Hopefully, we should be able to try again until we find ourselves. The worry is that there's something else funky, preventing COM from EVER giving us a monarch. If that's the case, this solution will HANG the terminal on startup. * On release, we're just gonna fall back to a in-proc Monarch. This is definitely torn state - this window won't be able to communicate with other windows, but theoretically other windows could communicate with this process (though, they won't be talking with the fallback monarch instance). This is a bigger hammer - it'll definitely prevent us from exploding. but it's torn. We don't have the runway to test the preview one, then submit the Release one if the Preview one doesn't work. So we're just gonna commit the big hammer to the OS now, and test the small hammer in the preview builds. If the preview version of the fix works, we'll just enable that for all 1.13+ builds, and get rid of the big hammer. ### Checklist * [x] @dhowett double check my velocity flag logic here. Should be always true for Release, and off for Dev, Preview. * [x] closes #12774
claunia added the pull-request label 2026-01-31 09:33:46 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29257