Skip to content

Fix unsound Send impl for inspector::CharacterArray (T: Copy -> T: Sync) - #2074

Open
fairfairfair-210 wants to merge 1 commit into
denoland:mainfrom
fairfairfair-210:fix/characterarray-send-bound
Open

fairfairfair-210 wants to merge 1 commit into
denoland:mainfrom
fairfairfair-210:fix/characterarray-send-bound

Conversation

@fairfairfair-210

Copy link
Copy Markdown

Fix unsound Send impl for inspector::CharacterArray (T: CopyT: Sync)

CharacterArray<'a, T> is semantically a borrowed slice &[T] (safe From<&[T]> constructor, Deref<Target = [T]>), but its handwritten Send impl requires T: Copy while the Sync impl on the same type correctly requires T: Sync.

For a &[T]-like type the correct condition is T: Sync in both directions (&[T]: Send ⇔ T: Sync). T: Copy neither implies nor is implied by T: Sync — e.g. &'static Cell<i32> is Copy but !Sync, so safe code can currently send CharacterArray<'static, &'static Cell<i32>> across threads and obtain shared &Cell<i32> accesses — a data race without any unsafe at the use site.

The fix tightens the Send bound to T: Sync. All in-tree instantiations are u8/u16 (both Sync), so nothing else is affected.

@CLAassistant

CLAassistant commented Sep 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants