Tar hangs with 100 % CPU load if the --files-from <LISTFILE> option is used and the <LISTFILE> contains leading spaces. Why is that?

To reproduce: Given two files file1 and file2 of arbitrary content and a file list with the following content:


When I issue tar czf test.tar.gz --files-from list, the command will never finish, and system load is ~ 1.

If I change list to read


The above tar command completes without problems.

This happens on both Ubuntu 14.04.2 LTS server edition and on my Ubuntu 14.10 desktop; both have GNU tar 1.27.1.

  • Works on OSX/bsdtar 2.8.3 – Kevin Apr 16 '15 at 2:31
  • And Arch/GNU tar 1.28 – Kevin Apr 16 '15 at 2:36
  • I built GNU tar 1.28 from source and can still reproduce the behavior. Puzzles me. – bovender Apr 17 '15 at 1:37

I cannot reproduce the results that you are getting, although I can get tar to throw an error when doing what you describe.

Ignoring that, providing a list with spaces before a file name is incorrect; whitespaces are not insignificant in Unix. If you tell tar that a file is called "  file2" then tar looks for a file called "  file2" and if it does not not find one, there is an error.

If you rename file2:

mv file2 '  file2'

and then run tar, it works.

Either way, tar should error out, not crash as it is doing on your system.

  • I get the error message ("No such file or directory") too if I issue the command tar czf test.tar.gz "file1" " file2". Using the --files-from option, tar will still hang if there are leading spaces. – bovender Apr 17 '15 at 1:34
  • what version of tar are you using. I am not able to replicate the hanging behaviour. – Klaatu von Schlacker Apr 17 '15 at 1:40
  • GNU tar 1.27.1 (Ubuntu package) as well as 1.28 (which I compiled from source). It happens on my laptop and on a server that I administer (so I don't think it's something to do with my personal profile). – bovender Apr 17 '15 at 5:58

I have reproduced this behaviour. This is like a bug to me (the tar gets hanged with 100% cpu).

This problem was preventing my Proxmox host to restore backups correctly. And it was thanks to this question I found out about it.

As a temporary workaround, I downgraded to tar v1.26, from here https://packages.debian.org/wheezy/amd64/tar/download (if you use Debian/Ubuntu, download your corresponding .deb version and install with dpkg -i, it's pretty straightforward) and it worked for me.

  • If you start with your workaround, this would look more like an answer. Just delete everything up to and including "As a temporary workaround," and from ",it's pretty" until the end. You can then use the comments on your own post to give information about you considering this being a bug. That is also where you put thanks, if you feel chit-chat is needed (read help→tour). Remember this is a Q&A site not a forum. – Anthon Sep 4 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.