-
Notifications
You must be signed in to change notification settings - Fork 35
mruby.Run does not work with a Proc returned from LoadString #23
Comments
Pretty odd. I expect its some weirdness with the C API. Steps forward would be:
|
(Note: not telling you you have to do this, just posting that thats what the steps are in general) |
while I was trying to verify this, I ran into a full panic with the following ruby: def foo
end The return value is indeed the
|
@erikh I've replicated it but given that this code already isn't behaving as we anticipated I'm not entirely surprised. My test case was: mrb := mruby.NewMrb()
defer mrb.Close()
result, err := mrb.LoadString(`
def foo
end
`)
// mrb.Run(result, nil) // Causes SIGSEGV
fmt.Printf("Result: %#v, %s\n", result, err) This printed:
IRB behaves similarly (returning a symbol from a function declaration):
I think we'd need to expose / use mrb_f_send to make your test work. |
makes sense. I'll see what I can do this week. On 6 Oct 2016, at 6:53, Mike Simons wrote:
|
Just a note; since such an easy mistake to make can cause a segfault, we should probably inspect the mrbvalue and ensure it's a proc before handing it over to C. Might also be interesting to try this with a more recent version of mruby (I tested against the version in the makefile) |
Expected: Prints "1", returns nil, nil
Actual: (_mruby.MrbValue)(nil), &mruby.Exception{MrbValue:(_mruby.MrbValue)(0xc8200920e0), cachedString:"unexpected return"}
For some reason
mruby.Run
does not work with aProc
returned frommruby.LoadString
. There may be good technical reasons (though I can't think of what they might be) but this surprised me. The errorunexpected return
is also non-obvious as there is noreturn
injected anywhere AFAICT.It is necessary to use something like the following to create a
Proc
that works withmruby.Run
:This works as expected. Drilling down in to the differences between the MrbValues generated with these two approaches should be sufficient to determine a cause (and potential solution).
The text was updated successfully, but these errors were encountered: