unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#29151: [PATCH] ia64: fix crash in thread context switch
@ 2017-11-05  9:30 Sergei Trofimovich
  2017-11-22 15:16 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Trofimovich @ 2017-11-05  9:30 UTC (permalink / raw)
  To: 29151; +Cc: Sergei Trofimovich

Backtrace looks like that:

  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x200000000014a5c0 in scm_ia64_longjmp (JB=0x6000000000817020, VAL=1) at continuations.c:372
  372                   t->pending_rbs_continuation->backing_store,
  [Current thread is 1 (Thread 0x2000000000049340 (LWP 8190))]
  (gdb) bt
  #0  0x200000000014a5c0 in scm_ia64_longjmp (JB=0x6000000000817020, VAL=1) at continuations.c:372
  #1  0x2000000000148e00 in scm_c_abort (vm=0x60000000000edea0, tag=0x6000000000795ba0, n=0, argv=0x60000fffff7f0ce0, cookie=-1) at control.c:239
  #2  0x2000000000149070 in scm_at_abort (tag=0x6000000000795ba0, args=0x304) at control.c:258
  (gdb) print t
  $2 = (scm_i_thread *) 0x6000000000068000
  (gdb) print t->pending_rbs_continuation
  $3 = (scm_t_contregs *) 0xffeb

The problem here is the value of 't->pending_rbs_continuation' pointer.
It's supposed to poin to a register stack pointer or be NULL if not yet
backed up.

The problem is it is never initialized to NULL at creation time and
contained garbage on stack. Sometimes people are lucky and have zeros
on stack and guile works. But sometimes there is something and guile
crashes.

The fix is trivial: initialize 'pending_rbs_continuation = NULL'
at thread registration time (the same way other threads are registered).

Reported-by: Matt Turner
Bug: https://bugs.gentoo.org/613986

* libguile/threads.c(guilify_self_1): initialize pending_rbs_continuation
  to avoid guile crash on ia64.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 libguile/threads.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libguile/threads.c b/libguile/threads.c
index 9ceb5b88a..770f62c44 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -395,6 +395,7 @@ guilify_self_1 (struct GC_stack_base *base, int needs_unregister)
   t.base = base->mem_base;
 #ifdef __ia64__
   t.register_backing_store_base = base->reg_base;
+  t.pending_rbs_continuation = 0;
 #endif
   t.continuation_root = SCM_EOL;
   t.continuation_base = t.base;
-- 
2.15.0






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

* bug#29151: [PATCH] ia64: fix crash in thread context switch
  2017-11-05  9:30 bug#29151: [PATCH] ia64: fix crash in thread context switch Sergei Trofimovich
@ 2017-11-22 15:16 ` Ludovic Courtès
  2017-11-26 19:37   ` Sergei Trofimovich
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-11-22 15:16 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: 29151-done

Hi Sergei,

Sergei Trofimovich <slyfox@gentoo.org> skribis:

> Backtrace looks like that:
>
>   Program terminated with signal SIGSEGV, Segmentation fault.
>   #0  0x200000000014a5c0 in scm_ia64_longjmp (JB=0x6000000000817020, VAL=1) at continuations.c:372
>   372                   t->pending_rbs_continuation->backing_store,
>   [Current thread is 1 (Thread 0x2000000000049340 (LWP 8190))]
>   (gdb) bt
>   #0  0x200000000014a5c0 in scm_ia64_longjmp (JB=0x6000000000817020, VAL=1) at continuations.c:372
>   #1  0x2000000000148e00 in scm_c_abort (vm=0x60000000000edea0, tag=0x6000000000795ba0, n=0, argv=0x60000fffff7f0ce0, cookie=-1) at control.c:239
>   #2  0x2000000000149070 in scm_at_abort (tag=0x6000000000795ba0, args=0x304) at control.c:258
>   (gdb) print t
>   $2 = (scm_i_thread *) 0x6000000000068000
>   (gdb) print t->pending_rbs_continuation
>   $3 = (scm_t_contregs *) 0xffeb
>
> The problem here is the value of 't->pending_rbs_continuation' pointer.
> It's supposed to poin to a register stack pointer or be NULL if not yet
> backed up.
>
> The problem is it is never initialized to NULL at creation time and
> contained garbage on stack. Sometimes people are lucky and have zeros
> on stack and guile works. But sometimes there is something and guile
> crashes.
>
> The fix is trivial: initialize 'pending_rbs_continuation = NULL'
> at thread registration time (the same way other threads are registered).
>
> Reported-by: Matt Turner
> Bug: https://bugs.gentoo.org/613986
>
> * libguile/threads.c(guilify_self_1): initialize pending_rbs_continuation
>   to avoid guile crash on ia64.

I’ve applied the patch to the ‘stable-2.2’ branch, thank you, and thanks
to Jason for testing!

Ludo’.





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

* bug#29151: [PATCH] ia64: fix crash in thread context switch
  2017-11-22 15:16 ` Ludovic Courtès
@ 2017-11-26 19:37   ` Sergei Trofimovich
  2017-11-26 20:32     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Trofimovich @ 2017-11-26 19:37 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29151-done

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

> I’ve applied the patch to the ‘stable-2.2’ branch, thank you, and thanks
> to Jason for testing!

Thank you!

Should I do anything specific in order for fix to get to master branch?
Or will it happen on it's own at some point?

-- 

  Sergei

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* bug#29151: [PATCH] ia64: fix crash in thread context switch
  2017-11-26 19:37   ` Sergei Trofimovich
@ 2017-11-26 20:32     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-11-26 20:32 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: 29151-done

Sergei Trofimovich <slyfox@gentoo.org> skribis:

>> I’ve applied the patch to the ‘stable-2.2’ branch, thank you, and thanks
>> to Jason for testing!
>
> Thank you!
>
> Should I do anything specific in order for fix to get to master branch?
> Or will it happen on it's own at some point?

I think Andy will eventually merge ‘stable-2.2’ in ‘master’, so it will
happen “on its own”.  :-)

Ludo’.





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

end of thread, other threads:[~2017-11-26 20:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-05  9:30 bug#29151: [PATCH] ia64: fix crash in thread context switch Sergei Trofimovich
2017-11-22 15:16 ` Ludovic Courtès
2017-11-26 19:37   ` Sergei Trofimovich
2017-11-26 20:32     ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).