Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Created September 12, 2012 16:54
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/3708084 to your computer and use it in GitHub Desktop.
Save hnakamur/3708084 to your computer and use it in GitHub Desktop.
segfault on Linux
$ build/lev tools/checkit tests/test-fs.lua
*lev core started: 3842
✔ fs_sync_test: 10/10 within 0.178 ms
Lua Stack Dump: fs_open before set_callback starting at 5
1: 'LICENSE.txt'
2: 'r'
3: 438
4: <function 0x419d3958>
5: <userdata 0x419d39d8>
Core exited with status 0, signal 11
static int fs_open(lua_State* L) {
int mode;
uv_fs_cb cb;
uv_loop_t *loop = luv_get_loop(L);
int arg_n = lua_gettop(L);
fs_req_holder *holder = (fs_req_holder *)create_obj_init_ref(L,
sizeof(fs_req_holder), "lev.fs");
uv_fs_t *req = &holder->req;
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++);
lev_handle_ref(L, (LevRefStruct_t *)holder, -1);
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);
int ret_n = push_results(L, req);
if (!LEV_IS_ASYNC_REQ(req)) {
uv_fs_req_cleanup(req);
}
return ret_n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment