Invalid argument with ... no argument present #4276

issue Hasimir opened this issue on June 2, 2014
  1. Hasimir commented at 9:59 PM on June 2, 2014: none

    This is running the 32-bit bitcoin-qt binary released with 0.9.1. I had received numerous errors, so I decided to draw things back to as basic a configuration as possible (the bitcoin.conf file has been renamed so the client would not use it and just assume default settings).

    Please note that my local time (and thus my system time) is UTC+10:00

    bash-4.2$ ls -l
    total 17111392
    -rwxr-xr-x 0 ben root        1710 Jun  3 06:49 bitcoin.conf~
    -rwxr-xr-x 0 ben root        1712 Jun  3 06:56 bitcoin.conf0
    -rwxr-xr-x 0 ben root 17522056398 Jun  3 06:21 bootstrap.dat
    bash-4.2$ /usr/local/bitcoin/bitcoin-qt 
    bash-4.2$ ls -l
    total 17111400
    -rwxr-xr-x 0 ben root        1710 Jun  3 06:49 bitcoin.conf~
    -rwxr-xr-x 0 ben root        1712 Jun  3 06:56 bitcoin.conf0
    drwxr-xr-x 0 ben root           0 Jun  3 06:59 blocks
    -rwxr-xr-x 0 ben root 17522056398 Jun  3 06:21 bootstrap.dat
    drwxr-xr-x 0 ben root           0 Jun  3 06:59 database
    -rwxr-xr-x 0 ben root           0 Jun  3 06:59 db.log
    -rwxr-xr-x 0 ben root        1615 Jun  3 06:59 debug.log
    -rwxr-xr-x 0 ben root        1106 Jun  3 06:59 peers.dat
    bash-4.2$ less debug.log 
    bash-4.2$ less peers.dat 
    "peers.dat" may be a binary file.  See it anyway? 
    bash-4.2$ ls database/
    log.0000000001
    bash-4.2$ ls -l database/log.0000000001 
    -rwxr-xr-x 1 ben root 1048576 Jun  3 06:59 database/log.0000000001
    bash-4.2$ file database/log.0000000001 
    database/log.0000000001: Berkeley DB (Log, version 16, native byte-order)
    bash-4.2$ ls blocks/index/
    000003.log  CURRENT  LOCK  LOG  MANIFEST-000001
    bash-4.2$ ls blocks/index/LOG
    blocks/index/LOG
    bash-4.2$ cat blocks/index/LOG
    2014/06/03-06:59:20.843543 b3a37b40 MANIFEST write: IO error: /home/ben/.bitcoin/blocks/index: Invalid argument
    bash-4.2$ 
    

    The bootstrap.dat file is the result of the torrent from bitcoin.org (not the other one from BitcoinArmory).

    The debug.log (with around 15 blank lines removed):

    Requesting initialize
    Running AppInit2 in thread
    2014-06-02 20:59:16 
    
    
    2014-06-02 20:59:16 Bitcoin version v0.9.1.0-g026a939-beta (Tue, 8 Apr 2014 12:04:06 +0200)
    2014-06-02 20:59:16 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
    2014-06-02 20:59:16 Default data directory /home/ben/.bitcoin
    2014-06-02 20:59:16 Using data directory /home/ben/.bitcoin
    2014-06-02 20:59:16 Using at most 125 connections (1024 file descriptors available)
    2014-06-02 20:59:16 Using wallet wallet.dat
    2014-06-02 20:59:16 init message: Verifying wallet...
    2014-06-02 20:59:16 dbenv.open LogDir=/home/ben/.bitcoin/database ErrorFile=/home/ben/.bitcoin/db.log
    2014-06-02 20:59:16 Bound to [::]:8333
    2014-06-02 20:59:16 Bound to 0.0.0.0:8333
    2014-06-02 20:59:16 init message: Loading block index...
    2014-06-02 20:59:16 Opening LevelDB in /home/ben/.bitcoin/blocks/index
    2014-06-02 20:59:16 IO error: /home/ben/.bitcoin/blocks/index: Invalid argument
    2014-06-02 20:59:20 init message: Loading block index...
    2014-06-02 20:59:20 Wiping LevelDB in /home/ben/.bitcoin/blocks/index
    2014-06-02 20:59:20 Opening LevelDB in /home/ben/.bitcoin/blocks/index
    2014-06-02 20:59:20 IO error: /home/ben/.bitcoin/blocks/index: Invalid argument
    2014-06-02 20:59:22 Initialization result: 0
    2014-06-02 20:59:22 Requesting shutdown
    2014-06-02 20:59:22 Running Shutdown in thread
    2014-06-02 20:59:22 Shutdown : In progress...
    2014-06-02 20:59:22 StopNode()
    2014-06-02 20:59:22 Shutdown : done
    2014-06-02 20:59:22 Shutdown finished
    2014-06-02 20:59:22 Shutdown result: 1
    2014-06-02 20:59:22 Stopping thread
    2014-06-02 20:59:22 Stopped thread
    

    Additional system, fs and directory details:

    bash-4.2$ uname -a
    Linux sardonic 3.10.17-smp [#2](/bitcoin-bitcoin/2/) SMP Wed Oct 23 17:13:14 CDT 2013 i686 Intel(R) Core(TM)2 Duo CPU     T9500  @ 2.60GHz GenuineIntel GNU/Linux
    bash-4.2$ pwd
    /home/ben/.bitcoin
    bash-4.2$ mount
    /dev/sda1 on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    tmpfs on /dev/shm type tmpfs (rw)
    //172.17.23.100/Data/bitcoin on /home/ben/.bitcoin type cifs (rw)
    bash-4.2$ df
    Filesystem                    1K-blocks       Used Available Use% Mounted on
    /dev/sda1                      12253360    9757056   1850828  85% /
    tmpfs                            511860          0    511860   0% /dev/shm
    //172.17.23.100/Data/bitcoin 1951417392 1822055272 129362120  94% /home/ben/.bitcoin
    bash-4.2$ 
    

    Running this on a samba mount is necessary because I just don't have the room for the blockchain on this system anymore. I doubt it makes much difference, but sardonic is a VirtualBox VM running Slackware 14.1 on ironic, which is:

    bash-3.2$ uname -a
    Darwin ironic.adversary.org 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 i386
    bash-3.2$ 
    

    Now, I could be wrong, but the error in debug.log appears to indicate that an invalid argument was passed to bitcoin-qt. Except no arguments have been passed to it, so strange as it may appear, someone may have hard coded an argument that doesn't exist. No idea why, but that's what it looks like. The offending code appears to be in src/leveldb/util/status.cc:

    std::string Status::ToString() const {
      if (state_ == NULL) {
        return "OK";
      } else {
        char tmp[30];
        const char* type;
        switch (code()) {
          case kOk:
            type = "OK";
            break;
          case kNotFound:
            type = "NotFound: ";
            break;
          case kCorruption:
            type = "Corruption: ";
            break;
          case kNotSupported:
            type = "Not implemented: ";
            break;
          case kInvalidArgument:
            type = "Invalid argument: ";
            break;
          case kIOError:
            type = "IO error: ";
            break;
          default:
            snprintf(tmp, sizeof(tmp), "Unknown code(%d): ",
                     static_cast<int>(code()));
            type = tmp;
            break;
        }
        std::string result(type);
        uint32_t length;
        memcpy(&length, state_, sizeof(length));
        result.append(state_ + 5, length);
        return result;
      }
    }
    

    Of course, my C coding is a bit crap, so that's probably just the beginning.

  2. Hasimir commented at 10:18 PM on June 2, 2014: none

    I just ran bitcoind on the off chance the result might be different. It wasn't:

    bash-4.2$ /usr/local/bitcoin/bitcoind
    : Error opening block database.
    
    Do you want to rebuild the block database now?
    bash-4.2$ ls -l
    total 17111400
    -rwxr-xr-x 0 ben root        1710 Jun  3 06:49 bitcoin.conf~
    -rwxr-xr-x 0 ben root        1712 Jun  3 06:56 bitcoin.conf0
    drwxr-xr-x 0 ben root           0 Jun  3 06:59 blocks
    -rwxr-xr-x 0 ben root 17522056398 Jun  3 06:21 bootstrap.dat
    drwxr-xr-x 0 ben root           0 Jun  3 06:59 database
    -rwxr-xr-x 0 ben root           0 Jun  3 06:59 db.log
    -rwxr-xr-x 0 ben root        2784 Jun  3 08:07 debug.log
    -rwxr-xr-x 0 ben root        1106 Jun  3 08:07 peers.dat
    bash-4.2$ ls -l blocks/index/
    total 16
    -rwxr-xr-x 0 ben root   0 Jun  3 06:59 000003.log
    -rwxr-xr-x 0 ben root   0 Jun  3 08:08 000004.log
    -rwxr-xr-x 0 ben root  16 Jun  3 06:59 CURRENT
    -rwxr-xr-x 0 ben root   0 Jun  3 06:59 LOCK
    -rwxr-xr-x 0 ben root 166 Jun  3 08:07 LOG
    -rwxr-xr-x 0 ben root 112 Jun  3 06:59 LOG.old
    -rwxr-xr-x 0 ben root  41 Jun  3 06:59 MANIFEST-000001
    bash-4.2$ cat blocks/index/LOG
    2014/06/03-08:08:31.021803 b6c9b700 Recovering log [#3](/bitcoin-bitcoin/3/)
    2014/06/03-08:08:31.044073 b6c9b700 MANIFEST write: IO error: /home/ben/.bitcoin/blocks/index: Invalid argument
    bash-4.2$ 
    

    And the debug.log output (with the previous data and numerous blank lines culled), again, no surprises. The same thing happens:

    2014-06-02 22:08:30 
    
    
    
    2014-06-02 22:08:30 Bitcoin version v0.9.1.0-g026a939-beta (Tue, 8 Apr 2014 12:04:06 +0200)
    2014-06-02 22:08:30 Using OpenSSL version OpenSSL 1.0.1g 7 Apr 2014
    2014-06-02 22:08:30 Default data directory /home/ben/.bitcoin
    2014-06-02 22:08:30 Using data directory /home/ben/.bitcoin
    2014-06-02 22:08:30 Using at most 125 connections (1024 file descriptors available)
    2014-06-02 22:08:30 Using wallet wallet.dat
    2014-06-02 22:08:30 init message: Verifying wallet...
    2014-06-02 22:08:30 dbenv.open LogDir=/home/ben/.bitcoin/database ErrorFile=/home/ben/.bitcoin/db.log
    2014-06-02 22:08:30 Bound to [::]:8333
    2014-06-02 22:08:30 Bound to 0.0.0.0:8333
    2014-06-02 22:08:30 init message: Loading block index...
    2014-06-02 22:08:30 Opening LevelDB in /home/ben/.bitcoin/blocks/index
    2014-06-02 22:08:31 IO error: /home/ben/.bitcoin/blocks/index: Invalid argument
    2014-06-02 22:08:31 : Error opening block database.
    
    Do you want to rebuild the block database now?
    2014-06-02 22:08:31 Aborted block database rebuild. Exiting.
    2014-06-02 22:08:31 Shutdown : In progress...
    2014-06-02 22:08:31 StopNode()
    2014-06-02 22:08:31 Shutdown : done
    
  3. sipa commented at 10:54 PM on June 2, 2014: member

    No, this is LevelDB reporting that an internal system call returned with an error status indicating that an invalid argument was passed.

    I assume that the samba filesystem does not offer certain functionality that LevelDB requires of its databases, such a certain types of locking, syncing or mmaping.

  4. Hasimir commented at 11:02 PM on June 2, 2014: none

    Ah, interesting ... nothing would surprise me with samba. I'll be upgrading the server in a few days (also to Slack 14.1) and try running it there with no VM and no samba and we'll see what happens.

  5. Hasimir commented at 11:04 PM on June 2, 2014: none

    Closing, will raise a new issue if I suffer the same pain on a real system.

  6. Hasimir closed this on Jun 2, 2014

  7. Hasimir commented at 1:39 AM on June 3, 2014: none

    Looks like you were right, but there being more than one way to skin a cat I thought I'd leave this here in case anyone else had the same issue (which bound to happen the larger the blockchain gets):

    Rather than try to mount a samba share containing the blockchain and related data if using a VM like me, do this:

    • Create a virtual disk on the file/network server.
    • Get VirtualBox (or VMWare or whatever) to see that.
    • Mount the disk image as normal.
    • As far as the VM/OS is concerned it's just an ordinary drive.
    • This means you can do other nifty things to such a drive (like encrypt it with LUKS/dm-crypt).

    My work here is done ... ;)

  8. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me