-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Wrapper for DBusMessageIter doesn't reference the DBusMessage used to initialize it #20
Comments
huh. Seems weird to me that the
There should be no need for that level of indirection: |
Same, since there's already some type of reference counting existing for DBusMessage. But the RC cannot be done with current API as you're allowed to memcpy an iterator. I think it's a design mistake.
Maybe 2 is the only option. |
Weirdly, an DBusMessageIter doesn't increase the refcount of the referred DBusMessage, thus we need to maintain the reference manually to avoid underlying DBusMessage gets garbagecollected before the DBusMessageIter, which results in a dangling reference. Let's introduce a new type, lDBusMessageIter, which contains both the iterator and the underlying DBusMessage, and refer/unref the message during creation, initialization and garbage collection of the iterator. Closes: daurnimator#20 Signed-off-by: Yao Zi <[email protected]>
Weirdly, an DBusMessageIter doesn't increase the refcount of the referred DBusMessage, thus we need to maintain the reference manually to prevent underlying DBusMessage from garbage collection before the DBusMessageIter is collected, which results in a dangling reference. Let's introduce a new type, lDBusMessageIter, which contains both the iterator and the underlying DBusMessage, and refer/unref the message during creation, initialization and garbage collection of the iterator. Closes: daurnimator#20 Signed-off-by: Yao Zi <[email protected]>
After a
DBusMessageIter
is initialized with aDBusMessage
throughdbus_message_iter_init()
, the iterator actually references the message: usage of the iterator requires the message to stay valid.ldbus doesn't claim the reference, so it's possible that a message gets garbage collected while some iterators still reference it, thus usage of such a iterator triggers a segfault, for example,
segfaults during
iter:get_arg_type()
(ldbus master with Lua 5.4), since the message returned bysend_with_reply_and_block()
has been collected, which makesiter
a dangdling reference.Suggest fix: when creating/cloning new iterators, reference the underlying
dbus.message
withluaL_ref()
in the registry table, and unref the message during__gc
.The text was updated successfully, but these errors were encountered: