Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/iocore/cache/Stripe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace
{

DbgCtl dbg_ctl_cache_init{"cache_init"};
DbgCtl dbg_ctl_cache_free{"cache_free"};

constexpr int DIRECTORY_FOOTER_SIZE{ROUND_TO_STORE_BLOCK(sizeof(StripeHeaderFooter))};

Expand Down Expand Up @@ -172,12 +173,26 @@ Stripe::_init_directory(std::size_t directory_size, int header_size, int footer_
Stripe::~Stripe()
{
if (this->directory.raw_dir != nullptr) {
// Debug logging to track cleanup - helps correlate with crash location
Dbg(dbg_ctl_cache_free, "Stripe %s: freeing raw_dir=%p size=%zu huge=%s", hash_text.get() ? hash_text.get() : "(null)",
this->directory.raw_dir, this->directory.raw_dir_size, this->directory.raw_dir_huge ? "true" : "false");

// Validate that size is reasonable (catches corruption before free)
ink_assert(this->directory.raw_dir_size > 0);
ink_assert(this->directory.raw_dir_size < MAX_STRIPE_SIZE);

#ifdef DEBUG
// Poison memory before freeing to help detect use-after-free
memset(this->directory.raw_dir, 0xDE, this->directory.raw_dir_size);
#endif

if (this->directory.raw_dir_huge) {
ats_free_hugepage(this->directory.raw_dir, this->directory.raw_dir_size);
} else {
ats_free(this->directory.raw_dir);
}
this->directory.raw_dir = nullptr;
this->directory.raw_dir = nullptr;
this->directory.raw_dir_size = 0;
}
}

Expand Down