Skip to content

ZeroCopyBuf and MagicBuffer should not be Send or Sync #129

@andreubotella

Description

@andreubotella

ZeroCopyBuf wraps a reference to a backing store that is potentially shared with an ArrayBuffer object, and thus is only safely accessible from one thread. Therefore, ZeroCopyBuf, and MagicBuffer which wraps it, must not be Send or Sync – yet they are both. In fact, ZeroCopyBuf unsafely implements Send, even though that is not needed – which seems to be a holdover from previous iterations of this API.

Once denoland/deno#12678 is solved, it might be possible to allow a way safely send ZeroCopyBuf values, as long as their backing store was created for a SharedArrayBuffer – but implementing Send directly on ZeroCopyBuf would still not be sound. We can tackle this when the time comes.

See also denoland/rusty_v8#798.

This was discovered when investigating denoland/deno#12341.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions