tarantool / tarantool/tarantool

The Lua function console.completion_handler() crashes when executed without arguments

Open Beginner friendly
#12,747 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Bug description

  • OS: Linux
  • OS Version: Ubuntu
  • Architecture: amd64

Version: c1076ccc853a80d35d3a7763b4c77413c40e1d06

Steps to reproduce

./src/tarantool -e "require('console').completion_handler()"

Actual behavior

Segmentation fault
  code: SEGV_MAPERR
  addr: (nil)
  context: 0x7f1672161680
  siginfo: 0x7f16721617b0
  rax      0x0                0
  rbx      0x7f166e7fd620     139734319879712
  rcx      0x0                0
  rdx      0x0                0
  rsi      0x0                0
  rdi      0x7d466dfe8d00     137741446581504
  rsp      0x7f166e7fd620     139734319879712
  rbp      0x7f166e7fd8b0     139734319880368
  r8       0x0                0
  r9       0x7fffffffff01     140737488355073
  r10      0xf01              3841
  r11      0x1                1
  r12      0x0                0
  r13      0x0                0
  r14      0x7d466dfe9d80     137741446585728
  r15      0x562aecce1400     94742361543680
  rip      0x562aecce3186     94742361551238
  eflags   0x10246            66118
  cs       0x33               51
  gs       0x0                0
  fs       0x0                0
  cr2      0x0                0
  err      0x4                4
  oldmask  0x0                0
  trapno   0xe                14
Current time: 1779808772
Please file a bug at https://github.com/tarantool/tarantool/issues
Attempting backtrace... Note: since the server has already crashed, 
this may fail as well
#1  0x562aece0e862 in crash_collect+1122
#2  0x562aece0e2f6 in crash_signal_cb+374
#3  0x7f166ee45330 in __sigaction+80
#4  0x562aecce3186 in lua_rl_complete+454
#5  0x562aecce157f in lbox_console_completion_handler+383
#6  0x562aecf72eb9 in lj_BC_FUNCC+86
#7  0x562aecf9b15b in lua_pcall+3003
#8  0x562aecdb016b in luaT_call+107
#9  0x562aecd88d08 in run_script_f+5976
#10 0x562aec592da3 in fiber_cxx_invoke(int (*)(__va_list_tag*), __va_list_tag*)+115
#11 0x562aece3001d in fiber_loop+781
#12 0x562aed9bb8b8 in coro_init+248

Expected behavior

no crash

Possible fix

lua_rl_complete() is calling with text as a null-pointer.

@@ -1180,6 +1214,8 @@ lua_rl_getfield(lua_State *L, const char *s, size_t n)
 static char **
 lua_rl_complete(lua_State *L, const char *text, int start, int end)
 {
+       if (!text)
+               return NULL;
        dmlist ml;
        const char *s;
        size_t i, n, dot, items_checked;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running ./src/tarantool -e "require('console').completion_handler()" to reproduce the crash, then trace the call from console.completion_handler() through lbox_console_completion_handler() to lua_rl_complete(). Verify that calling the handler without arguments completes without a segmentation fault.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.