Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package chromium for openSUSE:Factory checked in at 2025-02-06 22:02:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/chromium (Old) and /work/SRC/openSUSE:Factory/.chromium.new.2316 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "chromium" Thu Feb 6 22:02:43 2025 rev:447 rq:1243304 version:133.0.6943.53 Changes: -------- --- /work/SRC/openSUSE:Factory/chromium/chromium.changes 2025-01-30 14:51:13.401497347 +0100 +++ /work/SRC/openSUSE:Factory/.chromium.new.2316/chromium.changes 2025-02-06 22:05:16.885761090 +0100 @@ -1,0 +2,58 @@ +Wed Feb 5 10:36:43 CET 2025 - r...@suse.de + +- Chromium 133.0.6943.53 + (stable released 2024-02-04) (bsc#1236806) + * CVE-2025-0444: Use after free in Skia + * CVE-2025-0445: Use after free in V8 + * CVE-2025-0451: Inappropriate implementation in Extensions API + +------------------------------------------------------------------- +Thu Jan 30 18:17:42 CET 2025 - r...@suse.de + +- dropped patches: (obsolete with recent llvm) + chromium-130-no-hardware_destructive_interference_size.patch + +------------------------------------------------------------------- +Thu Jan 30 18:08:11 CET 2025 - r...@suse.de + +- Chromium 133.0.6943.35 + (beta released 2025-01-29) +- use llvm19 also on 15.6/SLE-15-SP6 +- dropped patches: + chromium-125-disable-FFmpegAllowLists.patch + chromium-119-assert.patch + (code dropped upstream) +- modified patches + chromium-129-revert-AVFMT_FLAG_NOH264PARSE.patch + (rest of code is gone upstream, see commit + 574c1e6678da435efb2ea9dba5dd890c2704b8af) +- update context in + chromium-102-regex_pattern-array.patch + chromium-125-ffmpeg-5.x-reordered_opaque.patch +- add to keeplibs: + third_party/simdutf + third_party/wasm_tts_engine (needed by tools/grit) + v8/third_party/siphash (moved inside of v8) + v8/third_party/utf8-decoder (moved inside of v8) + v8/third_party/valgrind (moved inside of v8) +- drop from keeplibs (gone in source): + third_party/jstemplate does not exist + third_party/qcms does not exist +- drop buildreq for libevent and libevent from system libs + as the lib was dropped upstream +- added patches (as revert for llvm17 in sp6): + chromium-add-atomicops.patch + (upstream commit d29b01737a841b5627249d50f007dcdc7e26462b) + (upstream commit 780efe38034cfdc1bdf4c74e82e7ca7c14e8ac5b + does not seem to be in 133 yet) + chromium-133-string_view.patch + (one more place to use string_view, also only llvm17) +- update INSTALL.sh to generate appdata.xml from template + +------------------------------------------------------------------- +Thu Jan 30 18:06:26 CET 2025 - r...@suse.de + +- drop chromium-132-old_libdrm.patch + obsolete as we are not building for 15.5 anymore + +------------------------------------------------------------------- @@ -32 +89,0 @@ - Old: ---- chromium-119-assert.patch chromium-125-disable-FFmpegAllowLists.patch chromium-130-no-hardware_destructive_interference_size.patch chromium-132-old_libdrm.patch chromium-132.0.6834.159.tar.xz New: ---- chromium-133-string_view.patch chromium-133.0.6943.53.tar.xz chromium-add-atomicops.patch BETA DEBUG BEGIN: Old: chromium-125-disable-FFmpegAllowLists.patch chromium-119-assert.patch (code dropped upstream) Old:- dropped patches: chromium-125-disable-FFmpegAllowLists.patch chromium-119-assert.patch Old:- dropped patches: (obsolete with recent llvm) chromium-130-no-hardware_destructive_interference_size.patch Old: - drop chromium-132-old_libdrm.patch obsolete as we are not building for 15.5 anymore BETA DEBUG END: BETA DEBUG BEGIN: New: does not seem to be in 133 yet) chromium-133-string_view.patch (one more place to use string_view, also only llvm17) New:- added patches (as revert for llvm17 in sp6): chromium-add-atomicops.patch (upstream commit d29b01737a841b5627249d50f007dcdc7e26462b) BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ chromium.spec ++++++ --- /var/tmp/diff_new_pack.ehE5WR/_old 2025-02-06 22:05:38.154637520 +0100 +++ /var/tmp/diff_new_pack.ehE5WR/_new 2025-02-06 22:05:38.154637520 +0100 @@ -3,7 +3,7 @@ # # Copyright (c) 2025 SUSE LLC # Copyright (c) 2024 Callum Farmer <gm...@opensuse.org> -# Copyright (c) 2025 Andreas Stieger <andreas.stie...@gmx.de> +# Copyright (c) 2024 Andreas Stieger <andreas.stie...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -58,7 +58,7 @@ %define ffmpeg_version 58 %endif %bcond_with system_zstd -%if 0%{?suse_version} >= 1600 || 0%{?sle_version} >= 150700 +%if 0%{?suse_version} >= 1600 || 0%{?sle_version} >= 150600 # LLVM version %define llvm_version 19 # RUST version @@ -99,11 +99,6 @@ %else %bcond_with libxml2_2_12 %endif -%if %{pkg_vcmp libdrm-devel >= 2.4.115} -%bcond_without libdrm_2_4_115 -%else -%bcond_with libdrm_2_4_115 -%endif # Package names %if %{with is_beta} %define chromedriver_name %{name}-chromedriver @@ -113,7 +108,7 @@ %define n_suffix %{nil} %endif Name: chromium%{n_suffix} -Version: 132.0.6834.159 +Version: 133.0.6943.53 Release: 0 Summary: Google's open source browser project License: BSD-3-Clause AND LGPL-2.1-or-later @@ -150,17 +145,14 @@ # PATCH-FIX-SUSE: allow prop codecs to be set with chromium branding Patch202: chromium-prop-codecs.patch Patch240: chromium-117-string-convert.patch -Patch248: chromium-119-assert.patch Patch256: chromium-120-make_unique-struct.patch Patch261: chromium-121-rust-clang_lib.patch -Patch311: chromium-125-disable-FFmpegAllowLists.patch Patch337: chromium-123-missing-QtGui.patch Patch359: chromium-126-quiche-interator.patch Patch360: chromium-127-bindgen.patch Patch361: chromium-127-rust-clanglib.patch Patch363: chromium-127-constexpr.patch Patch364: chromium-129-revert-AVFMT_FLAG_NOH264PARSE.patch -Patch366: chromium-130-no-hardware_destructive_interference_size.patch Patch368: chromium-131-clang-stack-protector.patch Patch369: chromium-132-pdfium-explicit-template.patch # conditionally applied patches @@ -173,10 +165,10 @@ Patch1006: chromium-93-ffmpeg-4.4-rest.patch # patch where libxml < 2.12 Patch1010: chromium-124-system-libxml.patch -# patch where libdrm < 2.4.115 -Patch1015: chromium-132-old_libdrm.patch # patch where llvm < 19 Patch1020: chromium-127-clang17-traitors.patch +Patch1021: chromium-add-atomicops.patch +Patch1022: chromium-133-string_view.patch # end conditionally applied patches BuildRequires: SDL-devel BuildRequires: bison @@ -243,7 +235,6 @@ BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(libelf) BuildRequires: pkgconfig(libevdev) -BuildRequires: pkgconfig(libevent) BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(libffi) BuildRequires: pkgconfig(libpci) @@ -450,14 +441,11 @@ %patch -p1 -P 1010 %endif -# apply only on 15.5 with libdrm < 2.4.116 -%if 0%{?sle_version} <= 150500 -%patch -p1 -P 1015 -%endif - %if 0%{?llvm_version} == 17 # chromium-127-clang17-traitors.patch only needed for older clang %patch -p1 -P 1020 +%patch -p1 -R -P 1021 +%patch -p1 -R -P 1022 %endif %build @@ -622,7 +610,6 @@ third_party/ipcz third_party/jinja2 third_party/jsoncpp - third_party/jstemplate third_party/khronos third_party/lens_server_proto third_party/leveldatabase @@ -685,7 +672,6 @@ third_party/puffin third_party/pyjson5 third_party/pyyaml - third_party/qcms third_party/rapidhash third_party/rnnoise third_party/rust @@ -696,6 +682,7 @@ third_party/sentencepiece third_party/sentencepiece/src/third_party/darts_clone third_party/shell-encryption + third_party/simdutf third_party/simplejson third_party/skia third_party/skia/include/third_party/vulkan/ @@ -723,6 +710,7 @@ third_party/utf third_party/vulkan third_party/wayland + third_party/wasm_tts_engine third_party/webdriver third_party/webgpu-cts third_party/webrtc @@ -743,11 +731,11 @@ third_party/zlib/google third_party/zxcvbn-cpp url/third_party/mozilla - v8/src/third_party/siphash - v8/src/third_party/utf8-decoder - v8/src/third_party/valgrind v8/third_party/glibc v8/third_party/inspector_protocol + v8/third_party/siphash + v8/third_party/utf8-decoder + v8/third_party/valgrind v8/third_party/v8/builtins v8/third_party/v8/codegen ) @@ -892,7 +880,6 @@ flac fontconfig libdrm - libevent libjpeg libpng libusb ++++++ INSTALL.sh ++++++ --- /var/tmp/diff_new_pack.ehE5WR/_old 2025-02-06 22:05:38.222640322 +0100 +++ /var/tmp/diff_new_pack.ehE5WR/_new 2025-02-06 22:05:38.226640487 +0100 @@ -12,6 +12,24 @@ SHLIB_PERMS="755" PROGNAME="chrome" PACKAGE="chromium-browser" +MAINTMAIL="chromium-...@chromium.org" +PROJECT_LICENSE="BSD-3-Clause and LGPL-2.1+ and Apache-2.0 and IJG and MIT and GPL-2.0+ and ISC and OpenSSL and (MPL-1.1 or GPL-2.0 or LGPL-2.0)" +SHORTDESC="The web browser from Chromium project" +FULLDESC=" Chromium is an open-source browser project that aims to build a safer, faster,\ + and more stable way to experience the web.\ + </p>\ + <p>\ + We invite you to join our effort to build a powerful platform for developing a\ + new generation of web applications.\ + </p>\ + <p>\ + Chromium supports Vorbis, Theora, WebM and HTML5 audio and video standards, but\ + does not include the non-free AAC, H.264, MP3 or Adobe Flash code that is found\ + in Chrome." +PRODUCTURL="https://www.chromium.org/Home" +DEVELOPER_NAME="The Chromium Authors" +BUGTRACKERURL="https://www.chromium.org/for-testers/bug-reporting-guidelines" +HELPURL="https://chromium.googlesource.com/chromium/src/+/main/docs/linux/debugging.md" MENUNAME="Chromium Web Browser" CHANNEL="stable" INSTALLDIR="${LIBDIR}/chromium" @@ -133,8 +151,18 @@ # desktop integration ## AppData -install -m 644 "chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml" \ -"${STAGEDIR}/usr/share/metainfo/${PACKAGE}.appdata.xml" +sed \ + -e "s#@@PACKAGE@@#${PACKAGE}#g" \ + -e "s#@@MAINTMAIL@@#${MAINTMAIL}#g" \ + -e "s#@@PROJECT_LICENSE@@#${PROJECT_LICENSE}#g" \ + -e "s#@@MENUNAME@@#${MENUNAME}#g" \ + -e "s#@@SHORTDESC@@#${SHORTDESC}#g" \ + -e "s#@@FULLDESC@@#${FULLDESC}#g" \ + -e "s#@@PRODUCTURL@@#${PRODUCTURL}#g" \ + -e "s#@@DEVELOPER_NAME@@#${DEVELOPER_NAME}#g" \ + -e "s#@@BUGTRACKERURL@@#${BUGTRACKERURL}#g" \ + -e "s#@@HELPURL@@#${HELPURL}#g" \ + "chrome/installer/linux/common/appdata.xml.template" > "${STAGEDIR}/usr/share/metainfo/${PACKAGE}.appdata.xml" ## Desktop file sed \ ++++++ chromium-102-regex_pattern-array.patch ++++++ --- /var/tmp/diff_new_pack.ehE5WR/_old 2025-02-06 22:05:38.282642795 +0100 +++ /var/tmp/diff_new_pack.ehE5WR/_new 2025-02-06 22:05:38.286642959 +0100 @@ -2,7 +2,7 @@ =================================================================== --- chromium-123.0.6312.46.orig/components/autofill/core/browser/BUILD.gn +++ chromium-123.0.6312.46/components/autofill/core/browser/BUILD.gn -@@ -58,6 +58,11 @@ action("regex_patterns_inl_h") { +@@ -64,6 +64,11 @@ } static_library("browser") { @@ -12,6 +12,6 @@ + ] + } sources = [ - "address_data_cleaner.cc", - "address_data_cleaner.h", + "autofill_browser_util.cc", + "autofill_browser_util.h", ++++++ chromium-125-ffmpeg-5.x-reordered_opaque.patch ++++++ --- /var/tmp/diff_new_pack.ehE5WR/_old 2025-02-06 22:05:38.322644444 +0100 +++ /var/tmp/diff_new_pack.ehE5WR/_new 2025-02-06 22:05:38.330644773 +0100 @@ -54,7 +54,7 @@ auto video_frame = VideoFrame::WrapExternalDataWithLayout( opaque->layout, visible_rect, natural_size, opaque->data, opaque->size, pts); -@@ -498,8 +505,10 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config, +@@ -482,8 +482,10 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config, codec_context_->thread_count = GetFFmpegVideoDecoderThreadCount(config); codec_context_->thread_type = FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME); @@ -63,8 +63,8 @@ codec_context_->get_buffer2 = GetVideoBufferImpl; + codec_context_->flags |= AV_CODEC_FLAG_COPY_OPAQUE; - if (base::FeatureList::IsEnabled(kFFmpegAllowLists)) { - // Note: FFmpeg will try to free this string, so we must duplicate it. + if (decode_nalus_) { + codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS; diff --git a/media/filters/ffmpeg_video_decoder.h b/media/filters/ffmpeg_video_decoder.h index d02cb89c3ddf7..0a2de1c623fff 100644 --- a/media/filters/ffmpeg_video_decoder.h ++++++ chromium-129-revert-AVFMT_FLAG_NOH264PARSE.patch ++++++ --- /var/tmp/diff_new_pack.ehE5WR/_old 2025-02-06 22:05:38.394647410 +0100 +++ /var/tmp/diff_new_pack.ehE5WR/_new 2025-02-06 22:05:38.398647575 +0100 @@ -1,25 +1,13 @@ -diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc -index eaabc740e710e..229818059dc2c 100644 ---- a/media/filters/ffmpeg_glue.cc -+++ b/media/filters/ffmpeg_glue.cc -@@ -21,7 +21,7 @@ namespace media { - // TODO(crbug.com/355485812): Re-enable this flag. - BASE_FEATURE(kAllowOnlyAudioCodecsDuringDemuxing, - "AllowOnlyAudioCodecsDuringDemuxing", -- base::FEATURE_ENABLED_BY_DEFAULT); -+ base::FEATURE_DISABLED_BY_DEFAULT); - BASE_FEATURE(kForbidH264ParsingDuringDemuxing, - "ForbidH264ParsingDuringDemuxing", - base::FEATURE_ENABLED_BY_DEFAULT); -@@ -121,7 +121,8 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) { +--- chromium-133.0.6943.16/media/filters/ffmpeg_glue.cc 2025/01/20 15:06:56 1.1 ++++ chromium-133.0.6943.16/media/filters/ffmpeg_glue.cc 2025/01/20 15:07:32 +@@ -111,7 +111,8 @@ + // We don't allow H.264 parsing during demuxing since we have our own parser // and the ffmpeg one increases memory usage unnecessarily. - if (base::FeatureList::IsEnabled(kForbidH264ParsingDuringDemuxing)) { -- format_context_->flags |= AVFMT_FLAG_NOH264PARSE; -+ // TODO(crbug.com/355485812): Re-enable this flag. -+ // format_context_->flags |= AVFMT_FLAG_NOH264PARSE; - } +- format_context_->flags |= AVFMT_FLAG_NOH264PARSE; ++ // TODO(crbug.com/355485812): Re-enable this flag. ++ // format_context_->flags |= AVFMT_FLAG_NOH264PARSE; // Ensures format parsing errors will bail out. From an audit on 11/2017, all - + // instances were real failures. Solves bugs like http://crbug.com/710791. ++++++ chromium-133-string_view.patch ++++++ --- chromium-133.0.6943.16/chrome/browser/task_manager/task_manager_metrics_recorder.cc 2025/01/22 14:22:01 1.1 +++ chromium-133.0.6943.16/chrome/browser/task_manager/task_manager_metrics_recorder.cc 2025/01/22 14:22:21 @@ -27,7 +27,7 @@ void RecordEndProcessEvent(const base::TimeTicks& start_time, const base::TimeTicks& end_time, size_t end_process_count) { - constexpr static std::array<std::string, 5> kEndProcessCountToString = { + constexpr static std::array<std::string_view, 5> kEndProcessCountToString = { "First", "Second", "Third", "Fourth", "Fifth"}; // Only record the first five end process events per task manager session. ++++++ chromium-132.0.6834.159.tar.xz -> chromium-133.0.6943.53.tar.xz ++++++ /work/SRC/openSUSE:Factory/chromium/chromium-132.0.6834.159.tar.xz /work/SRC/openSUSE:Factory/.chromium.new.2316/chromium-133.0.6943.53.tar.xz differ: char 15, line 1 ++++++ chromium-add-atomicops.patch ++++++ >From d29b01737a841b5627249d50f007dcdc7e26462b Mon Sep 17 00:00:00 2001 From: Eugene Zemtsov <eug...@chromium.org> Date: Thu, 19 Dec 2024 13:20:12 -0800 Subject: [PATCH] Introducing base::RelaxedAtomicWriteMemcpy This is an analogue of `WTF::AtomicWriteMemcpy` and it should be used for copying data into buffers owned by `SharedArrayBuffer`. While the copy is being done, JS and WASM code can access the `dst` buffer on a different thread. The data observed by JS may not be consistent from application point of view (which is always the case with `SharedArrayBuffer`), but it won't trigger C++ UB and won't upset TSAN. Reads from the `src` buffer are not atomic and should be `src` access should be synchronized via other means. Bug: 340606792 Change-Id: I95fd92d344dce4d463fa281b68b266bb0a8053a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6065639 Reviewed-by: Shu-yu Guo <s...@chromium.org> Reviewed-by: Daniel Cheng <dch...@chromium.org> Reviewed-by: Gabriel Charette <g...@chromium.org> Commit-Queue: Eugene Zemtsov <eug...@chromium.org> Cr-Commit-Position: refs/heads/main@{#1398823} diff --git a/base/BUILD.gn b/base/BUILD.gn index 0b0d3c262a1d4..97bec1f29bc3b 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -186,6 +186,7 @@ component("base") { "at_exit.h", "atomic_ref_count.h", "atomic_sequence_num.h", + "atomicops.cc", "atomicops.h", "atomicops_internals_atomicword_compat.h", "atomicops_internals_portable.h", diff --git a/base/atomicops.cc b/base/atomicops.cc new file mode 100644 index 0000000000000..7b6aca4d6c3c3 --- /dev/null +++ b/base/atomicops.cc @@ -0,0 +1,65 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/atomicops.h" + +#include <atomic> + +#include "base/memory/aligned_memory.h" + +namespace base::subtle { + +void RelaxedAtomicWriteMemcpy(base::span<uint8_t> dst, + base::span<const uint8_t> src) { + CHECK_EQ(dst.size(), src.size()); + size_t bytes = dst.size(); + uint8_t* dst_byte_ptr = dst.data(); + const uint8_t* src_byte_ptr = src.data(); + // Make sure that we can at least copy byte by byte with atomics. + static_assert(std::atomic_ref<uint8_t>::required_alignment == 1); + + // Alignment for uintmax_t atomics that we use in the happy case. + constexpr size_t kDesiredAlignment = + std::atomic_ref<uintmax_t>::required_alignment; + + // Copy byte-by-byte until `dst_byte_ptr` is not properly aligned for + // the happy case. + while (bytes > 0 && !IsAligned(dst_byte_ptr, kDesiredAlignment)) { + std::atomic_ref<uint8_t>(*dst_byte_ptr) + .store(*src_byte_ptr, std::memory_order_relaxed); + // SAFETY: We check above that `dst_byte_ptr` and `src_byte_ptr` point + // to spans of sufficient size. + UNSAFE_BUFFERS(++dst_byte_ptr); + UNSAFE_BUFFERS(++src_byte_ptr); + --bytes; + } + + // Happy case where both `src_byte_ptr` and `dst_byte_ptr` are both properly + // aligned and the largest possible atomic is used for copying. + if (IsAligned(src_byte_ptr, kDesiredAlignment)) { + while (bytes >= sizeof(uintmax_t)) { + std::atomic_ref<uintmax_t>(*reinterpret_cast<uintmax_t*>(dst_byte_ptr)) + .store(*reinterpret_cast<const uintmax_t*>(src_byte_ptr), + std::memory_order_relaxed); + // SAFETY: We check above that `dst_byte_ptr` and `src_byte_ptr` point + // to spans of sufficient size. + UNSAFE_BUFFERS(dst_byte_ptr += sizeof(uintmax_t)); + UNSAFE_BUFFERS(src_byte_ptr += sizeof(uintmax_t)); + bytes -= sizeof(uintmax_t); + } + } + + // Copy what's left after the happy-case byte-by-byte. + while (bytes > 0) { + std::atomic_ref<uint8_t>(*dst_byte_ptr) + .store(*src_byte_ptr, std::memory_order_relaxed); + // SAFETY: We check above that `dst_byte_ptr` and `src_byte_ptr` point + // to spans of sufficient size. + UNSAFE_BUFFERS(++dst_byte_ptr); + UNSAFE_BUFFERS(++src_byte_ptr); + --bytes; + } +} + +} // namespace base::subtle diff --git a/base/atomicops.h b/base/atomicops.h index 47a10e65e7ac7..33b17dae4aaa9 100644 --- a/base/atomicops.h +++ b/base/atomicops.h @@ -51,6 +51,9 @@ // - libstdc++: captures bits/c++config.h for __GLIBCXX__ #include <cstddef> +#include "base/base_export.h" +#include "base/compiler_specific.h" +#include "base/containers/span.h" #include "build/build_config.h" namespace base { @@ -139,6 +142,28 @@ Atomic64 NoBarrier_Load(volatile const Atomic64* ptr); Atomic64 Acquire_Load(volatile const Atomic64* ptr); #endif // ARCH_CPU_64_BITS +// Copies non-overlapping spans of the same size. Writes are done using C++ +// atomics with `std::memory_order_relaxed`. +// +// This is an analogue of `WTF::AtomicWriteMemcpy` and it should be used +// for copying data into buffers that are accessible from another +// thread while the copy is being done. The buffer will appear inconsistent, +// but it won't trigger C++ UB and won't upset TSAN. The end of copy needs to +// be signaled through a synchronization mechanism like fence, after +// which the `dst` buffer will be observed as consistent. +// +// Notable example is a buffer owned by `SharedArrayBuffer`. +// While the copy is being done, JS and WASM code can access the `dst` buffer +// on a different thread. The data observed by JS may not be consistent +// from application point of view (which is always the case with +// `SharedArrayBuffer`). +// +// Reads from the `src` buffer are not atomic and `src` access +// should be synchronized via other means. +// More info: crbug.com/340606792 +BASE_EXPORT void RelaxedAtomicWriteMemcpy(base::span<uint8_t> dst, + base::span<const uint8_t> src); + } // namespace subtle } // namespace base diff --git a/base/atomicops_unittest.cc b/base/atomicops_unittest.cc index b494bd136bc15..1227dc3b2e053 100644 --- a/base/atomicops_unittest.cc +++ b/base/atomicops_unittest.cc @@ -6,7 +6,9 @@ #include <stdint.h> #include <string.h> + #include <type_traits> +#include <vector> #include "testing/gtest/include/gtest/gtest.h" @@ -239,3 +241,24 @@ TEST(AtomicOpsTest, Load) { TestLoad<base::subtle::Atomic32>(); TestLoad<base::subtle::AtomicWord>(); } + +TEST(AtomicOpsTest, RelaxedAtomicWriteMemcpy) { + std::vector<uint8_t> src(17); + for (size_t i = 0; i < src.size(); i++) { + src[i] = i + 1; + } + + for (size_t i = 0; i < src.size(); i++) { + std::vector<uint8_t> dst(src.size()); + size_t bytes_to_copy = src.size() - i; + base::subtle::RelaxedAtomicWriteMemcpy( + base::span(dst).first(bytes_to_copy), + base::span(src).subspan(i, bytes_to_copy)); + for (size_t j = 0; j < bytes_to_copy; j++) { + EXPECT_EQ(src[i + j], dst[j]); + } + for (size_t j = bytes_to_copy; j < dst.size(); j++) { + EXPECT_EQ(0, dst[j]); + } + } +}