Skip to content

Segfault in ngx_http_set_cookie_header #237

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

Closed
rfwatson opened this issue May 8, 2013 · 5 comments
Closed

Segfault in ngx_http_set_cookie_header #237

rfwatson opened this issue May 8, 2013 · 5 comments

Comments

@rfwatson
Copy link

rfwatson commented May 8, 2013

This is against the latest nginx 1.4.1 release, Ubuntu 11.10.

Stack trace below:

Let me know if you need any more information.

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Core was generated by `nginx: worker process'.
Program terminated with signal 11, Segmentation fault.
#0 0x0000000000415a97 in ngx_array_push (a=0x19ffcc8) at src/core/ngx_array.c:62

62 if ((u_char *) a->elts + size == p->d.last
(gdb) bt
#0 0x0000000000415a97 in ngx_array_push (a=0x19ffcc8) at src/core/ngx_array.c:62
#1 0x00000000004a0417 in ngx_http_set_cookie_header (r=0x19ffb40, hv=0x7fff51fd2460, value=0x7fff51fd2440)

at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_headers_in.c:437

#2 0x00000000004a082a in ngx_http_lua_set_input_header (r=0x19ffb40, key=..., value=..., override=)

at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_headers_in.c:514

#3 0x00000000004988cf in ngx_http_lua_ngx_req_header_set_helper (L=0x412aeed0) at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_headers.c:716
#4 0x0000000000498935 in ngx_http_lua_ngx_req_header_set (L=0x412aeed0) at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_headers.c:603
#5 0x00007fdffba7ae23 in ?? () from /usr/local/lib/libluajit-5.1.so.2
#6 0x00000000004a4628 in ngx_http_lua_run_thread (L=0x414e3378, r=0x19ffb40, ctx=0x1a00f80, nret=1) at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_util.c:1035
#7 0x0000000000493d7c in ngx_http_lua_subrequest_resume (r=0x19ffb40) at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_subrequest.c:1525
#8 0x00000000004a79b1 in ngx_http_lua_rewrite_handler (r=0x19ffb40) at /home/webuser/sources/lua-nginx-module-0.8.1/src/ngx_http_lua_rewriteby.c:102
#9 0x0000000000440cab in ngx_http_core_rewrite_phase (r=0x19ffb40, ph=0x19bb158) at src/http/ngx_http_core_module.c:942
#10 0x000000000043cc63 in ngx_http_core_run_phases (r=0x19ffb40) at src/http/ngx_http_core_module.c:888
#11 0x00000000004456f7 in ngx_http_run_posted_requests (c=0x7fdfe65a5f90) at src/http/ngx_http_request.c:2170
#12 0x00000000004576f6 in ngx_http_upstream_handler (ev=0x7fdffc19e188) at src/http/ngx_http_upstream.c:972
#13 0x00000000004336da in ngx_epoll_process_events (cycle=0x187e400, timer=, flags=) at src/event/modules/ngx_epoll_module.c:683
#14 0x000000000042a926 in ngx_process_events_and_timers (cycle=0x187e400) at src/event/ngx_event.c:249
#15 0x0000000000431d2e in ngx_worker_process_cycle (cycle=0x187e400, data=) at src/os/unix/ngx_process_cycle.c:807
#16 0x00000000004304cb in ngx_spawn_process (cycle=0x187e400, proc=0x431c3f <ngx_worker_process_cycle>, data=0x0, name=0x4bc511 "worker process", respawn=0)

at src/os/unix/ngx_process.c:198

#17 0x00000000004329d7 in ngx_reap_children (cycle=0x187e400) at src/os/unix/ngx_process_cycle.c:619
#18 ngx_master_process_cycle (cycle=0x187e400) at src/os/unix/ngx_process_cycle.c:180
#19 0x000000000041440a in main (argc=, argv=) at src/core/nginx.c:412

@rfwatson
Copy link
Author

rfwatson commented May 8, 2013

This was against 0.8.1 nginx lua module tag, I should add

@agentzh
Copy link
Member

agentzh commented May 8, 2013

I had not run ngx_lua's test suite against nginx 1.4.1 and it's been working with 1.2.x. I just tried running the test suite against 1.4.1 and the tests for setting request cookies are indeed failing (and also crashing) with exactly the same backtraces you've shown. I'll try to find a fix for it. Thank you for the report :)

agentzh added a commit that referenced this issue May 8, 2013
…gx.req.set_header on the Cookie request headers because recent versions of nginx no longer always initialize r->headers_in.cookies. thanks Rob W for reporting this issue as #237.
@agentzh
Copy link
Member

agentzh commented May 8, 2013

Just fixed in git master HEAD. Please try it out :)

@rfwatson
Copy link
Author

rfwatson commented May 8, 2013

Thank you! I will test in the morning and let you know if successful.
:)

On 8 May 2013 21:09, Yichun Zhang [email protected] wrote:

Just fixed in git master HEAD. Please try it out :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/237#issuecomment-17630560
.

@rfwatson
Copy link
Author

rfwatson commented May 9, 2013

It works beautifully. Thank you for such a fast fix.

@rfwatson rfwatson closed this as completed May 9, 2013
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