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

lupa+coroutines segfaults in IPython #24

Closed
kmike opened this issue Oct 11, 2014 · 6 comments
Closed

lupa+coroutines segfaults in IPython #24

kmike opened this issue Oct 11, 2014 · 6 comments
Labels

Comments

@kmike
Copy link
Collaborator

kmike commented Oct 11, 2014

I'm using lupa 1.0, ipython 2.3 (both installed using pip) and lua 5.2.3 (installed using homebrew). The issue is quite strange: lupa segfaults in IPython but not in python.

Python:

>>> import lupa; lua = lupa.LuaRuntime()
>>> f = lua.eval("function(N) coroutine.yield(N) end")
>>> list(f.coroutine(1))
[1]
>>> f.coroutine(1)
<Lua thread at 0x7ff198f00b30>

IPython:

In [1]: import lupa; lua = lupa.LuaRuntime()
In [2]: f = lua.eval("function(N) coroutine.yield(N) end")
In [3]: list(f.coroutine(1))  # f.coroutine always seems to work fine when wrapped in list()
Out[3]: [1]
In [4]: f.coroutine(1)
Segmentation fault: 11

It is likely a manifistation of a problem unrelated to python vs ipython, it could segfault in IPython e.g. because memory layout of python and ipython processes are different. I've had a similar issue in one of my wrappers once (works in python, doesn't work in ipython); the cause was improper handling of null-terminated strings. But I'm sure you know all this stuff way better :)

@kmike
Copy link
Collaborator Author

kmike commented Oct 11, 2014

With lua 5.1.5 (installed using homebrew) this also fails the same way both for lupa==1.0 and lupa==0.21.

@kmike
Copy link
Collaborator Author

kmike commented Oct 11, 2014

Commands like bool(f.coroutine(1)) or repr(f.coroutine(1)) or gen = f.coroutine(1) don't segfaut for me, while just f.coroutine(1) or gen segfaults always - tried it on 2 different machines.

@kmike
Copy link
Collaborator Author

kmike commented Oct 11, 2014

It fails the same way on Debian - in python example works, in ipython it segfaults.

@scoder
Copy link
Owner

scoder commented Oct 11, 2014

Thanks for the report, I can reproduce this. Working on a fix.

@scoder scoder added the fixed label Oct 11, 2014
@scoder
Copy link
Owner

scoder commented Oct 11, 2014

Fixed:
4c3a9e1
Thanks!

@scoder scoder closed this as completed Oct 11, 2014
@kmike
Copy link
Collaborator Author

kmike commented Oct 11, 2014

Thanks for a quick fix!

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

2 participants