qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4


From: John Paul Adrian Glaubitz
Subject: Re: [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4
Date: Thu, 19 Nov 2015 10:28:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Icedove/42.0

On 11/19/2015 10:17 AM, Peter Maydell wrote:
> Unfortunately this isn't sufficient. You also need to add
> the code to the sh4-specific functions in linux-user/signal.c
> which honours the requested sigaltstack when taking and returning
> from signal handlers.

My supplied test case shows that sigaltstack works unless I am
overseeing anything? Laurent Vivier (CC'ed) who has done some
extensive qemu development thinks that my change should be enough.

Here's the output of my test case (CC'ing Michael Karcher who
suggested the test case):

(sid-sh4-sbuild)address@hidden:/tmp# cat stackoverflow.c

#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>

jmp_buf exit_jmp;

void handler(int x)
{
  longjmp(exit_jmp, 1);
}

int f(void)
{
  return f();
}

int main(void)
{
  stack_t sigstack;
  sigstack.ss_sp = malloc(1024*1024);
  sigstack.ss_size = 1024*1024;
  sigstack.ss_flags = 0;
  sigaltstack(&sigstack, NULL);
  struct sigaction sa;
  sa.sa_handler = handler;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_ONSTACK;
  sigaction(SIGSEGV, &sa, NULL);
  if (setjmp(exit_jmp) == 0)
    {
      return f();
    }
  puts("recovered");
  return 0;
}
(sid-sh4-sbuild)address@hidden:/tmp# gcc stackoverflow.c -o stackoverflow
(sid-sh4-sbuild)address@hidden:/tmp# ./stackoverflow
recovered
(sid-sh4-sbuild)address@hidden:/tmp#

Now commenting "sigaltstack" out:

(sid-sh4-sbuild)address@hidden:/tmp# cat stackoverflow.c

#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>

jmp_buf exit_jmp;

void handler(int x)
{
  longjmp(exit_jmp, 1);
}

int f(void)
{
  return f();
}

int main(void)
{
  stack_t sigstack;
  sigstack.ss_sp = malloc(1024*1024);
  sigstack.ss_size = 1024*1024;
  sigstack.ss_flags = 0;
  // sigaltstack(&sigstack, NULL);
  struct sigaction sa;
  sa.sa_handler = handler;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_ONSTACK;
  sigaction(SIGSEGV, &sa, NULL);
  if (setjmp(exit_jmp) == 0)
    {
      return f();
    }
  puts("recovered");
  return 0;
}
(sid-sh4-sbuild)address@hidden:/tmp# gcc stackoverflow.c -o stackoverflow
(sid-sh4-sbuild)address@hidden:/tmp# ./stackoverflow
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
(sid-sh4-sbuild)address@hidden:/tmp#

Thus, for me it seems sigaltstack behaves as expected with the patch
applied.

Am I missing something obvious?

Cheers,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - address@hidden
`. `'   Freie Universitaet Berlin - address@hidden
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



reply via email to

[Prev in Thread] Current Thread [Next in Thread]