Fixed the segfault. Still a problem though. The program hangs and never finishes executing. I think it has to do with future->result never getting updated and always being null, so in future_get() it ends up in an infinite loop.