Phantom "Out of Memory" error
keithpre at gmail.com
Tue Jul 17 08:50:31 PDT 2007
So I've been debugging a randomly occurring "Out of Memory" error.
In my trace of what is happening in my multithreaded program, I have
come across this function below as my problem.
protected_change_timeout (DBusConnection *connection,
/* This isn't really safe or reasonable; a better pattern is the "do
* drop lock and call out" one; but it has to be propagated up
through all callers
timeouts = connection->timeouts;
connection->timeouts = NULL;
retval = (* add_function) (timeouts, timeout);
else if (remove_function)
retval = TRUE;
(* remove_function) (timeouts, timeout);
retval = TRUE;
(* toggle_function) (timeouts, timeout, enabled);
connection->timeouts = timeouts;
Apparently DBus sets the timeout list temporarily to NULL and drops
the lock to the connection for changing the timeout . However if
another thread acquires the lock and happens to get to this function
again, it fails out of the function because connection->timeouts is
null. This is proprogated down the stack and eventually turns up as
an "Out of Memory" abort in the glib bindings. So I have two
First does anyone know the designed purpose of this function and what
would be a safe way to modify the function so that this case doesn't
happen? I can imply some meaning to the function, but hesitate to
quickly change some locking scheme I am not completely familiar with.
Secondly is there a good way we can modify the error return system to
give better output of what actually happened? We can't change api,
but maybe FALSE can represent error, and whoever set FALSE can call a
dbus_set_current_error_string(char *), and outside program can print
out from dbus_get_current_error_string(char *)?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the dbus