Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Created September 12, 2012 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnakamur/3707846 to your computer and use it in GitHub Desktop.
Save hnakamur/3707846 to your computer and use it in GitHub Desktop.
SEGV and stackdump
static int fs_open(lua_State* L) {
int mode;
uv_fs_cb cb;
uv_loop_t *loop = luv_get_loop(L);
uv_fs_t *req = alloc_fs_req(L);
int arg_n = lua_gettop(L);
int arg_i = 1;
const char *path = luaL_checkstring(L, arg_i++);
int flags = fs_checkflags(L, arg_i++);
if (arg_i <= arg_n && lua_isnumber(L, arg_i)) {
mode = luaL_checkint(L, arg_i++);
} else {
mode = 0666;
}
if (arg_i <= arg_n) {
luv_lua_debug_stackdump(L, "fs_open before set_callback");
set_callback(L, CALLBACK_NAME, arg_i++);
luv_lua_debug_stackdump(L, "fs_open after set_callback");
cb = on_fs_callback;
} else {
cb = NULL;
}
uv_fs_open(loop, req, path, flags, mode, cb);
return fs_post_handling(L, req);
}
[hnakamur@naruh lev]$ build/lev tools/checkit tests/test-fs.lua
*lev core started: 2456
✔ fs_sync_test: 10/10 within 0.178 ms
Lua Stack Dump: fs_open before set_callback starting at 4
1: 'LICENSE.txt'
2: 'r'
3: 438
4: <function 0x40b9c958>
Core exited with status 0, signal 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment