Skip to content

Commit 003c3cf

Browse files
use panic functions to init
1 parent daf58fc commit 003c3cf

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

profiling/src/allocation/allocation_ge84.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ struct ZendMMState {
5656
shutdown: unsafe fn(bool, bool),
5757
}
5858

59+
unsafe fn alloc_prof_panic_alloc(_len: size_t) -> *mut c_void {
60+
panic!("");
61+
}
62+
63+
unsafe fn alloc_prof_panic_realloc(_prev_ptr: *mut c_void, _len: size_t) -> *mut c_void {
64+
panic!("");
65+
}
66+
67+
unsafe fn alloc_prof_panic_free(_ptr: *mut c_void) {
68+
panic!("");
69+
}
70+
71+
unsafe fn alloc_prof_panic_gc() -> size_t {
72+
panic!("");
73+
}
74+
75+
unsafe fn alloc_prof_panic_shutdown(_full: bool, _silent: bool) {
76+
panic!("");
77+
}
78+
5979
impl ZendMMState {
6080
const fn new() -> ZendMMState {
6181
ZendMMState {
@@ -71,11 +91,11 @@ impl ZendMMState {
7191
prev_custom_mm_free: None,
7292
prev_custom_mm_gc: None,
7393
prev_custom_mm_shutdown: None,
74-
alloc: alloc_prof_orig_alloc,
75-
realloc: alloc_prof_orig_realloc,
76-
free: alloc_prof_orig_free,
77-
gc: alloc_prof_orig_gc,
78-
shutdown: alloc_prof_orig_shutdown,
94+
alloc: alloc_prof_panic_alloc,
95+
realloc: alloc_prof_panic_realloc,
96+
free: alloc_prof_panic_free,
97+
gc: alloc_prof_panic_gc,
98+
shutdown: alloc_prof_panic_shutdown,
7999
}
80100
}
81101
}
@@ -169,6 +189,14 @@ pub fn alloc_prof_ginit() {
169189
ptr::addr_of_mut!((*zend_mm_state).shutdown).write(alloc_prof_prev_shutdown);
170190
}
171191
}
192+
} else {
193+
unsafe {
194+
ptr::addr_of_mut!((*zend_mm_state).alloc).write(alloc_prof_orig_alloc);
195+
ptr::addr_of_mut!((*zend_mm_state).free).write(alloc_prof_orig_free);
196+
ptr::addr_of_mut!((*zend_mm_state).realloc).write(alloc_prof_orig_realloc);
197+
ptr::addr_of_mut!((*zend_mm_state).gc).write(alloc_prof_orig_gc);
198+
ptr::addr_of_mut!((*zend_mm_state).shutdown).write(alloc_prof_orig_shutdown);
199+
}
172200
}
173201

174202
// Create a new (to be observed) heap and prepare custom handlers

profiling/src/allocation/allocation_le83.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ thread_local! {
7070
})
7171
};
7272
}
73+
74+
unsafe fn alloc_prof_panic_alloc(_len: size_t) -> *mut c_void {
75+
panic!("");
76+
}
77+
78+
unsafe fn alloc_prof_panic_realloc(_prev_ptr: *mut c_void, _len: size_t) -> *mut c_void {
79+
panic!("");
80+
}
81+
82+
unsafe fn alloc_prof_panic_free(_ptr: *mut c_void) {
83+
panic!("");
84+
}
85+
7386
#[cfg(not(php_zts))]
7487
static mut ZEND_MM_STATE: ZendMMState = {
7588
ZendMMState {
@@ -78,9 +91,9 @@ static mut ZEND_MM_STATE: ZendMMState = {
7891
prev_custom_mm_realloc: None,
7992
prev_custom_mm_free: None,
8093
prepare_restore_zend_heap: (prepare_zend_heap, restore_zend_heap),
81-
alloc: alloc_prof_orig_alloc,
82-
realloc: alloc_prof_orig_realloc,
83-
free: alloc_prof_orig_free,
94+
alloc: alloc_prof_panic_alloc,
95+
realloc: alloc_prof_panic_realloc,
96+
free: alloc_prof_panic_free,
8497
}
8598
};
8699

0 commit comments

Comments
 (0)