-
Notifications
You must be signed in to change notification settings - Fork 2k
关于ngx.thread.spawn+ngx.location.capture+ngx.exit引发的内存泄露以及coredump问题 #2394
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
Comments
能否在 最新的 ngx_lua 版本上进行验证? |
可以,我抽空在最新的版本上也尝试复现下 |
结论在最新的1.27.1.1能够复现 编译环境Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 编译命令nginx version: openresty/1.27.1.1 复现过程使用fortio工具以 100 QPS 请求http://localhost:8090/example0 或者 http://localhost:8090/example2 异常时调用栈复现时的nginx.conf
|
问题版本号
ngx_lua-0.10.13
最新的代码,应该也存在问题
问题复现用例
出现异常时的堆栈(运行行为未定义,可能是segment fault,也可能是死循环)
lj_gc_step
会进入死循环分析
复现用例协程调度图
如何修复
思路:防范于未然,调用ngx.exit时如果有未结束的capture,直接抛异常。
其实ngx.exit内部有检查是否能结束请求的逻辑
这个检查在只有一个capture子请求时是生效的。如果如用例所示有多个capture时,就会失效。
解决办法是将no_abort的语义由bool类型改为对capture的计数,创建时+1,结束时-1,具体代码如下所示:
The text was updated successfully, but these errors were encountered: