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

Lua coroutines loses arguments when calling python functions. #50

Closed
greatwolf opened this issue Feb 12, 2017 · 0 comments
Closed

Lua coroutines loses arguments when calling python functions. #50

greatwolf opened this issue Feb 12, 2017 · 0 comments
Labels

Comments

@greatwolf
Copy link
Collaborator

greatwolf commented Feb 12, 2017

The follow reproduces the problem:

py = require 'python'
pyprint = py.eval "print"
co = coroutine.create(function()
                        pyprint(math.sin)
                      end)
coroutine.resume(co)

That prints Lua nil on the python side instead of the function value of math.sin. Likewise when passing an empty table eg. pyprint({}, 1)}.

The problem is in LuaObject_New, it always uses the same global lua_State. This creates a problem when using coroutines since a different lua_State is used -- pushing arguments to the global state context is wrong in this scenario resulting in 'lost' parameters. Simple primitive types are fine but any non-trivial types like tables, functions, udata, other coroutines etc. that involves LuaObject_New during conversion will be affected by this bug.

greatwolf added a commit to greatwolf/lunatic-python that referenced this issue Feb 12, 2017
greatwolf added a commit that referenced this issue Feb 12, 2017
Fix for issue #50 - coroutine param passing bug.
@greatwolf greatwolf added the bug label Mar 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant