8227011: Starting a JFR recording in response to JVMTI VMInit and / or Java agent premain corrupts memory

Reviewed-by: egahlin, rwestberg
This commit is contained in:
Markus Grönlund 2019-07-02 17:46:38 +02:00
parent 6e16ff4cea
commit ebde73209f
4 changed files with 13 additions and 7 deletions

View file

@ -135,8 +135,7 @@ static bool setup_event_writer_offsets(TRAPS) {
bool JfrJavaEventWriter::initialize() {
static bool initialized = false;
if (!initialized) {
Thread* thread = Thread::current();
initialized = setup_event_writer_offsets(thread);
initialized = setup_event_writer_offsets(Thread::current());
}
return initialized;
}
@ -155,6 +154,7 @@ jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, Ja
// large enough to accommodate the "requested size".
const bool is_valid = buffer->free_size() >= (size_t)(used + requested);
u1* const new_current_position = is_valid ? buffer->pos() + used : buffer->pos();
assert(start_pos_offset != invalid_offset, "invariant");
w->long_field_put(start_pos_offset, (jlong)buffer->pos());
w->long_field_put(current_pos_offset, (jlong)new_current_position);
// only update java writer if underlying memory changed