-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
SEGFAULT calling lua #84
Comments
I know it can be hard, but could you try creating a small-ish reproducible example? |
I have really tried boiling this down to a simple example to reproduce this issue. I am not sure I have succeded but in the mean time I have been able to reproduce a similar segfault. Not sure if this is the same issue.
|
I think I have some more information. I think the cause is two different threads try to access the lua runtime. The above example does this intentionally but in my software this is a side effect. Let me try to explain. I have not managed to create an isolated example of this but it is fairly reproducible in my project. Here is an example of the wrapper object:
The segfault happens even without the destructor. I added the destructor with an implicit "freeing" of |
Backtrace of the above observations:
|
Finally, a small-ish reproducible example! No threads or anything special... ;) |
Did you do any more work on this? I'm new to lua, but have done my share of python.. can i help? |
I can only answer from my side. I have tried to see where the crash happen but I could not understand fully why. |
I can reproduce the crash, but the stack trace changes on each run. That suggests that there might be some kind of Lua stack corruption that only shows at a later point. Meaning, the crash is almost certainly not where the problem is. |
Able to reproduce using Going to test a couple of versions now |
Well, it's certainly worth git bisect-ing it, although my intuition wants me to assume that it's been there forever, or at least as long as the features that the reproducer script uses are around...
|
Tried a couple of random versions..
all crashes randomly between 15 and 400.. |
Running the test and just watching it fail, dumps a lot of different errors on the console. Mostly segfaults, but also python malloc ( This might be a stupid question, but if I move |
Maybe you could try to strip down the test case? It's very complex and uses lots of features: Lua couroutines, the |
I'm very new to lua, so I'm not sure where to begin... I'll continue playing with it a little tho.. |
Another strange find is that if I set anything under Example..
is the original..
does not crash... But
do crash.. |
I have simplified the test case. Actually, removing the runtime options makes the script crash sooner on my machine. Two observations:
Maybe this has something to do when the |
I tried to turn off gc. |
Has there been any work done on this? I'm running into the same issue with coroutines unpredictably segfaulting. |
From my side, no, unfortunately not. |
There is a reproducing script in https://gist.github.com/mickeprag/75a0fbf04cfd06c3fe48b759da22f5ef |
Here's a slightly more minimal reproducing script: from lupa import LuaRuntime
class PendingRequest:
def __init__(self, callback):
self.callback = callback
def make_request(callback):
return PendingRequest(callback)
lua = LuaRuntime()
lua.globals().make_request = make_request
run = lua.eval("""
function()
make_request(function() end)
end
""")
for i in range(10000):
print("Start call", i)
thread = run.coroutine()
try:
thread.send(None)
except StopIteration:
pass
print("Finished successfully") Almost every time I run this I get an error similar to this:
So I do think it's likely there is some error with garbage collection/deallocation. I'm still not so comfortable debugging Cython but I'll try to look at this more over the weekend. |
I am getting segfaults from time to time. It seems to happen when python objects are wrapped and sent to the lua runtime.
Lupa version 1.4
Lua: tested version 5.1.5, 5.2.3, and luajit 2.0.4
Backtraces of the crash:
Lua:
Luajit:
The text was updated successfully, but these errors were encountered: