IssueNo:解决CoreService对象两次析构问题

Description:解决CoreService对象两次析构问题
Sig:SIG_Telephony
Feature or Bugfix: Bugfix
Binary Source: No

Signed-off-by: liuxiyao223 <liuxiyao223@huawei.com>
This commit is contained in:
liuxiyao223 2024-05-22 19:53:20 +08:00
parent 5d4ce2b72f
commit 072d71ca5a
11 changed files with 24 additions and 76 deletions

View File

@ -33,18 +33,12 @@ static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SIM_TYPE_NUM = 2; constexpr int32_t SIM_TYPE_NUM = 2;
constexpr int32_t SIZE_LIMIT = 4; constexpr int32_t SIZE_LIMIT = 4;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
constexpr uint32_t FUCTION_SIZE = 100; constexpr uint32_t FUCTION_SIZE = 100;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "addiccdiallingnumbers_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -246,5 +240,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -33,17 +33,11 @@ namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t CHOICE_NUM = 2; constexpr int32_t CHOICE_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "getsimeons_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -189,5 +183,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -32,17 +32,12 @@ using namespace OHOS::Telephony;
namespace OHOS { namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10; constexpr int32_t SLEEP_TIME_SECONDS = 3;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "sendenvelopecmd_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -234,5 +229,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -31,17 +31,11 @@ using namespace OHOS::Telephony;
namespace OHOS { namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "sendterminalresponsecmd_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -168,5 +162,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -38,17 +38,11 @@ constexpr int32_t SLOT_NUM = 2;
constexpr int32_t IMS_TYPE = 3; constexpr int32_t IMS_TYPE = 3;
constexpr int32_t NR_MODE = 4; constexpr int32_t NR_MODE = 4;
constexpr int32_t NETWORK_MODE = 7; constexpr int32_t NETWORK_MODE = 7;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setradiostate_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -331,5 +325,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -33,17 +33,11 @@ using namespace OHOS::Telephony;
namespace OHOS { namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setshowname_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -169,5 +163,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -32,17 +32,11 @@ using namespace OHOS::Telephony;
namespace OHOS { namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setshownumber_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -152,5 +146,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -33,17 +33,11 @@ namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t LOCK_TYPE = 2; constexpr int32_t LOCK_TYPE = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "setvoicemailinfo_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -155,5 +149,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -33,7 +33,6 @@ namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t TYPE_NUM = 2; constexpr int32_t TYPE_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10;
constexpr int32_t SIM_AUTH_EAP_SIM_TYPE = 128; constexpr int32_t SIM_AUTH_EAP_SIM_TYPE = 128;
constexpr int32_t SIM_AUTH_EAP_AKA_TYPE = 129; constexpr int32_t SIM_AUTH_EAP_AKA_TYPE = 129;
bool g_flag = false; bool g_flag = false;
@ -41,12 +40,7 @@ bool g_flag = false;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "simauthentication_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -185,5 +179,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -32,17 +32,12 @@ using namespace OHOS::Telephony;
namespace OHOS { namespace OHOS {
static bool g_isInited = false; static bool g_isInited = false;
constexpr int32_t SLOT_NUM = 2; constexpr int32_t SLOT_NUM = 2;
constexpr int32_t SLEEP_TIME_SECONDS = 10; constexpr int32_t SLEEP_TIME_SECONDS = 3;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "unlockpin_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -280,5 +275,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }

View File

@ -38,12 +38,7 @@ constexpr int32_t SLEEP_TIME_SECONDS = 2;
bool IsServiceInited() bool IsServiceInited()
{ {
if (!g_isInited) { if (!g_isInited) {
auto onStart = [] { DelayedSingleton<CoreService>::GetInstance()->OnStart(); }; DelayedSingleton<CoreService>::GetInstance()->OnStart();
std::thread startThread(onStart);
pthread_setname_np(startThread.native_handle(), "updateiccdiallingnumbers_fuzzer");
startThread.join();
sleep(SLEEP_TIME_SECONDS);
if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() == if (DelayedSingleton<CoreService>::GetInstance()->GetServiceRunningState() ==
static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) { static_cast<int32_t>(ServiceRunningState::STATE_RUNNING)) {
g_isInited = true; g_isInited = true;
@ -217,5 +212,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
OHOS::AddCoreServiceTokenFuzzer token; OHOS::AddCoreServiceTokenFuzzer token;
/* Run your code on data */ /* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size); OHOS::DoSomethingInterestingWithMyAPI(data, size);
OHOS::DelayedSingleton<CoreService>::DestroyInstance();
return 0; return 0;
} }