-
Notifications
You must be signed in to change notification settings - Fork 3
Fix soundness bug on Multicursor #4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks @yjh0502. I'm a bit unhappy that there were so many formatting-only changes that it took some time to spot the actual changes you made. There are some things I'd have mentioned in this comment but I will do a proper code-review instead and annotate the patch. |
ptrs.push(ptr); | ||
} | ||
pub fn new(cursors: &'a [Cursor<'a>]) -> MultiCursor<'a> { | ||
use std::iter::FromIterator; |
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.
Is there a reason you put the FromIterator inclusion into the method itself?
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.
The trait is only used for the method, so I thought it's better to include the trait inside the method. We could also use cursors.into_iter().collect()
instead of Self::from_iter(cursors)
. Does it sound better?
let mut multi_cursor = MultiCursor::new(&cursors); | ||
let mut cursor1 = cursors[0].borrow_mut(); | ||
let mut cursor2 = cursors[1].borrow_mut(); | ||
let mut cursors = vec![db.cursor(), db.cursor()]; |
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.
This is so much better..
Is there a particular rustfmt configuration you used for the reformatted methods or did you do that manually? If it was for me I'd apply that formatting project-wide. |
I'll keep this pending for a few days to give @knutin the ability to chime in. |
Sorry for noisy patch. I should made seperated
|
Looks good, thanks for the patch @yjh0502! Maybe we should just remove the |
Yeah, sorry. I started this project when I had lots of opinions and little experience. These days I never customize |
MultiCursor is currently unsound because of wrong lifetime. For example following example crashes with use-after-free.
with valgrind output
I make following changes