-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Segfault when using dynamic_lib #8189
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
Comments
I think this has to do with dtors and Result, because I am getting similar issues working on rust-zmq |
As another, smaller, example: use std::libc;
fn main() {
let context = zmq::Context::new();
let responder = match context.socket(zmq::REP) {
Ok(x) => x,
Err(x) => fail!("%?", x)
};
let x = responder.bind("tcp://*:5555");
error!("%? %?", responder, x);
let x = x.unwrap();
let mut buf = [0, ..10];
loop {
unsafe { responder.recv_into(buf, 0) };
println("Received Hello");
responder.send(bytes!("Hello"), 0);
unsafe { libc::sleep(1) };
}
} works correctly (the socket destructor isn't called early), but use std::libc;
fn main() {
let context = zmq::Context::new();
let responder = match context.socket(zmq::REP).get();
let x = responder.bind("tcp://*:5555");
error!("%? %?", responder, x);
let x = x.unwrap();
let mut buf = [0, ..10];
loop {
unsafe { responder.recv_into(buf, 0) };
println("Received Hello");
responder.send(bytes!("Hello"), 0);
unsafe { libc::sleep(1) };
}
} doesn't (the destructor is called during/immediately after the |
Actually, the problem with the zmq example was with a misplaced |
I actually already figured out the problem, and will be sending a pull request along shortly. Basically, the problem is that the |
@sstewartgallus you are awesome 💓 |
Fixed with #8219 |
I have re-tested the original issue with the latest master (dc48adc) I confirm this issue is fixed and can be closed |
See https://gist.github.com/cmr/82459f5715e673a8e90f. The destructor seems to be called before the constructor ever returns.
@sstewartgallus
The text was updated successfully, but these errors were encountered: