All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4
@ 2017-12-10 23:05 John Paul Adrian Glaubitz
  2018-10-23 20:28 ` [Qemu-devel] [Bug 1737444] " Alex Bennée
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2017-12-10 23:05 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

While testing gccgo on sh4 to add SH platform definitions to libgo, I
discovered that the following conftest program which is part of the
libgo configure script crashes on qemu-sh4:

(sid-sh4-sbuild)root@z6:/# cat setcontext.c
#include <pthread.h>                                                                                                                                                                                                                                                           
#include <stdlib.h>                                                                                                                                                                                                                                                            
#include <ucontext.h>                                                                                                                                                                                                                                                          
#include <unistd.h>                                                                                                                                                                                                                                                            

__thread int tls;

static char stack[10 * 1024 * 1024];
static ucontext_t c;

/* Called via makecontext/setcontext.  */

static void
cfn (void)
{
  exit (tls);
}

/* Called via pthread_create.  */

static void *
tfn (void *dummy)
{
  /* The thread should still see this value after calling
     setcontext.  */
  tls = 0;

  setcontext (&c);

  /* The call to setcontext should not return.  */
  abort ();
}

int
main ()
{
  pthread_t tid;

  /* The thread should not see this value.  */
  tls = 1;

  if (getcontext (&c) < 0)
    abort ();

  c.uc_stack.ss_sp = stack;
#ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
  c.uc_stack.ss_sp += sizeof stack;
#endif                                                                                                                                                                                                                                                                         
  c.uc_stack.ss_flags = 0;
  c.uc_stack.ss_size = sizeof stack;
  c.uc_link = NULL;
  makecontext (&c, cfn, 0);

  if (pthread_create (&tid, NULL, tfn, NULL) != 0)
    abort ();

  if (pthread_join (tid, NULL) != 0)
    abort ();

  /* The thread should have called exit.  */
  abort ();
}

(sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
(sid-sh4-sbuild)root@z6:/# ./setcontext 
Unhandled trap: 0x180
pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
(sid-sh4-sbuild)root@z6:/#

The same code works fine on my Renesas SH7785LCR evaluation board:

root@tirpitz:~> uname -a
Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
root@tirpitz:~> ./setcontext 
root@tirpitz:~> echo $?
0
root@tirpitz:~>

Due to this bug, it is not possible to compile gcc-7 with the Go
frontend enabled on qemu-sh4.

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737444

Title:
  gccgo setcontext conftest crashes qemu-sh4

Status in QEMU:
  New

Bug description:
  While testing gccgo on sh4 to add SH platform definitions to libgo, I
  discovered that the following conftest program which is part of the
  libgo configure script crashes on qemu-sh4:

  (sid-sh4-sbuild)root@z6:/# cat setcontext.c
  #include <pthread.h>                                                                                                                                                                                                                                                           
  #include <stdlib.h>                                                                                                                                                                                                                                                            
  #include <ucontext.h>                                                                                                                                                                                                                                                          
  #include <unistd.h>                                                                                                                                                                                                                                                            

  __thread int tls;

  static char stack[10 * 1024 * 1024];
  static ucontext_t c;

  /* Called via makecontext/setcontext.  */

  static void
  cfn (void)
  {
    exit (tls);
  }

  /* Called via pthread_create.  */

  static void *
  tfn (void *dummy)
  {
    /* The thread should still see this value after calling
       setcontext.  */
    tls = 0;

    setcontext (&c);

    /* The call to setcontext should not return.  */
    abort ();
  }

  int
  main ()
  {
    pthread_t tid;

    /* The thread should not see this value.  */
    tls = 1;

    if (getcontext (&c) < 0)
      abort ();

    c.uc_stack.ss_sp = stack;
  #ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
    c.uc_stack.ss_sp += sizeof stack;
  #endif                                                                                                                                                                                                                                                                         
    c.uc_stack.ss_flags = 0;
    c.uc_stack.ss_size = sizeof stack;
    c.uc_link = NULL;
    makecontext (&c, cfn, 0);

    if (pthread_create (&tid, NULL, tfn, NULL) != 0)
      abort ();

    if (pthread_join (tid, NULL) != 0)
      abort ();

    /* The thread should have called exit.  */
    abort ();
  }

  (sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
  (sid-sh4-sbuild)root@z6:/# ./setcontext 
  Unhandled trap: 0x180
  pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
  spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
  sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
  r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
  r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
  r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
  r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
  r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
  r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
  (sid-sh4-sbuild)root@z6:/#

  The same code works fine on my Renesas SH7785LCR evaluation board:

  root@tirpitz:~> uname -a
  Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
  root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
  root@tirpitz:~> ./setcontext 
  root@tirpitz:~> echo $?
  0
  root@tirpitz:~>

  Due to this bug, it is not possible to compile gcc-7 with the Go
  frontend enabled on qemu-sh4.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737444/+subscriptions

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [Bug 1737444] Re: gccgo setcontext conftest crashes qemu-sh4
  2017-12-10 23:05 [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4 John Paul Adrian Glaubitz
@ 2018-10-23 20:28 ` Alex Bennée
  2018-12-14 12:36 ` John Paul Adrian Glaubitz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2018-10-23 20:28 UTC (permalink / raw)
  To: qemu-devel

** Tags added: linux-user sh4

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737444

Title:
  gccgo setcontext conftest crashes qemu-sh4

Status in QEMU:
  New

Bug description:
  While testing gccgo on sh4 to add SH platform definitions to libgo, I
  discovered that the following conftest program which is part of the
  libgo configure script crashes on qemu-sh4:

  (sid-sh4-sbuild)root@z6:/# cat setcontext.c
  #include <pthread.h>                                                                                                                                                                                                                                                           
  #include <stdlib.h>                                                                                                                                                                                                                                                            
  #include <ucontext.h>                                                                                                                                                                                                                                                          
  #include <unistd.h>                                                                                                                                                                                                                                                            

  __thread int tls;

  static char stack[10 * 1024 * 1024];
  static ucontext_t c;

  /* Called via makecontext/setcontext.  */

  static void
  cfn (void)
  {
    exit (tls);
  }

  /* Called via pthread_create.  */

  static void *
  tfn (void *dummy)
  {
    /* The thread should still see this value after calling
       setcontext.  */
    tls = 0;

    setcontext (&c);

    /* The call to setcontext should not return.  */
    abort ();
  }

  int
  main ()
  {
    pthread_t tid;

    /* The thread should not see this value.  */
    tls = 1;

    if (getcontext (&c) < 0)
      abort ();

    c.uc_stack.ss_sp = stack;
  #ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
    c.uc_stack.ss_sp += sizeof stack;
  #endif                                                                                                                                                                                                                                                                         
    c.uc_stack.ss_flags = 0;
    c.uc_stack.ss_size = sizeof stack;
    c.uc_link = NULL;
    makecontext (&c, cfn, 0);

    if (pthread_create (&tid, NULL, tfn, NULL) != 0)
      abort ();

    if (pthread_join (tid, NULL) != 0)
      abort ();

    /* The thread should have called exit.  */
    abort ();
  }

  (sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
  (sid-sh4-sbuild)root@z6:/# ./setcontext 
  Unhandled trap: 0x180
  pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
  spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
  sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
  r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
  r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
  r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
  r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
  r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
  r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
  (sid-sh4-sbuild)root@z6:/#

  The same code works fine on my Renesas SH7785LCR evaluation board:

  root@tirpitz:~> uname -a
  Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
  root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
  root@tirpitz:~> ./setcontext 
  root@tirpitz:~> echo $?
  0
  root@tirpitz:~>

  Due to this bug, it is not possible to compile gcc-7 with the Go
  frontend enabled on qemu-sh4.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737444/+subscriptions

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [Bug 1737444] Re: gccgo setcontext conftest crashes qemu-sh4
  2017-12-10 23:05 [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4 John Paul Adrian Glaubitz
  2018-10-23 20:28 ` [Qemu-devel] [Bug 1737444] " Alex Bennée
@ 2018-12-14 12:36 ` John Paul Adrian Glaubitz
  2021-04-22  5:30 ` Thomas Huth
  2021-06-22  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2018-12-14 12:36 UTC (permalink / raw)
  To: qemu-devel

This still reproduces on git master:

(sid-sh4-sbuild)root@nofan:/# gcc setcontext.c -o setcontext -lpthread
(sid-sh4-sbuild)root@nofan:/# ./setcontext 
Unhandled trap: 0x180
pc=0x7f68e99e sr=0x00000000 pr=0x00400750 fpscr=0x00080000
spc=0x00000000 ssr=0x00000000 gbr=0x7f7a2de8 vbr=0x00000000
sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f68e960 fpul=0x00000000
r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff590
r4=0x00e11068 r5=0x7ffff5c4 r6=0x7ffff5cc r7=0x00000000
r8=0x004007f0 r9=0x00000000 r10=0x00000000 r11=0x00000000
r12=0x7f79ec64 r13=0x00000000 r14=0x7ffff538 r15=0x7ffff538
r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
(sid-sh4-sbuild)root@nofan:/#

And it is fixed by reverting 61dedf2af7

(sid-sh4-sbuild)root@nofan:/# ./setcontext 
(sid-sh4-sbuild)root@nofan:/# echo $?
0
(sid-sh4-sbuild)root@nofan:/#

So it's presumably the same bug as
https://bugs.launchpad.net/qemu/+bug/1796520

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737444

Title:
  gccgo setcontext conftest crashes qemu-sh4

Status in QEMU:
  New

Bug description:
  While testing gccgo on sh4 to add SH platform definitions to libgo, I
  discovered that the following conftest program which is part of the
  libgo configure script crashes on qemu-sh4:

  (sid-sh4-sbuild)root@z6:/# cat setcontext.c
  #include <pthread.h>                                                                                                                                                                                                                                                           
  #include <stdlib.h>                                                                                                                                                                                                                                                            
  #include <ucontext.h>                                                                                                                                                                                                                                                          
  #include <unistd.h>                                                                                                                                                                                                                                                            

  __thread int tls;

  static char stack[10 * 1024 * 1024];
  static ucontext_t c;

  /* Called via makecontext/setcontext.  */

  static void
  cfn (void)
  {
    exit (tls);
  }

  /* Called via pthread_create.  */

  static void *
  tfn (void *dummy)
  {
    /* The thread should still see this value after calling
       setcontext.  */
    tls = 0;

    setcontext (&c);

    /* The call to setcontext should not return.  */
    abort ();
  }

  int
  main ()
  {
    pthread_t tid;

    /* The thread should not see this value.  */
    tls = 1;

    if (getcontext (&c) < 0)
      abort ();

    c.uc_stack.ss_sp = stack;
  #ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
    c.uc_stack.ss_sp += sizeof stack;
  #endif                                                                                                                                                                                                                                                                         
    c.uc_stack.ss_flags = 0;
    c.uc_stack.ss_size = sizeof stack;
    c.uc_link = NULL;
    makecontext (&c, cfn, 0);

    if (pthread_create (&tid, NULL, tfn, NULL) != 0)
      abort ();

    if (pthread_join (tid, NULL) != 0)
      abort ();

    /* The thread should have called exit.  */
    abort ();
  }

  (sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
  (sid-sh4-sbuild)root@z6:/# ./setcontext 
  Unhandled trap: 0x180
  pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
  spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
  sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
  r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
  r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
  r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
  r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
  r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
  r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
  (sid-sh4-sbuild)root@z6:/#

  The same code works fine on my Renesas SH7785LCR evaluation board:

  root@tirpitz:~> uname -a
  Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
  root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
  root@tirpitz:~> ./setcontext 
  root@tirpitz:~> echo $?
  0
  root@tirpitz:~>

  Due to this bug, it is not possible to compile gcc-7 with the Go
  frontend enabled on qemu-sh4.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737444/+subscriptions

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug 1737444] Re: gccgo setcontext conftest crashes qemu-sh4
  2017-12-10 23:05 [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4 John Paul Adrian Glaubitz
  2018-10-23 20:28 ` [Qemu-devel] [Bug 1737444] " Alex Bennée
  2018-12-14 12:36 ` John Paul Adrian Glaubitz
@ 2021-04-22  5:30 ` Thomas Huth
  2021-06-22  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2021-04-22  5:30 UTC (permalink / raw)
  To: qemu-devel

The QEMU project is currently considering to move its bug tracking to
another system. For this we need to know which bugs are still valid
and which could be closed already. Thus we are setting older bugs to
"Incomplete" now.

If you still think this bug report here is valid, then please switch
the state back to "New" within the next 60 days, otherwise this report
will be marked as "Expired". Or please mark it as "Fix Released" if
the problem has been solved with a newer version of QEMU already.

Thank you and sorry for the inconvenience.

** Changed in: qemu
       Status: New => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737444

Title:
  gccgo setcontext conftest crashes qemu-sh4

Status in QEMU:
  Incomplete

Bug description:
  While testing gccgo on sh4 to add SH platform definitions to libgo, I
  discovered that the following conftest program which is part of the
  libgo configure script crashes on qemu-sh4:

  (sid-sh4-sbuild)root@z6:/# cat setcontext.c
  #include <pthread.h>                                                                                                                                                                                                                                                           
  #include <stdlib.h>                                                                                                                                                                                                                                                            
  #include <ucontext.h>                                                                                                                                                                                                                                                          
  #include <unistd.h>                                                                                                                                                                                                                                                            

  __thread int tls;

  static char stack[10 * 1024 * 1024];
  static ucontext_t c;

  /* Called via makecontext/setcontext.  */

  static void
  cfn (void)
  {
    exit (tls);
  }

  /* Called via pthread_create.  */

  static void *
  tfn (void *dummy)
  {
    /* The thread should still see this value after calling
       setcontext.  */
    tls = 0;

    setcontext (&c);

    /* The call to setcontext should not return.  */
    abort ();
  }

  int
  main ()
  {
    pthread_t tid;

    /* The thread should not see this value.  */
    tls = 1;

    if (getcontext (&c) < 0)
      abort ();

    c.uc_stack.ss_sp = stack;
  #ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
    c.uc_stack.ss_sp += sizeof stack;
  #endif                                                                                                                                                                                                                                                                         
    c.uc_stack.ss_flags = 0;
    c.uc_stack.ss_size = sizeof stack;
    c.uc_link = NULL;
    makecontext (&c, cfn, 0);

    if (pthread_create (&tid, NULL, tfn, NULL) != 0)
      abort ();

    if (pthread_join (tid, NULL) != 0)
      abort ();

    /* The thread should have called exit.  */
    abort ();
  }

  (sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
  (sid-sh4-sbuild)root@z6:/# ./setcontext 
  Unhandled trap: 0x180
  pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
  spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
  sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
  r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
  r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
  r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
  r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
  r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
  r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
  (sid-sh4-sbuild)root@z6:/#

  The same code works fine on my Renesas SH7785LCR evaluation board:

  root@tirpitz:~> uname -a
  Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
  root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
  root@tirpitz:~> ./setcontext 
  root@tirpitz:~> echo $?
  0
  root@tirpitz:~>

  Due to this bug, it is not possible to compile gcc-7 with the Go
  frontend enabled on qemu-sh4.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737444/+subscriptions


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug 1737444] Re: gccgo setcontext conftest crashes qemu-sh4
  2017-12-10 23:05 [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4 John Paul Adrian Glaubitz
                   ` (2 preceding siblings ...)
  2021-04-22  5:30 ` Thomas Huth
@ 2021-06-22  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 5+ messages in thread
From: Launchpad Bug Tracker @ 2021-06-22  4:17 UTC (permalink / raw)
  To: qemu-devel

[Expired for QEMU because there has been no activity for 60 days.]

** Changed in: qemu
       Status: Incomplete => Expired

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737444

Title:
  gccgo setcontext conftest crashes qemu-sh4

Status in QEMU:
  Expired

Bug description:
  While testing gccgo on sh4 to add SH platform definitions to libgo, I
  discovered that the following conftest program which is part of the
  libgo configure script crashes on qemu-sh4:

  (sid-sh4-sbuild)root@z6:/# cat setcontext.c
  #include <pthread.h>                                                                                                                                                                                                                                                           
  #include <stdlib.h>                                                                                                                                                                                                                                                            
  #include <ucontext.h>                                                                                                                                                                                                                                                          
  #include <unistd.h>                                                                                                                                                                                                                                                            

  __thread int tls;

  static char stack[10 * 1024 * 1024];
  static ucontext_t c;

  /* Called via makecontext/setcontext.  */

  static void
  cfn (void)
  {
    exit (tls);
  }

  /* Called via pthread_create.  */

  static void *
  tfn (void *dummy)
  {
    /* The thread should still see this value after calling
       setcontext.  */
    tls = 0;

    setcontext (&c);

    /* The call to setcontext should not return.  */
    abort ();
  }

  int
  main ()
  {
    pthread_t tid;

    /* The thread should not see this value.  */
    tls = 1;

    if (getcontext (&c) < 0)
      abort ();

    c.uc_stack.ss_sp = stack;
  #ifdef MAKECONTEXT_STACK_TOP                                                                                                                                                                                                                                                   
    c.uc_stack.ss_sp += sizeof stack;
  #endif                                                                                                                                                                                                                                                                         
    c.uc_stack.ss_flags = 0;
    c.uc_stack.ss_size = sizeof stack;
    c.uc_link = NULL;
    makecontext (&c, cfn, 0);

    if (pthread_create (&tid, NULL, tfn, NULL) != 0)
      abort ();

    if (pthread_join (tid, NULL) != 0)
      abort ();

    /* The thread should have called exit.  */
    abort ();
  }

  (sid-sh4-sbuild)root@z6:/# gcc -o setcontext -lpthread setcontext.c
  (sid-sh4-sbuild)root@z6:/# ./setcontext 
  Unhandled trap: 0x180
  pc=0x7f69235e sr=0x00000000 pr=0x00400710 fpscr=0x00080000
  spc=0x00000000 ssr=0x00000000 gbr=0x7f658478 vbr=0x00000000
  sgr=0x00000000 dbr=0x00000000 delayed_pc=0x7f692320 fpul=0x00000000
  r0=0x00e11158 r1=0x00000000 r2=0x00000001 r3=0x7ffff2e0
  r4=0x00e11068 r5=0x7ffff314 r6=0x7ffff31c r7=0x00000000
  r8=0x004007b0 r9=0x00000000 r10=0x00000000 r11=0x00000000
  r12=0x7f79ac54 r13=0x00000000 r14=0x7ffff288 r15=0x7ffff288
  r16=0x00000000 r17=0x00000000 r18=0x00000000 r19=0x00000000
  r20=0x00000000 r21=0x00000000 r22=0x00000000 r23=0x00000000
  (sid-sh4-sbuild)root@z6:/#

  The same code works fine on my Renesas SH7785LCR evaluation board:

  root@tirpitz:~> uname -a
  Linux tirpitz 3.16.7-ckt7 #8 PREEMPT Fri Oct 21 18:47:41 CEST 2016 sh4a GNU/Linux
  root@tirpitz:~> gcc -o setcontext setcontext.c  -lpthread
  root@tirpitz:~> ./setcontext 
  root@tirpitz:~> echo $?
  0
  root@tirpitz:~>

  Due to this bug, it is not possible to compile gcc-7 with the Go
  frontend enabled on qemu-sh4.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737444/+subscriptions


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-22  5:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-10 23:05 [Qemu-devel] [Bug 1737444] [NEW] gccgo setcontext conftest crashes qemu-sh4 John Paul Adrian Glaubitz
2018-10-23 20:28 ` [Qemu-devel] [Bug 1737444] " Alex Bennée
2018-12-14 12:36 ` John Paul Adrian Glaubitz
2021-04-22  5:30 ` Thomas Huth
2021-06-22  4:17 ` Launchpad Bug Tracker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.