After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 144627 - Some async functions leak memory for the proxy
Some async functions leak memory for the proxy
Status: RESOLVED FIXED
Product: gnome-vfsmm
Classification: Deprecated
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-06-18 21:41 UTC by Hicham BOUHMADI
Modified: 2011-01-16 23:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Partial correction of the problem of proxy objects pointers in async-handle.ccg (15.12 KB, patch)
2004-06-19 19:04 UTC, Hicham BOUHMADI
none Details | Review
patch of async-handle.ccg. (14.69 KB, patch)
2004-06-28 18:20 UTC, Hicham BOUHMADI
none Details | Review
vfs_async2.patch (20.04 KB, patch)
2004-07-08 15:32 UTC, Murray Cumming
none Details | Review

Description Hicham BOUHMADI 2004-06-18 21:41:21 UTC
I am writing an application that uses async support in gnome-vfsmm.
It crashes because it passes a pointer to proxy object which is on the stack and
on the c_callback methods, it reference it...

I changed the code so that proxy objects are created on the heap and destroyed
with the c_callback methods.

It works on the cases I tested but I don't master gnome-vfs enough to consider
it as ok.

My solution will work iff c_callback methods are called once and only once (How
gnome-vfs handles cancel calls relatively to callbacks?)
Comment 1 Murray Cumming 2004-06-19 16:50:47 UTC
Could we see a patch, please?
http://www.gtkmm.org/bugs.shtml#CreatingPatches
Comment 2 Hicham BOUHMADI 2004-06-19 19:04:33 UTC
Created attachment 28865 [details] [review]
Partial correction of the problem of proxy objects pointers in async-handle.ccg

Here is the patch.
Please, notice that I have tested only few methods (open, read, close). I am
testing load_directory (which *seems* BTW not to work!).
There is places (identified by //TODO MemoryLeak:) where I don't destroy proxy
objects since I don't know how the underlying async call behaves: how to
identify the last call to the callback?

PS: This is my first contribution to an open source project.
I hope it is ok :)
Comment 3 Hicham BOUHMADI 2004-06-28 18:20:16 UTC
Created attachment 29075 [details] [review]
patch of async-handle.ccg.
Comment 4 Murray Cumming 2004-06-30 21:00:25 UTC
I agree that this is a problem. Well done.

We need to ask on the gnome-vfs list about 
1. Whether the async callbacks are called more than once.
2. Whether they are called at least once. Or, what happens if the operation is
cancelled - how do we clean up the memory. New versios of the functions with 
destroy_callback parameters might be necessary in gnome-vfs.
Comment 5 Murray Cumming 2004-07-08 15:29:31 UTC
It looks like you found a real problem. Thanks:
http://lists.gnome.org/archives/gnome-vfs-list/2004-July/msg00009.html

For now, I have appplied the patch with these changes:

1. I added comments next to every new and every delete.

2. I think that the callback given to gnome_vfs_async_find_directory will only
be called once, so we can delete the proxy there.
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-20-gnome-vfs-async-ops.html#gnome-vfs-async-find-directory

3. I added g_warnings where there are leaks, so that people can decide not to
use them. I think that is just Handle::transfer() and Handle::cancel().

I have attached the revised patch so you can see what I did. Please look it over
and test the changes, because I am not using these methods. In fact, it would be
great if you could add an example that uses them.

Please make a cvs patch if you need to patch it again:
http://www.gtkmm.org/bugs.shtml#CreatingPatches

Thanks again.
Comment 6 Murray Cumming 2004-07-08 15:32:24 UTC
Created attachment 29351 [details] [review]
vfs_async2.patch
Comment 7 Murray Cumming 2008-02-10 16:38:00 UTC
Closing because giomm seems like the answer to all our gnome-vfs problems.