RFR: 8307517: Add VMErrorCallback infrastructure to extend hs_err dumping

David Holmes dholmes at openjdk.org
Mon May 8 06:18:16 UTC 2023


On Fri, 5 May 2023 07:57:53 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> 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.

I'm fine with the code as-is. Thanks.

-------------

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13824#pullrequestreview-1416179463


More information about the hotspot-dev mailing list