Skip to content

bugfix: segment fault due to access of uninitialized value. #215

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

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ngx_stream_lua_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ ngx_stream_lua_timer_handler(ngx_event_t *ev)
failed:

/* co stack: func [args] */
lua_pushvalue(tctx.co, 1);
/* co stack: func [args] func */
lua_getinfo(tctx.co, ">Sf", &ar);

source = ar.source;
Expand Down
44 changes: 44 additions & 0 deletions t/106-timer.t
Original file line number Diff line number Diff line change
Expand Up @@ -1910,3 +1910,47 @@ qr/\[alert\] .*? lua failed to run timer with function defined at @.+\/test.lua:
[crit]
[error]
[warn]



=== TEST 33: log function location when failed to run a timer with arg (lua file)
--- user_files
>>> test.lua
local _M = {}

function _M.run()
ngx.sleep(0.01)
end

return _M
--- stream_config
lua_package_path '$TEST_NGINX_HTML_DIR/?.lua;./?.lua;;';
lua_max_running_timers 1;
--- stream_server_config
content_by_lua_block {
local test = require "test"

local ok, err = ngx.timer.at(0, test.run, "arg")
if not ok then
ngx.say("failed to set timer: ", err)
return
end

local ok, err = ngx.timer.at(0, test.run, "arg")
if not ok then
ngx.say("failed to set timer: ", err)
return
end

ngx.say("ok")
}
--- stream_response
ok
--- wait: 0.1
--- error_log eval
qr/\[alert\] .*? lua failed to run timer with function defined at @.+\/test.lua:3: stream lua: 1 lua_max_running_timers are not enough/
--- no_error_log
[emerg]
[crit]
[error]
[warn]