Skip to content

Conversation

nmaier
Copy link
Collaborator

@nmaier nmaier commented Feb 6, 2015

When I try to download any file, I get this error:

aria2c: SimpleRandomizer.cc:93: void aria2::SimpleRandomizer::getRandomBytes(unsigned char*, size_t): Assertion `rv >= 0 && (size_t)rv == len' failed.
---------
=> aria2c --version 
aria2 version 1.18.9
Copyright (C) 2006, 2014 Tatsuhiro Tsujikawa

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

** Configuration **
Enabled Features: Async DNS, BitTorrent, Firefox3 Cookie, GZip, HTTPS, Message Digest, Metalink, XML-RPC
Hash Algorithms: sha-1, sha-224, sha-256, sha-384, sha-512, md5, adler32
Libraries: zlib/1.2.8 libxml2/2.9.2 sqlite3/3.8.8.1 GnuTLS/3.3.12 nettle GMP/6.0.0 c-ares/1.10.0
Compiler: gcc 4.9.2 20141224 (prerelease)
  built by   x86_64-unknown-linux-gnu
  on         Feb  2 2015 08:14:18
System: Linux 3.15.8-1-ARCH #1 SMP PREEMPT Fri Aug 1 08:51:42 CEST 2014 x86_64

Report bugs to https://github.com/tatsuhiro-t/aria2/issues
Visit http://aria2.sourceforge.net/
--------

Let me know if any further data or log is needed.

@tatsuhiro-t
Copy link
Collaborator

Thank you for reporting bug.
@nmaier any idea about this issue?

@tatsuhiro-t
Copy link
Collaborator

As a quick workaround, comment out the following 2 lines from config.h after running configure:

#define HAVE_GETRANDOM 1
#define HAVE_GETRANDOM_INTERFACE 1

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

Seeing that, it would be good to know what rv actually was at that point...
In theory, since we call getrandom in urandom and blocking mode, the call should not fail. Turns out that there are four instances where this is not the case:

  1. The kernel is totally borked. (E?)
  2. The buffer is bogus (outside of address space) (EFAULT)
  3. The pool is not initialized AND there was an interrupt (EINTR)
  4. The request is a large request (>256b) AND there was an interrupt (EINTR)

I developed the initial patch on Arch as well, but was not seeing this problem there, hmm.

Anyway, I'll write some code to handle EINTR and "short" returns (although short returns should not happen at all) and add some additional output to the failure case.

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

@nkhdiscovery Do you have any more details on step to reproduce?

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

@tatsuhiro-t Any objections?

@tatsuhiro-t
Copy link
Collaborator

No objection if it fixes this issue.

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

@nkhdiscovery Any chance you can try this branch yourself?

@nkhdiscovery
Copy link
Author

@tatsuhiro-t @nmaier I've a total broken system these days as I was upgrading my archlinux, I try to test this as soon as possible.

@ClaudiaJ
Copy link

ClaudiaJ commented Feb 6, 2015

Branch built successfully on my Arch vm through Linode, fails with following error number:

getrandom returned an unhandled error: 38
aria2c: SimpleRandomizer.cc:93: void aria2::SimpleRandomizer::getRandomBytes(unsigned char*, size_t): Assertion `rv >= 0 && (size_t)rv == len' failed.

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

hmm. interesting. 38 should be ENOSYS aka. not implemented. That shouldn't happen unless the linux headers and the kernel are a mismatch.

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

Alright, I'll write some more code to handle ENOSYS gracefully and fall back to the generic implementation if encountered.

@ClaudiaJ
Copy link

ClaudiaJ commented Feb 6, 2015

I wonder if it might be directly relating to how the kernel is managed on Linode configurations. I haven't reboot into anything newer than the following in almost a month and a half:

Linux dev 3.16.7-x86_64-linode49 #3 SMP Fri Nov 14 16:55:37 EST 2014 x86_64 GNU/Linux

A description of how Linode's kernels are handled can be found here

@nmaier
Copy link
Collaborator

nmaier commented Feb 6, 2015

@ClaudiaJ Yeah, that's the problem right there. You got the usual 3.18 linux headers, but the kernel is in fact only 3.16 (from Linode). Looking closely at the output from @nkhdiscovery it says Linux 3.15.8-1-ARCH, so same issue.

@ClaudiaJ and/or @nkhdiscovery can you retry this branch? I pushed again and hope this latest commit handles the missing syscall/implementation gracefully now.

@ClaudiaJ
Copy link

ClaudiaJ commented Feb 6, 2015

Branch is built successfully on my Linode vm, and a quick test download of some diff from gist is also successful.
I'll also pick up a newer kernel this weekend.

@nkhdiscovery
Copy link
Author

@ClaudiaJ @nmaier @tatsuhiro-t I updated my kernel and it works fine now, I think I can't risk to reproduce the error right now by downgrading my kernel as I'm in the middle of my master project... Thank you guys for your quick response :)

@nmaier nmaier closed this in ba0e32a Feb 7, 2015
@nmaier nmaier deleted the getrandom-handle-eintr branch February 7, 2015 16:34
@tatsuhiro-t tatsuhiro-t mentioned this pull request Feb 22, 2015
@Haocen
Copy link

Haocen commented Jan 6, 2017

Run into similar problem since version 1.26.1:
1.25.0 is fine.

[/Aria2] # ./bin/aria2c -v
aria2 version 1.30.0
Copyright (C) 2006, 2016 Tatsuhiro Tsujikawa

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

** Configuration **
Enabled Features: Async DNS, BitTorrent, Firefox3 Cookie, GZip, HTTPS, Message Digest, Metalink, XML-RPC, SFTP
Hash Algorithms: sha-1, sha-224, sha-256, sha-384, sha-512, md5, adler32
Libraries: zlib/1.2.8 expat/2.1.0 sqlite3/3.11.0 OpenSSL/1.0.2g c-ares/1.10.0 libssh2/1.5.0
Compiler: gcc 5.4.0 20160609
  built by   x86_64-pc-linux-gnu
  on         Jan  5 2017 23:33:21
System: Linux 3.12.6 #1 SMP Wed Dec 14 04:23:22 CST 2016 x86_64

Report bugs to https://github.com/aria2/aria2/issues
Visit https://aria2.github.io/
<-conf-path=./Aria2/a.conf 
aria2c: SimpleRandomizer.cc:117: void aria2::SimpleRandomizer::getRandomBytes(unsigned char*, size_t): Assertion `rv >= 0 && (size_t)rv == len' failed.
Aborted

@tatsuhiro-t
Copy link
Collaborator

@Haocen thank you. #823 will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants