Closed udzura closed 7 years ago
context->alive seems to be marked FALSE in the end of mrb_thread_func.
context->alive
mrb_thread_func
https://github.com/mattn/mruby-thread/blob/master/src/mrb_thread.c#L362
So I guess only threads to invoke pthread_kill are context->alive = TRUE ones.
context->alive = TRUE
Thank you. I didn't notice this issue because it doesn't occur on Windows.
I tested this on Linux too. Thanks.
Thankththth!!!
context->alive
seems to be marked FALSE in the end ofmrb_thread_func
.https://github.com/mattn/mruby-thread/blob/master/src/mrb_thread.c#L362
So I guess only threads to invoke pthread_kill are
context->alive = TRUE
ones.(BTW, this patch may fix this kind of segfault)
### before ```console $ ./bin/mruby -e '10.times.map{ Thread.new { raise "Foo" } }.each_with_index{|t, i| t.join && puts("OK: #{i}") }' OK: 0 OK: 1 OK: 2 OK: 3 OK: 4 OK: 5 OK: 6 OK: 7 OK: 8 OK: 9 Segmentation fault (core dumped) ``` bt: ``` Thread 1 "mruby" received signal SIGSEGV, Segmentation fault. __pthread_kill (threadid=140737219917568, signo=2) at ../sysdeps/unix/sysv/linux/pthread_kill.c:39 39 ../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill (threadid=140737219917568, signo=2) at ../sysdeps/unix/sysv/linux/pthread_kill.c:39 #1 0x000000000046947d in mrb_thread_context_free (mrb=0x69f010, p=0x86aa20) at /Users/udzura/.ghq/github.com/mattn/mruby-thread/src/mrb_thread.c:53 #2 0x0000000000410449 in obj_free (mrb=0x69f010, obj=0x6e6100, end=1) at /Users/udzura/.ghq/github.com/mattn/mruby-thread/mruby_build/src/gc.c:809 #3 0x0000000000410528 in free_heap (gc=