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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Mojo Repl crashes after two tab presses #1796

Closed
TrevorMassey opened this issue Feb 23, 2024 · 5 comments
Closed

[BUG]: Mojo Repl crashes after two tab presses #1796

TrevorMassey opened this issue Feb 23, 2024 · 5 comments
Assignees
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.

Comments

@TrevorMassey
Copy link

TrevorMassey commented Feb 23, 2024

Bug description

Mojo Repl fails after pressing any whitespace followed by a tab

Steps to reproduce

Sample:

Welcome to Mojo! 馃敟

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1>  /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1060: std::vector::const_reference std::vector<lldb_private::Args::ArgEntry>::operator[](std::vector::size_type) const [_Tp = lldb_private::Args::ArgEntry, _Alloc = std::allocator<lldb_private::Args::ArgEntry>]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
[19001:19001:20240222,232147.505565:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[19001:19001:20240222,232147.505721:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
Aborted

I pressed spacebar, then tab, then it crashed.

Same issue occurs regardless of typing two tabs, or space then a tab, or 10 spaces then a tab, or if I write a function definition, which causes an auto-indent, then pressing tab.

Does NOT occur if the line contains any character other than whitespace. In this case, pressing tab causes autocomplete options to pop up, and does not crash.

Does NOT occur regardless of how many spaces I type. Only tabs cause the crash.

I suspect its a bug in autocomplete.

System information

- What OS did you do install Mojo on ?
WSL2 with Ubuntu 22.04.2 LTS
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 0.7.0 (af002202)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.5.0 (47924ae4)
@TrevorMassey TrevorMassey added bug Something isn't working mojo Issues that are related to mojo labels Feb 23, 2024
@Sharktheone
Copy link

Can confirm, but I get a different error, it fails to read a directory.

  1>  /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1060: std::vector::const_reference std::vector<lldb_private::Args::ArgEntry>::operator[](std::vector::size_type) const [_Tp = lldb_private::Args::ArgEntry, _Alloc = std::allocator<lldb_private::Args::ArgEntry>]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
[263032:263033:20240223,083737.339241:ERROR directory_reader_posix.cc:42] opendir /home/shark/.modular/crashdb/attachments/8b064724-175d-4793-a8d9-037585255ccd: No such file or directory (2)
[1]    263019 IOT instruction (core dumped)  mojo

@gryznar
Copy link
Contributor

gryznar commented Feb 23, 2024

@TrevorMassey this issue is missing a title in form: "[BUG] title"

@TrevorMassey TrevorMassey changed the title [BUG]: [BUG]: Mojo Repl crashes after two tab presses Feb 23, 2024
@ematejska ematejska added the mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. label Feb 27, 2024
@River707
Copy link
Collaborator

Thanks for reporting!

@walter-erquinigo This looks like a bug in LLDB, it crashes before we even get to our REPL code AFAICT, wonder if it just isn't prepared to handle empty lines?

@walter-erquinigo
Copy link
Contributor

Thanks for the report!
I was able to repro this on Linux. It works on MAC though. I'll try to get a fix soon.

@walter-erquinigo walter-erquinigo self-assigned this Feb 27, 2024
walter-erquinigo added a commit to walter-erquinigo/llvm-project that referenced this issue Feb 28, 2024
modularml/mojo#1796 discovered that if you try to complete a space-only line in the REPL on Linux, LLDB crashes. I suspect that editline doesn't behave the same way on linux and on darwin, because I can't replicate this on darwin.

Adding a boundary check in the completion code prevents the crash from happening.
walter-erquinigo added a commit to llvm/llvm-project that referenced this issue Feb 28, 2024
modularml/mojo#1796 discovered that if you try
to complete a space-only line in the REPL on Linux, LLDB crashes. I
suspect that editline doesn't behave the same way on linux and on
darwin, because I can't replicate this on darwin.

Adding a boundary check in the completion code prevents the crash from
happening.
@walter-erquinigo
Copy link
Contributor

The fix has landed in upstream LLDB and will be available in a future release of our SDK.
Cheers

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.
Projects
None yet
Development

No branches or pull requests

6 participants