You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately the title is long winded because I can not further narrow down the issue.
I have found a bug.
To summarize the issue, I get a segfault with a program that does the following steps:
create a proc from an irep with mrb_proc_new
assign the proc to a Ruby variable
define a method somewhere that calls the proc (in an .rb file)
use method to get a proc of this method
if I invoke the new proc from within Ruby it will run but segfault before returning
if I invoke the new proc from within c it will run and return with no exception in mrb->exc, but the next time I try to run any code it will segfault
This is how to reproduce:
# app.rb# this code get turned in to the proc# it could be empty and still result in the bug, but we will print so we know it runsputs'app.rb'
# test_program.rbdefstart_app
$app_proc.callend#start_app # calling this directly is not an issue# method(:start_app).call # calling this here will run the proc and then segfaultputs'test_program.rb'
// test_stub.c#include<stdio.h>#include<mruby.h>#include<mruby/class.h>#include<mruby/proc.h>#include<mruby/variable.h>#include<mruby/irep.h>#include<mruby/dump.h>#include"test_program.c"#include"app.c"intmain(void)
{
mrb_state*mrb=mrb_open();
// set up app_procmrb_irep*app_mrb_irep=mrb_read_irep(mrb, app_irep);
structRProc*app_proc=mrb_proc_new(mrb, app_mrb_irep);
mrb_valueapp_proc_mrb_value=mrb_obj_value(app_proc);
mrb_gv_set(mrb, mrb_intern_lit(mrb, "$app_proc"), app_proc_mrb_value);
mrb_load_irep(mrb, test_symbol);
// invoke app_procmrb_valuecode=mrb_str_new(mrb, "method(:start_app)", 20);
mrb_valuereturn_value=mrb_funcall_argv(mrb, mrb_top_self(mrb), mrb_intern_lit(mrb, "eval"), 1, &code);
mrb_funcall_argv(mrb, return_value, mrb_intern_lit(mrb, "call"), 0, NULL);
// running any other code after the app_proc will cause problems// running "tt = 88" will segfaultcode=mrb_str_new(mrb, "test = 88", 9);
mrb_funcall_argv(mrb, mrb_top_self(mrb), mrb_intern_lit(mrb, "eval"), 1, &code);
if (mrb->exc)
{
mrb_print_error(mrb);
mrb->exc=NULL;
return1;
}
mrb_close(mrb);
return0;
}
Unfortunately the title is long winded because I can not further narrow down the issue.
I have found a bug.
To summarize the issue, I get a segfault with a program that does the following steps:
mrb_proc_new
method
to get a proc of this methodmrb->exc
, but the next time I try to run any code it will segfaultThis is how to reproduce:
Add gems to build_config.rb
Compile and run with:
I get the output:
FYI:
TypeError: allocation failure
The text was updated successfully, but these errors were encountered: