Skip to content

Commit 4ff4cbc

Browse files
committed
fix asan false positive
1 parent 7e90732 commit 4ff4cbc

File tree

7 files changed

+7
-6
lines changed

7 files changed

+7
-6
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112112

113113
- name: Test with ASAN
114-
run: cargo test --tests --target x86_64-unknown-linux-gnu
114+
run: cargo test --tests --target x86_64-unknown-linux-gnu --features asan
115115
env:
116116
RUST_TARGET: x86_64-unknown-linux-gnu
117117
RUST_BACKTRACE: 1

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ path = "examples/escape.rs"
1818

1919
[features]
2020
codspeed = ["criterion2/codspeed"]
21+
asan = [] # for ASAN
2122

2223
[[bench]]
2324
name = "escape"

src/simd/avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub unsafe fn format_string(value: &str, dst: &mut [u8]) -> usize {
232232
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
233233
Simd256u::loadu(placeholder[..].as_ptr())
234234
} else {
235-
#[cfg(any(debug_assertions, miri))]
235+
#[cfg(any(debug_assertions, miri, feature = "asan"))]
236236
{
237237
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
238238
Simd256u::loadu(placeholder[..].as_ptr())

src/simd/avx512.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub unsafe fn format_string(value: &str, dst: &mut [u8]) -> usize {
225225
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
226226
Simd512u::loadu(placeholder[..].as_ptr())
227227
} else {
228-
#[cfg(any(debug_assertions, miri))]
228+
#[cfg(any(debug_assertions, miri, feature = "asan"))]
229229
{
230230
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
231231
Simd512u::loadu(placeholder[..].as_ptr())

src/simd/neon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub unsafe fn format_string(value: &str, dst: &mut [u8]) -> usize {
233233
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
234234
Simd128u::loadu(placeholder[..].as_ptr())
235235
} else {
236-
#[cfg(any(debug_assertions, miri))]
236+
#[cfg(any(debug_assertions, miri, feature = "asan"))]
237237
{
238238
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
239239
Simd128u::loadu(placeholder[..].as_ptr())

src/simd/sse2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub unsafe fn format_string(value: &str, dst: &mut [u8]) -> usize {
229229
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
230230
Simd128u::loadu(placeholder[..].as_ptr())
231231
} else {
232-
#[cfg(any(debug_assertions, miri))]
232+
#[cfg(any(debug_assertions, miri, feature = "asan"))]
233233
{
234234
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
235235
Simd128u::loadu(placeholder[..].as_ptr())

src/simd/v128.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn format_string(value: &str, dst: &mut [u8]) -> usize {
161161
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
162162
Simd128u::loadu(placeholder[..].as_ptr())
163163
} else {
164-
#[cfg(any(debug_assertions, miri))]
164+
#[cfg(any(debug_assertions, miri, feature = "asan"))]
165165
{
166166
std::ptr::copy_nonoverlapping(sptr, placeholder[..].as_mut_ptr(), nb);
167167
Simd128u::loadu(placeholder[..].as_ptr())

0 commit comments

Comments
 (0)