base64: v0.5.1 breaks `base64 -d` on Alpine Linux (musl libc)

base64 v0.5.0 works fine, v0.5.1 is broken on Alpine Linux Edge (both with gcc and cmake):

cmake -B build -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DBUILD_SHARED_LIBS=ON \
        -DBASE64_BUILD_CLI=ON \
        -DBASE64_BUILD_TESTS=ON \
        -DBASE64_WITH_OpenMP=OFF \
        -DBASE64_WITH_AVX512=OFF \
        -DBASE64_WITH_AVX2=OFF \
        -DBASE64_WITH_AVX=OFF
cmake --build build

 ctest --test-dir build --output-on-failure
Test project base64-0.5.1/build
    Start 1: test_base64
    Start 2: benchmark
1/2 Test #1: test_base64 ......................   Passed    0.00 sec
2/2 Test #2: benchmark ........................   Passed    1.04 sec

100% tests passed, 0 tests failed out of 2
echo foo | ./build/bin/base64 | ./build/bin/base64 -d
./build/bin/base64: stdin: decoding error
execve("./build/bin/base64", ["./build/bin/base64", "-d"], 0x7ffc6def0e48 /* 19 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7fc7571dcb08) = 0
set_tid_address(0x7fc7571dcf70)         = 32459
brk(NULL)                               = 0x55b6d3d97000
brk(0x55b6d3d99000)                     = 0x55b6d3d99000
mmap(0x55b6d3d97000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55b6d3d97000
open("build/bin/libbase64.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=67656, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 69632, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc75712a000
mmap(0x7fc75712b000, 40960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x7fc75712b000
mmap(0x7fc757135000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0xb000) = 0x7fc757135000
mmap(0x7fc757139000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xe000) = 0x7fc757139000
close(3)                                = 0
mprotect(0x7fc757139000, 4096, PROT_READ) = 0
mprotect(0x7fc7571d9000, 4096, PROT_READ) = 0
mprotect(0x55b6d2d08000, 4096, PROT_READ) = 0
mmap(NULL, 1048596, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc757029000
mmap(NULL, 1398137, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc756ed3000
readv(0, [{iov_base="Zm9vCg==\n", iov_len=1048575}, {iov_base="", iov_len=1024}], 2) = 9
readv(0, [{iov_base="", iov_len=1048566}, {iov_base="", iov_len=1024}], 2) = 0
writev(2, [{iov_base="./build/bin/base64: stdin: decod"..., iov_len=42}, {iov_base=NULL, iov_len=0}], 2./build/bin/base64: stdin: decoding error
) = 42
munmap(0x7fc757029000, 1052672)         = 0
munmap(0x7fc756ed3000, 1400832)         = 0
close(0)                                = 0
close(1)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@aklomp, you mean I have to download that branch and compile it myself? o_O

@sergeevabc Well yes, how else do you get a binary? This project does not publish any binaries.

But anyway, I think I’ll merge the branch today because it fixes the issue, and create a follow-up issue to deal with the slow decoding. The fix works, it’s pretty trivial and I tested it locally. It’s just quite slow because it scans the input twice.