JDK-8213713 : Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-11
  • Updated: 2019-07-17
  • Resolved: 2018-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b21Fixed
Related Reports
Blocks :  
Description
I noticed this issue while looking into shared space and class space allocations for dynamic archiving. In MetaspaceShared::initialize_runtime_shared_and_meta_spaces(), the compressed class space start is computed as cds_base+cds_total_size. The cd_total_size is MetaspaceShared::core_spaces_size(), which is only valid at dump time. At runtime, MetaspaceShared::core_spaces_size() is 0. As as result, it tries to allocate the class space at the beginning of the mapped shared space, and the first ReservedSpace() fails (in Metaspace::allocate_metaspace_compressed_klass_ptrs). Then it needs to retry at an address that 1G above the initial address.

There is another issue with MetaspaceShared::initialize_runtime_shared_and_meta_spaces(). If shared space mapping fails due to shared_path validation failure, map_shared_spaces() may still return 'true'. That is because FileMapInfo::validate_shared_path_table() does not handle shared_path(i)->validate failure properly. The 'else' case in MetaspaceShared::initialize_runtime_shared_and_meta_spaces would not be taken in that case.




Comments
The MetaspaceShared::_core_spaces_size is reloaded from the archive by MetaspaceShared::initialize_shared_spaces() at runtime. However, MetaspaceShared::initialize_shared_spaces() happens after MetaspaceShared::initialize_runtime_shared_and_meta_spaces (). We can load the MetaspaceShared::_core_spaces_size immediately after mapping the shared spaces. Then the value can be used correctly. As there are several places use the value, so this probably is the easiest fix for the first issue above.
11-11-2018