Grive / grive

an open source Linux client for Google Drive
http://www.lbreda.com/grive/start
GNU General Public License v2.0
1.59k stars 378 forks source link

grive crashes when refreshing auth token #315

Open ontore opened 9 years ago

ontore commented 9 years ago

When sync to Google drive takes a little longer, auth expires and Grive tries to refresh auth token, then crashes. Steps to reproduce: Sync large local folder to Google drive. Error message:

resquest failed due to auth token expired: 401. refreshing token exception: /build/grive2-JFQ2lp/grive2-0.4.0/libgrive/src/json/JsonParser.cc(169): Throw in function void gr::JsonParser::Parse(const char*, std::size_t) Dynamic exception type: N5boost16exception_detail10clone_implIN2gr10JsonParser5ErrorEEE [PN2gr4expt12BacktraceTagE] = #0 0x47d0fc grive gr::Exception::Exception()

1 0x465511 grive gr::JsonParser::Error::Error()

2 0x4647b0 grive gr::JsonParser::Parse(char const*, unsigned long)

3 0x4767cd grive gr::http::ValResponse::Write(char const*, unsigned long)

4 0x7f45b404f508 /usr/lib/x86_64-linux-gnu/libcurl.so.4

5 0x7f45b4064b5b /usr/lib/x86_64-linux-gnu/libcurl.so.4

6 0x7f45b406e909 /usr/lib/x86_64-linux-gnu/libcurl.so.4

7 0x7f45b406f181 /usr/lib/x86_64-linux-gnu/libcurl.so.4 curl_multi_perform

8 0x7f45b4065d7b /usr/lib/x86_64-linux-gnu/libcurl.so.4 curl_easy_perform

9 0x45b145 grive gr::http::CurlAgent::ExecCurl(std::string const&, gr::DataStream*, gr::http::Header const&)

10 0x45b6e8 grive gr::http::CurlAgent::Put(std::string const&, gr::File, gr::DataStream, gr::http::Header const&)

11 0x4607f1 grive gr::AuthAgent::Put(std::string const&, gr::File, gr::DataStream, gr::http::Header const&)

12 0x456e7c grive gr::v2::Syncer2::Upload(gr::Resource*)

13 0x457e88 grive gr::v2::Syncer2::Create(gr::Resource*)

14 0x446aa7 grive gr::Resource::SyncSelf(gr::Syncer*, gr::Val const&)

15 0x446e5b grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

16 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

17 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

18 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

19 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

20 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

21 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

22 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

23 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

24 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

25 0x446f70 grive gr::Resource::Sync(gr::Syncer*, gr::DateTime&, gr::Val const&)

26 0x440548 grive gr::State::Sync(gr::Syncer*, gr::Val const&)

27 0x44a3e6 grive gr::Drive::Update()

28 0x42fd85 grive Main(int, char**)

29 0x42db8b grive main

30 0x7f45b2906a40 /lib/x86_64-linux-gnu/libc.so.6 __libc_start_main

31 0x42e8f9 grive _start

[PN2gr8JsonTextE] = { "error": { "errors": [ { "domain": "global", "reason": "authError", "message": "Invalid Credentials", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Invalid Credentials" } }

[PN2gr8ParseErrE] = parse error: trailing garbage { "error": { "errors": [
(right here) ------^

JuniorJPDJ commented 9 years ago

the same here

sync "./Music/RY23/Ramona23 - Uliczny Flowklor [2009]/03-ry23-uliczny_flowklor.mp3" doesn't exist in server, uploading
resquest failed due to auth token expired: 401. refreshing token
exception: /thereShitHappenes/yaourt-tmp-juniorjpdj/aur-grive/src/grive2-master/libgrive/src/json/JsonParser.cc(169): Throw in function void gr::JsonParser::Parse(const char*, std::size_t)
Dynamic exception type: boost::exception_detail::clone_impl<gr::JsonParser::Error>
[gr::JsonText*] = {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}

[gr::ParseErr*] = parse error: trailing garbage
                                       {  "error": {   "errors": [    
                     (right here) ------^
pbreuer commented 9 years ago

Grive 0.3 and 0.2 don't work any more because of a change to the Google API in April. For that you need grive2, from Vitaliy Filippov at http://yourcmc.ru/wiki/Grive2 and http://yourcmc.ru/wiki/Grive2#Installation in particular. Works fine.

ontore commented 9 years ago

I am getting this error with the following version: grive version 0.4.0-pre May 25 2015 13:40:47 installed from the grive2 fork via https://github.com/MasterSoft24/Grive2 and https://launchpad.net/~nilarimogard/+archive/ubuntu/webupd8/+packages?field.name_filter=grive2&field.status_filter=published&field.series_filter= So I assume this error also exists in grive2

pbreuer commented 9 years ago

You mean THAT error (above)? (there is no THIS error attached to your post or referenced from it - did you mean to?).

To be precise, my working grive2 code fork is from https://github.com/vitalif/grive2. The URL you mention above looks different, at face value. There could be different "grive2"s out there.

Yes, that error looks to be in the sync routine itself, when the code has started to retrieve the remote data. But I notice that you are running 64-bit and running a platform-specific 64-bit libcurl4, whereas I am running 32-bit and running the libcurl from libcurl4-gnutls, which is a difference that I would be very suspicious about as it took me a long time to find a curl3/4 installation and partners for it that didn't make various things crash, grive included. My installation syncs fine.

The error from the main branch grive 0.2/0.3 code I think I recall is earlier than the backtrace shown above indicates, before syncing has started. Still, the two points are close. Your error looks to be in parsing a particular thing, rather than an overall problem. It may be worthwhile trying to vary the filenames (try a blank directory sync) to see what changes and maybe confirm that it's a content sensitive issue.

So I'd contact Vitaliy. But it may be worth seeing if it is a problem that has been discovered and sorted by checking out the latest code.

For the record, the list of things my (OK) grive2 compilation is linked to is

/usr/lib/i386-linux-gnu/libboost_program_options.so.1.55.0 /usr/lib/i386-linux-gnu/libyajl.so.2.1.0 /usr/lib/i386-linux-gnu/libcurl.so.4.3.0 /lib/i386-linux-gnu/libgcrypt.so.20.0.3 /usr/lib/i386-linux-gnu/libboost_filesystem.so.1.55.0 /usr/lib/i386-linux-gnu/libboost_unit_test_framework.so.1.55.0 /usr/lib/i386-linux-gnu/libboost_system.so.1.55.0 /lib/i386-linux-gnu/libexpat.so.1.6.0 /lib/i386-linux-gnu/i686/cmov/libdl-2.19.so /usr/lib/libbfd-2.25-system.so /lib/i386-linux-gnu/libz.so.1.2.8 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.20 /lib/i386-linux-gnu/i686/cmov/libm-2.19.so /lib/i386-linux-gnu/libgcc_s.so.1 /lib/i386-linux-gnu/i686/cmov/libc-2.19.so /lib/i386-linux-gnu/i686/cmov/librt-2.19.so /lib/i386-linux-gnu/i686/cmov/libpthread-2.19.so /usr/lib/i386-linux-gnu/libidn.so.11.6.12 /usr/lib/i386-linux-gnu/librtmp.so.1 /usr/lib/i386-linux-gnu/libssh2.so.1.0.1 /usr/lib/i386-linux-gnu/i686/cmov/libssl.so.1.0.0 /usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0 /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2 /usr/lib/i386-linux-gnu/libkrb5.so.3.3 /usr/lib/i386-linux-gnu/libk5crypto.so.3.1 /lib/i386-linux-gnu/libcom_err.so.2.1 /usr/lib/i386-linux-gnu/liblber-2.4.so.2.10.3 /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.10.3 /lib/i386-linux-gnu/libgpg-error.so.0.13.0 /lib/i386-linux-gnu/ld-2.19.so /usr/lib/i386-linux-gnu/libgnutls-deb0.so.28.41.0 /usr/lib/i386-linux-gnu/libhogweed.so.2.5 /usr/lib/i386-linux-gnu/libnettle.so.4.7 /usr/lib/i386-linux-gnu/libgmp.so.10.2.0 /usr/lib/i386-linux-gnu/libkrb5support.so.0.1 /lib/i386-linux-gnu/libkeyutils.so.1.5 /lib/i386-linux-gnu/i686/cmov/libresolv-2.19.so /usr/lib/i386-linux-gnu/libsasl2.so.2.0.25 /usr/lib/i386-linux-gnu/libp11-kit.so.0.0.0 /usr/lib/i386-linux-gnu/libtasn1.so.6.3.2 /usr/lib/i386-linux-gnu/libffi.so.6.0.2

The stuff libcurl is itself linked to here (which was the hard part to get properly arranged for me) is

/usr/lib/i386-linux-gnu/libidn.so.11.6.12 /usr/lib/i386-linux-gnu/librtmp.so.1 /usr/lib/i386-linux-gnu/libssh2.so.1.0.1 /usr/lib/i386-linux-gnu/i686/cmov/libssl.so.1.0.0 /usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0 /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2 /usr/lib/i386-linux-gnu/libkrb5.so.3.3 /usr/lib/i386-linux-gnu/libk5crypto.so.3.1 /lib/i386-linux-gnu/libcom_err.so.2.1 /usr/lib/i386-linux-gnu/liblber-2.4.so.2.10.3 /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.10.3 /lib/i386-linux-gnu/libz.so.1.2.8 /lib/i386-linux-gnu/i686/cmov/libpthread-2.19.so /lib/i386-linux-gnu/i686/cmov/libc-2.19.so /usr/lib/i386-linux-gnu/libgnutls-deb0.so.28.41.0 /usr/lib/i386-linux-gnu/libhogweed.so.2.5 /usr/lib/i386-linux-gnu/libnettle.so.4.7 /usr/lib/i386-linux-gnu/libgmp.so.10.2.0 /lib/i386-linux-gnu/libgcrypt.so.20.0.3 /lib/i386-linux-gnu/i686/cmov/libdl-2.19.so /usr/lib/i386-linux-gnu/libkrb5support.so.0.1 /lib/i386-linux-gnu/libkeyutils.so.1.5 /lib/i386-linux-gnu/i686/cmov/libresolv-2.19.so /lib/i386-linux-gnu/ld-2.19.so /usr/lib/i386-linux-gnu/libsasl2.so.2.0.25 /usr/lib/i386-linux-gnu/libp11-kit.so.0.0.0 /usr/lib/i386-linux-gnu/libtasn1.so.6.3.2 /lib/i386-linux-gnu/libgpg-error.so.0.13.0 /usr/lib/i386-linux-gnu/libffi.so.6.0.2

With that mountain of dependencies, things are intrinsically delicate. As I recall I was battling a problem in which libcurl4 code calls for something like SSLv3_clientmethod() but links to libssl.so.1.0.0 to supply it, and libssl.so has all its methods named SSL*, with no "v3". The trick was to get a libcurl that didn't do that, then, or get one that linked to libgnutls-openssl instead. The problem resolved either way ... but the setup was plainly delicate.

You may wish to try grive2 on another platform (32-bit and/or a virtual machine running on your own native platform) to see what varies as you vary the setup.

ontore commented 9 years ago

This is getting too complicated for me. For the time being I switched to rclone, which works fine. http://rclone.org/

pbreuer commented 9 years ago

OK. https://github.com/vitalif/grive2 compiles and runs fine for me (debian stable). That's not complicated!