Compare commits

1 Commits

Author SHA256 Message Date
956c6b7557 Upgrade to 1.51.0-1:
- Fix use-after-free in new_thread
    - feat: add binding for semaphore to test synchronization
    - ci: Add check that docs.md and meta.lua are up-to-date
    - docs: move to new directory
    - Remove unused function luv_gc_cb
Upgrade to 1.51.0-0:
    - Bump Libuv to 1.51.0
        - Added the constants FS_UTIME_NOW and FS_UTIME_OMIT
        - Made the atime/mtime parameters of
          fs_utime/fs_futime/fs_lutime accept nil, a string, or
          a number. If nil, the argument is translated to
          FS_UTIME_OMIT. If it is a string, it must be "omit" or
          "now".
        - Adds the constant TTY_MODE_RAW_VT ("raw_vt" is the
          shorthand string version) (context:
          libuv/libuv@843b64f)
    - Fix typos
    - feat(doc): move to structured format
    - Update luv-scm-0.rockspec
    - feat(doc): generate meta file
Upgrade to v1.50.0-1:
    - test-misc: Allow big endian WTF-16, too
    - Clean up test step and exclude it from the "all" target
    - rework luv work vm storage into userdata
Upgrade to v1.50.0-0:
    - docs: Clarify types for mode arg in some filesystem
      functions
    - Disable flaky UDP test on macOS CI
    - ci: handle EBUSY for udp
    - Lua 5.4.7 update
    - Clean up and expand docs for constants/options
    - docs: typo fix
    - update submodules
    - Remove unnecessary allocation from wtf8 functions
    - Bump Libuv to 1.49.1
    - Bump Libuv to 1.49.2
    - Support Lua integer in thread and async arguments
    - Fix a misleading skip message in test-tty.lua
    - Use main thread of current Lua state for callbacks, when
      known
    - luv_cfpcall: Fix stack balancing after an uncaught error
    - try safe handle external handle
    - Update minimum cmake version to 3.10
    - fix: prevent calling uv.run while already running.
    - move luv_work_cleanup into loop gc
    - fix unused-variable warning
    - test-dns: Don't skip 'Get only ipv6 tcp adresses for
      luvit.io' test
    - Bump Libuv to 1.50.0
    - bump LuaJIT to v2.1.1736781742
Upgrade to 1.48.0-2:
    - Fix garbage collection of scandir reqs
        - This fixes a regression (use-after-free) that was
          introduced in 1.48.0-1, see #694 (comment)
    - Fix a few instances of undefined behavior caught by UBSan
    - msvcbuild: Set MSVC 2022 as the default
Upgrade to 1.48.0-1:
    - fix memory leak in fs.scandir sync mode
    - bump lua-compat-5.3 to 0.13
Upgrade to v1.48.0-0:
    - fix: Use os_uname() to check for Linux
    - docs: typo in a table field name
    - docs: most new_handle methods won't return fail
    - test-tty: Don't depend on stdin/stdout handle type
    - Bump/libuv
    - Annotate .gitmodules with branch and tag
Upgrade to v1.47.0-0:
    - Bump/luajit
    - docs: Correct uv.spawn options.args docs about the first
      argument
    - Remove redundant CMake policy change
    - docs: new_async callback is not optional
    - update submodule
    - Bump version to 1.47.0 in CMakeLists.txt
Upgrade to 1.46.0-0:
    - update libuv to v1.46.0
    - chore: update uv.tty_set_mode, and add tty test
    - chore: fix crash in loop_gc
    - fix: avoid dir be gc early.
    - fix: callback handle error with non-strings
    - docs: make process_kill signum arg optional
    - docs: add missing uv.os_unsetenv() parameter
    - docs: make uv.kill's signum optional
Remove upstreamed patch luv-fix-segfault-from-gc.patch
2025-07-25 21:42:24 +02:00
8 changed files with 118 additions and 110 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
.osc
_scmsync.obsinfo
_buildconfig-*
_buildinfo-*.xml
lua-luv-*-build/

View File

@@ -1,6 +1,12 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,7 +260,7 @@
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: luv-1.51.0-1/CMakeLists.txt
===================================================================
--- luv-1.51.0-1.orig/CMakeLists.txt 2025-05-17 06:24:53.000000000 +0200
+++ luv-1.51.0-1/CMakeLists.txt 2025-07-25 19:14:46.432241486 +0200
@@ -267,7 +267,7 @@
endif (USE_LUAJIT)
endif (LUA)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

View File

@@ -1,3 +1,92 @@
-------------------------------------------------------------------
Fri Jul 25 17:20:27 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Upgrade to 1.51.0-1:
- Fix use-after-free in new_thread
- feat: add binding for semaphore to test synchronization
- ci: Add check that docs.md and meta.lua are up-to-date
- docs: move to new directory
- Remove unused function luv_gc_cb
- Upgrade to 1.51.0-0:
- Bump Libuv to 1.51.0
- Added the constants FS_UTIME_NOW and FS_UTIME_OMIT
- Made the atime/mtime parameters of
fs_utime/fs_futime/fs_lutime accept nil, a string, or
a number. If nil, the argument is translated to
FS_UTIME_OMIT. If it is a string, it must be "omit" or
"now".
- Adds the constant TTY_MODE_RAW_VT ("raw_vt" is the
shorthand string version) (context:
libuv/libuv@843b64f)
- Fix typos
- feat(doc): move to structured format
- Update luv-scm-0.rockspec
- feat(doc): generate meta file
- Upgrade to v1.50.0-1:
- test-misc: Allow big endian WTF-16, too
- Clean up test step and exclude it from the "all" target
- rework luv work vm storage into userdata
- Upgrade to v1.50.0-0:
- docs: Clarify types for mode arg in some filesystem
functions
- Disable flaky UDP test on macOS CI
- ci: handle EBUSY for udp
- Lua 5.4.7 update
- Clean up and expand docs for constants/options
- docs: typo fix
- update submodules
- Remove unnecessary allocation from wtf8 functions
- Bump Libuv to 1.49.1
- Bump Libuv to 1.49.2
- Support Lua integer in thread and async arguments
- Fix a misleading skip message in test-tty.lua
- Use main thread of current Lua state for callbacks, when
known
- luv_cfpcall: Fix stack balancing after an uncaught error
- try safe handle external handle
- Update minimum cmake version to 3.10
- fix: prevent calling uv.run while already running.
- move luv_work_cleanup into loop gc
- fix unused-variable warning
- test-dns: Don't skip 'Get only ipv6 tcp adresses for
luvit.io' test
- Bump Libuv to 1.50.0
- bump LuaJIT to v2.1.1736781742
- Upgrade to 1.48.0-2:
- Fix garbage collection of scandir reqs
- This fixes a regression (use-after-free) that was
introduced in 1.48.0-1, see #694 (comment)
- Fix a few instances of undefined behavior caught by UBSan
- msvcbuild: Set MSVC 2022 as the default
- Upgrade to 1.48.0-1:
- fix memory leak in fs.scandir sync mode
- bump lua-compat-5.3 to 0.13
- Upgrade to v1.48.0-0:
- fix: Use os_uname() to check for Linux
- docs: typo in a table field name
- docs: most new_handle methods won't return fail
- test-tty: Don't depend on stdin/stdout handle type
- Bump/libuv
- Annotate .gitmodules with branch and tag
- Upgrade to v1.47.0-0:
- Bump/luajit
- docs: Correct uv.spawn options.args docs about the first
argument
- Remove redundant CMake policy change
- docs: new_async callback is not optional
- update submodule
- Bump version to 1.47.0 in CMakeLists.txt
- Upgrade to 1.46.0-0:
- update libuv to v1.46.0
- chore: update uv.tty_set_mode, and add tty test
- chore: fix crash in loop_gc
- fix: avoid dir be gc early.
- fix: callback handle error with non-strings
- docs: make process_kill signum arg optional
- docs: add missing uv.os_unsetenv() parameter
- docs: make uv.kill's signum optional
- Remove upstreamed patch luv-fix-segfault-from-gc.patch
-------------------------------------------------------------------
Mon Dec 4 10:05:58 UTC 2023 - Noah Dörr <archecraft1@gmail.com>

View File

@@ -21,8 +21,8 @@
%define lua_default 1
%endif
%define mod_name luv
%define upver 1.45.0-0
%define fixver %(echo %{upver}|sed 's|-|~|g')
%define upver 1.51.0-1
%define fixver %(echo %{upver}|sed 's|-|+|g')
%define libluv_sover 1
%define flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == ""
@@ -36,15 +36,10 @@ Release: 0
Summary: Bare libuv bindings for lua
License: Apache-2.0
Group: Development/Languages/Other
URL: https://github.com/luvit/%{mod_name}
Source0: https://github.com/luvit/%{mod_name}/releases/download/%{upver}/%{mod_name}-%{upver}.tar.gz
URL: https://github.com/luvit/luv
Source0: https://github.com/luvit/luv/releases/download/%{upver}/luv-%{upver}.tar.gz
Patch0: lua-link.patch
Patch1: luv-module-install.patch
# PATCH-FIX-UPSTREAM luv-fix-segfault-from-gc.patch gh#luvit/luv#599 mcepl@suse.com
# merged https://github.com/luvit/luv/commit/ff5e90249e08 and
# https://github.com/luvit/luv/commit/ecf3988c0be9
# Also closes gh#luvit/luv#644
Patch2: luv-fix-segfault-from-gc.patch
BuildRequires: %{flavor}-compat-5.3
BuildRequires: %{flavor}-devel
BuildRequires: %{flavor}-luafilesystem

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fa6c46fb09f88320afa7f88017efd7b0d2b3a0158c5ba5b6851340b0332a2b81
size 1468792

BIN
luv-1.51.0-1.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -1,92 +0,0 @@
diff --git a/src/handle.c b/src/handle.c
index 9180da34..0977a565 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -88,13 +88,19 @@ static int luv_is_closing(lua_State* L) {
return 1;
}
+static void luv_handle_free(uv_handle_t* handle);
+
static void luv_close_cb(uv_handle_t* handle) {
lua_State* L;
luv_handle_t* data = (luv_handle_t*)handle->data;
if (!data) return;
L = data->ctx->L;
- luv_call_callback(L, data, LUV_CLOSED, 0);
- luv_unref_handle(L, data);
+ if(data->ref > 0) {
+ luv_call_callback(L, data, LUV_CLOSED, 0);
+ luv_unref_handle(L, data);
+ } else {
+ luv_handle_free(handle);
+ }
}
static int luv_close(lua_State* L) {
@@ -127,12 +133,13 @@ static void luv_gc_cb(uv_handle_t* handle) {
static int luv_handle_gc(lua_State* L) {
uv_handle_t** udata = (uv_handle_t**)lua_touserdata(L, 1);
uv_handle_t* handle = *udata;
+ luv_handle_t* data = (luv_handle_t*)handle->data;
// Only cleanup if the handle hasn't been cleaned up yet.
- if (handle) {
+ if (data->ref == LUA_NOREF) {
if (!uv_is_closing(handle)) {
// If the handle is not closed yet, close it first before freeing memory.
- uv_close(handle, luv_gc_cb);
+ uv_close(handle, luv_handle_free);
}
else {
// Otherwise, free the memory right away.
@@ -140,6 +147,10 @@ static int luv_handle_gc(lua_State* L) {
}
// Mark as cleaned up by wiping the dangling pointer.
*udata = NULL;
+ } else {
+ // os.exit maybe cause gc before close_cb
+ // use LUA_REFNIL to tell close_cb to free memory.
+ data->ref = LUA_REFNIL;
}
return 0;
diff --git a/src/lhandle.c b/src/lhandle.c
index 92b725a9..1c4cc800 100644
--- a/src/lhandle.c
+++ b/src/lhandle.c
@@ -104,6 +104,7 @@ static void luv_call_callback(lua_State* L, luv_handle_t* data, luv_callback_id
static void luv_unref_handle(lua_State* L, luv_handle_t* data) {
luaL_unref(L, LUA_REGISTRYINDEX, data->ref);
+ data->ref = LUA_NOREF;
luaL_unref(L, LUA_REGISTRYINDEX, data->callbacks[0]);
luaL_unref(L, LUA_REGISTRYINDEX, data->callbacks[1]);
}
diff --git a/src/fs.c b/src/fs.c
index 8ef36145..af59caa9 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -363,6 +363,9 @@ static int push_fs_result(lua_State* L, uv_fs_t* req) {
return 1;
}
case UV_FS_READDIR: {
+ luaL_unref(L, LUA_REGISTRYINDEX, data->data_ref);
+ data->data_ref = LUA_NOREF;
+
if(req->result > 0) {
size_t i;
uv_dir_t *dir = (uv_dir_t*)req->ptr;
@@ -938,6 +941,11 @@ static int luv_fs_readdir(lua_State* L) {
req = (uv_fs_t*)lua_newuserdata(L, uv_req_size(UV_FS));
req->data = luv_setup_req(L, ctx, ref);
+
+ // ref the luv_dir_t so it doesn't get garbage collected before the readdir cb
+ lua_pushvalue(L, 1);
+ ((luv_req_t*)req->data)->data_ref = luaL_ref(L, LUA_REGISTRYINDEX);
+
FS_CALL(uv_fs_readdir, req, dir->handle);
}
p(stat)

View File

@@ -1,6 +1,12 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -271,7 +271,8 @@
---
CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: luv-1.51.0-1/CMakeLists.txt
===================================================================
--- luv-1.51.0-1.orig/CMakeLists.txt 2025-07-25 19:14:46.432241486 +0200
+++ luv-1.51.0-1/CMakeLists.txt 2025-07-25 19:15:15.325766468 +0200
@@ -278,7 +278,8 @@
if (WIN32)
set(MODULE_INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
else (WIN32)