GNU bug report logs - #29151
[PATCH] ia64: fix crash in thread context switch

Previous Next

Package: guile;

Reported by: Sergei Trofimovich <slyfox <at> gentoo.org>

Date: Sun, 5 Nov 2017 09:32:02 UTC

Severity: normal

Tags: patch

Merged with 29194

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29151 in the body.
You can then email your comments to 29151 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#29151; Package guile. (Sun, 05 Nov 2017 09:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sergei Trofimovich <slyfox <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 05 Nov 2017 09:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sergei Trofimovich <slyfox <at> gentoo.org>
To: bug-guile <at> gnu.org
Cc: Sergei Trofimovich <slyfox <at> gentoo.org>
Subject: [PATCH] ia64: fix crash in thread context switch
Date: Sun,  5 Nov 2017 09:30:45 +0000
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 <at> 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





Merged 29151 29194. Request was from Mark H Weaver <mhw <at> netris.org> to control <at> debbugs.gnu.org. (Wed, 08 Nov 2017 04:21:03 GMT) Full text and rfc822 format available.

Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Wed, 22 Nov 2017 15:17:02 GMT) Full text and rfc822 format available.

Notification sent to Sergei Trofimovich <slyfox <at> gentoo.org>:
bug acknowledged by developer. (Wed, 22 Nov 2017 15:17:02 GMT) Full text and rfc822 format available.

Message #12 received at 29151-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Sergei Trofimovich <slyfox <at> gentoo.org>
Cc: 29151-done <at> debbugs.gnu.org
Subject: Re: bug#29151: [PATCH] ia64: fix crash in thread context switch
Date: Wed, 22 Nov 2017 16:16:17 +0100
Hi Sergei,

Sergei Trofimovich <slyfox <at> 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’.




Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Wed, 22 Nov 2017 15:17:03 GMT) Full text and rfc822 format available.

Notification sent to Jason Duerstock <jason.duerstock <at> gmail.com>:
bug acknowledged by developer. (Wed, 22 Nov 2017 15:17:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-guile <at> gnu.org:
bug#29151; Package guile. (Sun, 26 Nov 2017 19:38:01 GMT) Full text and rfc822 format available.

Message #20 received at 29151-done <at> debbugs.gnu.org (full text, mbox):

From: Sergei Trofimovich <slyfox <at> gentoo.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 29151-done <at> debbugs.gnu.org
Subject: Re: bug#29151: [PATCH] ia64: fix crash in thread context switch
Date: Sun, 26 Nov 2017 19:37:10 +0000
[Message part 1 (text/plain, inline)]
> 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
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#29151; Package guile. (Sun, 26 Nov 2017 20:33:01 GMT) Full text and rfc822 format available.

Message #23 received at 29151-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Sergei Trofimovich <slyfox <at> gentoo.org>
Cc: 29151-done <at> debbugs.gnu.org
Subject: Re: bug#29151: [PATCH] ia64: fix crash in thread context switch
Date: Sun, 26 Nov 2017 21:32:36 +0100
Sergei Trofimovich <slyfox <at> 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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 25 Dec 2017 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.