Skip to content

[JSC] TypedArray setFromTypedArray cannot use memmove when region is intentionally overlapping and spec algorithm read back the modified result - #72765

Open
Constellation wants to merge 1 commit into
WebKit:mainfrom
Constellation:eng/JSC-TypedArray-setFromTypedArray-cannot-use-memmove-when-region-is-intentionally-overlapping-and-spec-algorithm-read-back-the-modified-result
Open

[JSC] TypedArray setFromTypedArray cannot use memmove when region is intentionally overlapping and spec algorithm read back the modified result#72765
Constellation wants to merge 1 commit into
WebKit:mainfrom
Constellation:eng/JSC-TypedArray-setFromTypedArray-cannot-use-memmove-when-region-is-intentionally-overlapping-and-spec-algorithm-read-back-the-modified-result

Conversation

@Constellation

@Constellation Constellation commented Aug 29, 2026

Copy link
Copy Markdown
Member

1c95fcd

[JSC] TypedArray setFromTypedArray cannot use memmove when region is intentionally overlapping and spec algorithm read back the modified result
https://bugs.webkit.org/show_bug.cgi?id=322892
rdar://186145219

Reviewed by NOBODY (OOPS!).

TypedArray setFromTypedArray cannot use memmove when

1. region is overlapping
2. we end up reading the written result

memmove can avoid (2) by changing the scanning direction. But the spec algorithm
sometimes explicitly requests CopyType::LeftToRight, and in this case,
this reading the written value should be observable.

Test: JSTests/stress/typed-array-slice-species-same-buffer-overlap.js

* JSTests/stress/typed-array-slice-species-same-buffer-overlap.js: Added.
(shouldBe):
(fill):
(bytesOf):
(const.TA.of.constructors.resultIndex.elementCount.ta.Symbol.species):
(const.TA.of.constructors.resultIndex.elementCount):
(const.TA.of.constructors.targetIndex.elementCount):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::setFromTypedArray):

1c95fcd

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
❌ πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe ❌ πŸ›  win ⏳ πŸ›  ios-apple
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2 ❌ πŸ§ͺ win-tests ⏳ πŸ›  mac-apple
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe ⏳ πŸ›  vision-apple
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ api-mac-debug βœ… πŸ§ͺ jsc-wpe
βœ… πŸ§ͺ jsc-x86-64 βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk3-gcc
βœ… πŸ›  πŸ§ͺ jsc-debug-arm64 loading πŸ›  ios-safer-cpp βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ›  gtk
βœ… πŸ›  vision βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  vision-sim βœ… πŸ§ͺ mac-intel-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ§ͺ vision-wk2 βœ… πŸ›  mac-safer-cpp βœ… πŸ›  playstation
βœ… πŸ›  tv βœ… πŸ§ͺ mac-site-isolation
βœ… πŸ›  tv-sim
βœ… πŸ›  watch
βœ… πŸ›  watch-sim

…intentionally overlapping and spec algorithm read back the modified result

https://bugs.webkit.org/show_bug.cgi?id=322892
rdar://186145219

Reviewed by NOBODY (OOPS!).

TypedArray setFromTypedArray cannot use memmove when

1. region is overlapping
2. we end up reading the written result

memmove can avoid (2) by changing the scanning direction. But the spec algorithm
sometimes explicitly requests CopyType::LeftToRight, and in this case,
this reading the written value should be observable.

Test: JSTests/stress/typed-array-slice-species-same-buffer-overlap.js

* JSTests/stress/typed-array-slice-species-same-buffer-overlap.js: Added.
(shouldBe):
(fill):
(bytesOf):
(const.TA.of.constructors.resultIndex.elementCount.ta.Symbol.species):
(const.TA.of.constructors.resultIndex.elementCount):
(const.TA.of.constructors.targetIndex.elementCount):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::setFromTypedArray):
@Constellation
Constellation requested a review from a team as a code owner August 29, 2026 08:34
@Constellation Constellation self-assigned this Aug 29, 2026
@Constellation Constellation added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Aug 29, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 29, 2026
@Constellation Constellation removed the merging-blocked Applied to prevent a change from being merged label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants