8258396: SIGILL in jdk.jfr.internal.PlatformRecorder.rotateDisk()

Reviewed-by: egahlin
Backport-of: a06cea50a5ea04fb0399d7ea3f6a2a20d9b4d254
This commit is contained in:
Jaroslav Bachorik 2021-01-15 15:12:03 +00:00
parent 4307fa68b7
commit e85892bfe2

View File

@ -405,7 +405,7 @@ BufferPtr JfrStorage::flush(BufferPtr cur, size_t used, size_t req, bool native,
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
@ -417,7 +417,8 @@ BufferPtr JfrStorage::flush_regular(BufferPtr cur, const u1* const cur_pos, size
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;