diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-06-01 12:34:09 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-06-01 12:34:09 +0200 |
commit | 7862537993ef9f47ad6c79dce3f569e2df1477dc (patch) | |
tree | 831144c5f6f48fd9704adafe8b56153be4e49922 | |
parent | 1fc292c45e2136ef3feea99873eadf1300670f4e (diff) | |
parent | edfabff0a4a766b6812239209f94d80defb23dd0 (diff) | |
download | crash-worker-7862537993ef9f47ad6c79dce3f569e2df1477dc.tar.gz crash-worker-7862537993ef9f47ad6c79dce3f569e2df1477dc.tar.bz2 crash-worker-7862537993ef9f47ad6c79dce3f569e2df1477dc.zip |
Merge branch 'tizen' into tizen_5.5submit/tizen_5.5/20200602.093504submit/tizen_5.5/20200601.114801accepted/tizen/5.5/unified/20200603.230103
Change-Id: Ic9c38d8dc354da3f82e7c9e10fb54eea092f7467
-rw-r--r-- | packaging/crash-worker.spec | 2 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.c | 57 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.conf | 8 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.h | 1 | ||||
-rw-r--r-- | src/shared/config.c | 8 | ||||
-rw-r--r-- | src/shared/config.h | 2 | ||||
-rwxr-xr-x | tests/system/full_core/full_core.sh.template | 12 |
7 files changed, 58 insertions, 32 deletions
diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 68fb993..013e409 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -13,7 +13,7 @@ Name: crash-worker Summary: Coredump handler and report generator for Tizen -Version: 5.5.39 +Version: 5.5.40 Release: 1 Group: Framework/system License: Apache-2.0 and BSD-2-Clause and MIT diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 42044be..ea4c3b7 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -299,6 +299,13 @@ static bool get_cmd_info(struct crash_info *cinfo) if (!cinfo->cmd_line) return false; + if (!read_proc_file(cinfo->tid_info, "comm", buf, sizeof(buf), filter_drop_trailing_whitespace)) + goto err; + + cinfo->comm = strdup(buf); + if (!cinfo->comm) + goto err; + if (!get_exe_path(cinfo->pid_info, buf, sizeof(buf))) goto err; @@ -311,6 +318,8 @@ static bool get_cmd_info(struct crash_info *cinfo) err: free(cinfo->cmd_line); cinfo->cmd_line = NULL; + free(cinfo->comm); + cinfo->comm = NULL; return false; } @@ -616,9 +625,6 @@ static void launch_dbus_notify(struct crash_info *cinfo) char pid_str[11], tid_str[11], sig_str[11]; char *prstatus_fd_str = NULL; - char tid_comm_str[KERNEL_DEFINED_TASK_COMM_LEN + 1] = { 0, }; - - (void)read_proc_file(cinfo->tid_info, "comm", tid_comm_str, sizeof(tid_comm_str), filter_drop_trailing_whitespace); if (asprintf(&prstatus_fd_str, "%d", cinfo->prstatus_fd) == -1) { _E("Unable to allocate memory: %m"); @@ -641,7 +647,7 @@ static void launch_dbus_notify(struct crash_info *cinfo) "--reportpath", cinfo->result_path, "--prstatus_fd", prstatus_fd_str, "--signal", sig_str, - "--tid-comm", tid_comm_str, + "--tid-comm", cinfo->comm, legacy_notification_str, NULL }; @@ -702,12 +708,9 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code) /* Minicoredumper must be executed to dump at least PRSTATUS for other tools, coredump, however, might have been disabled. */ if (!config.dump_core && file_exists_in_dir(cinfo->pfx, coredump_name)) { + _E("Saving core disabled but coredump found (minicoredumper bug?). Removing coredump %s/%s", cinfo->pfx, coredump_name); if (!remove_file_in_dir(cinfo->pfx, coredump_name)) - _E("Saving core disabled - removing coredump %s/%s failed: %m", - cinfo->pfx, coredump_name); - else - _D("Saving core disabled - removed coredump %s/%s", - cinfo->pfx, coredump_name); + _E("Removing coredump %s/%s failed: %m", cinfo->pfx, coredump_name); } out: @@ -1208,6 +1211,7 @@ static void free_crash_info(struct crash_info *cinfo) { free(cinfo->cmd_line); free(cinfo->cmd_path); + free(cinfo->comm); free(cinfo->temp_dir); free(cinfo->result_path); free(cinfo->app_root_path); @@ -1233,6 +1237,7 @@ void crash_info_init(struct crash_info *cinfo) cinfo->executable_path = NULL; cinfo->cmd_line = NULL; cinfo->cmd_path = NULL; + cinfo->comm = NULL; cinfo->temp_dir = NULL; cinfo->app_root_path = NULL; cinfo->pfx = NULL; @@ -1246,6 +1251,23 @@ void crash_info_init(struct crash_info *cinfo) cinfo->lock_fd = -1; } +static void release_crashed_process() +{ + /* Release the core pipe as passed by kernel, allowing another + * coredump to be handled. + * + * Due to usage of core_pipe_limit there is limited number of + * crash-manager processes that kernel is going to invoke + * concurrently. As the next and last step is a _synchronous_ + * call to crash-popup we close the descriptor here. + * + * Note: for VIP processes this will likely cause the system + * to reboot without showing popup. + */ + close(STDIN_FILENO); + _I("Released crashed process lock"); +} + static bool run(struct crash_info *cinfo) { /* Execute processes in parallel */ @@ -1272,6 +1294,9 @@ static bool run(struct crash_info *cinfo) return false; } + if (!cinfo->livedump && config.release_early) + release_crashed_process(); + char *temp_report; if (config.report_type >= REP_TYPE_FULL) { /* Save shared objects info (file names, bulid IDs, rpm package names) */ @@ -1299,18 +1324,8 @@ static bool run(struct crash_info *cinfo) printf("REPORT_PATH=%s\n", cinfo->result_path); if (!cinfo->livedump) { - /* Release the core pipe as passed by kernel, allowing another - * coredump to be handled. - * - * Due to usage of core_pipe_limit there is limited number of - * crash-manager processes that kernel is going to invoke - * concurrently. As the next and last step is a _synchronous_ - * call to crash-popup we close the descriptor here. - * - * Note: for VIP processes this will likely cause the system - * to reboot without showing popup. - */ - close(STDIN_FILENO); + if (!config.release_early) + release_crashed_process(); launch_dbus_notify(cinfo); diff --git a/src/crash-manager/crash-manager.conf b/src/crash-manager/crash-manager.conf index 09f3926..d1f58af 100644 --- a/src/crash-manager/crash-manager.conf +++ b/src/crash-manager/crash-manager.conf @@ -5,6 +5,14 @@ MaxRetentionSec=0 MaxCrashDump=0 AllowZip=yes +# Release process before report completion (default - no) +# This option determines whether the crashing process should be released +# immediately after reading the necessary data from /proc/<PID>/ to allow the +# process to be cleaned up. This is important for VIP processes because if they +# are cleaned up too early, the device will be rebooted before the full report +# is written. +# ReleaseProcessLockEarly=no + # Crash report path must exist for the reports to be created # CrashRootPath=/usr/opt/share/crash/ diff --git a/src/crash-manager/crash-manager.h b/src/crash-manager/crash-manager.h index 320ef41..bd4f85b 100644 --- a/src/crash-manager/crash-manager.h +++ b/src/crash-manager/crash-manager.h @@ -36,6 +36,7 @@ struct crash_info { int prstatus_fd; char *cmd_line; char *cmd_path; + char *comm; char *temp_dir; char *name; char *app_root_path; diff --git a/src/shared/config.c b/src/shared/config.c index b3bce77..694596d 100644 --- a/src/shared/config.c +++ b/src/shared/config.c @@ -154,6 +154,7 @@ static bool config_load_from_dict(config_t *c, dictionary *ini) UPDATE(c->dump_so_info, boolean, "DumpSharedObjectInfo"); UPDATE(c->allow_zip, boolean, "AllowZip"); UPDATE(c->legacy_notification, boolean, "UseLegacyNotification"); + UPDATE(c->release_early, boolean, "ReleaseProcessLockEarly"); #undef UPDATE @@ -251,6 +252,7 @@ static bool config_apply_defaults(config_t *c) c->dump_so_info = DUMP_SO_INFO; c->allow_zip = ALLOW_ZIP; c->legacy_notification = LEGACY_NOTIFICATION; + c->release_early = RELEASE_EARLY; return c->crash_root_path != NULL; } @@ -269,7 +271,8 @@ static void config_dump(config_t *c) "config: dump_core = %d\n" "config: dump_so_info = %d\n" "config: allow_zip = %d\n" - "config: legacy_notification = %d\n", + "config: legacy_notification = %d\n" + "config: release_early = %d\n", c->crash_root_path, c->extra_script, report_type_to_str(c->report_type), @@ -280,7 +283,8 @@ static void config_dump(config_t *c) c->dump_core, c->dump_so_info, c->allow_zip, - c->legacy_notification); + c->legacy_notification, + c->release_early); } bool config_init(config_t *c, const char *const path) diff --git a/src/shared/config.h b/src/shared/config.h index e209dfb..99a5485 100644 --- a/src/shared/config.h +++ b/src/shared/config.h @@ -29,6 +29,7 @@ #define DUMP_SO_INFO 1 #define ALLOW_ZIP 1 #define LEGACY_NOTIFICATION 0 +#define RELEASE_EARLY 0 #define CRASH_SECTION "CrashManager" @@ -52,6 +53,7 @@ typedef struct config { bool dump_core; bool dump_so_info; bool legacy_notification; + bool release_early; enum ReportType report_type; int system_max_use; int system_keep_free; diff --git a/tests/system/full_core/full_core.sh.template b/tests/system/full_core/full_core.sh.template index df74f75..5d5595f 100755 --- a/tests/system/full_core/full_core.sh.template +++ b/tests/system/full_core/full_core.sh.template @@ -12,26 +12,22 @@ clean_crash_dump MINICOREDUMPER_DIR=/etc/minicoredumper/ CONFIG_FILE=${MINICOREDUMPER_DIR}/generic.recept.json -DOTNET_CONFIG_FILE=${MINICOREDUMPER_DIR}/dotnet.recept.json +ORIG_CONFIG_FILE=$(readlink ${CONFIG_FILE}) +FULLCORE_CONFIG_FILE=${MINICOREDUMPER_DIR}/generic-fullcore.recept.json BACKUP_CONFIG_FILE=/tmp/generic.recept.json -function backup_config { - cp ${CONFIG_FILE} ${BACKUP_CONFIG_FILE} -} - function modify_config { - cp ${DOTNET_CONFIG_FILE} ${CONFIG_FILE} + ln -sf ${FULLCORE_CONFIG_FILE} ${CONFIG_FILE} } function restore { - cp ${BACKUP_CONFIG_FILE} ${CONFIG_FILE} + ln -sf ${ORIG_CONFIG_FILE} ${CONFIG_FILE} popd } trap restore 0 pushd ${CRASH_DUMP_PATH} -backup_config modify_config { |