Remove blocking and unblocking all sub threads 78/294478/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 20 Jun 2023 04:37:11 +0000 (04:37 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 20 Jun 2023 04:37:11 +0000 (04:37 +0000)
If the launchpad library tries to block the sub thread, the main thread
can be blocked. Because, if the sub thread calls the dlsym(), the global
mutex is locked. In this case, the main thread can be blocked by the mutex.

+------------------------------------------------------------------------------+
| Thread 22 (Thread 0xa5bf9250 (LWP 8524)):                                    |
| #0  0xb60cc754 in pthread_cond_wait@@GLIBC_2.4 () from                       |
|     target:/lib/libpthread.so.0                                              |
| #1  0xb5fe5c84 in std::condition_variable::wait(                             |
|     std::unique_lock<std::mutex>&) () from target:/lib/libstdc++.so.6        |
| #2  0xaf315a90 in launchpad::ThreadControl::SignalHandler(int) () from       |
|     target:/lib/liblaunchpad.so.0                                            |
| #3  <signal handler called>                                                  |
| #4  0xb60d06c4 in __lll_lock_wait () from target:/lib/libpthread.so.0        |
| #5  0xb60c7de8 in pthread_mutex_lock () from target:/lib/libpthread.so.0     |
| #6  0xb60e9098 in dlsym () from target:/lib/libdl.so.2                       |
|                                                                              |
| Thread 1 (Thread 0xb61be010 (LWP 5386)):                                     |
| #0  0xb60d06c4 in __lll_lock_wait () from target:/lib/libpthread.so.0        |
| #1  0xb60c7de8 in pthread_mutex_lock () from target:/lib/libpthread.so.0     |
| #2  0xb619f6d4 in _dl_lookup_symbol_x () from target:/lib/ld-linux.so.3      |
| #3  0xb61a3d00 in _dl_fixup () from target:/lib/ld-linux.so.3                |
+------------------------------------------------------------------------------+

Change-Id: I98ab129dabcc73e9fc7457ea400cab735bd3e4a2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad/step_prepare_execution.cc

index 88d2fa0..1c19ce0 100644 (file)
@@ -110,12 +110,10 @@ int StepPrepareExecution::MountResourceDirectories(AppInfo* app_info) {
 int StepPrepareExecution::SecurityManagerPrepareApp(AppInfo* app_info) {
   auto* enabled_light_user = bundle_get_val(app_info->GetBundle().GetHandle(),
       kAulEnabledLightUser);
-  ThreadControl::GetInst().BlockThreads();
   _W("security_manager_prepare_app2() ++ %s", app_info->GetAppId().c_str());
   int ret = security_manager_prepare_app2(app_info->GetAppId().c_str(),
       enabled_light_user);
   _W("security_manager_prepare_app2() -- %s", app_info->GetAppId().c_str());
-  ThreadControl::GetInst().UnblockThreads();
   if (ret != SECURITY_MANAGER_SUCCESS) {
     _E("security_manager_prepare_app2() is failed. appid: %s, error: %d",
         app_info->GetAppId().c_str(), ret);