CMake ignores "-E tar xf" unpacking errors when no space is left on the device
This issue is tricky to reproduce since it's related to the disk space exhausting error. I've tried my best to make it as easy to test as possible. If somebody knows the better way (or even a configuration suitable for unit testing), feel free to share.
Here is the archive with 1250 files, 1024 bytes each, random data: archive.tar.gz
> ls -lh archive.tar.gz
-rw-r--r-- 1 ... ... 1.3M ... archive.tar.gz
> openssl sha1 archive.tar.gz
SHA1(archive.tar.gz)= 0646335992e18b09c5d3aa35610e64517bb427d5
I'm on Linux, Ubuntu 22.04:
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
Creating a small 5MB (size is important!) loop device for testing. File first:
> rm -f ~/small_disk_stub_file
> dd if=/dev/zero of=~/small_disk_stub_file bs=1M count=5
> ls -lah ~/small_disk_stub_file
-rw-r--r-- 1 ... ... 5.0M ... ~/small_disk_stub_file
Create filesystem and mount:
> mkfs -t ext4 -q ~/small_disk_stub_file -F
> sudo mkdir /media/small_disk_test
> sudo mount -o loop,rw ~/small_disk_stub_file /media/small_disk_test
> sudo chown $USER:$USER /media/small_disk_test
> cd /media/small_disk_test
> df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/loop27 4.7M 60K 4.3M 2% /media/small_disk_test
Now let's try to unarchive the *.tar.gz
file:
> cmake --version
cmake version 3.28.1
> cmake -E tar xf ~/archive.tar.gz
cmake -E tar: warning: unknown warning
...
cmake -E tar: warning: unknown warning
> echo $?
0
There are tons of warnings. However, the exit code is a success.
If you compare the files, some of them unpacked correctly, but some of them are not:
> openssl sha1 85.bin /media/small_disk_test/85.bin
SHA1(85.bin)= 78dc9fff541c7e2a739c5915f546f4da340cb325
SHA1(/media/small_disk_test/85.bin)= 78dc9fff541c7e2a739c5915f546f4da340cb325
> openssl sha1 86.bin /media/small_disk_test/86.bin
SHA1(86.bin)= 919a43ba41faadca058650cb15081b00a937a02f
SHA1(/media/small_disk_test/86.bin)= 60cacbf3d72e1e7834203da608037b1bf83b40e8
If a smaller disk size is used, e.g., 2MB instead of 5MB, there will be an error message and error code:
> cmake -E tar xf ~/archive.tar.gz
CMake Error: Problem with archive_write_header(): Can't create '1218.bin'
CMake Error: Current file: ./1218.bin
CMake Error: Problem extracting tar: ~/archive.tar.gz
> echo $?
1
CMake 3.11.4, tons of archive_write_data_block()
warning messages, but exit code still is a success:
> ~/opt/cmake-3.11.4-Linux-x86_64/bin/cmake -E tar xf ~/archive.tar.gz
archive_write_data_block()
...
archive_write_data_block()
CMake 3.12.0, error message this time, but exit code still is a success:
> ~/opt/cmake-3.12.0-Linux-x86_64/bin/cmake -E tar xf ~/archive.tar.gz
archive_write_data_block()
CMake Error: Problem with copy_data
Related: