Skip to content

Commit a8443ad

Browse files
committed
Revert "fix: use pointer provenance APIs"
This reverts commit 4fab4b1.
1 parent 6d2f343 commit a8443ad

File tree

5 files changed

+8
-30
lines changed

5 files changed

+8
-30
lines changed

Cargo.lock

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

profiling/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ serde_json = {version = "1.0"}
3434
rand = { version = "0.8.5" }
3535
rand_distr = { version = "0.4.3" }
3636
rustc-hash = "1.1.0"
37-
sptr = "0.3"
3837
uuid = { version = "1.0", features = ["v4"] }
3938

4039
[dev-dependencies]

profiling/src/profiling/stack_walking.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,9 @@ unsafe fn extract_file_and_line(execute_data: &zend_execute_data) -> (Option<Thi
9292

9393
#[cfg(php_run_time_cache)]
9494
mod detail {
95-
// See: https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance
96-
#![allow(unstable_name_collisions, unused_imports)]
97-
use sptr::Strict;
98-
9995
use super::*;
10096
use crate::string_set::StringSet;
101-
use datadog_thin_str::ThinStr;
97+
use datadog_thin_str::{ThinHeader, ThinStr};
10298
use log::{debug, trace};
10399
use std::cell::RefCell;
104100
use std::ops::Deref;
@@ -130,7 +126,7 @@ mod detail {
130126
// SAFETY: the slot is in-bounds from CacheSlot -> usize conv.
131127
let cached = unsafe { self.cache_slots.get_unchecked_mut(slot as usize) };
132128

133-
let ptr = sptr::from_exposed_addr_mut(*cached);
129+
let ptr = *cached as *mut ThinHeader;
134130
match NonNull::new(ptr) {
135131
Some(non_null) => {
136132
// SAFETY: the string set is only reset between requests,
@@ -143,7 +139,7 @@ mod detail {
143139
let string = f()?;
144140
let thin_str = self.string_set.insert(&string);
145141
let non_null = thin_str.header_ptr();
146-
*cached = non_null.as_ptr().expose_addr();
142+
*cached = non_null.as_ptr() as usize;
147143
Some(string)
148144
}
149145
}

thin-str/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ tagged-pointer = { version = "0.2", default-features = false }
2222

2323
[dev-dependencies]
2424
naughty-strings = "0.2"
25-
sptr = { version = "0.3", default-features = false }

thin-str/src/thin_string.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ mod ext {
265265

266266
#[cfg(test)]
267267
mod tests {
268-
// See: https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance
269-
#![allow(unstable_name_collisions, unused_imports)]
270-
use sptr::Strict;
271-
272268
use super::*;
273269
use allocator_api2::alloc::Global;
274270

@@ -331,19 +327,15 @@ This is a tribute.
331327
fn test_round_tripping_to_usize() {
332328
let datadog = "See inside any stack, any app, at any scale, anywhere.";
333329
let string = ThinString::from(datadog);
334-
let ptr = {
330+
331+
let bits = {
335332
let thin_str = string.as_thin_str();
336-
thin_str.header_ptr().as_ptr()
333+
let non_null = thin_str.header_ptr();
334+
non_null.as_ptr() as usize
337335
};
338336

339-
let bits = ptr.addr();
340-
341337
let restored = {
342-
// with_addr allows us to restore the provenance of the pointer,
343-
// and we can do this because we have the original to restore it.
344-
// The actually PHP profiler will not have such things available,
345-
// and should use `expose_addr` and similar.
346-
let non_null = unsafe { ptr::NonNull::new_unchecked(ptr.with_addr(bits)) };
338+
let non_null = unsafe { ptr::NonNull::new_unchecked(bits as *mut ThinHeader) };
347339
unsafe { ThinStr::from_header(non_null) }
348340
};
349341

0 commit comments

Comments
 (0)