Skip to content

Commit cc0bc04

Browse files
committed
adjust the handling of non-handle frees
1 parent f77876a commit cc0bc04

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

runtime/core/ThreadCache.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,11 @@ namespace alaska {
186186
void ThreadCache::hfree(void *handle) {
187187
alaska::Mapping *m = alaska::Mapping::from_handle_safe(handle);
188188
if (unlikely(m == nullptr)) {
189+
190+
// printf("attempt to free non handle %p\n", handle);
189191
bool worked = this->runtime.heap.huge_allocator.free(handle);
190-
ALASKA_ASSERT(worked, "huge free failed");
192+
(void)worked;
193+
// ALASKA_ASSERT(worked, "huge free failed");
191194
return;
192195
}
193196
// Free the allocation behind a mapping
@@ -199,7 +202,10 @@ namespace alaska {
199202

200203

201204
size_t ThreadCache::get_size(void *handle) {
202-
alaska::Mapping *m = alaska::Mapping::from_handle(handle);
205+
alaska::Mapping *m = alaska::Mapping::from_handle_safe(handle);
206+
if (m == nullptr) {
207+
return this->runtime.heap.huge_allocator.size_of(handle);
208+
}
203209
void *ptr = m->get_pointer();
204210
auto *page = this->runtime.heap.pt.get_unaligned(ptr);
205211
if (page == nullptr) return this->runtime.heap.huge_allocator.size_of(ptr);

runtime/rt/halloc.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ void hfree(void *ptr) {
7575
// no-op if NULL is passed
7676
if (unlikely(ptr == NULL)) return;
7777

78-
// Grab the Mapping
79-
auto *m = alaska::Mapping::from_handle_safe(ptr);
80-
81-
// Not a handle? Pass it to the system allocator.
82-
if (unlikely(m == NULL)) {
83-
return ::free(ptr);
84-
}
85-
8678
// Simply ask the thread cache to free it!
8779
get_tc()->hfree(ptr);
8880
}

0 commit comments

Comments
 (0)