-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
gems mrblib does not have c extension available #3
Comments
Did you do: rake clean all? On 2/5/13, ppibburr notifications@github.com wrote:
|
actually, i get arena overflow. I suppose arena overflow is the issue and my attempt to fix it was incorrect. |
The overflow may not occur in mruby-require. Can you handle it?
|
Ah, it seens that |
ppibburr@localhost: Breakpoint 1, __GI_abort () at abort.c:53 |
However, mruby-require is doing arena save/restore already. https://github.com/mattn/mruby-require/blob/master/src/mrb_require.c#L343-L345 Also, generated gem_init.c file.
|
So I guess, probably, it occur in mruby-cfunc. /cc @masuidrive Do you know something to handle this issue? |
fail $ bin/mruby -e "require 'mrbgems-example'"
-e:1: constant look-up for non class/module (TypeError) success export MRUBY_REQUIRE=mrbgems-example
bin/mruby -e "p ExampleExtension" is the use of the environment variable explicit? and as a side note.
|
Could you please show me the code of mrbgems-example? |
the full gem is at: https://github.com/masuidrive/mrbgems-example module ExampleExtension
def ExampleExtension.ruby_method
puts "A Ruby Extension"
end
end |
this works however, note the :: module ::ExampleExtension
def ExampleExtension.ruby_method
puts "A Ruby Extension"
end
end |
maybe, It's a mruby's bug. https://twitter.com/yukihiro_matz/statuses/298712377623465985 sorry, probably, you don't understand japanese... |
i translated it, kind of :) headers #include <mruby.h>
#include <mruby/string.h>
#include <mruby/proc.h>
#include <mruby/array.h>
#include <mruby/hash.h>
#include <mruby/variable.h>
#include <mruby/dump.h>
#include <mruby/opcode.h>
#include <setjmp.h> added these functions mrb_value
mrb_yield_internal(mrb_state *mrb, mrb_value b, int argc, mrb_value *argv, mrb_value self, struct RClass *c);
static void
replace_stop_with_return(mrb_state *mrb, mrb_irep *irep)
{
if (irep->iseq[irep->ilen - 1] == MKOP_A(OP_STOP, 0)) {
irep->iseq = mrb_realloc(mrb, irep->iseq, (irep->ilen + 1) * sizeof(mrb_code));
irep->iseq[irep->ilen - 1] = MKOP_A(OP_LOADNIL, 0);
irep->iseq[irep->ilen] = MKOP_AB(OP_RETURN, 0, OP_R_NORMAL);
irep->ilen++;
}
} changed the gem init void GENERATED_TMP_mrb_mruby_cfunc_gem_init(mrb_state *mrb) {
int ai = mrb_gc_arena_save(mrb);
mrb_mruby_cfunc_gem_init(mrb);
mrb_gc_arena_restore(mrb, ai);
ai = mrb_gc_arena_save(mrb);
int n;
n = mrb_read_irep(mrb, gem_mrblib_irep_mruby_cfunc);
mrb_gc_arena_restore(mrb, ai);
if (n >= 0) {
struct RProc *proc;
mrb_irep *irep = mrb->irep[n];
replace_stop_with_return(mrb, irep);
proc = mrb_proc_new(mrb, irep);
proc->target_class = mrb->object_class;
mrb_yield_internal(mrb, mrb_obj_value(proc), 0, NULL, mrb_top_self(mrb), mrb->object_class);
}
else if (mrb->exc) {
// fail to load.
longjmp(*(jmp_buf*)mrb->jmp, 1);
}
} then ran and it works without the envirionment variable. but not with the varaible export MRUBY_REQUIRE=mruby-cfunc
bin/mruby -e "p 1"
aborted i use code from mobiruby-common's require |
can you hook |
i also copied opcode.h to include/mruby/opcode.h |
Breakpoint 1, mrb_raise (mrb=0x80ca458, c=0x80cfa60, msg=0x80a33b0 "arena overflow error") at src/error.c:219 |
seems the overflow is present when loaded from ENV |
agreed |
mrbgems-example works too when i applied the same gem_init.c changes to its generated file Should maybe mrbgem temp file genration be modified? |
I'm going to bed for now. |
This is problem in mruby. So I'll file this into https://github.com/mruby/mruby/issues good night. |
i forked at https://github.com/ppibburr/mruby-require/ this at least lets more mrbgems load successfully, albeit from ENV as described above on larger mrblibs. |
Thanks for your activity. I hope to it works on windows also. |
And I noticed your fork remove & add files, so I can't see the diff |
dlsym cannot get address of variable... you mean the the irep data? |
i revert fork to only commit of mrb_require.c
|
It's a same that you did. |
Thanks :) |
I'm asking to matz: could you please do the patch above officially. :) |
I sent a pull-req mruby/mruby#826 |
nice and thank you! :) |
However, I wonder whether we should fix mrb_load_irep it self or not. Do you have any opinion? |
Sorry, I changed policy. And close the pull-req. Whether mrb_load_irep must not fixed with changing |
Welcome and thank you as well. Loading ireps seems buggy in general. i have libraries that as regular MRBGEM segfaullt but will work if required at runtime from main program. , |
crash with MRUBY_REQUIRE is known issue. |
The text was updated successfully, but these errors were encountered: