[llvm-bugs] [Bug 30376] New: std::promise/future deadlock

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 13 23:09:37 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30376

            Bug ID: 30376
           Summary: std::promise/future deadlock
           Product: libc++
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vrba at mixedrealities.no
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

The bug happens with "Apple LLVM 7.0.0" (clang 7) on OSX 10.11.1 (El Capitan)
with XCode 7.0.1. The program below will write out a series of numbers and
after a short while hang, whereas it shouldn't. It runs flawlessly on Linux.

#include <iostream>
#include <thread>
#include <future>
#include <boost/asio.hpp>

using std::cout;
using std::endl;

static boost::asio::io_service io;

static void asio_thread()
{
    boost::asio::io_service::work work(io);
    cout << "STARTING ASIO" << endl;
    io.run();
    cout << "STOPPING ASIO" << endl;
}

static int poll()
{
  static int n;

  std::promise<int> promise;
  auto fut = promise.get_future();

  io.post([&promise]() {
    promise.set_value(n++);
  });

  return fut.get();
}

int main()
{
  std::thread thread(asio_thread);

  size_t n = 0;

  while (1)
    cout << "POLL: " << poll() << "\n";

  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160914/fac1ee5a/attachment-0001.html>


More information about the llvm-bugs mailing list