8378935: C2 crash in PhaseOutput::fill_buffer: wrong size of mach node

Reviewed-by: iklam, asmehra
This commit is contained in:
Vladimir Kozlov 2026-03-20 20:18:12 +00:00
parent d0841c6bde
commit 137d97131b
4 changed files with 10 additions and 52 deletions

View File

@ -1187,8 +1187,8 @@ void AOTMetaspace::dump_static_archive_impl(StaticArchiveBuilder& builder, TRAPS
CDSConfig::enable_dumping_aot_code();
{
builder.start_ac_region();
// Write the contents to AOT code region and close AOTCodeCache before packing the region
AOTCodeCache::close();
// Write the contents to AOT code region before packing the region
AOTCodeCache::dump();
builder.end_ac_region();
}
CDSConfig::disable_dumping_aot_code();

View File

@ -108,6 +108,8 @@ void CDSConfig::ergo_initialize() {
}
AOTMapLogger::ergo_initialize();
setup_compiler_args();
}
const char* CDSConfig::default_archive_path() {
@ -635,8 +637,6 @@ bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_fla
FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
}
setup_compiler_args();
if (AOTClassLinking) {
// If AOTClassLinking is specified, enable all AOT optimizations by default.
FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);

View File

@ -284,11 +284,11 @@ bool AOTCodeCache::open_cache(bool is_dumping, bool is_using) {
return true;
}
void AOTCodeCache::close() {
void AOTCodeCache::dump() {
if (is_on()) {
delete _cache; // Free memory
_cache = nullptr;
opened_cache = nullptr;
assert(is_on_for_dump(), "should be called only when dumping AOT code");
MutexLocker ml(Compile_lock);
_cache->finish_write();
}
}
@ -304,7 +304,6 @@ AOTCodeCache::AOTCodeCache(bool is_dumping, bool is_using) :
_store_size(0),
_for_use(is_using),
_for_dump(is_dumping),
_closing(false),
_failed(false),
_lookup_failed(false),
_table(nullptr),
@ -381,30 +380,6 @@ void AOTCodeCache::init_early_c1_table() {
}
}
AOTCodeCache::~AOTCodeCache() {
if (_closing) {
return; // Already closed
}
// Stop any further access to cache.
_closing = true;
MutexLocker ml(Compile_lock);
if (for_dump()) { // Finalize cache
finish_write();
}
_load_buffer = nullptr;
if (_C_store_buffer != nullptr) {
FREE_C_HEAP_ARRAY(char, _C_store_buffer);
_C_store_buffer = nullptr;
_store_buffer = nullptr;
}
if (_table != nullptr) {
MutexLocker ml(AOTCodeCStrings_lock, Mutex::_no_safepoint_check_flag);
delete _table;
_table = nullptr;
}
}
void AOTCodeCache::Config::record(uint cpu_features_offset) {
_flags = 0;
#ifdef ASSERT
@ -1545,18 +1520,6 @@ void AOTCodeAddressTable::init_early_c1() {
#undef SET_ADDRESS
AOTCodeAddressTable::~AOTCodeAddressTable() {
if (_extrs_addr != nullptr) {
FREE_C_HEAP_ARRAY(address, _extrs_addr);
}
if (_stubs_addr != nullptr) {
FREE_C_HEAP_ARRAY(address, _stubs_addr);
}
if (_shared_blobs_addr != nullptr) {
FREE_C_HEAP_ARRAY(address, _shared_blobs_addr);
}
}
#ifdef PRODUCT
#define MAX_STR_COUNT 200
#else

View File

@ -152,7 +152,6 @@ public:
_early_c1_complete(false),
_complete(false)
{ }
~AOTCodeAddressTable();
void init_extrs();
void init_early_stubs();
void init_shared_blobs();
@ -260,7 +259,6 @@ private:
uint _store_size; // Used when writing cache
bool _for_use; // AOT cache is open for using AOT code
bool _for_dump; // AOT cache is open for dumping AOT code
bool _closing; // Closing cache file
bool _failed; // Failed read/write to/from cache (cache is broken?)
bool _lookup_failed; // Failed to lookup for info (skip only this code load)
@ -290,7 +288,6 @@ private:
public:
AOTCodeCache(bool is_dumping, bool is_using);
~AOTCodeCache();
const char* cache_buffer() const { return _load_buffer; }
bool failed() const { return _failed; }
@ -314,8 +311,6 @@ public:
bool for_use() const { return _for_use && !_failed; }
bool for_dump() const { return _for_dump && !_failed; }
bool closing() const { return _closing; }
AOTCodeEntry* add_entry() {
_store_entries_cnt++;
_store_entries -= 1;
@ -375,8 +370,8 @@ public:
static AOTCodeCache* cache() { assert(_passed_init2, "Too early to ask"); return _cache; }
static void initialize() NOT_CDS_RETURN;
static void init2() NOT_CDS_RETURN;
static void close() NOT_CDS_RETURN;
static bool is_on() CDS_ONLY({ return cache() != nullptr && !_cache->closing(); }) NOT_CDS_RETURN_(false);
static void dump() NOT_CDS_RETURN;
static bool is_on() CDS_ONLY({ return cache() != nullptr; }) NOT_CDS_RETURN_(false);
static bool is_on_for_use() CDS_ONLY({ return is_on() && _cache->for_use(); }) NOT_CDS_RETURN_(false);
static bool is_on_for_dump() CDS_ONLY({ return is_on() && _cache->for_dump(); }) NOT_CDS_RETURN_(false);
static bool is_dumping_stub() NOT_CDS_RETURN_(false);