GNU bug report logs - #25238
guile-2.2 threading bug

Previous Next

Package: guile;

Reported by: linasvepstas <at> gmail.com

Date: Tue, 20 Dec 2016 20:15:02 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

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 25238 in the body.
You can then email your comments to 25238 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#25238; Package guile. (Tue, 20 Dec 2016 20:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to linasvepstas <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 20 Dec 2016 20:15:02 GMT) Full text and rfc822 format available.

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

From: Linas Vepstas <linasvepstas <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: guile-2.2 threading bug
Date: Tue, 20 Dec 2016 14:13:44 -0600
Merry Christmas!  A guile-git threading bug!

-- linas


$ cat fail.cc
//
// fail.cc
//
// This C++ program crashes, when compiled against todays (20 Dec 2016)
// guile-2.2 from git. git log says a recent commit is
//    0ce8a9a5e01d3a12d83fea85968e1abb602c9298
// but I beielve any guile-2.2 version from late 2016 will crash.
//
// I built this as:
// cc fail.cc -I /usr/local/include/guile/2.2 -lguile-2.2  -lpthread -lstdc++
//
// gdb gives the following stack trace:
/*****
Thread 7 "a.out" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff3306700 (LWP 23578)]
0x00007ffff7b03076 in is_dynamic_state (x=0x0) at ../../libguile/fluids.c:97
97  return SCM_HAS_TYP7 (x, scm_tc7_dynamic_state);
(gdb) bt
#0  0x00007ffff7b03076 in is_dynamic_state (x=0x0) at ../../libguile/fluids.c:97
#1  scm_set_current_dynamic_state (state=state <at> entry=0x0)
    at ../../libguile/fluids.c:496
#2  0x00007ffff7b6351a in guilify_self_2 (dynamic_state=dynamic_state <at> entry=0x0)
    at ../../libguile/threads.c:466
#3  0x00007ffff7b63e0c in scm_i_init_thread_for_guile (base=0x7ffff3305df0,
    dynamic_state=0x0) at ../../libguile/threads.c:595
#4  0x00007ffff7b63e59 in with_guile (base=base <at> entry=0x7ffff3305df0,
    data=data <at> entry=0x7ffff3305e20) at ../../libguile/threads.c:638
#5  0x00007ffff6c15812 in GC_call_with_stack_base (
    fn=fn <at> entry=0x7ffff7b63e40 <with_guile>, arg=arg <at> entry=0x7ffff3305e20)
    at misc.c:1925
#6  0x00007ffff7b641f8 in scm_i_with_guile (dynamic_state=<optimized out>,
    data=<optimized out>, func=<optimized out>) at ../../libguile/threads.c:688
#7  scm_with_guile (func=<optimized out>, data=<optimized out>)
    at ../../libguile/threads.c:694
#8  0x0000555555555064 in foo(int) ()
#9  0x0000555555556776 in void std::_Bind_simple<void
(*(int))(int)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) ()
#10 0x00005555555566c9 in std::_Bind_simple<void (*(int))(int)>::operator()() ()
#11 0x00005555555566a8 in
std::thread::_State_impl<std::_Bind_simple<void (*(int))(int)>
>::_M_run() ()
#12 0x00007ffff75cccdf in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#13 0x00007ffff789b464 in start_thread (arg=0x7ffff3306700) at
pthread_create.c:333
#14 0x00007ffff70469df in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:105
(gdb)
 ****/


#include <libguile.h>

#include <thread>
#include <vector>

void * wrap_foo(void *p)
{
   scm_c_eval_string ("(setlocale LC_ALL \"\")");
}

static volatile bool hold = true;

void foo(int thread_id)
{
   while (hold) {} // spin
   // A long sleep here avoids the crash
   // usleep(thread_id * 100000);
   scm_with_guile(wrap_foo, nullptr);
}

main()
{
   int n_threads = 12;
   std::vector<std::thread> thread_pool;
   for (int i=0; i < n_threads; i++)
      thread_pool.push_back(std::thread(&foo, i));

   printf("Done creating %d threads\n", n_threads);
   hold = false;

   for (std::thread& t : thread_pool) t.join();
   printf("Done joining %d threads\n", n_threads);
}




Reply sent to Andy Wingo <wingo <at> pobox.com>:
You have taken responsibility. (Wed, 01 Mar 2017 14:43:01 GMT) Full text and rfc822 format available.

Notification sent to linasvepstas <at> gmail.com:
bug acknowledged by developer. (Wed, 01 Mar 2017 14:43:01 GMT) Full text and rfc822 format available.

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

From: Andy Wingo <wingo <at> pobox.com>
To: Linas Vepstas <linasvepstas <at> gmail.com>
Cc: 25238-done <at> debbugs.gnu.org
Subject: Re: bug#25238: guile-2.2 threading bug
Date: Wed, 01 Mar 2017 15:42:31 +0100
On Tue 20 Dec 2016 21:13, Linas Vepstas <linasvepstas <at> gmail.com> writes:

> Thread 7 "a.out" received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7ffff3306700 (LWP 23578)]
> 0x00007ffff7b03076 in is_dynamic_state (x=0x0) at ../../libguile/fluids.c:97
> 97  return SCM_HAS_TYP7 (x, scm_tc7_dynamic_state);
> (gdb) bt
> #0  0x00007ffff7b03076 in is_dynamic_state (x=0x0) at ../../libguile/fluids.c:97
> #1  scm_set_current_dynamic_state (state=state <at> entry=0x0)
>     at ../../libguile/fluids.c:496
> #2  0x00007ffff7b6351a in guilify_self_2 (dynamic_state=dynamic_state <at> entry=0x0)
>     at ../../libguile/threads.c:466
> #3  0x00007ffff7b63e0c in scm_i_init_thread_for_guile (base=0x7ffff3305df0,
>     dynamic_state=0x0) at ../../libguile/threads.c:595
> #4  0x00007ffff7b63e59 in with_guile (base=base <at> entry=0x7ffff3305df0,
>     data=data <at> entry=0x7ffff3305e20) at ../../libguile/threads.c:638

I believe this one was fixed in 63bf6ffa0d3cdddf8151cc80ac18fe5dfb614587
which was released in 2.1.7.  Please open a new bug when you find
another one :)

Andy




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 30 Mar 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 142 days ago.

Previous Next


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