forked from pool/lua-luv
Accepting request 1130698 from home:ArcheCraft:branches:devel:languages:lua
Updated to version 1.45 Also fixed segfault with weird lua-gc issue OBS-URL: https://build.opensuse.org/request/show/1130698 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua-luv?expand=0&rev=42
This commit is contained in:
@@ -1,3 +1,30 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 4 10:05:58 UTC 2023 - Noah Dörr <archecraft1@gmail.com>
|
||||
|
||||
- Update to version 1.45.0-0:
|
||||
* Add access(2) constants to the constants table
|
||||
* thread_setaffinity: Allow affinity param to have a length less
|
||||
than cpumask_size()
|
||||
* avoid thread be released before it done
|
||||
* fix thread arguments limit
|
||||
* fix segfault in luv_check_handle/luv_check_stream
|
||||
* add uv.errno table contains all uv errno value
|
||||
* segfault on new_thread and worker.queue
|
||||
* segfault on luv_check_handle
|
||||
* uv.spawn example code in docs is broken
|
||||
* pthread_create possible leak
|
||||
- Update to version 1.44.2-1:
|
||||
* Removed output to stderr from poll callback
|
||||
- Update to version 1.44.2-0:
|
||||
* Adds new function uv.available_parallelism
|
||||
* uv.os_get_passwd: Better handling of gid/uid
|
||||
* uv.fs_opendir and friends: Fix race condition when uv_dir_t
|
||||
pointer doesn't change between allocations
|
||||
* Fix leak from fs_scandir whenever it wasn't fully iterated via
|
||||
fs_scandir_next
|
||||
* Fix two possible fs_scandir segfaults
|
||||
- Add luv-fix-segfault-with-gc: Fix segfault
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Feb 13 12:31:33 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
|
||||
|
||||
|
15
lua-luv.spec
15
lua-luv.spec
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package lua-luv
|
||||
# spec file
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
# Copyright (c) 2012 Togan Muftuoglu toganm@opensuse.org
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
@@ -16,11 +16,12 @@
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%if %{lua_version_nodots} == 51
|
||||
%define lua_default 1
|
||||
%endif
|
||||
%define mod_name luv
|
||||
%define upver 1.43.0-0
|
||||
%define upver 1.45.0-0
|
||||
%define fixver %(echo %{upver}|sed 's|-|~|g')
|
||||
%define libluv_sover 1
|
||||
%define flavor @BUILD_FLAVOR@%{nil}
|
||||
@@ -39,12 +40,14 @@ URL: https://github.com/luvit/%{mod_name}
|
||||
Source0: https://github.com/luvit/%{mod_name}/releases/download/%{upver}/%{mod_name}-%{upver}.tar.gz
|
||||
Patch0: lua-link.patch
|
||||
Patch1: luv-module-install.patch
|
||||
# Merged https://github.com/luvit/luv/commit/ff5e90249e08471396f73f599edcdfe405ac4e6e and https://github.com/luvit/luv/commit/ecf3988c0be907f624b0597673617f95ea66f64e
|
||||
Patch2: luv-fix-segfault-from-gc.patch
|
||||
BuildRequires: %{flavor}-compat-5.3
|
||||
BuildRequires: %{flavor}-devel
|
||||
BuildRequires: %{flavor}-luafilesystem
|
||||
BuildRequires: cmake
|
||||
BuildRequires: libuv-devel
|
||||
BuildRequires: lua-macros
|
||||
BuildRequires: %{flavor}-devel
|
||||
BuildRequires: %{flavor}-luafilesystem
|
||||
BuildRequires: %{flavor}-compat-5.3
|
||||
Requires: %{flavor}
|
||||
%lua_provides
|
||||
%if "%{flavor}" == "lua"
|
||||
|
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:567a6f3dcdcf8a9b54ddc57ffef89d1e950d72832b85ee81c8c83a9d4e0e9de2
|
||||
size 1452021
|
3
luv-1.45.0-0.tar.gz
Normal file
3
luv-1.45.0-0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fa6c46fb09f88320afa7f88017efd7b0d2b3a0158c5ba5b6851340b0332a2b81
|
||||
size 1468792
|
92
luv-fix-segfault-from-gc.patch
Normal file
92
luv-fix-segfault-from-gc.patch
Normal file
@@ -0,0 +1,92 @@
|
||||
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)
|
Reference in New Issue
Block a user