-
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
Occasional SEGSIGV with lgi.DBus #88
Comments
One more:
This one happen when invoking a service created with LGI EDIT: The valgrind: This one doesn't cause a crash
But this one does
I tried to install FFI with more debug symbols, but given how it work this did not improve the valgrind log. The closure here is declared using core.marshal.callback(Gio.DBusInterfaceMethodCallFunc ,
function(conn, sender, path, interface_name,method_name,parameters,invok)
--...
Gio.DBusMethodInvocation.return_value(invok,gvar)
---... It work fine maybe 30 times and then it crash. I tested could always reproduce by calling the method using a "while true" from bash |
I tried to reproduce but had no luck :/ |
I cannot reproduce anything either, but I just noticed that all(?) the backtraces contain |
Hey, I was trying to get a semi-nice API, but looks like I was able to produce a nice example of segfaulting code: https://gist.github.com/mlen/61b474ad7fa32a274187bf52f0bcb6b1 I probably did something wrong, but I can't see anything obvious. |
I can reproduce that crash and "minimised" it to the following code: local lgi = require 'lgi'
local Gio = lgi.require 'Gio'
local GLib = lgi.require 'GLib'
local name = "org.freedesktop.DBus"
local path = "/"
local iface = "org.freedesktop.DBus"
local bus = Gio.bus_get_sync(Gio.BusType.SESSION)
local result, e = bus:call_sync(name, path, "org.freedesktop.DBus.Introspectable", "Introspect", nil, nil, Gio.DBusSendMessageFlags.NONE, -1, nil)
assert(result, e)
local info = Gio.DBusNodeInfo.new_for_xml(result.value[1]):lookup_interface(iface)
local proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, info, name, path, iface, nil)
local info2 = proxy:get_interface_info()
print(info, info2) Valgrind's output sounds like a double free (
@pavouk This should tell you all you need for fixing this, right? |
Oh, another thing: @mlen Does the following fix your crash? --- ldbus.lua.before 2016-10-23 09:35:51.727075728 +0200
+++ ldbus.lua 2016-10-23 09:36:34.382285509 +0200
@@ -7,7 +7,7 @@ ldbus.Bus = {}
ldbus.Object = {}
function ldbus.Object:__index(method)
- local info = self.proxy:get_interface_info()
+ local info = self.info
local minfo = info:lookup_method(method)
if minfo then
@@ -86,8 +86,8 @@ function ldbus.Bus:GetObject(name, path,
return nil
end
- local info = Gio.DBusNodeInfo.new_for_xml(result.value[1]):lookup_interface(iface)
- table.proxy = Gio.DBusProxy.new_sync(self.bus, Gio.DBusProxyFlags.NONE, info, name, path, iface, nil)
+ table.info = Gio.DBusNodeInfo.new_for_xml(result.value[1]):lookup_interface(iface)
+ table.proxy = Gio.DBusProxy.new_sync(self.bus, Gio.DBusProxyFlags.NONE, table.info, name, path, iface, nil)
if not table.proxy then
return nil Edit: @Elv13 wirefu also uses |
@psychon it does fix it. Thanks! |
Actually it turned out passing |
Thanks a lot for report and also exactly pinning down the place where the problem is. As expected, get_interface_info() is the culprit; see the snippet from its definition from Gio-2.0.gir: <method name="get_interface_info"
c:identifier="g_dbus_proxy_get_interface_info"
version="2.26">
<doc xml:space="preserve">Returns the #GDBusInterfaceInfo, if any, specifying the interface
that @proxy conforms to. See the #GDBusProxy:g-interface-info
property for more details.</doc>
<return-value transfer-ownership="full">
<doc xml:space="preserve">A #GDBusInterfaceInfo or %NULL. Do not unref the returned
object, it is owned by @proxy.</doc>
<type name="DBusInterfaceInfo" c:type="GDBusInterfaceInfo*"/>
</return-value> Doc string implies that ownership transfer is |
BTW, this should be probably split into separate issue, because I don't think that this is the original non-deterministic problem for which this issue was created. Bad annotation of get_interface_info will probably get very deterministic crash whenever it is hit. |
@mlen - your 'wrapper' is really cool! I was always thinking about built-in dbus support in this style, but I never got to actually implement it. If you are interested in building such support directly into lgi (i.e. mostly by extending existing imported classes instead of building parallel ones like ldbus.Bus), it would be very welcome! |
Why not? Calling @mlen hit this earlier, because the GC never run and so the crash occurred during All of these can very well be caused by the wrong annotation.
Since you are "my local G* expert", I would prefer if you were to report this. If I don't hear anything from you in this direction, I'll try to do this next weekend.
Sorry to hear that about your time. I'll try to cook up a patch, but in the past I never managed to do that for this kind of issue. |
Sorry, unrelated spam, but: @mlen --- ldbus.lua.orig 2016-10-24 10:29:41.144193232 +0200
+++ ldbus.lua 2016-10-24 10:41:16.867617506 +0200
@@ -17,7 +17,7 @@ function ldbus.Object:__index(method)
if #args == #minfo.in_args and #args > 0 then
for i, t in ipairs(minfo.in_args) do
- serialized[i] = GLib.Variant(t, args[i])
+ serialized[i] = GLib.Variant(t.signature, args[i])
end
end
@@ -32,9 +32,9 @@ function ldbus.Object:__index(method)
else
local pinfo = info:lookup_property(method)
if pinfo then
- return self.bus:GetObject(self.object_name, self.object_path, "org.freedesktop.DBus.Properties").Get(self.object_iface, method)
+ return self.proxy:get_cached_property(method)
else
- return nil
+ error("unknown key: " .. tostring(method))
end
end
end
@@ -95,6 +95,9 @@ function ldbus.Bus:GetObject(name, path,
return table
end
-local bus = ldbus.Bus:Open('SYSTEM')
-local ck = bus:GetObject('org.freedesktop.ConsoleKit', '/org/freedesktop/ConsoleKit/Manager', 'org.freedesktop.ConsoleKit.Manager')
-print(ck.CanStop())
+local bus = ldbus.Bus:Open('SESSION')
+local ck = bus:GetObject('org.gnome.evince.Daemon', '/org/gnome/evince/Daemon', 'org.gnome.evince.Daemon')
+print("Call result:", ck.FindDocument("file:///tmp", false))
+local ck = bus:GetObject('org.gnome.evince.Daemon', '/org/gnome/evince/Daemon', 'org.gtk.Application')
+print("Property Busy", ck.Busy:print())
+print("done") |
Hello,
Thanks for answering the question on the other DBus issue. I implemented a DBus wrapper (wor in progress) and it usually work just fine. However, I notice there is occasional segfaults
luajit:
lua:
Other luajit error:
Code:
https://github.com/Elv13/wirefu/blob/05996b995c08e46bf40e56dad528e0d4c9e95942/client.lua
Using the VLC interface as most people have it installed, can be reproduced with other:
It would not be my first crash in career using various DBus clients API, but I don't think the current code should crash like this
(Cannot access memory at address 0x6c123000)>
is bad.Any idea?
The text was updated successfully, but these errors were encountered: