RFR: 8284274: Error reporting crashes because missing ResourceMarks [v2]

Thomas Stuefe stuefe at openjdk.java.net
Tue Apr 12 16:24:36 UTC 2022


On Tue, 12 Apr 2022 16:17:13 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Taking the suggestion from @stefank in the bug report, disable the ResourceMark missing assert during error reporting.  There's a ResourceArea in the thread that can be used.  Added a test.
>> Tested with tier1-4 on x86 and aarch64 platforms.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add some variable names for test values.

Trying to understand this...

We cannot just wrap VMError::report() in a ResourceMark since that requires Thread::current() to be != NULL and would crash immediately when called in a non-VM-attached thread.

But there are instances where RA allocation happens in error reporting. We don't really like that, but don't have the time to fix that, so we tolerate them. But we don't especially care for cleanup, since we will die anyway. Also the less we do with C-heap the better, and better avoid those unnecessary free() calls. So we tolerate missing ResourceMarks during error handling.

The only thing to remark is that the crashing step should really not use RA. "printing registers" is a very basic thing, should only require a valid ucontext_t and nothing else. Maybe that would be worth hunting down.

I always thought a NoResourceAreaMark, similar to a NoHandleMark, would be nice to have. But I always shied away from the cleanup that would follow :)

test/hotspot/jtreg/runtime/ErrorHandling/ResourceMarkTest.java line 64:

> 62:     output_detail.shouldMatch("#.+SIGFPE.*");
> 63:     output_detail.shouldMatch("This is a message with no ResourceMark");
> 64: 

Note that we introduced -XX:+ErrorFileToStdout and -XX:+ErrorFileToStderr, you could use that instead of looking for the hs-err file, and parse output_detail directly for the strings in question. The ErrorHandler tests are older than those switches and could be rewritten too.

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

Marked as reviewed by stuefe (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/8201


More information about the hotspot-dev mailing list