Skip to content

Commit 06e98c7

Browse files
realFlowControlbwoebi
authored andcommitted
reset interrupt count when removing interrupt (#3455)
(cherry picked from commit 1fa51af)
1 parent 14ca9e9 commit 06e98c7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

profiling/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ extern "C" fn rinit(_type: c_int, _module_number: c_int) -> ZendResult {
577577
let result = REQUEST_LOCALS.try_with_borrow_mut(|locals| {
578578
// SAFETY: we are in rinit on a PHP thread.
579579
locals.vm_interrupt_addr = unsafe { zend::datadog_php_profiling_vm_interrupt_addr() };
580-
locals.interrupt_count.store(0, Ordering::SeqCst);
581580

582581
// SAFETY: We are after first rinit and before mshutdown.
583582
unsafe {

profiling/src/profiling/interrupts.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ impl InterruptManager {
4646
pub(super) fn remove_interrupt(&self, interrupt: VmInterrupt) {
4747
let mut vm_interrupts = self.vm_interrupts.lock().unwrap();
4848
vm_interrupts.remove(&interrupt);
49+
unsafe {
50+
// Reset interrupt counter to prevent sampling during `mshutdown` (PHP 8.0 bug with
51+
// userland destructors), but leave the interrupt flag unchanged as other extensions
52+
// may have raised it.
53+
(*interrupt.interrupt_count_ptr).store(0, Ordering::SeqCst);
54+
}
4955
}
5056

5157
#[inline]

0 commit comments

Comments
 (0)