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

FastText struct shouldn't implement clone #9

Closed
caio opened this issue Feb 6, 2022 · 1 comment
Closed

FastText struct shouldn't implement clone #9

caio opened this issue Feb 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@caio
Copy link

caio commented Feb 6, 2022

Hello,

First of all, thanks a lot for your work on this crate!

Cloning doesn't play well with the custom drop logic, it's better to remove the Clone bit from derive and let users share it via Arc/Rc I think, otherwise this can easily happen:

use fasttext::FastText;

fn main() {
    let mut ft = FastText::new();
    ft.load_model("cooking.model.bin").unwrap();

    let cloned = ft.clone();
    drop(cloned);

    // boom!
    ft.is_quant();
}

Running it causes a 'cargo run' terminated by signal SIGSEGV (Address boundary error)

@messense
Copy link
Owner

messense commented Feb 7, 2022

Thanks for reporting.

@messense messense added the bug Something isn't working label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants