-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make linenoise safe & various improvements to extra::rl #9096
Conversation
unsafe { | ||
// hasn't been called before: initialise the lock. | ||
// XXX: probably incorrect wrt races. | ||
rl_lock = Some(Mutex::new()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd guess this is wrong, since it's too late for me to actually work if this is correct/what is the correct solution.
Indeed this initialization is racy and it also leaks the To fix this without doing #9105 first I'd suggest creating some C++ helper functions in rust_builtins.cpp, like |
Hm, this appears to be wrong (tab completion in rusti double-locks the mutex and makes it abort); deleted the r+, will investigate later. |
Ok, deadlock resolved. |
- Removes a layer of indirection in the storage of the completion callback. - Handles user tab completion in a task in which `complete` hasn't been properly. Previously, if `complete` was called in one task, and `read` called in another, attempting to get completions would crash. This makes the completion handlers non-ambiguously task-local only. - Fix a mismatch in return values between the Rust code and linenoise.
This test has to be run by a human, to check inputs etc. Fortunately, it won't bitrot (syntactically, or type-check-ly; it might bitrot semantically), as it is designed so that the test runner compiles it with `--cfg robot_mode`, which is used to disable the actual running of code.
- Wrap calls into linenoise in a mutex so that the functions don't have to be `unsafe` any more (fixes #3921) - Stop leaking every line that linenoise reads. - Handle the situation of `rl::complete(some_function); do spawn { rl::read(""); }` which would crash (`fail!` that turned into an abort, possibly due to failing with the lock locked) when the user attempted to tab-complete anything. - Add a test for the various functions; it has to be run by hand to verify anything works, but it won't bitrot.
…arth Fix `needless_borrow` 9095 fixes rust-lang#9095 changelog: Don't lint `needless_borrow` on method receivers when it would change which trait impl is called
unsafe
any more (fixes std::rl is unsafe #3921)rl::complete(some_function); do spawn { rl::read(""); }
which would crash (fail!
that turned into an abort, possibly due to failing with the lock locked) when the user attempted to tab-complete anything.