#1000023 vim: E315: ml_get: invalid lnum: 37 (or another number)

Package:
vim
Source:
vim
Description:
Vi IMproved - enhanced vi editor
Submitter:
Alejandro Colomar
Date:
2021-11-22 00:45:02 UTC
Severity:
minor
Tags:
#1000023#5
Date:
2021-11-18 12:21:53 UTC
From:
To:
Dear Maintainer,

If you have a small file that fits in a single screen
(in my case, it was 38 lines, which is smaller than half a FullHD screen),
and
you delete the last lines of the file in the following way:

	If you're going to remove from line 30 to the end,
	- goto line 30		30G
	- set visual mode	V
	- advance a screen	^f
	- delete		d
	- go back a screen	^b

You'll end up with an empty screen (all ~s) after the deletion,
and when you then go up with ^b,
you'll receive an error message:
E315: ml_get invalid lnum: 37


It's not a problem,
and it doesn't affect usability,
but it would be nicer if that error didn't show up,
since there's really no error;
is there?


Thanks,
Alex
--- real paths of main Vim binaries ---
/usr/bin/vi is /usr/bin/vim.basic
/usr/bin/vim is /usr/bin/vim.basic

#1000023#10
Date:
2021-11-19 16:40:19 UTC
From:
To:
I tried reproducing this by creating a 38 line file via “seq 38 > foo.txt”
and then following your steps by running “vim --clean foo.txt”.  I saw
no errors.

What are the dimensions of your terminal when you do this?
“:set columns? lines?” from Vim will show this.

Can you reproduce it with the file I mentioned, or is it more specific
to the contents you had?

Cheers,

#1000023#15
Date:
2021-11-19 16:46:14 UTC
From:
To:
Hi James,

Huh, I could reproduce it yesterday many times,
and now I forgot which files I used to do that,
and can't reproduce it anymore.

I remember that I could reproduce it with:

vim -u NORC -U NORC -N

but not with

vim -u NONE -U NONE -N


When I manage to reproduce it again I'll come back here.

Cheers,
Alex

#1000023#20
Date:
2021-11-21 22:03:01 UTC
From:
To:
Hi James,

I reproduced it again.
I'm not sure, when it happens and when not.

Try the following vi commands in the following file file:

vi test.c;
38G	// this should put you in the line starting with 'auto'.
V
^f
d
^b

That should reproduce the bug.

Cheers,
Alex



$ cat test.c;
// Copyright (c) 2019 by Alejandro Colomar <alx.manpages@gmail.com>
// SPDX-License-Identifier:  LGPL-2.0-only


#ifndef INCLUDE_ALX_BASE_COMPILER_SIZE_H_
#define INCLUDE_ALX_BASE_COMPILER_SIZE_H_


#include <bsd/sys/cdefs.h>
#include <limits.h>
#include <stddef.h>
#include <sys/types.h>

#include <alx/base/assert/array.h>
#include <alx/base/compiler/cast.h>


#define ssizeof(x)               static_cast(ssize_t, sizeof(x))

#define widthof(x)               (sizeof(x) * CHAR_BIT)
#define swidthof(x)              static_cast(ssize_t, widthof(x))

#if defined(__cplusplus)
#define lengthof(arr)            std::size(arr)
#else
#define lengthof(arr)            (__arraycount((arr)) +
alx_must_be_array(arr))
#endif
#define slengthof(arr)           static_cast(ptrdiff_t, lengthof(arr))

#define ARRAY_BYTES(arr)         (sizeof((arr)[0]) * lengthof(arr))
#define ARRAY_SBYTES(arr)        static_cast(ssize_t, ARRAY_BYTES(arr))
#define ARRAY_BITS(arr)          (ARRAY_BYTES(arr) * CHAR_BIT)

#define memberof(T, f)            (((T *) NULL)->f)

#define containerof(ptr, T, f)   (					\
{									\
	auto  p_  = (ptr);						\
	void *vp_ = p_;							\
									\
	static_assert(alx_is_same_type(*p_, memberof(T, f)) ||		\
	              alx_is_same_type(*p_, void));			\
									\
	(T *) (vp_ - offsetof(T, f));					\
}									\
)


#endif  // INCLUDE_ALX_BASE_COMPILER_SIZE_H_

#1000023#25
Date:
2021-11-22 00:41:15 UTC
From:
To:
This is using your entire personal config?  Can you reproduce it with
“vim --clean test.c”?

What does “:set columns? lines?” report when you start vim?

Unfortunately, it still doesn't.  Since you're able to hit this
semi-regularly, can you try running vim under valgrind and see if it
shows anything when this happens?

Cheers,