Skip to content

Commit b389c65

Browse files
fix(profiling): use cached heap in alloc_prof_orig_* functions
A crash report indicated that `_zend_mm_alloc` was being called with an invalid heap pointer This invalid pointer originated from the call to `zend::zend_mm_get_heap()` within `alloc_prof_orig_alloc`.
1 parent 4a26042 commit b389c65

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

profiling/src/allocation/allocation_le83.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ unsafe fn alloc_prof_prev_alloc(len: size_t) -> *mut c_void {
373373
}
374374

375375
unsafe fn alloc_prof_orig_alloc(len: size_t) -> *mut c_void {
376-
let heap = zend::zend_mm_get_heap();
376+
let heap = tls_zend_mm_state_get!(heap).unwrap();
377377
let (prepare, restore) = tls_zend_mm_state_get!(prepare_restore_zend_heap);
378378
let custom_heap = prepare(heap);
379379
let ptr: *mut c_void = zend::_zend_mm_alloc(heap, len);
@@ -398,7 +398,7 @@ unsafe fn alloc_prof_prev_free(ptr: *mut c_void) {
398398
}
399399

400400
unsafe fn alloc_prof_orig_free(ptr: *mut c_void) {
401-
let heap = zend::zend_mm_get_heap();
401+
let heap = tls_zend_mm_state_get!(heap).unwrap();
402402
zend::_zend_mm_free(heap, ptr);
403403
}
404404

@@ -432,7 +432,7 @@ unsafe fn alloc_prof_prev_realloc(prev_ptr: *mut c_void, len: size_t) -> *mut c_
432432
}
433433

434434
unsafe fn alloc_prof_orig_realloc(prev_ptr: *mut c_void, len: size_t) -> *mut c_void {
435-
let heap = zend::zend_mm_get_heap();
435+
let heap = tls_zend_mm_state_get!(heap).unwrap();
436436
let (prepare, restore) = tls_zend_mm_state_get!(prepare_restore_zend_heap);
437437
let custom_heap = prepare(heap);
438438
let ptr: *mut c_void = zend::_zend_mm_realloc(heap, prev_ptr, len);

0 commit comments

Comments
 (0)