我尝试过修改LuaJIT-2.1.0-beta3 开启XCFLAGS+= -DLUAJIT_USE_SYSMALLOC CFLAGS+= -DLUAJIT_USE_VALGRIND用valgrind 分析,没得到太大的帮助,而且gdb 下能nginx 会奔溃,在valgrind 下没有奔溃。
0x000055563b276eaa in ngx_http_lua_socket_tcp_cleanup (data=0x40df7e88) at /mnt/home/ts/svn/SDP/Gateway/trunk/sslvpn/appframe/src/lua/ngx_http_lua_socket_tcp.c:3757
3757 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
(gdb) bt
#0 0x000055563b276eaa in ngx_http_lua_socket_tcp_cleanup (data=0x40df7e88) at /mnt/home/ts/svn/SDP/Gateway/trunk/sslvpn/appframe/src/lua/ngx_http_lua_socket_tcp.c:3757
================
(gdb) p *r
$6 = {signature = 0, connection = 0x30, ctx = 0x14, main_conf = 0x55564535b970, srv_conf = 0x55564535d000, loc_conf = 0x0, read_event_handler = 0x0, write_event_handler = 0x0, cache = 0x0,
upstream = 0x0, upstream_states = 0x0, pool = 0x0, header_in = 0x0, headers_in = {headers = {last = 0x0, part = {elts = 0x0, nelts = 0, next = 0x0}, size = 0, nalloc = 0, pool = 0x0},
host = 0x0, connection = 0x0, if_modified_since = 0x0, if_unmodified_since = 0x0, if_match = 0x0, if_none_match = 0x0, user_agent = 0x0, referer = 0x0, content_length = 0x0,
content_type = 0x55563b2cf50a, range = 0x0, if_range = 0x0, transfer_encoding = 0x55564535c900, expect = 0x1, upgrade = 0x8, accept_encoding = 0x1, via = 0x55564535b970,
authorization = 0x7, keep_alive = 0x555645348fcb, x_forwarded_for = {elts = 0xffffffffffffffff, nelts = 18446744073709551615, size = 1, nalloc = 93829016697752, pool = 0x55564535bf30},
user = {len = 1, data = 0x0}, passwd = {len = 48, data = 0x14 <
error: Cannot access memory at address 0x14>}, cookies = {elts = 0x55564535b970, nelts = 302, size = 0, nalloc = 0,
pool = 0x0}, server = {len = 0, data = 0x0}, content_length_n = 0, keep_alive_n = 0, connection_type = 0, chunked = 0, msie = 0, msie6 = 0, opera = 0, gecko = 0, chrome = 0, safari = 0,
konqueror = 0}, headers_out = {headers = {last = 0x0, part = {elts = 0x0, nelts = 0, next = 0x0}, size = 0, nalloc = 0, pool = 0x0}, status = 9, status_line = {len = 9,
data = 0x55563b2bbd5b "text/html"}, server = 0x0, date = 0x0, content_length = 0x0, content_encoding = 0x0, location = 0x0, refresh = 0x0, last_modified = 0x0, content_range = 0x0,
accept_ranges = 0x0, www_authenticate = 0x9d, expires = 0x0, etag = 0xffffffffffffffff, override_charset = 0x0, content_type_len = 0, content_type = {len = 1666235392,
data = 0x22e <
error: Cannot access memory at address 0x22e>}, charset = {len = 2, data = 0x3e9 <
error: Cannot access memory at address 0x3e9>}, content_type_lowcase = 0x0,
content_type_hash = 93829016620976, cache_control = {elts = 0x10, nelts = 93829016704736, size = 0, nalloc = 0, pool = 0x0}, content_length_n = 0, date_time = 6,
last_modified_time = 93829016620980}, request_body = 0x3, lingering_time = 93829016620976, start_sec = 7, start_msec = 93828857128912, method = 0, http_version = 0, request_line = {
len = 0, data = 0x0}, uri = {len = 0, data = 0x0}, args = {len = 0, data = 0x0}, exten = {len = 0, data = 0x0}, unparsed_uri = {len = 0, data = 0x0}, method_name = {len = 0, data = 0x0},
http_protocol = {len = 0, data = 0x0}, out = 0x0, main = 0x0, parent = 0xffffffffffffffff, postponed = 0x55564535db20, post_subrequest = 0xffffffff040000c9, posted_requests = 0x182f18,
phase_handler = 0, content_handler = 0x55564535d030, access_code = 93828847937627, variables = 0x55564535be38, ncaptures = 0, captures = 0x0,
captures_data = 0x40773818 "\300^~@\001\006\001\001\300\343\364A", limit_rate = 0, header_size = 0, request_length = 0, err_status = 0, http_connection = 0x0, log_handler = 0x0,
cleanup = 0x0, subrequests = 0, count = 0, blocked = 0, aio = 0, http_state = 0, complex_uri = 0, quoted_uri = 0, plus_in_uri = 0, space_in_uri = 0, invalid_header = 0,
add_uri_to_alias = 0, valid_location = 0, valid_unparsed_uri = 0, uri_changed = 0, uri_changes = 0, request_body_in_single_buf = 0, request_body_in_file_only = 0,
request_body_in_persistent_file = 0, request_body_in_clean_file = 0, request_body_file_group_access = 0, request_body_file_log_level = 0, subrequest_in_memory = 0, waited = 0, cached = 0,
gzip_tested = 0, gzip_ok = 0, gzip_vary = 0, proxy = 0, bypass_cache = 0, no_cache = 0, limit_conn_set = 0, limit_req_set = 0, pipeline = 0, chunked = 0, header_only = 0, keepalive = 0,
lingering_close = 0, discard_body = 0, internal = 0, error_page = 0, ignore_content_encoding = 0, filter_finalize = 0, post_action = 0, request_complete = 0, request_output = 0,
header_sent = 0, expect_tested = 0, root_tested = 0, done = 0, logged = 0, buffered = 0, main_filter_need_in_memory = 0, filter_need_in_memory = 0, filter_need_temporary = 0,
allow_ranges = 0, state = 0, header_hash = 0, lowcase_index = 0, lowcase_header = '\000' <repeats 31 times>, header_name_start = 0x0, header_name_end = 0x0, header_start = 0x0,
header_end = 0x0, uri_start = 0x0, uri_end = 0x0, uri_ext = 0x0, args_start = 0x6fffffffe <error:
Cannot access memory at address 0x6fffffffe>, request_start = 0x0,
request_end = 0x1ff9 <
error: Cannot access memory at address 0x1ff9>, method_end = 0x0, schema_start = 0x0, schema_end = 0x0, host_start = 0x0, host_end = 0x0, port_start = 0x0,
port_end = 0x0, buf = 0x0, bytes_read = 16, bytes_write = 93829016698992, connect_start = 0x0, connect_end = 0x0, connect_host_start = 0x0, connect_host_end = 0x0, connect_port_start = 0x0,
connect_port_end = 0x0, http_minor = 0, http_major = 0, ftp_port = 0}
================
#1 0x000055563b276f3b in ngx_http_lua_socket_tcp_upstream_destroy (L=<optimized out>) at /mnt/home/ts/svn/SDP/Gateway/trunk/sslvpn/appframe/src/lua/ngx_http_lua_socket_tcp.c:5694
#2 0x00007f1debbf9dd7 in ?? () from /usr/local/lib/libluajit-5.1.so.2
#3 0x00007f1debbfbff8 in ?? () from /usr/local/lib/libluajit-5.1.so.2
#4 0x00007f1debbfc0b6 in ?? () from /usr/local/lib/libluajit-5.1.so.2
#5 0x00007f1debbfca33 in ?? () from /usr/local/lib/libluajit-5.1.so.2
#6 0x00007f1debbfd09c in ?? () from /usr/local/lib/libluajit-5.1.so.2
#7 0x00007f1debc09bbe in lua_pushlstring () from /usr/local/lib/libluajit-5.1.so.2
#8 0x000055563b278124 in ngx_http_lua_socket_tcp_close (L=0x4011d2a8) at /mnt/home/ts/svn/SDP/Gateway/trunk/sslvpn/appframe/src/lua/ngx_http_lua_socket_tcp.c:3092
================
(gdb) p *u
$3 = {read_prepare_retvals = 0x0, write_prepare_retvals = 0x0, read_event_handler = 0x0, write_event_handler = 0x0, socket_pool = 0x4001d028, conf = 0x55563bb14710, cleanup = 0x0,
request = 0x55564535d030, peer = {connection = 0x0, sockaddr = 0x55564535c3c0, socklen = 16, name = 0x55564535c3e0, tries = 0, get = 0x55563b2738b9 <ngx_http_lua_socket_tcp_get_peer>,
free = 0x0, data = 0x0, set_session = 0x0, save_session = 0x0, local = 0x0, rcvbuf = 0, log = 0x555645350060, cached = 0, transparent = 0, log_error = 1, check_index = 0},
read_timeout = 60000, send_timeout = 60000, connect_timeout = 60000, resolved = 0x55564535c3e0, bufs_in = 0x0, buf_in = 0x0, buffer = {pos = 0x0, last = 0x0, file_pos = 0, file_last = 0,
start = 0x0, end = 0x0, tag = 0x0, file = 0x0, shadow = 0x0, temporary = 0, memory = 0, mmap = 0, recycled = 0, in_file = 0, flush = 0, sync = 0, last_buf = 0, last_in_chain = 0,
last_shadow = 0, temp_file = 0, num = 0}, length = 0, rest = 0, socket_errno = 11, input_filter = 0x0, input_filter_ctx = 0x0, request_len = 0, request_bufs = 0x0, read_co_ctx = 0x0,
write_co_ctx = 0x0, reused = 0, ssl_name = {len = 0, data = 0x0}, ft_type = 0, no_close = 0, conn_waiting = 0, read_waiting = 0, write_waiting = 0, eof = 0, body_downstream = 0,
raw_downstream = 0, read_closed = 1, write_closed = 1, conn_closed = 0, ssl_verify = 0, ssl_session_reuse = 0}
(gdb) p L
$4 = (lua_State *) 0x4011d2a8
(gdb) p *r
$5 = {signature = 1347703880, connection = 0x7f1dd13cc120, ctx = 0x55564535d960, main_conf = 0x55563bac2d70, srv_conf = 0x55563baf0de0, loc_conf = 0x55563bb13530,
read_event_handler = 0x55563b1f1982 <ngx_http_block_reading>, write_event_handler = 0x55563b1e7783 <ngx_http_core_run_phases>, cache = 0x0, upstream = 0x0, upstream_states = 0x0,
pool = 0x55564535cfe0, header_in = 0x555645334570, headers_in = {headers = {last = 0x55564535d0a0, part = {elts = 0x55564535b990, nelts = 3, next = 0x0}, size = 48, nalloc = 20,
pool = 0x55564535cfe0}, host = 0x55564535b990, connection = 0x0, if_modified_since = 0x0, if_unmodified_since = 0x0, if_match = 0x0, if_none_match = 0x0, user_agent = 0x0,
referer = 0x0, content_length = 0x0, content_type = 0x0, range = 0x0, if_range = 0x0, transfer_encoding = 0x0, expect = 0x0, upgrade = 0x0, accept_encoding = 0x0, via = 0x0,
authorization = 0x0, keep_alive = 0x0, x_forwarded_for = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0}, user = {len = 0, data = 0x0}, passwd = {len = 0, data = 0x0},
cookies = {elts = 0x55564535df70, nelts = 1, size = 8, nalloc = 1, pool = 0x55564535cfe0}, server = {len = 7, data = 0x555645348fcb "
3.3.3.1:4443"}, content_length_n = -1,
keep_alive_n = -1, connection_type = 1, chunked = 0, msie = 0, msie6 = 0, opera = 0, gecko = 0, chrome = 0, safari = 0, konqueror = 0}, headers_out = {headers = {last = 0x55564535d208,
part = {elts = 0x55564535d5a0, nelts = 0, next = 0x0}, size = 48, nalloc = 20, pool = 0x55564535cfe0}, status = 0, status_line = {len = 0, data = 0x0}, server = 0x0, date = 0x0,
content_length = 0x0, content_encoding = 0x0, location = 0x0, refresh = 0x0, last_modified = 0x0, content_range = 0x0, accept_ranges = 0x0, www_authenticate = 0x0, expires = 0x0,
etag = 0x0, override_charset = 0x0, content_type_len = 0, content_type = {len = 0, data = 0x0}, charset = {len = 0, data = 0x0}, content_type_lowcase = 0x0, content_type_hash = 0,
cache_control = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0}, content_length_n = -1, date_time = 0, last_modified_time = -1}, request_body = 0x0, lingering_time = 0,
start_sec = 1666235392, start_msec = 764, method = 2, http_version = 1001, request_line = {len = 19, data = 0x555645348fb0 "GET /sag1/ HTTP/1.1\r\nHost"}, uri = {len = 16,
data = 0x55564535c070 "/WEB_PROXY/sag1/p7\257;VU"}, args = {len = 0, data = 0x0}, exten = {len = 0, data = 0x0}, unparsed_uri = {len = 6, data = 0x555645348fb4 "/sag1/ HTTP/1.1\r\nHost"},
method_name = {len = 3, data = 0x555645348fb0 "GET /sag1/ HTTP/1.1\r\nHost"}, http_protocol = {len = 8, data = 0x555645348fbb "HTTP/1.1\r\nHost"}, out = 0x0, main = 0x55564535d030,
parent = 0x0, postponed = 0x0, post_subrequest = 0x0, posted_requests = 0x0, phase_handler = 11, content_handler = 0x55563b2b2ecb <ngx_http_proxy_switch_handler>, access_code = 0,
variables = 0x55564535dbc0, ncaptures = 0, captures = 0x55564535bdf0, captures_data = 0x0, limit_rate = 0, header_size = 0, request_length = 109, err_status = 0,
http_connection = 0x5556453500a0, log_handler = 0x55563b1f0046 <ngx_http_log_error_handler>, cleanup = 0x55564535c360, subrequests = 201, count = 2, blocked = 0, aio = 0, http_state = 2,
complex_uri = 0, quoted_uri = 0, plus_in_uri = 0, space_in_uri = 0, invalid_header = 0, add_uri_to_alias = 0, valid_location = 1, valid_unparsed_uri = 0, uri_changed = 0, uri_changes = 10,
request_body_in_single_buf = 0, request_body_in_file_only = 0, request_body_in_persistent_file = 0, request_body_in_clean_file = 0, request_body_file_group_access = 0,
request_body_file_log_level = 5, subrequest_in_memory = 0, waited = 0, cached = 0, gzip_tested = 0, gzip_ok = 0, gzip_vary = 0, proxy = 0, bypass_cache = 0, no_cache = 0,
limit_conn_set = 0, limit_req_set = 0, pipeline = 0, chunked = 0, header_only = 0, keepalive = 0, lingering_close = 0, discard_body = 0, internal = 1, error_page = 0,
ignore_content_encoding = 0, filter_finalize = 0, post_action = 0, request_complete = 0, request_output = 0, header_sent = 0, expect_tested = 0, root_tested = 0, done = 0, logged = 0,
buffered = 0, main_filter_need_in_memory = 1, filter_need_in_memory = 0, filter_need_temporary = 0, allow_ranges = 0, state = 0, header_hash = 2940209764, lowcase_index = 6,
lowcase_header = "cookietion", '\000' <repeats 21 times>, header_name_start = 0x55564534901b "\r\n", header_name_end = 0x555645348ff2 "",
header_start = 0x555645348ff4 "ETRUST_SESSIONID=jA2lUeCU2eDjAjxmJRwf", header_end = 0x55564534901b "\r\n", uri_start = 0x555645348fb4 "/sag1/ HTTP/1.1\r\nHost",
uri_end = 0x555645348fba " HTTP/1.1\r\nHost", uri_ext = 0x0, args_start = 0x0, request_start = 0x555645348fb0 "GET /sag1/ HTTP/1.1\r\nHost", request_end = 0x555645348fc3 "\r\nHost",
method_end = 0x555645348fb2 "T /sag1/ HTTP/1.1\r\nHost", schema_start = 0x0, schema_end = 0x0, host_start = 0x0, host_end = 0x0, port_start = 0x0, port_end = 0x0, buf = 0x0, bytes_read = 0,
bytes_write = 0, connect_start = 0x0, connect_end = 0x0, connect_host_start = 0x0, connect_host_end = 0x0, connect_port_start = 0x0, connect_port_end = 0x0, http_minor = 1, http_major = 1,
ftp_port = 0}
================
#10 0x000055563b269cae in ngx_http_lua_run_thread (L=L@entry=0x41f4e378, r=r@entry=0x55564535d030, ctx=ctx@entry=0x55564535c180, nrets=nrets@entry=0)
at /mnt/home/ts/svn/SDP/Gateway/trunk/sslvpn/appframe/src/lua/ngx_http_lua_util.c:1091