]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
global: store assert msg in global and dump to crash meta
authorMykola Golub <mgolub@suse.com>
Sun, 21 Oct 2018 07:34:30 +0000 (10:34 +0300)
committerMykola Golub <mgolub@suse.com>
Sun, 21 Oct 2018 07:44:41 +0000 (10:44 +0300)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/common/assert.cc
src/global/global_context.cc
src/global/global_context.h
src/global/signal_handler.cc

index 2803e0b7305bc652164d80b1240ceb6d3af72689..f5b74263dbaadf76d9c55983fc44190d58b2a7bd 100644 (file)
@@ -48,13 +48,12 @@ namespace ceph {
     ostringstream tss;
     tss << ceph_clock_now();
 
-    char buf[8096];
-    snprintf(buf, sizeof(buf),
+    snprintf(g_assert_msg, sizeof(g_assert_msg),
             "%s: In function '%s' thread %llx time %s\n"
             "%s: %d: FAILED ceph_assert(%s)\n",
             file, func, (unsigned long long)pthread_self(), tss.str().c_str(),
             file, line, assertion);
-    dout_emergency(buf);
+    dout_emergency(g_assert_msg);
 
     // TODO: get rid of this memory allocation.
     ostringstream oss;
@@ -62,7 +61,7 @@ namespace ceph {
     dout_emergency(oss.str());
 
     if (g_assert_context) {
-      lderr(g_assert_context) << buf << std::endl;
+      lderr(g_assert_context) << g_assert_msg << std::endl;
       *_dout << oss.str() << dendl;
 
       // dump recent only if the abort signal handler won't do it for us
@@ -124,8 +123,7 @@ namespace ceph {
     ceph_pthread_getname(pthread_self(), g_assert_thread_name,
                       sizeof(g_assert_thread_name));
 
-    char buf[8096];
-    BufAppender ba(buf, sizeof(buf));
+    BufAppender ba(g_assert_msg, sizeof(g_assert_msg));
     BackTrace *bt = new BackTrace(1);
     ba.printf("%s: In function '%s' thread %llx time %s\n"
             "%s: %d: FAILED ceph_assert(%s)\n",
@@ -137,7 +135,7 @@ namespace ceph {
     ba.vprintf(msg, args);
     va_end(args);
     ba.printf("\n");
-    dout_emergency(buf);
+    dout_emergency(g_assert_msg);
 
     // TODO: get rid of this memory allocation.
     ostringstream oss;
@@ -145,7 +143,7 @@ namespace ceph {
     dout_emergency(oss.str());
 
     if (g_assert_context) {
-      lderr(g_assert_context) << buf << std::endl;
+      lderr(g_assert_context) << g_assert_msg << std::endl;
       *_dout << oss.str() << dendl;
 
       // dump recent only if the abort signal handler won't do it for us
index 0eb6e62bf3dd23441f26d66eede9125df6ce0b52..4adfa0ff28bc7d3a67f7c551a1dad1285e3f8aaa 100644 (file)
@@ -33,3 +33,4 @@ const char *g_assert_func = 0;
 const char *g_assert_condition = 0;
 unsigned long long g_assert_thread = 0;
 char g_assert_thread_name[4096];
+char g_assert_msg[8096];
index a58e4b26c9046e42447e72f5e1b0bb3753f91979..59031f4c68fbbc795f8d37b4d5a9b22da0999e21 100644 (file)
@@ -28,5 +28,6 @@ extern const char *g_assert_func;
 extern const char *g_assert_condition;
 extern unsigned long long g_assert_thread;
 extern char g_assert_thread_name[4096];
+extern char g_assert_msg[8096];
 
 #endif
index 3ac35626cb35ebff9532e9c2719129fc6742e417..45155b3bf16e13e387bed06d6707941be2b86266 100644 (file)
@@ -249,6 +249,9 @@ static void handle_fatal_signal(int signum)
        if (g_assert_thread_name[0]) {
          jf.dump_string("assert_thread_name", g_assert_thread_name);
        }
+       if (g_assert_msg[0]) {
+         jf.dump_string("assert_msg", g_assert_msg);
+       }
 
        // backtrace
        bt.dump(&jf);