[PR #9618] [MERGED] Add some read and write locks around pattern tree manipulation #27661

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/9618
Author: @DHowett
Created: 3/25/2021
Status: Merged
Merged: 3/26/2021
Merged by: @undefined

Base: mainHead: dev/duhowett/lock


📝 Commits (3)

📊 Changes

1 file changed (+20 additions, -4 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+20 -4)

📄 Description

We have been seeing some crashes (#9410) originating from a
use-after-free or a double-free in the renderer. The renderer is
iterating over the dirty rects from the render engine¹ and the rect list
is being freed out from under it.

Things like this are usually the result of somebody manipulating the
renderer's state outside of lock.

Therefore, this pull request introduces some targeted locking fixes
around manipulation of the pattern buffer (which, in turn, changes the
renderer state.)

¹ This was not a problem until #8621, which made the renderer return a
span instead of a copy for the list of dirty rects.

Validation

I ran Terminal under App Verifier, and introduced a manul delay (under
lock) in the renderer such that the invalid map would definitely have
been invalidated between the renderer taking the lock and the renderer
handling the frame. AppVerif failed us without these locking changes,
and did not do so once they were introduced.

Closes #9410.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/9618 **Author:** [@DHowett](https://github.com/DHowett) **Created:** 3/25/2021 **Status:** ✅ Merged **Merged:** 3/26/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/duhowett/lock` --- ### 📝 Commits (3) - [`71ef2cf`](https://github.com/microsoft/terminal/commit/71ef2cfff682de7281e7f4024e0538974c9cbe07) LOCK IT UP - [`921c248`](https://github.com/microsoft/terminal/commit/921c248cdb45a81910ab68ca4594416e3c4329b6) eh - [`b53c414`](https://github.com/microsoft/terminal/commit/b53c4142927d2623bf48b85c97e76f8af845f031) I CANNOT SPEEL ### 📊 Changes **1 file changed** (+20 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+20 -4) </details> ### 📄 Description We have been seeing some crashes (#9410) originating from a use-after-free or a double-free in the renderer. The renderer is iterating over the dirty rects from the render engine¹ and the rect list is being freed out from under it. Things like this are usually the result of somebody manipulating the renderer's state outside of lock. Therefore, this pull request introduces some targeted locking fixes around manipulation of the pattern buffer (which, in turn, changes the renderer state.) ¹ This was not a problem until #8621, which made the renderer return a span instead of a copy for the list of dirty rects. ## Validation I ran Terminal under App Verifier, and introduced a manul delay (under lock) in the renderer such that the invalid map would definitely have been invalidated between the renderer taking the lock and the renderer handling the frame. AppVerif failed us without these locking changes, and did not do so once they were introduced. Closes #9410. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:23:20 +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#27661