git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481)

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Jan 5, 2024, 17:41 UTC
Message-ID
<d1f739fe-b28e-451f-9e01-3d2e24a0fe0d@app.fastmail.com>
You can trigger an assertion by giving these arguments to `git mv`:
    <dir>/file <dir> <other dir>
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)

``` git config --global --add safe.directory /tmp dir=$(mktemp -d) cd $dir git init mkdir a touch a/a.txt git add a/a.txt git commit -m 'init' mkdir b # Assertion triggered git mv a/a.txt a b # `.git/index.lock` still lingers after this; commands like `git add # <file>` will fail ```

The output:

``` git: builtin/mv.c:481: cmd_mv: Assertion `pos >= 0' failed. Aborted (core dumped) ```

Also `.git/index.lock` is still there.
> What did you expect to happen? (Expected behavior)

A normal error message if the command is nonsensical (I don’t know; that’s not the point). Also `.git/index.lock` to be cleaned up.

> What happened instead? (Actual behavior)
An assertion failed. `.git/index.lock` is not cleaned up.
> What's different between what you expected and what actually happened?
See above.
> Anything else you want to add:
Same behavior on `master` (a26002b628 (The fifth batch, 2024-01-02)).

``` ./bin-wrappers/git config --global --add safe.directory /tmp dir=$(mktemp -d) ./bin-wrappers/git -C $dir init mkdir $dir/a touch $dir/a/a.txt ./bin-wrappers/git -C $dir add $dir/a/a.txt ./bin-wrappers/git -C $dir commit -m 'init' mkdir $dir/b # Assertion triggered ./bin-wrappers/git -C $dir mv $dir/a/a.txt $dir/a $dir/b ```

> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.

[System Info] git version: git version 2.43.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 compiler info: gnuc: 11.4 libc info: glibc: 2.35 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
-- 
Kristoffer Haugsbakk
Next: Junio C Hamano
Message 1 of 10 in “[BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481)”
  1. Kristoffer HaugsbakkJan 5, 2024
  2. Junio C HamanoJan 5, 2024
  3. Dragan SimicJan 5, 2024
  4. Kristoffer HaugsbakkFeb 18, 2024
  5. t7001: add failure test which triggers assertionkristofferhaugsbakk@fastmail.com, Oct 20, 2024
  6. Taylor BlauOct 21, 2024
  7. Kristoffer HaugsbakkOct 21, 2024
  8. Taylor BlauOct 21, 2024
  9. t7001: add failure test which triggers assertionkristofferhaugsbakk@fastmail.com, Oct 22, 2024
  10. Taylor BlauOct 23, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.