alexcrichton/tokio-curl

Segfault on tokio-curl Session::Perform

Opened this issue · 3 comments

mgild commented

Stack trace posted below.

It seems on quick, consecutive calls to Session::perform, it is possible that the underlying curl library may close a session while trying to access the connection handlers.
bt.txt

Thanks for the report! Would you be able to post a way to reproduce this as well?

mgild commented

Sure thing, this will reproduce the issue within a few minutes:

dependencies:
curl = "0.4.22"
futures = "0.1.26"
tokio = "0.1"
tokio-core = "0.1.17"
tokio-curl = "0.1.11"

Source code:

use curl::easy::Easy;
use futures::future::{lazy, ok, Future};
use std::thread;
use std::time::Duration;
use tokio_core::reactor::Core;
use tokio_curl::Session;

fn main() {
    let mut lp = Core::new().unwrap();
    let session = Session::new(lp.handle());
    thread::spawn(move || {
        tokio::run(lazy(move || {
            tokio::spawn(lazy(move || {
                loop {
                    thread::sleep(Duration::from_millis(25));
                    let session = session.clone();
                    tokio::spawn(lazy(move || {
                        let mut req = Easy::new();
                        req.get(true).unwrap();
                        req.url("https://www.google.com").unwrap();
                        session
                            .perform(req)
                            .map(move |_| {
                                println!("received");
                            })
                            .map_err(|e| {
                                println!("error, {}", e);
                            })
                    }));
                }
                ok(())
            }));
            Ok(())
        }));
    });
    loop {
        lp.turn(Some(Duration::new(1, 0)));
    }
}

Thanks! Unfortuantely nothing jumps out at me. The best way to get this fixed (if you're interested) is likely to keep reducing it, ideally without tokio entirely and only with the curl crate, and then perhaps without than and just as a C program.