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

Not removing sleep timer when deleting a thread? #248

Closed
aviramc opened this issue Jun 10, 2013 · 6 comments
Closed

Not removing sleep timer when deleting a thread? #248

aviramc opened this issue Jun 10, 2013 · 6 comments

Comments

@aviramc
Copy link

aviramc commented Jun 10, 2013

Hi!

Debugging an issue that I have with my Lua code, I ran across this issue - the function ngx_http_lua_del_thread doesn't remove the sleep timer of the thread in case the thread waits for sleep.

Is this really a bug? And in a more general perspective - shouldn't ngx_http_lua_del_thread call coctx->cleanup for cleaning up any action in which it is stuck?

I've ran across this bug when debugging an issue that might also be interesting - I have a Lua thread that sleeps, and under certain conditions I want the request to end without waiting for this thread to end, so I call ngx.exit. This works okay, but under a stress of roughly 1000 requests per seconds, it crashes. The core dump shows various location in each crash (sometimes in Nginx code and sometimes in LuaJIT), and this looks like a memory corruption that might occur if, for example, a timer event of an already finished request would occur...

Regards
Aviram

@agentzh
Copy link
Member

agentzh commented Jun 10, 2013

No, it is ngx_http_lua_finalize_coroutines's responsibility to call coctx->cleanup (so as to remove pending sleep timers and etc).

When you call ngx.exit() on the Lua land to abort all the pending threads in the current request, it will trigger calling ngx_http_lua_handle_exit, which then calls ngx_http_lua_request_cleanup that again calls ngx_http_lua_finalize_coroutines.

The crash looks like a bug in ngx_lua. It'll be great if you can prepare a minimized example that can help reproduce the issue on my side so that I can fix it much more easily.

BTW, which version of nginx, ngx_lua, and LuaJIT are you using?

Thank you for the report!

@agentzh
Copy link
Member

agentzh commented Sep 8, 2013

@aviramc Any updates on this issue?

@aviramc
Copy link
Author

aviramc commented Sep 8, 2013

Hello!

Unfortunately, I haven't had time to reproduce this, I'll do it soon.
When I try it, I'll try to reproduce with the latest version of ngx_lua, back then I used 0.8.1 I think.

@agentzh
Copy link
Member

agentzh commented Jun 20, 2014

@aviramc Any updates regarding this issue?

@aviramc
Copy link
Author

aviramc commented Jun 22, 2014

@agentzh , sorry for the delay in the response. This was a bug in a code change I've made (related to the bug fixed in commit 47836ce).

So this is a non-issue.

@agentzh
Copy link
Member

agentzh commented Jun 22, 2014

@aviramc Cool! Good to know. Then I'm closing this :)

@agentzh agentzh closed this as completed Jun 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants