Skip to content

[piper] do not index past the end for an empty demuxed body - #1765

Open
akashchamp wants to merge 1 commit into
tstack:masterfrom
akashchamp:fix-piper-empty-body
Open

akashchamp wants to merge 1 commit into
tstack:masterfrom
akashchamp:fix-piper-empty-body

Conversation

@akashchamp

Copy link
Copy Markdown

Fixes #1759.

When the first line of a docker-compose log has an empty body (db-1 | ), piper_log_format::get_subline() copies zero bytes to &plf_cached_line[prefix_len], which is one past the end of the vector. Release builds don't notice, but builds with -D_GLIBCXX_ASSERTIONS (like Arch's package) abort. This switches the destination to plf_cached_line.data() + prefix_len, same as the #1505 fix.

Added test/logfile_docker_compose_empty_body.0 and a case in test_demux.sh for it.

Verification, on Ubuntu 24.04 / GCC 13 with CXXFLAGS="-O1 -g -Wp,-D_GLIBCXX_ASSERTIONS":

  • On master, printf 'a | \n' > t.log && lnav -n t.log hits Assertion '__n < this->size()' failed in stl_vector.h, and the new test_demux.sh case fails with the same assertion.
  • With the change, the repros from the issue (file and stdin) exit 0 and show the empty line with its timestamp, and make check TESTS=test_demux.sh passes.
  • make -k -C test check: 54/56 pass. test_sessions.sh and test_sql.sh fail only because this machine has no sqlite3 CLI (timeout: failed to run command 'sqlite3').

When a demuxed line has an empty body, like a blank docker-compose
line "db-1  | ", the memcpy() destination in
piper_log_format::get_subline() was &plf_cached_line[prefix_len], which
is one past the end of the vector. Builds with -D_GLIBCXX_ASSERTIONS
(Arch Linux, for one) abort on that. Use data() + prefix_len instead.

Fixes tstack#1759

This branch has not been deployed

No deployments
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.

Crash on docker-compose logs when hardened with -D_GLIBCXX_ASSERTIONS

1 participant