Re: glib memory allocation problems

> I don't understand some things however, so here are some questions to glib devs: 
> 1) Why the crash didn't occur when using G_SLICE=always-malloc?

Because only the gslice code used thread private data, the malloc()
code is thread safe without needing any initialization.

> 2) I never got any warning when using G_SLICE=debug-blocks, although I reproduced the crash several times. Is it normal?

Yes.  This wasn't a misuse of the slice inteface as suspected.

> 3) What about the constantly increasing memory usage that I described in my first email, is it expected when using G_SLICE=always-malloc? I was certainly surprised to witness my system crawl down to a halt, because of swapping...

Oh I forgot: I've hunted down a memory leak with valgrind and
G_SLICE=always-malloc.  This wasn't caught earlier, because the gslice
code hides memory leaks from valgrind. The allocator keeps track of
bigger chunks of memory, so to valgrind it looks as if the memory is
not lost.

Patch attached.

Thanks for the report and testing Dimitrios.


Index: sshfs.c
RCS file: /cvsroot/fuse/sshfs/sshfs.c,v
retrieving revision 1.83
diff -u -r1.83 sshfs.c
--- sshfs.c	18 Apr 2007 09:44:08 -0000	1.83
+++ sshfs.c	15 May 2007 14:11:12 -0000
@@ -1817,8 +1817,11 @@
     buf_add_path(&buf, path);
     err2 = sftp_request(sshfs.follow_symlinks ? SSH_FXP_STAT : SSH_FXP_LSTAT,
                         &buf, SSH_FXP_ATTRS, &outbuf);
-    if (!err2 && buf_get_attrs(&outbuf, &stbuf, NULL) == -1)
-        err2 = -EIO;
+    if (!err2) {
+        if (buf_get_attrs(&outbuf, &stbuf, NULL) == -1)
+            err2 = -EIO;
+        buf_free(&outbuf);
+    }
     err = sftp_request_wait(open_req, SSH_FXP_OPEN, SSH_FXP_HANDLE,
     if (!err && err2) {

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]