]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: segv in a portable way 7790/head
authorKefu Chai <kchai@redhat.com>
Thu, 25 Feb 2016 04:19:06 +0000 (12:19 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 26 Feb 2016 07:19:45 +0000 (15:19 +0800)
this piece of code creates a SEGV from logging code to verify a
bug fix at e3fe18a.

clang will delete the null-referencing code. so we need to either
- pass -Wnonull-dereference to $(CC)
- or use  __builtin_trap() offered by GCC/clang
- or use `volatile`
seems volatile is easier and probably more portable.

Fixes: #14856
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/log/Log.cc

index ee4039608f9ce2de1cc38cbbc93c3557539ce71c..8cfdc0b5fd8aa3b6a902c9e38c67e4433b592edb 100644 (file)
@@ -190,7 +190,7 @@ void Log::submit_entry(Entry *e)
   m_queue_mutex_holder = pthread_self();
 
   if (m_inject_segv)
-    *(int *)(0) = 0xdead;
+    *(volatile int *)(0) = 0xdead;
 
   // wait for flush to catch up
   while (m_new.m_len > m_max_new)