From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E323B4765E0 for ; Thu, 24 Dec 2020 20:15:05 +0300 (MSK) References: <20201223154155.234884-1-gorcunov@gmail.com> <20201223154155.234884-5-gorcunov@gmail.com> <30a781d7-4f4e-3543-f67e-2fb1f7cce172@tarantool.org> <20201223212253.GA298600@grain> <20201224131601.GB298600@grain> From: Vladislav Shpilevoy Message-ID: <8c0b2bda-5614-eac0-c0b9-36630c4bf315@tarantool.org> Date: Thu, 24 Dec 2020 18:15:02 +0100 MIME-Version: 1.0 In-Reply-To: <20201224131601.GB298600@grain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v5 4/4] crash: report crash data to the feedback server List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tml On 24.12.2020 14:16, Cyrill Gorcunov wrote: > On Thu, Dec 24, 2020 at 12:22:53AM +0300, Cyrill Gorcunov wrote: >> On Wed, Dec 23, 2020 at 07:47:44PM +0100, Vladislav Shpilevoy wrote: >>> Hi! Thanks for the patch! >>> >>> See 3 comments and fixes below, and top of the branch in a >>> separate commit. >>> >> >> Vlad, since we can use json_escape I dropped usage of base64 >> encoder for backtrace. The final interdiff I pushed into >> gorcunov/gh-5261-crash-report-6 is the following > > FWIW gorcunov/gh-5261-crash-report-6 passes all tests > https://gitlab.com/tarantool/tarantool/-/pipelines/234153923 The branch didn't work on my machine when I tried to crash Tarantool. Because uname.version even being json-escaped contained a substring which is not a valid Lua string. This was the broken string: "Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2\/RELEASE_X86_64" Lua didn't understand symbol sequence `\/`. To workaround this I made the child process accept the dump data and the feedback host via command line arguments. Now seems to be working. I pushed my fixes on top of the branch, and pasted them below. ==================== diff --git a/src/lib/core/crash.c b/src/lib/core/crash.c index e62af6836..ee4991b52 100644 --- a/src/lib/core/crash.c +++ b/src/lib/core/crash.c @@ -258,10 +258,10 @@ crash_report_feedback_daemon(struct crash_info *cinfo) * modifications in future. */ size = (char *)uname_ptr - p; - snprintf_safe("require(\'http.client\').post(\'%s\'," - "'{\"crashdump\":{\"version\":\"%d\"," - "\"data\":", feedback_host, - crashinfo_version); + snprintf_safe("{"); + snprintf_safe("\"crashdump\":{"); + snprintf_safe("\"version\":\"%d\",", crashinfo_version); + snprintf_safe("\"data\":"); /* The "data" key value */ snprintf_safe("{"); @@ -334,15 +334,20 @@ crash_report_feedback_daemon(struct crash_info *cinfo) * main feedback daemon uses. */ size = e - p; - snprintf_safe("}}',{timeout=1});os.exit(1);"); + snprintf_safe("}"); + snprintf_safe("}"); pr_debug("crashinfo script: %s", head); - char *exec_argv[4] = { + char *exec_argv[7] = { [0] = tarantool_path, [1] = "-e", - [2] = head, - [3] = NULL, + [2] = "require('http.client').post(arg[1],arg[2],{timeout=1});" + "os.exit(1);", + [3] = "-", + [4] = feedback_host, + [5] = head, + [6] = NULL, }; /* @@ -360,9 +365,11 @@ crash_report_feedback_daemon(struct crash_info *cinfo) * is running fine. */ execve(exec_argv[0], exec_argv, environ); - pr_crit("exec(%s,[%s,%s,%s]) failed", + pr_crit("exec(%s,[%s,%s,%s,%s,%s,%s,%s]) failed", exec_argv[0], exec_argv[0], - exec_argv[1], exec_argv[2]); + exec_argv[1], exec_argv[2], + exec_argv[3], exec_argv[4], + exec_argv[5], exec_argv[6]); _exit(1); } else if (pid < 0) { pr_crit("unable to vfork (errno %d)", errno);