-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I'm seeing crashes on MacOS Catalina (10.15.3) with Rust 1.43.1. This happens in the original clipboard crate as well, but since that seems unmaintained I'm reporting it here.
You can reproduce the crash by running cargo test in my fork.
You may need to run it a few times, but you will get different errors such as:
failing-517cc89e9cb2a459(35714,0x70000ebe5000) malloc: *** error for object 0x7f8eb170a6e0: pointer being freed was not allocated
failing-517cc89e9cb2a459(35714,0x70000ebe5000) malloc: *** set a breakpoint in malloc_error_break to debug
Or:
failing-517cc89e9cb2a459(35969,0x700000ae7000) malloc: Double free of object 0x7fe935c10a50
failing-517cc89e9cb2a459(35969,0x700000ae7000) malloc: *** set a breakpoint in malloc_error_break to debug
I'm unfortunately no MacOS developer so I have no idea what causes this, but it only seems to occur when I'm accessing the clipboard from both my test code and my regular (under test) code, like in some_other_fn in the code below. Moving the ClipboardContext to a shared static using something like lazy_static! does not help.
The test is fairly simple:
use copypasta::{ClipboardContext, ClipboardProvider};
fn some_other_fn() {
let mut ctx = ClipboardContext::new().unwrap();
ctx.get_contents().unwrap();
}
#[cfg(test)]
mod tests {
use super::*;
fn clear_clipboard() {
let mut clipboard: ClipboardContext = ClipboardContext::new().unwrap();
clipboard.set_contents("".into()).unwrap();
}
#[test]
fn foo() {
clear_clipboard();
let mut ctx = ClipboardContext::new().unwrap();
ctx.set_contents("Dummy".into()).unwrap();
ctx.get_contents().unwrap();
some_other_fn();
}
#[test]
fn bar() {
clear_clipboard();
let mut ctx = ClipboardContext::new().unwrap();
ctx.set_contents("Dummy".into()).unwrap();
ctx.get_contents().unwrap();
some_other_fn();
}
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working