Skip to content

Commit 61be8bf

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 0994638 commit 61be8bf

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
@@ -375,7 +375,7 @@ unsafe fn alloc_prof_prev_alloc(len: size_t) -> *mut c_void {
375375
}
376376

377377
unsafe fn alloc_prof_orig_alloc(len: size_t) -> *mut c_void {
378-
let heap = zend::zend_mm_get_heap();
378+
let heap = tls_zend_mm_state_get!(heap).unwrap();
379379
let (prepare, restore) = tls_zend_mm_state_get!(prepare_restore_zend_heap);
380380
let custom_heap = prepare(heap);
381381
let ptr: *mut c_void = zend::_zend_mm_alloc(heap, len);
@@ -400,7 +400,7 @@ unsafe fn alloc_prof_prev_free(ptr: *mut c_void) {
400400
}
401401

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

@@ -436,7 +436,7 @@ unsafe fn alloc_prof_prev_realloc(prev_ptr: *mut c_void, len: size_t) -> *mut c_
436436
}
437437

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

0 commit comments

Comments
 (0)