Skip to content

Commit 94cb15c

Browse files
committed
cpumask: provide patch to make ASAN SEGV
In order to trigger a SEGV in ASAN, apply the 0001-reproduce-SEGV.patch to dc48871 via git clone git@github.com:chaiken/util-scripts.git git am 0001-reproduce-SEGV.patch Then fix the path to the googletest headers in the Makefile and run make cpumask_test && ./cpumask_test
1 parent dc48871 commit 94cb15c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

0001-reproduce-SEGV.patch

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 3cb4d3859bb359cb266be0b014600e71fc749c14 Mon Sep 17 00:00:00 2001
2+
From: Alison Chaiken <alison@she-devel.com>
3+
Date: Mon, 26 Dec 2022 10:56:52 -0800
4+
Subject: [PATCH] reproduce SEGV
5+
6+
---
7+
Makefile | 4 +---
8+
cpumask_testsuite.cc | 4 +---
9+
2 files changed, 2 insertions(+), 6 deletions(-)
10+
11+
diff --git a/Makefile b/Makefile
12+
index f08f342..c1d3fa1 100644
13+
--- a/Makefile
14+
+++ b/Makefile
15+
@@ -46,11 +46,9 @@ cpumask: cpumask.c
16+
# $(CFLAGS) $(LDFLAGS)
17+
# make cpumask_test
18+
# ./cpumask_test
19+
-cpumask_testsuite.o: cpumask_testsuite.cc
20+
- $(CPPCC) -isystem $(GTEST_HEADERS) $(CVALGRINDFLAGS) -fsanitize=undefined -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
21+
22+
cpumask_test: cpumask_testsuite.o cpumask.c
23+
- $(CPPCC) $(CVALGRINDFLAGS) $(LDVALGRINDFLAGS) -fsanitize=undefined -Wall -o cpumask_test cpumask_testsuite.o $(GTESTLIBS)
24+
+ $(CPPCC) $(CFLAGS) $(LDFLAGS) -Wall -o cpumask_test cpumask_testsuite.o $(GTESTLIBS)
25+
26+
clean:
27+
/bin/rm -rf *.o *~ hex2dec dec2hex cdecl cpumask cpumask_test
28+
diff --git a/cpumask_testsuite.cc b/cpumask_testsuite.cc
29+
index 9834393..7f383be 100644
30+
--- a/cpumask_testsuite.cc
31+
+++ b/cpumask_testsuite.cc
32+
@@ -40,11 +40,9 @@ AddressSanitizer:DEADLYSIGNAL
33+
#7 0x55b280c0c595 in std::__shared_ptr<char const, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/include/c++/12/bits/shared_ptr_base.h:1524
34+
#8 0x55b280c0c603 in std::shared_ptr<char const>::~shared_ptr() /usr/include/c++/12/bits/shared_ptr.h:175
35+
#9 0x55b280c08847 in SimpleCpuMaskTest_ParseRange_Test::TestBody() /home/alison/gitsrc/util-scripts/cpumask_testsuite.cc:27
36+
-
37+
+ */
38+
std::shared_ptr<const char> str1("0-1");
39+
EXPECT_EQ(3, parse_range(str1.get(), 1U));
40+
- clang-format on
41+
- */
42+
// works with single-digit delimiters
43+
EXPECT_EQ(3, parse_range("0-1,", 1U));
44+
// works with multi-digit delimiters
45+
--
46+
2.35.1
47+

0 commit comments

Comments
 (0)