Coder Social home page Coder Social logo

track issues in neovim related with luv about luv HOT 4 OPEN

zhaozg avatar zhaozg commented on July 16, 2024 5
track issues in neovim related with luv

from luv.

Comments (4)

zhaozg avatar zhaozg commented on July 16, 2024

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.

from luv.

squeek502 avatar squeek502 commented on July 16, 2024

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.

from luv.

squeek502 avatar squeek502 commented on July 16, 2024

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.

from luv.

zhaozg avatar zhaozg commented on July 16, 2024

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.

from luv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.