Skip to content

Instantly share code, notes, and snippets.

View agentzh's full-sized avatar

Yichun Zhang agentzh

View GitHub Profile
@agentzh
agentzh / valgrind.out
Last active January 1, 2016 14:09
Valgrind 3.8.1 output for nginx-waf from startup to the assertion failure "lj_snap.c:120: snapshot_framelinks: Assertion `f == (MSize)(1 + J->framedepth)' failed."
==3932== Memcheck, a memory error detector
==3932== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==3932== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==3932== Command: /home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx -g pid\ /home/agentzh/git/lua-nginx-module/work/nginx/nginx-run.pid;
==3932==
==3932== Conditional jump or move depends on uninitialised value(s)
==3932== at 0x104A819F: ???
==3932== by 0x546BC3F: ???
==3932==
==3932== Conditional jump or move depends on uninitialised value(s)
@agentzh
agentzh / valgrind.out
Created December 28, 2013 04:46
Valgrind 3.8.1 output for nginx-waf from startup to the segmentation fault in `lj_cont_stitch`.
==5196== Memcheck, a memory error detector
==5196== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==5196== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==5196== Command: /home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx -g pid\ /home/agentzh/git/lua-nginx-module/work/nginx/nginx-run.pid;
==5196==
==5196== Conditional jump or move depends on uninitialised value(s)
==5196== at 0x104CD9BD: ???
==5196== by 0x565B38F: ???
==5196== by 0x564E1DF: ???
==5196== by 0x565AF57: ???
diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c
index 0dcd9e8..0311f8f 100644
--- a/src/ngx_http_lua_socket_tcp.c
+++ b/src/ngx_http_lua_socket_tcp.c
@@ -3967,17 +3967,35 @@ ngx_http_lua_socket_downstream_destroy(lua_State *L)
static void
ngx_http_lua_req_socket_cleanup(void *data)
{
+ ngx_event_t *wev, *rev;
+ ngx_connection_t *c;
diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c
index 0dcd9e8..c92510b 100644
--- a/src/ngx_http_lua_socket_tcp.c
+++ b/src/ngx_http_lua_socket_tcp.c
@@ -40,7 +40,6 @@ static void ngx_http_lua_socket_send_handler(ngx_http_request_t *r,
static void ngx_http_lua_socket_connected_handler(ngx_http_request_t *r,
ngx_http_lua_socket_tcp_upstream_t *u);
static void ngx_http_lua_socket_tcp_cleanup(void *data);
-static void ngx_http_lua_req_socket_cleanup(void *data);
static void ngx_http_lua_socket_tcp_finalize(ngx_http_request_t *r,
@agentzh
agentzh / a.md
Last active January 3, 2016 09:49

% The ktap Tutorial

Introduction

ktap is a new script-based dynamic tracing tool for linux http://www.ktap.org

ktap is a new script-based dynamic tracing tool for Linux, it uses a scripting language and lets the user trace the Linux kernel dynamically. ktap is designed to give operational insights with interoperability

@agentzh
agentzh / gist:8570578
Created January 23, 2014 00:39
Disable the stack shrink in LuaJIT 2.1
diff --git a/src/lj_state.c b/src/lj_state.c
index c7593f5..8c0ff33 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -8,7 +8,7 @@
#define lj_state_c
#define LUA_CORE
-
+#include <stdio.h>
@agentzh
agentzh / segfault.lua
Created January 31, 2014 19:28
LuaJIT v2.1 (commit 5a5a340f)
local function factory()
local f = function ()
local function func1()
return error([[blah]])
end
local function func2()
local v = func1()
return v
end
local function func3()
location = /cjson {
content_by_lua '
local json = require "cjson.safe"
ngx.say("cjson.safe: ", json.encode{foo = 123})
';
}
@agentzh
agentzh / gist:9421063
Created March 7, 2014 21:57
strace output for os.date("...", ngx.time())
$ strace -p 22507 -s 1024
Process 22507 attached
write(4, "2014/03/07 13:52:43 [info] 22507#0: epoll_wait() failed (4: Interrupted system call)\n", 85) = 85
epoll_wait(3, {?} 0xd122b0, 512, -1) = 1
accept4(6, {sa_family=AF_INET, sin_port=htons(57726), sin_addr=inet_addr("127.0.0.1")}, [16], SOCK_NONBLOCK) = 7
epoll_ctl(3, EPOLL_CTL_ADD, 7, {...}) = 0
epoll_wait(3, {?} 0xd122b0, 512, 60000) = 1
recvfrom(7, "GET /t HTTP/1.1\r\nUser-Agent: curl/7.24.0 (x86_64-redhat-linux-gnu) libcurl/7.24.0 NSS/3.14.3.0 zlib/1.2.5 libidn/1.24 libssh2/1.4.1\r\nHost: localhost:8080\r\nAccept: */*\r\n\r\n", 1024, 0, NULL, NULL) = 170
write(4, "2014/03/07 13:52:45 [notice] 22507#0: *3 [lua] [string \"content_by_lua\"]:2: hi, client: 127.0.0.1, server: localhost, request: \"GET /t HTTP/1.1\", host: \"localhost:8080\"\n", 169) = 169
write(2, "today is Friday, in March (03/07/14)\n", 37) = 37
$ ngx-lua-exec-time.sxx -x 14884
Start tracing process 14884 (/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx)...
Hit Ctrl-C to end.
^C
Distribution of Lua code pure execution time (accumulated in each request, in microseconds) for 10000 samples:
(min/avg/max: 4/6/65)
value |-------------------------------------------------- count
1 | 0
2 | 0
4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9204