meganz / MEGAcmd

Command Line Interactive and Scriptable Application to access MEGA
Other
1.94k stars 407 forks source link

megacmd segmentation fault in Ubuntu 19.10 #368

Open sebcolo opened 4 years ago

sebcolo commented 4 years ago

Hi, recently I've installed a new server with Ubuntu Server 19.10 and installed megacmd as usually with the megacmd .deb dowloaded from your web site.

After installation, when I run mega-cmd-server, the following error appears:

"segmentation fault (core dumped)"

I was getting the same error on Ubuntu server 20.04. For that, I changed to 19.10 because I thinked it was a problem with the new Ubuntu version but the same happens with 19.10.

I'm sure is not a syncronization problem because I'm getting this error in the first running. I'm not even syncronizing any file yet.

I'm using megacmd without any problem with other servers with Ubuntu server 18.04.4 but I don't want to install an older OS in the new servers.

Can you help me with this problem?.

Thanks.

shrx commented 4 years ago

FWIW I also get a segfault when I compile from the latest source on Xubuntu 20.04. Here is the configure output: https://gist.github.com/shrx/07288c37f8ea99f15872ef92eba41667

aabellagm commented 4 years ago

Hi @sebcolo and @shrx,

We are unable to reproduce the issue here, It works with no problems. If you are still facing problems and you wish to help us debugging:

After installing the package for the Ubuntu version you are using:

1 - install debug symbols sudo apt update && sudo apt install megacmd-dbg

2 - run mega-cmd-server in a debugger (you might need to install gdb) gdb mega-cmd-server It should say something like:

done.
(gdb) 

3 - Then run the program (type 'r' + Enter) Let it run until it crashes. (if it doesn't, open another console and use the interactive shell mega-cmd until it crashes)

4 - once so, then type in the gdb console: 'thread apply all bt' Press "Enter" until the output is complete, and

5 - then please, scroll back and send us the entire output of that command.

shrx commented 4 years ago

Hi @aabellagm thanks for the detailed debugging instructions, here is the generated output: https://gist.github.com/shrx/c69b829f006fe8cadaae14d5654169ee I hope it helps.

mattw-mega commented 4 years ago

Hi @shrx that is an interesting error to do with data alignment. What CPU are you running it on? It may be something that only shows up on CPUs which do not allow loading non-aligned data from RAM. thanks

polmr commented 4 years ago

@shrx Thanks for your report. you trace corresponds to a crash in libcryptopp. We had the same in MEGAsync: https://github.com/meganz/MEGAsync/issues/360. Linking with cryptopp 8.0.0 fixes the issue. We will do so for the incoming new version. Thanks again for reporting.

sebcolo commented 4 years ago

Hi @aabellagm , here is my output of the debbuging. Thanks for your help:

megacmd_crash.txt

aabellagm commented 4 years ago

Hi again @shrx and @sebcolo ,

We have prepared a package for Ubuntu 19.10 and another one for Ubuntu 20.04 linking with Cryptopp 8.0.0, what seems to fix the issue, just in case you wish to install the patched package. The fix will be included in the next version.

In order to install it:

1.- Download it from here --> MEGAcmd Open the folder for your distro and download the package.

2.- Access to the path where you have downloaded the package and verify it: $ sha256sum megacmd_*_amd64.deb The checksums are the following ones:

c22ffbea349d8df18c48f1e4afeebf508b7c18b13d7dcaee83921acfcb1b17a8  megacmd_xUbuntu_19.10_1.2.0-5.1_amd64.deb
dfc6b1e520b8637cf8b7494961f2894104c21f5b58fc92e211257978af09a02c  megacmd_xUbuntu_20.04_1.2.0-7.1_amd64.deb

3.- If everything is correct, install the package with one of the following commands, depending on your distro. It could be installed over the one you have installed now, it will be updated: $ sudo apt install ./megacmd_xUbuntu_19.10_1.2.0-5.1_amd64.deb or $ sudo apt install ./megacmd_xUbuntu_20.04_1.2.0-7.1_amd64.deb

4.- Use it =).

shrx commented 4 years ago

Hi, I installed the provided package and while the mega-cmd-server does not segfault anymore, mega-cmd still doesn't work:

[Initiating server in background. Log: /home/shrx/.megaCmd/megacmdserver.log]

[Server is probably down. Type to respawn or reconnect to it]
Server seems irresponsive
MEGA CMD> h[Initiating server in background. Log: /home/shrx/.megaCmd/megacmdserver.log]
ERROR reading output socket
MEGA CMD> help
[Initiating server in background. Log: /home/shrx/.megaCmd/megacmdserver.log]
Unable to connect to service: error=111
Please ensure mega-cmd-server is running
[Initiating server in background. Log: /home/shrx/.megaCmd/megacmdserver.log]
Unable to connect to service: error=111
Please ensure mega-cmd-server is running
Failed to create socket for registering for state changes
MEGA CMD>

The log is empty except from the megacmd ascii art header.

sebcolo commented 4 years ago

@aabellagm thanks for your help. mega-cmd-server worked fine with your correction. I'm using only this function.

polmr commented 4 years ago

Thank you guys for trying that out. @shrx , your server seems to be stuck somehow. Would you mind running it with mega-cmd-server --debug-full (first ensure there's no other mega-cmd-server instance running)

shrx commented 4 years ago

@polmr here is the full debug output: https://gist.github.com/shrx/58f420e375b65c9739390aed5dbcdf74

polmr commented 4 years ago

Hi @shrx The log indicates a regular initialization. Executing a shell (mega-cmd) in another terminal after the server starts gives you the Unable to connect to service: error=111 ??? Just in case, you need to execute both with the same user. The shell & the server connect via sockets placed in /tmp/megaCMD_${uid} (in your case /tmp/megaCMD_1000). Could there be any issue with permissions there? What is your OS?

shrx commented 4 years ago

I am not executing both mega-cmd and mega-cmd-server. I was under the impression that mega-cmd will spawn the server in the background on its own, isn't this the case?

folknor commented 3 years ago

I'm getting a segfault as well, and I even tried compiling megacmd from git. I notice that megacmd is using a 5 month old version of the SDK - I tried updating the SDK but there's too many changes in it for me to be bothered with updating the megacmd code. That said https://github.com/meganz/sdk/releases/tag/v3.7.3h notes "Target apps: MEGAcmd v1.4.1", so I'm guessing the devs just haven't pushed their code to the github repo for some reason.

Which is annoying.

Running mega-cmd-server --debug-full provides no additional information. I obviously compiled vs libcrypto++ 8.4, and there's thousands of normal errors in the log. The log is at least 390000 lines long, just from starting + instant crash. I'm not willing to share the log, but if you need anything specific then please ask.

Here's the last few lines with some identifiers replaced by three dots:

API:debug: 00:00:49] DB transaction BEGIN /home/folk/.megaCmd/megaclient_statecache12_...
[API:debug: 00:00:49] DB transaction COMMIT /home/folk/.megaCmd/megaclient_statecache12_...
[API:debug: 00:00:49] DNS cache hit for g.api.mega.co.nz (IPv4) ...
[API:debug: 00:00:49] cs POST target URL: ...
[API:debug: 00:00:49] cs Sending 593: [...]
[API:debug: 00:00:49] Using the IP of the hostname: ...
[API:debug: 00:00:49] Set cURL timeout[2] to 549872 from 0(ms) at ds: 549872
[API:debug: 00:00:49] Saving SCSN RTWruOci5c0 with 0 modified nodes, 0 users and 0 pcrs to local cache (1)
[API:debug: 00:00:49] Postponing DB commit until cs requests finish
[API:debug: 00:00:49] Processing of action packets finished.  More to follow: 0
[API:debug: 00:00:49] Local filesystem up to date
[API:warn: 00:00:49] Event 99426: [0,0,165767,165990,230,0,0,0,0,12,12,12,12,82,82,1]
[API:debug: 00:00:49] Nodes updated: 165990
[1]    229554 segmentation fault (core dumped)  ./mega-cmd-server --debug-full
folknor commented 3 years ago
$ gdb mega-cmd-server
GNU gdb (Ubuntu 10.1-1.6ubuntu1) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mega-cmd-server...
(gdb) r
Starting program: /usr/local/bin/mega-cmd-server 
/usr/local/bin/mega-cmd-server: error while loading shared libraries: libmega.so.30703: cannot open shared object file: No such file or directory
[Inferior 1 (process 230676) exited with code 0177]
(gdb) 
folknor commented 3 years ago

Using megasync works fine, but I don't want to use it because (1) I don't run any other QT apps, and (2) I don't have a systray, and (3) as long as the sync is running in the background, there's really nothing I want to know that would require an UI.

So,

  1. I started megasync
  2. It ran to completion, and all my files are now uploaded
  3. I quit megasync
  4. I ran mega-cmd-server
  5. It segfaults still, even with nothing to upload or download

Which might (but not necessarily, of course) suggest that whatever makes it segfault has been fixed in a more recent SDK update, so can you please push your megacmd 1.4.1 commits to github?

aabellagm commented 3 years ago

Hi @folknor ,

Thanks for reporting your issue.

if you wish to help us debugging, you can run gdb as posted here with the package for your OS downloaded from mega.nz/cmd

Which OS are you using?

folknor commented 3 years ago

I will, but first I need to uninstall the local compiled copy https://github.com/meganz/MEGAcmd/issues/497

I can work around that of course, but not today.

Frankly, the OS I am using is debian with ubuntu devel repositories, heavily customized on the system level. I've not reinstalled the OS in probably two decades.

folknor commented 3 years ago

@aabellagm Thanks, here is the complete output: https://gist.githubusercontent.com/folknor/94e228145bc8f7ce4e0a743fa8fc9f0c/raw

aabellagm commented 3 years ago

Hi again! Thanks a lot for your dump! If you are interested, we can prepare a 1.4.1 prerelease package with a tentative fix that we can get to you that I think could solve your problem. Is your base system a Debian Buster? I know you say that it is highly customized. Tell us which one could be the most similar, so we can generate a package linked against the appropriate system libraries.

folknor commented 3 years ago

I'd be happy to test. Please assume ubuntu 21.04 devel libraries.

aabellagm commented 3 years ago

Hi @folknor,

I'm so sorry. Sadly, we are not building packages for Ubuntu 21.04 right now. It will be offered as soon as it reaches Beta, but it is not included yet.

folknor commented 3 years ago

Your reply makes no sense.

Obviously I can use 20.04 or 20.10 packages as well, or even older. I can also run it in a chroot, so I can use whatever environment you want.

But whatever.

aabellagm commented 3 years ago

Hi again @folknor

My concern is about dynamically linked system libraries, which may not be available, depending on the system version.

Here you have a link with prerelease packages for 20.04. Please, install megacmd_1.4.1-1.1_amd64.deb. It could be installed over any other you may have installed. If debugging is needed again, install megacmd-dbg_1.4.1-1.1_amd64.deb. Hopefully, this will not be necessary

Thanks a lot for all your help and time debugging the issue.

folknor commented 3 years ago

No segfaults now :100: Thank you. There's no need to be concerned about dynamic libraries for a test like this, I can just install whatever I'm missing. And anyone who finds the link later will also have the context.

In any case I ran mega-cmd-server --verbose-full > log and it generated a 2-gig log file on first run. If you want that, you can have it, it compressed down to 23mb. I would want to sanitize it a bit first and I don't have time today.

It would be great if mega could sync .megaCmd/excluded between clients, and also between client software like the CLI and QT clients, but hopefully that is on your roadmap. Also, node_modules should probably be included by default. Also, please add support for ignoring anything in .gitignore-files found in all folders, for example.

folknor commented 3 years ago

I just noticed; the sync just overwrote the past 10 hours of work with an earlier copy from a computer at another location, where I worked in the same folder yesterday.

It's difficult to restrain myself from all the things I want to type.

folknor commented 3 years ago

By cat log | grep file I could find copies of the lost changed files in .debris.

Why mega would pick the remote files with older times and dates compared to the local files I have no clue, and just thinking about it makes me very upset. At this time I can't imagine a scenario where I continue paying for mega.

But it's bedtime. Perhaps I will have reconsidered tomorrow, or at least calmed down.