[vim/vim] Refactor cmdhist.c to remove calls to STRLEN() (PR #15888)

44 views
Skip to first unread message

John Marriott

unread,
Oct 16, 2024, 9:15:37 PM10/16/24
to vim/vim, Subscribed

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15888

Commit Summary

  • 1c309cb Refactor cmdhist.c to remove calls to STRLEN()

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888@github.com>

John Marriott

unread,
Oct 16, 2024, 9:26:58 PM10/16/24
to vim/vim, Push

@basilisk0315 pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/1c309cb0f7cbc8a04b3082cd261e6604d5e45733/after/1c75a1b16fb46e83ccc0a47216655e9ff0d0148b@github.com>

John Marriott

unread,
Oct 17, 2024, 7:55:22 PM10/17/24
to vim/vim, Push

@basilisk0315 pushed 1 commit.

  • b783c4c Changes based on test failures

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/1c75a1b16fb46e83ccc0a47216655e9ff0d0148b/after/b783c4cfb9a1916e5b0dba95d6c7fd6ba34d3ec6@github.com>

John Marriott

unread,
Oct 17, 2024, 10:59:31 PM10/17/24
to vim/vim, Push

@basilisk0315 pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/b783c4cfb9a1916e5b0dba95d6c7fd6ba34d3ec6/after/07060a4d7c1c7b32fab30988e6e2a40e8c792c49@github.com>

John Marriott

unread,
Oct 18, 2024, 5:39:58 PM10/18/24
to vim/vim, Push

@basilisk0315 pushed 1 commit.

  • 1d7c5b2 Fix incorrect calculation of pattern length

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/07060a4d7c1c7b32fab30988e6e2a40e8c792c49/after/1d7c5b27ee33970ab51f25c41df13941e11a54d7@github.com>

John Marriott

unread,
Oct 18, 2024, 6:53:00 PM10/18/24
to vim/vim, Subscribed

I am getting a heap-buffer-overflow error and I am having difficulty tracking down where the problem is.

Does anyone know how I can find exactly which test or tests are triggering the error? I have been trawling the logs but no joy.

Any help is appreciated.

Cheers


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/c2423341554@github.com>

Christ van Willegen

unread,
Oct 19, 2024, 5:00:26 AM10/19/24
to vim...@googlegroups.com, reply+ACY5DGCGG7GJEZ2YSU...@reply.github.com, vim/vim, Subscribed


Op za 19 okt 2024 00:52 schreef John Marriott <vim-dev...@256bit.org>:

I am getting a heap-buffer-overflow error and I am having difficulty tracking down where the problem is.

Does anyone know how I can find exactly which test or tests are triggering the error? I have been trawling the logs but no joy.

Any help is appreciated.


One thing I can think of is running your new code alongside the old one, and having a runtime assert on all calculations and function calls. That way, you'd get the information at the instant where the code differs in action? 

Christ van Willegen

vim-dev ML

unread,
Oct 19, 2024, 5:00:58 AM10/19/24
to vim/vim, vim-dev ML, Your activity

Op za 19 okt 2024 00:52 schreef John Marriott ***@***.***>:


> I am getting a heap-buffer-overflow error and I am having difficulty
> tracking down where the problem is.
>
> Does anyone know how I can find exactly which test or tests are triggering
> the error? I have been trawling the logs but no joy.
>
> Any help is appreciated.
>

One thing I can think of is running your new code alongside the old one,
and having a runtime assert on all calculations and function calls. That
way, you'd get the information at the instant where the code differs in
action?

Christ van Willegen

>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/c2423704259@github.com>

Christian Brabandt

unread,
Oct 19, 2024, 9:03:58 AM10/19/24
to vim/vim, vim-dev ML, Comment

Can you reproduce the heap buffer overflow locally? I typically use this: https://github.com/google/sanitizers/wiki/AddressSanitizerAndDebugger to have the debugger stop at the place where the buffer overflow is detected and then from there check the frames around it


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2423836316@github.com>

John Marriott

unread,
Oct 19, 2024, 6:13:37 PM10/19/24
to vim/vim, vim-dev ML, Comment

Thanks for the comments.

I probably didn't make myself clear. The heap buffer error is reported as part of github's asan tests, but I have not been able to reproduce it locally. I downloaded the test log files and have going through them to identify the specific test or tests that are triggering the error, but no luck so far. The logs do report the call stack and the line of code which had the error, but I was hoping the test logs would mention which test triggered the error.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2424237069@github.com>

Jacob Mealey

unread,
Oct 19, 2024, 10:06:34 PM10/19/24
to vim/vim, vim-dev ML, Comment

Hello, I was able to reproduce the heap overflow locally by turning on the address sanitizer around line 700 of src/makefile. I ran the tests and the failing one seems to be Test_viminfo_jumplist(). It provided the same stack trace from the sanitizer. When I ran the tests it wrote to src/testdir/messages to following:



From test_viminfo.vim:
Executed Test_cmdline_history()                    in   0.067899 seconds
Executed Test_cmdline_history_order()              in   0.032296 seconds
Executed Test_global_vars()                        in   0.021711 seconds
Executed Test_global_vars_with_circular_reference() in   0.016178 seconds
Executed Test_viminfo_bad_syntax()                 in   0.017160 seconds
Executed Test_viminfo_bad_syntax2()                in   0.014733 seconds
Executed Test_viminfo_bad_syntax3()                in   0.178377 seconds
Executed Test_viminfo_bufferlist()                 in   0.110349 seconds
Executed Test_viminfo_encoding()                   in   0.016602 seconds
Executed Test_viminfo_error()                      in   0.028616 seconds
Executed Test_viminfo_file_mark_tabclose()         in   0.025528 seconds
Executed Test_viminfo_file_mark_unloaded_buf()     in   0.025827 seconds
Executed Test_viminfo_file_mark_zero_time()        in   0.008175 seconds
Executed Test_viminfo_file_marks()                 in   0.045957 seconds
Executed Test_viminfo_hlsearch()                   in   0.020748 seconds
Executed 15 tests                        in   1.303385 seconds
1 FAILED:
Found errors in Test_viminfo_jumplist():
E94: No matching buffer for Xviminfo
Test caused Vim to exit: Test_viminfo_jumplist()

I tried to take a swing at fixing it, but no luck. Hope this helps narrow down the memory issue!


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2424406824@github.com>

Christian Brabandt

unread,
Oct 20, 2024, 4:34:39 AM10/20/24
to vim/vim, vim-dev ML, Comment

The logs do report the call stack and the line of code which had the error, but I was hoping the test logs would mention which test triggered the error.

Yeah, that is a bit unfortunate and I have wished for that as well. Hm, I wonder if we can set ASAN_OPTIONS to something like log_path=${LOG_DIR}/asan_<test_name> so it is easier to figure out which test caused the failure


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2424735047@github.com>

John Marriott

unread,
Oct 20, 2024, 5:53:26 PM10/20/24
to vim/vim, vim-dev ML, Comment

Hi @jacobmealey thanks for the heads up. Big help.

I initially could not reproduce the error at my end, but then I switched from clang to gcc the heap error popped up in the same test file as you (text_viminfo.vim) but at a different place (Test_viminfo_last_spat_magic).


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2425242095@github.com>

John Marriott

unread,
Oct 20, 2024, 7:17:42 PM10/20/24
to vim/vim, vim-dev ML, Comment

Yeah, that is a bit unfortunate and I have wished for that as well. Hm, I wonder if we can set ASAN_OPTIONS to something like log_path=${LOG_DIR}/asan_<test_name> so it is easier to figure out which test caused the failure

That would be very useful. I tried to get that to work but gave up. I don't have much experience with ASAN.

In the end I just redirect stderr (ASAN writes to stderr) to a different file named after the test file.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2425281978@github.com>

John Marriott

unread,
Oct 20, 2024, 7:23:21 PM10/20/24
to vim/vim, vim-dev ML, Push

@basilisk0315 pushed 1 commit.

  • f3aaff0 Fix heap-buffer-overflow error

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/1d7c5b27ee33970ab51f25c41df13941e11a54d7/after/f3aaff0670377862f0328f1938a4ef6e4fe96d19@github.com>

John Marriott

unread,
Oct 20, 2024, 8:46:45 PM10/20/24
to vim/vim, vim-dev ML, Push

@basilisk0315 pushed 1 commit.

  • a9127dd Fix calculating string length when reading from viminfo file

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/f3aaff0670377862f0328f1938a4ef6e4fe96d19/after/a9127dd19a2173e831935c641dd38f0678e87cf5@github.com>

John Marriott

unread,
Oct 20, 2024, 9:38:15 PM10/20/24
to vim/vim, vim-dev ML, Push

@basilisk0315 pushed 1 commit.

  • 229209f Fix string length calculation in barline_parse()

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15888/before/a9127dd19a2173e831935c641dd38f0678e87cf5/after/229209f47eb82cfac56f3ab8688195f6ef0764f9@github.com>

John Marriott

unread,
Oct 20, 2024, 10:37:21 PM10/20/24
to vim/vim, vim-dev ML, Comment

Phew! I have resolved the issues. This just leaves a couple of test failures regarding values being returned in the unexpected ranges. These types of errors seem to come and go.

Thanks for your help all.

Cheers
John


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2425437957@github.com>

Christian Brabandt

unread,
Oct 21, 2024, 4:36:11 PM10/21/24
to vim/vim, vim-dev ML, Comment

thanks, looks good


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/c2427668268@github.com>

Christian Brabandt

unread,
Oct 21, 2024, 4:39:29 PM10/21/24
to vim/vim, vim-dev ML, Comment

Closed #15888 via 8df07d0.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15888/issue_event/14771070546@github.com>

Reply all
Reply to author
Forward
0 new messages