-
Notifications
You must be signed in to change notification settings - Fork 69
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
Error when using UDP socket (libffi7+ specific?) #265
Comments
Quick first reaction: I need Now it's time for dinner, sorry. |
Oh and: Thanks a lot for this great bug report! Edit: local lgi = require 'lgi'
local Gio = lgi.Gio
local socket = lgi.Gio.Socket.new('IPV4', 'DATAGRAM', 'UDP')
--socket.blocking = false
local sa = lgi.Gio.InetSocketAddress.new(Gio.InetAddress.new_loopback('IPV4'), 3030)
assert(socket:bind(sa, true))
print('This will print')
local len, src = socket:receive_from(buf) -- CRASH!
print('And this will not') |
Note: your reduced example seems to never define |
And yet it still hits the same assert. Even calling Actually...The code with the failing assert is trying to allocate a If I add Adding an |
Random idea was to just skip things here: diff --git a/lgi/marshal.c b/lgi/marshal.c
index f56b821..fde21a5 100644
--- a/lgi/marshal.c
+++ b/lgi/marshal.c
@@ -1194,7 +1194,18 @@ lgi_marshal_2c_caller_alloc (lua_State *L, GITypeInfo *ti, GIArgument *val,
elt_size =
array_get_elt_size (g_type_info_get_param_type (ti, 0), FALSE);
size = g_type_info_get_array_fixed_size (ti);
- g_assert (size > 0);
+ // FIXME: This used to be g_assert (size > 0);, but it is
+ // possible that this assert fails, see test
+ // gio.socket_receive_from.
+ // This whole code seems fishy: socket_receive_from() reaches
+ // here with a C array, but this code allocates a GArray.
+ // Most likely a stricter check on the type is required here.
+ // However, I could not find any valid code reaching here and
+ // thus tried to only make "minimal damage".
+ if (size == 0)
+ {
+ break;
+ }
/* Allocate underlying array. It is temporary,
existing only for the duration of the call. */ However, this does not work... Since the Calling
So far: No idea where that The So... at least the Sigh. Dunno. |
Disclaimer: I know almost nothing about Lua, and certainly nothing about gobject-introspection But... I was looking at v1993/linuxmotehook#5 to figure out why that one was not working for me and I came across the same assertion in The thing is, in other places in the same file, there seems to be some logic to handle the case where https://github.com/pavouk/lgi/blob/a3d46f4f3cb1a3c19c61f46b856ee6683a2d57db/lgi/marshal.c#L494-L503 So I did a few checks and I saw that the assert is failing because the Unfortunately my understanding of the situation stops here. But it seems to me that if we were able to properly allocate based on the information returned by |
The thing is, it should not be allocating array here at all, it is an output argument. Intended usage is that you pass your own array in and function fills it (returning some other info too). |
hello, is there ANY workaround? this bug makes linuxmotehook totally unusable! |
This is a weird error that seems to occur only with libffi version 7/8, but not version 6 (or could it be another library?). Here's an example that can reproduce it:
Now, start this simple script and run in another window:
This will cause script to crash with following output:
This actually causes a crash in my application: v1993/linuxmotehook#5 (thread contains some limited digging into issue), which evidently worked with older versions of stuff. Any clue what's causing it?
The text was updated successfully, but these errors were encountered: