[Bug 502177] [NEW] gigantic memory leak

Stéphane Lesimple speed47_launchpad at speed47.net
Fri Jan 1 21:49:49 UTC 2010


Public bug reported:

Binary package hint: curlftpfs

I already posted this to the upstream tracker, but it doesn't seem to be
very active as all the bugs reported the last 1-2 years are still marked
as "NEW", so as I have a fix (which may require reviewing, because I
discovered the curlftpfs source code as I was trying to fix this bug),
I'm posting this here too.

$ dpkg -l curlftpfs | tail -n 1
ii  curlftpfs                                               0.9.2-1build1                      filesystem to access FTP hosts based on FUSE and cURL

After downloading several files of several megabytes each, my Ubuntu Karmic-packaged curlftpfs 0.9.2 eats up all available RAM, and is killed by the kernel OOM_killer.
I then compiled my own unstripped version for debugging purposes, A short run under valgrind says (among other less-important leaks) :

==11954== 4,039,584 bytes in 10 blocks are possibly lost in loss record 39 of 39
==11954==    at 0x4024D12: realloc (vg_replace_malloc.c:476)
==11954==    by 0x804A5E9: buf_add_mem (ftpfs.c:73)
==11954==    by 0x804A677: read_data (ftpfs.c:238)
==11954==    by 0x41247B7: Curl_client_write (in /usr/lib/libcurl-gnutls.so.4.1.1)
==11954==    by 0x4137B79: Curl_readwrite (in /usr/lib/libcurl-gnutls.so.4.1.1)
==11954==    by 0x413EFD3: multi_runsingle (in /usr/lib/libcurl-gnutls.so.4.1.1)
==11954==    by 0x413F578: curl_multi_perform (in /usr/lib/libcurl-gnutls.so.4.1.1)
==11954==    by 0x804BF13: ftpfs_read_chunk (ftpfs.c:406)
==11954==    by 0x804C359: ftpfs_read (ftpfs.c:837)
==11954==    by 0x40F065D: fuse_fs_read (in /lib/libfuse.so.2.7.4)
==11954==    by 0x40F6543: ??? (in /lib/libfuse.so.2.7.4)
==11954==    by 0x40FB83B: ??? (in /lib/libfuse.so.2.7.4)

I tracked down the problem to be in the free_ftpfs_file() function, where the passed ftpfs_file structure is not correctly freed. More specifically the two uint8_t *p of the 2 struct buffer contained in the ftpfs_file structure.
This means - if I am right - that all the files read on the FTP are kept into curlftpfs memory space for ever... which will undoubtedly lead to big problems when a lot of files are read from the FTP server.

Attached is a patch that fixes it. I'm running the patched version since
several hours, with intensive downloading of big backup files from an
FTP server, and top is now reporting a stable memory occupation for
curlftpfs.

** Affects: curlftpfs (Ubuntu)
     Importance: Undecided
         Status: New

-- 
gigantic memory leak
https://bugs.launchpad.net/bugs/502177
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs




More information about the universe-bugs mailing list