Double free and remote crash

Technical RetroShare discussions Forum

Double free and remote crash

Postby nake » Sat Sep 06, 2014 6:49 pm

Hello all!
I've just installed retroshare in linux and added a friend (that uses windows) and when he tries to download a file from my computer my RS crashes.
My version is 0.5.5-0.7068 (compiled from source) and his is 0.5.5c_7261 (the ones in sourceforge).

The console from gdb says:
Code: Select all
...
Wrong string passed to getGPGDetails: "Anonymous F2F tunnel <<edited out>>"
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
ftController: Adding source Anonymous F2F tunnel <<edited out>> to current download hash=<<edited out>>Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
TransfersDialog::downloadListHeaderCustomPopupMenu()
bdNodeManager::iteration(): FAILED ==> STARTUP
Failed to Open File: /home/nake/.retroshare/<<edited out>>/bdboot.txt ... No Peers
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
TransfersDialog::downloadListHeaderCustomPopupMenu()
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
RsServer::run() WARNING Excessively Long Cycle Time: 0,254025 secs => Please DEBUG
RsServer::run() WARNING Excessively Long Cycle Time: 0,533695 secs => Please DEBUG
[New Thread 0x7fffd0ff9700 (LWP 17095)]
RsServer::run() WARNING Excessively Long Cycle Time: 0,693669 secs => Please DEBUG
[Thread 0x7fffd0ff9700 (LWP 17095) exited]
RsServer::run() WARNING Excessively Long Cycle Time: 0,219408 secs => Please DEBUG
RsServer::run() WARNING Excessively Long Cycle Time: 0,214547 secs => Please DEBUG
Notifyqt::notifyDownloadCompleteCount 1
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
Asserting that at least 3 are dedicated to user transfers.
  collected 0 transfers to move.
Cannot fseek/read from file /shared/cube/shared/<<edited out>>.mp3 at position 5242880
*** Error in `/home/nake/bin/retroshare-0.5.5/src/retroshare-gui/src/RetroShare': double free or corruption (out): 0x00007fffac000dc0 ***

Program received signal SIGABRT, Aborted.


The file is in a remote computer (a NAS server I have at my local network) mounted locally at /shared/cube/, and at the same time this happened, RS was calculating some shares.

The backtrace says this:
Code: Select all
#0  0x00007ffff38c7077 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff38c8458 in __GI_abort () at abort.c:89
#2  0x00007ffff3904fb4 in __libc_message (do_abort=do_abort@entry=1,
    fmt=fmt@entry=0x7ffff39f7bc0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff390a78e in malloc_printerr (action=1, str=0x7ffff39f7d10 "double free or corruption (out)",
    ptr=<optimized out>) at malloc.c:4996
#4  0x00007ffff390b496 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007ffff38fb545 in _IO_new_fclose (fp=0x7fffac000dc0) at iofclose.c:85
#6  0x0000000000c0fc79 in ftDataMultiplex::handleRecvChunkCrcRequest (this=0x157a250,
    peerId="Anonymous F2F tunnel <<edited out>>", hash="<<edited out>>", chunk_number=5)
    at ft/ftdatamultiplex.cc:935
#7  0x0000000000c0e18c in ftDataMultiplex::doWork (this=0x157a250) at ft/ftdatamultiplex.cc:412
#8  0x0000000000b3d80f in RsQueueThread::run (this=0x157a258) at util/rsthreads.cc:146
#9  0x0000000000b3d57f in rsthread_init (p=0x157a258) at util/rsthreads.cc:62
#10 0x00007ffff44650a4 in start_thread (arg=0x7fffd3fff700) at pthread_create.c:309
#11 0x00007ffff3977c2d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111



I suppose that the problem is that as the network is overloaded calculating the shares (it has to download the file from the NAS to my computer to calculate the hash) fseek/read fails thus causing some kind of internal error in the program causing an easy to do DoS.
I don't know where in the code the failing fseek/read is (and I don't really have time to look for it), but I think that it should have some kind of if-case to check if the read function fails and retry a few times before continuing to avoid the remote crash.

Do you guys think that's the problem? Should I avoid using network shares at all?
I'm thinking in setting up another RS in the NAS server instead of the current setup. If I install another RS, should it have the same certificate with another location or should it be a new user? The NAS is headless so I suppose I'd have to set it up with the no-gui version. Is there a way to use it remotely access it with a GUI? Something like how Deluge works or something would be cool.

Thanks in advance!
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm

Re: Double free and remote crash

Postby electron » Sun Sep 07, 2014 9:22 am

Thank you for this detailed bug report. This is a stupid but easy to fix bug.

nake wrote:I don't know where in the code the failing fseek/read is (and I don't really have time to look for it), but I think that it should have some kind of if-case to check if the read function fails and retry a few times before continuing to avoid the remote crash.

there is an if-case, but it leads to a crash.

nake wrote:If I install another RS, should it have the same certificate with another location or should it be a new user?

If you use the same key with another location, your friends will automatically accept your connection attempt. If you use a new identity, then your friends have to add you like they would have to with a new friend.

nake wrote:The NAS is headless so I suppose I'd have to set it up with the no-gui version. Is there a way to use it remotely access it with a GUI?

yes:
http://retroshare.sourceforge.net/wiki/ ... hare-nogui

Still everything is not complete and requires a complicated setup.

Retroflux is probably the most maintained webinterface for Retroshare:
http://sourceforge.net/projects/retroflux/
electron
 
Posts: 96
Joined: Sun Aug 12, 2012 9:39 am

Re: Double free and remote crash

Postby nake » Sun Sep 07, 2014 11:16 am

electron wrote:Thank you for this detailed bug report. This is a stupid but easy to fix bug.

I'm happy to help :)

electron wrote:If you use the same key with another location, your friends will automatically accept your connection attempt.

But if I have the same identity, can I be connected to the network using two different computers with the same identity at the same time? How do they know which one is which?
And in the nogui wiki page says:
Copy a working .retroshare config directory from an existing system. (There may be an alternate to this, but it seems to be required).

So how do I change the 'location' of my identity without the gui?

I have a few more questions and problems with the nogui version, but I think I'd open another thread to avoid going offtopic in this one (that was for the bug report).

Thanks for the fast reply!
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm

Re: Double free and remote crash

Postby nake » Mon Sep 15, 2014 12:02 pm

electron wrote:Thank you for this detailed bug report. This is a stupid but easy to fix bug.


By the way, may I get a patch or something so that I can fix it in my computer too?
And is the svn version in a state useful for everyday use or could it be broken? I don't care if there are minor bugs or it's not very polished but at first I had trouble adding friends that used the stable version.
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm

Re: Double free and remote crash

Postby Distro » Mon Sep 15, 2014 12:49 pm

nake wrote:And is the svn version in a state useful for everyday use or could it be broken? I don't care if there are minor bugs or it's not very polished but at first I had trouble adding friends that used the stable version.

The svn ("branches/v0.5.5", not "trunk") version is generally stable but there is always the possibility of getting a revision that has an annoying bug, of course. Although nowadays the devs work mostly on v0.6 (trunk) so the 0.5.5 branch doesn’t change much.

There isn’t any incompatibility between the svn branches/v0.5.5 version and the official 0.5.5 release.
Distro
 
Posts: 303
Joined: Sun Sep 04, 2011 7:33 pm

Re: Double free and remote crash

Postby nake » Mon Sep 15, 2014 2:33 pm

Ok. Thanks!
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm

Re: Double free and remote crash

Postby nake » Tue Jan 13, 2015 10:04 pm

By the way, I fixed it in my v0.5.5-svn version (rev. 7844) by applying this patch to libretroshare/src/:
Code: Select all
--- ft/ftdatamultiplex.cc.original      2015-01-13 22:46:04.288537892 +0100
+++ ft/ftdatamultiplex.cc       2015-01-13 22:45:57.892673889 +0100
@@ -931,6 +931,7 @@
        {
                std::cerr << "Cannot fseek/read from file " << filename << " at position " << (uint64_t)chunk_number * (uint64_t)ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE << std::endl;
                fclose(fd) ;
+                delete[] buf ;
+               return false ;
        }
        fclose(fd) ;

AKA: add "return false ;" in a new line below line 933 in the file libretroshare/src/ft/ftdatamultiplex.cc.

Is this correct? I'm not having any crashes now but I don't know if returning false is the expected behavior.
Last edited by nake on Thu Jan 15, 2015 5:33 pm, edited 2 times in total.
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm

Re: Double free and remote crash

Postby electron » Thu Jan 15, 2015 3:50 pm

"return false;" is ok, but you want to add a "delete[] buf;" before the return.
Else you loose 1MB of ram every time this happens.
electron
 
Posts: 96
Joined: Sun Aug 12, 2012 9:39 am

Re: Double free and remote crash

Postby nake » Thu Jan 15, 2015 5:33 pm

electron wrote:"return false;" is ok, but you want to add a "delete[] buf;" before the return.
Else you loose 1MB of ram every time this happens.


Woah, true. Ok, I edited my patch.
Thanks for the help!!
nake
 
Posts: 15
Joined: Fri Sep 05, 2014 5:10 pm


Return to Technical RetroShare discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron