RFR: 8307517: Add VMErrorCallback infrastructure to extend hs_err dumping
Stefan Karlsson
stefank at openjdk.org
Fri May 5 08:12:25 UTC 2023
Sometimes when we crash in the GC we'd like to get some more information about what was going on the crashing thread. One example is when Generational ZGC crashes during store barrier flushing. From https://github.com/openjdk/zgc/blob/349cf9ae38664991879402a90c5e23e291f1c1c3/src/hotspot/share/gc/z/zStoreBarrierBuffer.cpp#L245
class ZStoreBarrierBuffer::OnError : public VMErrorCallback {
private:
ZStoreBarrierBuffer* _buffer;
public:
OnError(ZStoreBarrierBuffer* buffer) :
_buffer(buffer) {}
virtual void call(outputStream* st) {
_buffer->on_error(st);
}
};
void ZStoreBarrierBuffer::on_error(outputStream* st) {
st->print_cr("ZStoreBarrierBuffer: error when flushing");
st->print_cr(" _last_processed_color: " PTR_FORMAT, _last_processed_color);
st->print_cr(" _last_installed_color: " PTR_FORMAT, _last_installed_color);
for (int i = current(); i < (int)_buffer_length; ++i) {
st->print_cr(" [%2d]: base: " PTR_FORMAT " p: " PTR_FORMAT " prev: " PTR_FORMAT,
i,
untype(_base_pointers[i]),
p2i(_buffer[i]._p),
untype(_buffer[i]._prev));
}
}
void ZStoreBarrierBuffer::flush() {
if (!ZBufferStoreBarriers) {
return;
}
OnError on_error(this);
VMErrorCallbackMark mark(&on_error);
for (int i = current(); i < (int)_buffer_length; ++i) {
const ZStoreBarrierEntry& entry = _buffer[i];
const zaddress addr = ZBarrier::make_load_good(entry._prev);
ZBarrier::mark_and_remember(entry._p, addr);
}
clear();
}
If we crash in ZStoreBarrierBuffer::flush, we print the information above into the hs_err file.
We've found this information to be useful and would like to upstream the infrastructure separately from the much larger Generational ZGC PR.
Testing: this has been brewing and been used in the Generational ZGC repository for a long time.
-------------
Commit messages:
- 8307517: Add VMErrorCallback infrastructure to extend hs_err dumping
Changes: https://git.openjdk.org/jdk/pull/13824/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13824&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8307517
Stats: 49 lines in 4 files changed: 49 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/13824.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13824/head:pull/13824
PR: https://git.openjdk.org/jdk/pull/13824
More information about the hotspot-dev
mailing list