From 287adbfc205c02eac375f55fb94f13c073faec97 Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Thu, 28 Dec 2017 02:27:07 +0500 Subject: triton: fix crash due gcc mis-optimization of alloca() since alloca() result is used indirectly, gcc 4.7.2 thinks the whole call can be dropped on any optimization level. --- accel-pppd/triton/triton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'accel-pppd') diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 64ca7b8..a456746 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -54,6 +54,7 @@ struct triton_context_t default_ctx; static __thread struct triton_context_t *this_ctx; static __thread jmp_buf jmp_env; static __thread void *thread_frame; +static volatile void *thread_stack; #define log_debug2(fmt, ...) @@ -133,7 +134,7 @@ static void* triton_thread(struct _triton_thread_t *thread) if (this_ctx->before_switch) this_ctx->before_switch(this_ctx, thread->ctx->bf_arg); - alloca(thread->ctx->uc->uc_stack.ss_size + 64); + thread_stack = alloca(thread->ctx->uc->uc_stack.ss_size + 64); memcpy(thread_frame - thread->ctx->uc->uc_stack.ss_size, thread->ctx->uc->uc_stack.ss_sp, thread->ctx->uc->uc_stack.ss_size); setcontext(thread->ctx->uc); abort(); -- cgit v1.2.3