Skip to content
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

track issues in neovim related with luv #663

Open
3 tasks
zhaozg opened this issue Aug 19, 2023 · 4 comments
Open
3 tasks

track issues in neovim related with luv #663

zhaozg opened this issue Aug 19, 2023 · 4 comments

Comments

@zhaozg
Copy link
Member

zhaozg commented Aug 19, 2023

@zhaozg
Copy link
Member Author

zhaozg commented Aug 19, 2023

This mainly because of default behavior of luv will exit when error occurs in callback.

luv/src/luv.c

Lines 707 to 724 in bc01ad8

case LUA_ERRMEM:
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0)
fprintf(stderr, "System Error: %s\n", lua_tostring(L, -1));
if ((flags & LUVF_CALLBACK_NOEXIT) == 0)
exit(-1);
lua_pop(L, 1);
ret = -ret;
break;
case LUA_ERRRUN:
case LUA_ERRERR:
default:
if ((flags & LUVF_CALLBACK_NOERRMSG) == 0)
fprintf(stderr, "Uncaught Error: %s\n", lua_tostring(L, -1));
if ((flags & LUVF_CALLBACK_NOEXIT) == 0)
exit(-1);
lua_pop(L, 1);
ret = -ret;
break;

There are three opportunity or choice to handle this kind things.

1. The Lua developer has duty to write safe callback code.

2. The applications that use luv can use can change luv default process by luv c api.

luv/src/luv.h

Lines 124 to 141 in bc01ad8

/* Set or clear an external c routine for luv event callback
When using a custom/external function, this must be called before luaopen_luv
(otherwise luv will use the default callback function: luv_cfpcall)
*/
LUALIB_API void luv_set_callback(lua_State* L, luv_CFpcall pcall);
/* Set or clear an external c routine for luv thread When using
* a custom/external function, this must be called before luaopen_luv
* in the function that create the lua_State of the thread
(otherwise luv will use the default callback function: luv_cfpcall)
*/
LUALIB_API void luv_set_thread(lua_State* L, luv_CFpcall pcall);
/* Set or clear an external c routine for luv c thread When using
* a custom/external function, this must be called before luaopen_luv
* in the function that create the lua_State of the thread
(otherwise luv will use the default callback function: luv_cfcpcall)
*/

luv flags to control luv_CFpcall routine.

https://github.com/luvit/luv/blob/master/src/luv.h#L65-L93

3. luv set default flag with LUVF_CALLBACK_NOEXIT to avoid exit, continue to run but real errors

This is simplest way, but when luv use as a network server live long time, this maybe hide some applications errors. I hope receive more recommendations about whether to enable this.

Let's try change default LUVF_CALLBACK_FLAGS to LUVF_CALLBACK_NOEXIT.

@squeek502
Copy link
Member

Let's try change default LUVF_CALLBACK_FLAGS to LUVF_CALLBACK_NOEXIT.

This just runs into #433 again, see #433 (comment) for the problem with it.

@squeek502
Copy link
Member

Note also that neovim does not use the default luv_cfpcall, so fixing the non-string error problems on our end won't actually fix them for neovim.

@zhaozg
Copy link
Member Author

zhaozg commented Aug 20, 2023

Let's try change default LUVF_CALLBACK_FLAGS to LUVF_CALLBACK_NOEXIT.

This just runs into #433 again, see #433 (comment) for the problem with it.

I almost forget that.

@zhaozg zhaozg changed the title some issues in neovim track issues in neovim releatived with luv Aug 20, 2023
@zhaozg zhaozg changed the title track issues in neovim releatived with luv track issues in neovim related with luv Aug 20, 2023
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