Integrated: 8307517: Add VMErrorCallback infrastructure to extend hs_err dumping

Stefan Karlsson stefank at openjdk.org
Mon May 8 08:01:35 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.

This pull request has now been integrated.

Changeset: 33245d6b
Author:    Stefan Karlsson <stefank at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/33245d6b38d7488c22619f93eff3bf0157f3d7a9
Stats:     49 lines in 4 files changed: 49 ins; 0 del; 0 mod

8307517: Add VMErrorCallback infrastructure to extend hs_err dumping

Reviewed-by: eosterlund, aboldtch, dholmes, stuefe

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

PR: https://git.openjdk.org/jdk/pull/13824


More information about the hotspot-dev mailing list