changeset 10899:2025476613c2

8258396: SIGILL in jdk.jfr.internal.PlatformRecorder.rotateDisk() Reviewed-by: mgronlun
author jbachorik
date Tue, 12 Jan 2021 15:16:43 +0100
parents 3d026d2bda87
children aa3d863d3ab5
files src/share/vm/jfr/recorder/storage/jfrStorage.cpp
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jfr/recorder/storage/jfrStorage.cpp	Tue Nov 22 20:24:47 2016 -0500
+++ b/src/share/vm/jfr/recorder/storage/jfrStorage.cpp	Tue Jan 12 15:16:43 2021 +0100
@@ -483,7 +483,7 @@
 
 BufferPtr JfrStorage::flush_regular(BufferPtr cur, const u1* const cur_pos, size_t used, size_t req, bool native, Thread* t) {
   debug_only(assert_flush_regular_precondition(cur, cur_pos, used, req, t);)
-  // A flush is needed before memcpy since a non-large buffer is thread stable
+  // A flush is needed before memmove since a non-large buffer is thread stable
   // (thread local). The flush will not modify memory in addresses above pos()
   // which is where the "used / uncommitted" data resides. It is therefore both
   // possible and valid to migrate data after the flush. This is however only
@@ -495,7 +495,8 @@
   if (cur->free_size() >= req) {
     // simplest case, no switching of buffers
     if (used > 0) {
-      memcpy(cur->pos(), (void*)cur_pos, used);
+      // source and destination may overlap so memmove must be used instead of memcpy
+      memmove(cur->pos(), (void*)cur_pos, used);
     }
     assert(native ? t->jfr_thread_local()->native_buffer() == cur : t->jfr_thread_local()->java_buffer() == cur, "invariant");
     return cur;