Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault on GC #44

Open
ksss opened this issue Sep 24, 2016 · 2 comments
Open

Segmentation fault on GC #44

ksss opened this issue Sep 24, 2016 · 2 comments

Comments

@ksss
Copy link
Contributor

ksss commented Sep 24, 2016

The below code failed.

Thread.new { GC.start }
# Assertion failed: ((obj)->tt != MRB_TT_FREE), function mrb_gc_mark, mruby/src/gc.c, line 676

I dived into sea of the codes...
But I didn't resolve this issue.

Maybe main thread was calling mrb_close.
But sub thread GC mark anything main thread object. (Maybe from mrb->c->stack?)
It was method object (RProc *) in my env. And already freed.
mrb_thread_context_free have not yet called when failed.

Is this an unavoidable issue?

Of cause below code worked.

Thread.new { GC.start }.join

mruby: 08a1dd2ac89333bd928a3300f712d1a7fb57e8ff
mruby-thread: 0e2e003

@mattn
Copy link
Owner

mattn commented Sep 24, 2016

How about this?

diff --git a/src/mrb_thread.c b/src/mrb_thread.c
index 7d13e79..b8981d6 100644
--- a/src/mrb_thread.c
+++ b/src/mrb_thread.c
@@ -38,6 +38,7 @@ static void
 mrb_thread_context_free(mrb_state *mrb, void *p) {
   if (p) {
     mrb_thread_context* context = (mrb_thread_context*) p;
+    context->proc = NULL;
     if (context->mrb && context->mrb != mrb) mrb_close(context->mrb);
     pthread_kill(context->thread, SIGINT);
     if (context->argv) free(context->argv);

@ksss
Copy link
Contributor Author

ksss commented Sep 26, 2016

No, Didn't fix, mrb_thread_context_free have not yet called when failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants