From: Linas Vepstas <linasvepstas@gmail.com>
To: 25238@debbugs.gnu.org
Subject: bug#25238: guile-2.2 threading bug
Date: Tue, 20 Dec 2016 14:13:44 -0600 [thread overview]
Message-ID: <CAHrUA34CEQtgvtVmT3y41YhfV_4LMqeZCUB8V0ojrgqwZyNWxQ@mail.gmail.com> (raw)
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@entry=0x0)
at ../../libguile/fluids.c:496
#2 0x00007ffff7b6351a in guilify_self_2 (dynamic_state=dynamic_state@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@entry=0x7ffff3305df0,
data=data@entry=0x7ffff3305e20) at ../../libguile/threads.c:638
#5 0x00007ffff6c15812 in GC_call_with_stack_base (
fn=fn@entry=0x7ffff7b63e40 <with_guile>, arg=arg@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);
}
next reply other threads:[~2016-12-20 20:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 20:13 Linas Vepstas [this message]
2017-03-01 14:42 ` bug#25238: guile-2.2 threading bug Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHrUA34CEQtgvtVmT3y41YhfV_4LMqeZCUB8V0ojrgqwZyNWxQ@mail.gmail.com \
--to=linasvepstas@gmail.com \
--cc=25238@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).