Fix: coredump if invoke pthread_* with NULL thread handler 72/5972/3 accepted/tizen/ivi/genivi tizen_ivi_genivi accepted/tizen/20130729.233814 accepted/tizen/20130912.083416 accepted/tizen/20130912.085958 accepted/tizen/20130912.093250 accepted/tizen/ivi/genivi/20140131.062120 accepted/tizen_ivi_stable/20131116.111526 ivi_oct_m2 submit/tizen/20130729.235751 submit/tizen/20130912.075714 submit/tizen_ivi_genivi/20140131.061719 submit/tizen_ivi_stable/20131116.101025
authorChengwei Yang <chengwei.yang@intel.com>
Tue, 23 Jul 2013 08:09:47 +0000 (16:09 +0800)
committerChengwei Yang <chengwei.yang@intel.com>
Tue, 23 Jul 2013 08:09:47 +0000 (16:09 +0800)
This coredump can be triggered if download-provider request the
well-known dbus name failed, for example, currently, there is no dbus
policy conf for download-provider, so dbus daemon will reject its
request.

Bug: https://bugs.tizen.org/jira/browse/TDIST-276
Change-Id: Id341aa7da19bc89085bd5909391a37dde19b0173
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
agent/download-agent-client-mgr.c
packaging/download-provider.spec

index e4268ac..a19e3ba 100755 (executable)
@@ -44,6 +44,7 @@ da_result_t init_client_app_mgr()
        client_app_mgr.is_init = DA_TRUE;
        client_app_mgr.client_app_info.client_user_agent = DA_NULL;
        client_app_mgr.is_thread_init = DA_FALSE;
+       client_app_mgr.thread_id = 0;
 
        return DA_RESULT_OK;
 }
@@ -104,7 +105,7 @@ da_result_t dereg_client_app(void)
        _da_thread_mutex_lock(&(client_app_mgr.mutex_client_mgr));
        if (client_app_mgr.is_thread_init != DA_TRUE) {
                DA_LOG_CRITICAL(ClientNoti, "try to cancel client mgr thread id[%lu]", client_app_mgr.thread_id);
-               if (pthread_cancel(client_app_mgr.thread_id) < 0) {
+               if (client_app_mgr.thread_id && pthread_cancel(client_app_mgr.thread_id) < 0) {
                        DA_LOG_ERR(ClientNoti, "cancel thread is failed!!!");
                }
                free(client_noti);
@@ -113,7 +114,7 @@ da_result_t dereg_client_app(void)
                DA_LOG_VERBOSE(ClientNoti, "pushing Q_CLIENT_NOTI_TYPE_TERMINATE");
                push_client_noti(client_noti);
                DA_LOG_CRITICAL(Thread, "===try to join client mgr thread id[%lu]===", client_app_mgr.thread_id);
-               if (pthread_join(client_app_mgr.thread_id, &t_return) < 0) {
+               if (client_app_mgr.thread_id && pthread_join(client_app_mgr.thread_id, &t_return) < 0) {
                        DA_LOG_ERR(Thread, "join client thread is failed!!!");
                }
                DA_LOG_CRITICAL(Thread, "===thread join return[%d]===", (char*)t_return);
@@ -332,7 +333,7 @@ da_result_t  send_client_finished_info (
 
 da_result_t  __launch_client_thread(void)
 {
-       pthread_t thread_id = DA_NULL;
+       pthread_t thread_id = 0;
 
        DA_LOG_FUNC_START(Thread);
 
index a07c0bc..40437f7 100755 (executable)
@@ -2,7 +2,7 @@
 Name:       download-provider
 Summary:    Download the contents in background
 Version:    1.0.5
-Release:    9
+Release:    10
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz