# HG changeset patch # User jbachorik # Date 1610461003 -3600 # Node ID 2025476613c2874701ffae7c7b4756b90cfbd4e2 # Parent 3d026d2bda87987e8e2811eca36fbbb0f3f09fe4 8258396: SIGILL in jdk.jfr.internal.PlatformRecorder.rotateDisk() Reviewed-by: mgronlun diff -r 3d026d2bda87 -r 2025476613c2 src/share/vm/jfr/recorder/storage/jfrStorage.cpp --- 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;