RFR: 8296469: Instrument VMError::report with reentrant iteration step for register and stack printing [v9]

Axel Boldt-Christmas aboldtch at openjdk.org
Mon May 15 07:25:54 UTC 2023


On Fri, 5 May 2023 13:58:08 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Axel Boldt-Christmas has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
>> 
>>  - Merge remote-tracking branch 'upstream_jdk/master' into vmerror_report_register_stack_reentrant
>>  - Add test
>>  - Fix and strengthen print_stack_location
>>  - Missed variable rename
>>  - Copyright
>>  - Rework logic and use continuation state for reattempts
>>  - Merge remote-tracking branch 'upstream_jdk/master' into vmerror_report_register_stack_reentrant
>>  - Restructure os::print_register_info interface
>>  - Code syle and line length
>>  - Merge Fix
>>  - ... and 5 more: https://git.openjdk.org/jdk/compare/2009dc2b...2e12b4a5
>
> src/hotspot/share/utilities/vmError.cpp line 194:
> 
>> 192:   if (!check_stack_headroom(_thread, _reattempt_required_stack_headroom)) {
>> 193:     char stack_buffer[_reattempt_required_stack_headroom / 2];
>> 194:     static_cast<void>(stack_buffer[sizeof(stack_buffer) - 1] = '\0');
> 
> I would alloca() here instead of the array. I assume the touch at the end is to prevent the compiler from optimizing this away? With alloca you don't need that. No need for recursion either then, you can do that in a loop.

A little bit of a rabbit hole looking into this. But a good one. Noticed both that the current implementation was optimised away, that some platforms has a very large stack guard, that alloca will be optimised away with certain devkits. 

I reworked this to just do one allocation using alloca. I do still need to read the memory after the crashing call to for the compiler not to optimise away the allocation. At least on some platforms I tested with alloca in a loop. 

Also added some printing to make it clear what is happening incase this breaks with some devkit-os-cpu combination.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/11017#discussion_r1193424088


More information about the hotspot-dev mailing list