Repository navigation
src/libexpr/search-path.cc: avoid out-of-bounds read on string_view - #8825
Conversation
Without the change build with `-D_GLIBCXX_ASSERTIONS` exposes testsuite
assertion:
$ gdb src/libexpr/tests/libnixexpr-tests
Reading symbols from src/libexpr/tests/libnixexpr-tests...
(gdb) break __glibcxx_assert_fail
(gdb) run
(gdb) bt
in std::__glibcxx_assert_fail(char const*, int, char const*, char const*)@plt () from /mnt/archive/big/git/nix/src/libexpr/libnixexpr.so
in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffff56c0, __pos=4)
at /nix/store/r74fw2j8rx5idb0w8s1s6ynwwgs0qmh9-gcc-14.0.0/include/c++/14.0.0/string_view:258
in nix::SearchPath::Prefix::suffixIfPotentialMatch (this=0x7fffffff5780, path=...) at src/libexpr/search-path.cc:15
in nix::SearchPathElem_suffixIfPotentialMatch_partialPrefix_Test::TestBody (this=0x555555a17540) at src/libexpr/tests/search-path.cc:62
As string sizes are usigned types `(a - b) > 0` effectively means
`a != b`. While the intention should be `a > b`.
The change fixes test suite pass.
Initially reported by ThomasP at
https://discourse.nixos.org/t/error-while-installing-home-manager/31720
There `nix-build` triggered `libstdc++` assertion when `gcc` is built
with `-D_GLIBCXX_ASSERTIONS` enabled by default.
Apply a simple patch proposed upstream to avoid out-of-bounds access to
the `string_view`:
NixOS/nix#8825
|
Is this the only assertion that fails when |
|
Certainly that failure was the only one on the There is a tiny chance there are more bugs lurking, but so far it looks functioning. As for I hoped |
|
Backport failed for Please cherry-pick the changes locally. git fetch origin 2.15-maintenance
git worktree add -d .worktree/backport-8825-to-2.15-maintenance origin/2.15-maintenance
cd .worktree/backport-8825-to-2.15-maintenance
git checkout -b backport-8825-to-2.15-maintenance
ancref=$(git merge-base 5542c1f87ee3325bce8140f4087b12647b4107ef b74962c92b2d8d9b957934e0aefcf4983169ae1e)
git cherry-pick -x $ancref..b74962c92b2d8d9b957934e0aefcf4983169ae1e |
|
Thanks for fixing this! (I probably wrote the original) |
|
I think be518e7 changed |
|
Backport failed for Please cherry-pick the changes locally. git fetch origin 2.15-maintenance
git worktree add -d .worktree/backport-8825-to-2.15-maintenance origin/2.15-maintenance
cd .worktree/backport-8825-to-2.15-maintenance
git checkout -b backport-8825-to-2.15-maintenance
ancref=$(git merge-base 5542c1f87ee3325bce8140f4087b12647b4107ef b74962c92b2d8d9b957934e0aefcf4983169ae1e)
git cherry-pick -x $ancref..b74962c92b2d8d9b957934e0aefcf4983169ae1e |
|
Backport failed for Please cherry-pick the changes locally. git fetch origin 2.16-maintenance
git worktree add -d .worktree/backport-8825-to-2.16-maintenance origin/2.16-maintenance
cd .worktree/backport-8825-to-2.16-maintenance
git checkout -b backport-8825-to-2.16-maintenance
ancref=$(git merge-base 5542c1f87ee3325bce8140f4087b12647b4107ef b74962c92b2d8d9b957934e0aefcf4983169ae1e)
git cherry-pick -x $ancref..b74962c92b2d8d9b957934e0aefcf4983169ae1e |
|
Backport failed for Please cherry-pick the changes locally. git fetch origin 2.15-maintenance
git worktree add -d .worktree/backport-8825-to-2.15-maintenance origin/2.15-maintenance
cd .worktree/backport-8825-to-2.15-maintenance
git checkout -b backport-8825-to-2.15-maintenance
ancref=$(git merge-base 5542c1f87ee3325bce8140f4087b12647b4107ef b74962c92b2d8d9b957934e0aefcf4983169ae1e)
git cherry-pick -x $ancref..b74962c92b2d8d9b957934e0aefcf4983169ae1e |
|
Backport failed for Please cherry-pick the changes locally. git fetch origin 2.16-maintenance
git worktree add -d .worktree/backport-8825-to-2.16-maintenance origin/2.16-maintenance
cd .worktree/backport-8825-to-2.16-maintenance
git checkout -b backport-8825-to-2.16-maintenance
ancref=$(git merge-base 5542c1f87ee3325bce8140f4087b12647b4107ef b74962c92b2d8d9b957934e0aefcf4983169ae1e)
git cherry-pick -x $ancref..b74962c92b2d8d9b957934e0aefcf4983169ae1e |
|
Successfully created backport PR for |
|
Git push to origin failed for 2.17-maintenance with exitcode 1 |
Without the change build with
-D_GLIBCXX_ASSERTIONSexposes testsuite assertion:As string sizes are usigned types
(a - b) > 0effectively meansa != b. While the intention should bea > b.The change fixes test suite pass.
Motivation
Context
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.shsrc/*/teststests/nixos/*Priorities
Add 👍 to pull requests you find important.