RFR: Fix off-by-one error when verifying object registrations

Kelvin Nilsen kdnilsen at openjdk.org
Fri Sep 2 17:23:07 UTC 2022


On Fri, 2 Sep 2022 16:47:52 GMT, William Kemper <wkemper at openjdk.org> wrote:

> This change originally started with an effort to fix a build error caused by using the global `malloc` and `free` calls. Replacing these calls with hotspot idioms caused remembered set verification errors. The verification errors were, ultimately, due to the verification code reading past the end of an array. The `NEW_C_HEAP_ARRAY` macro tacks a bit of information onto the allocated array for the purpose of tracking native memory use (NMT). This was enough to change the behavior when the verifier read past the end of the array. This PR subsumes https://github.com/openjdk/shenandoah/pull/155 and fixes the root cause of the verification errors. This change also removes the unused `overreach_map` as this was also using global `malloc` and `free` calls.

src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp line 403:

> 401:     size_t end_card_index = index + offset / CardTable::card_size_in_words();
> 402: 
> 403:     if (end_card_index > index && end_card_index < _rs->last_valid_index()) {

If _rs->last_valid_index() is actually a valid index, why couldn't we make this test <=?  Or should we rename the last_valid_index() to be index_beyond_end()?

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

PR: https://git.openjdk.org/shenandoah/pull/160


More information about the shenandoah-dev mailing list