Tarantool development patches archive
 help / color / mirror / Atom feed
From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH] Fix libunwind segfault
Date: Fri,  8 Jun 2018 20:17:33 +0300	[thread overview]
Message-ID: <5c3b30016bc65a77804f995de0024a66a699ccc1.1528478042.git.georgy@tarantool.org> (raw)

Use volatile asm modifier to prevent unwanted and awkward optimizations
causing segfault while backtracing
---
branch: https://github.com/tarantool/tarantool/tree/gh-3448-unwind-fix
issues: https://github.com/tarantool/tarantool/issues/3448
 src/backtrace.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/backtrace.cc b/src/backtrace.cc
index a86255e1f..2512bc045 100644
--- a/src/backtrace.cc
+++ b/src/backtrace.cc
@@ -210,11 +210,11 @@ unw_getcontext_f(unw_context_t *unw_context, void *stack)
  * @param @unw_context unwind context to store execution state.
  * @param @coro_ctx fiber context to unwind.
  */
-void
+static void
 coro_unwcontext(unw_context_t *unw_context, struct coro_context *coro_ctx)
 {
 #if __amd64
-__asm__(
+__asm__ volatile(
 	/* Preserve current context */
 	"\tpushq %%rbp\n"
 	"\tpushq %%rbx\n"
@@ -249,11 +249,11 @@ __asm__(
 	"\tpopq %%rbp\n"
 	:
 	: "r" (unw_context), "r" (coro_ctx), "i" (unw_getcontext_f)
-	: "rdi", "rsi", "rax"
+	: "rdi", "rsi", "rax"//, "r8"//"rsp", "r11", "r10", "r9", "r8"
 	);
 
 #elif __i386
-__asm__(
+__asm__ volatile(
 	/* Save current context */
 	"\tpushl %%ebp\n"
 	"\tpushl %%ebx\n"
@@ -284,7 +284,7 @@ __asm__(
 	);
 
 #elif __ARM_ARCH==7
-__asm__(
+__asm__ volatile(
 	/* Save current context */
 	".syntax unified\n"
 	"\tvpush {d8-d15}\n"
@@ -314,7 +314,7 @@ __asm__(
 	);
 
 #elif __aarch64__
-__asm__(
+__asm__ volatile(
 	/* Save current context */
 	"\tsub x1, sp, #8 * 20\n"
 	"\tstp x19, x20, [x1, #16 * 0]\n"
-- 
2.17.1

                 reply	other threads:[~2018-06-08 17:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c3b30016bc65a77804f995de0024a66a699ccc1.1528478042.git.georgy@tarantool.org \
    --to=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH] Fix libunwind segfault' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox