git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481)
@ 2024-01-05 17:41 Kristoffer Haugsbakk
  2024-01-05 18:52 ` Junio C Hamano
  2024-02-18 12:42 ` Kristoffer Haugsbakk
  0 siblings, 2 replies; 10+ messages in thread
From: Kristoffer Haugsbakk @ 2024-01-05 17:41 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-10-23 20:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-05 17:41 [BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481) Kristoffer Haugsbakk
2024-01-05 18:52 ` Junio C Hamano
2024-01-05 19:06   ` Dragan Simic
2024-02-18 12:42 ` Kristoffer Haugsbakk
2024-10-20 22:14   ` [PATCH v2] t7001: add failure test which triggers assertion kristofferhaugsbakk
2024-10-21 21:21     ` Taylor Blau
2024-10-21 21:25       ` Kristoffer Haugsbakk
2024-10-21 21:29         ` Taylor Blau
2024-10-22 21:14     ` [PATCH v3] " kristofferhaugsbakk
2024-10-23 20:36       ` Taylor Blau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).