Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTP 26 shell edlin_expand crash with invalid autocomplete #8016

Closed
potatosalad opened this issue Jan 11, 2024 · 1 comment · Fixed by #8075
Closed

OTP 26 shell edlin_expand crash with invalid autocomplete #8016

potatosalad opened this issue Jan 11, 2024 · 1 comment · Fixed by #8075
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@potatosalad
Copy link
Contributor

Describe the bug

This was originally discovered when doing some property-based tests involving autocomplete in the OTP 26 shell.

The input a:x(b:y(c:z(a:x(0b:y(c:z(0) followed by pressing <TAB> results in a crash inside edlin_expand:

Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.2.1 (press Ctrl+G to abort, type help(). for help)
*** ERROR: Shell process terminated! ***
=ERROR REPORT==== 11-Jan-2024::13:16:57.319921 ===
Error in process <0.70.0> with exit value:
{{bad_generator,{no,[],[]}},
 [{edlin_expand,'-expand_function_type/6-lc$^0/1-0-',2,
                [{file,"edlin_expand.erl"},{line,573}]},
  {edlin_expand,expand_function_type,6,[{file,"edlin_expand.erl"},{line,573}]},
  {edlin_expand,expand,3,[{file,"edlin_expand.erl"},{line,108}]},
  {group,get_line1,5,[{file,"group.erl"},{line,664}]},
  {group,get_chars_loop,10,[{file,"group.erl"},{line,498}]},
  {group,io_request,6,[{file,"group.erl"},{line,202}]},
  {group,server_loop,3,[{file,"group.erl"},{line,128}]}]}

Eshell V14.2.1 (press Ctrl+G to abort, type help(). for help)
1> a:x(b:y(c:z(a:x(0b:y(c:z(0)1>

After manually shrinking the counterexample, it looks like 0:a( plus <TAB> is all that is needed to cause the crash:

Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.2.1 (press Ctrl+G to abort, type help(). for help)
*** ERROR: Shell process terminated! ***
Eshell V14.2.1 (press Ctrl+G to abort, type help(). for help)
1> 0:a(=ERROR REPORT==== 11-Jan-2024::13:18:58.846408 ===
Error in process <0.70.0> with exit value:
{{bad_generator,{no,[],[]}},
 [{edlin_expand,'-expand_function_type/6-lc$^0/1-0-',2,
                [{file,"edlin_expand.erl"},{line,573}]},
  {edlin_expand,expand_function_type,6,[{file,"edlin_expand.erl"},{line,573}]},
  {edlin_expand,expand,3,[{file,"edlin_expand.erl"},{line,108}]},
  {group,get_line1,5,[{file,"group.erl"},{line,664}]},
  {group,get_chars_loop,10,[{file,"group.erl"},{line,498}]},
  {group,io_request,6,[{file,"group.erl"},{line,202}]},
  {group,server_loop,3,[{file,"group.erl"},{line,128}]}]}

1>

To Reproduce

  1. Start an OTP 26 shell with erl
  2. Type in 0:a(
  3. Hit <TAB> to trigger autocomplete
  4. The shell will crash and restart itself

Alternatively, the following may be executed directly:

1> edlin_expand:expand(lists:reverse("0:a("), []).
** exception error: bad generator {no,[],[]}
     in function  edlin_expand:'-expand_function_type/6-lc$^0/1-0-'/2 (edlin_expand.erl, line 573)
     in call from edlin_expand:expand_function_type/6 (edlin_expand.erl, line 573)
     in call from edlin_expand:expand/3 (edlin_expand.erl, line 108)

Expected behavior

This behavior is not present in OTP 25. The shell should not crash due to an autocomplete error.

See output on OTP 25 for comparison:

1> edlin_expand:expand(lists:reverse("0:a(")).
{no,[],[]}

Affected versions

OTP 26.2.1 (and all other versions of OTP 26 as far as I've tested)

@potatosalad potatosalad added the bug Issue is reported as a bug label Jan 11, 2024
@potatosalad potatosalad changed the title OTP 26 shell edlin_expand crash with deeply nested autocomplete OTP 26 shell edlin_expand crash with invalid autocomplete Jan 11, 2024
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Jan 15, 2024
@garazdawi garazdawi linked a pull request Jan 31, 2024 that will close this issue
@garazdawi
Copy link
Contributor

Fixed in #8075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants