Commit 17590957 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2850] Throw std::bad_alloc if ZoneTable::create() throws MemorySegmentGrown

We don't attempt to recover in this case.

Also change some error handling to simply asserts.
parent e2889aab
......@@ -97,16 +97,7 @@ ZoneTableSegmentMapped::processChecksum(MemorySegmentMapped& segment,
*static_cast<size_t*>(checksum) = 0;
const bool grew = segment.setNamedAddress(ZONE_TABLE_CHECKSUM_NAME,
checksum);
if (grew) {
// If the segment grew here, we have a problem as the
// checksum address may no longer be valid. In this case, we
// cannot recover. This case is extremely unlikely as we
// reserved memory for the ZONE_TABLE_CHECKSUM_NAME
// above. It indicates a very restrictive MemorySegment
// which we should not use.
error_msg = "Segment grew unexpectedly in setNamedAddress()";
return (false);
}
assert(!grew);
}
return (true);
......@@ -141,19 +132,17 @@ ZoneTableSegmentMapped::processHeader(MemorySegmentMapped& segment,
// Do nothing and try again.
}
}
ZoneTableHeader* new_header = new(ptr)
ZoneTableHeader(ZoneTable::create(segment, rrclass_));
const bool grew = segment.setNamedAddress(ZONE_TABLE_HEADER_NAME,
new_header);
if (grew) {
// If the segment grew here, we have a problem as the table
// header address may no longer be valid. In this case, we
// cannot recover. This case is extremely unlikely as we
// reserved memory for the ZONE_TABLE_HEADER_NAME above. It
// indicates a very restrictive MemorySegment which we
// should not use.
error_msg = "Segment grew unexpectedly in setNamedAddress()";
return (false);
try {
ZoneTableHeader* new_header = new(ptr)
ZoneTableHeader(ZoneTable::create(segment, rrclass_));
const bool grew = segment.setNamedAddress(ZONE_TABLE_HEADER_NAME,
new_header);
assert(!grew);
} catch (const MemorySegmentGrown&) {
// This is extremely unlikely and we just throw a fatal
// exception here without attempting to recover.
throw std::bad_alloc();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment