<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 14, 2019, at 11:49, b via libcxx-dev <<a href="mailto:libcxx-dev@lists.llvm.org" class="">libcxx-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-size: 14px;" class="">Hello everyone,</span><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">I am new to this list. I am writing because I think I might have caught a bug in libc++. What I hope to get is a quick assessment of my issue so that I know if I should file this as a bug or some hints in how I should proceed to gather more information or even rectify the issue on my end.</div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">The issue I am seeing popped up in a macOS project (Xcode 10.2.1) I am working on but I was able to condense it into a very small test program, see below for the code.</div><div style="font-size: 14px;" class=""><br class=""></div><div class=""><span style="font-size: 14px;" class="">The issue presents itself as a crash in shared_future::wait_for due to an uncatchable exception. The crash does not occur immediately but only after a (huge) number of calls. Console output in Xcode reads  "libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: condition_variable timed_wait failed: Invalid argument“. See backtrace further down for details. Unfortunately I cannot step into code of the method where the exception originates which is condition_variable::__do_timed_wait. I browsed the code in the libcxx repository and found that the error must be the result code EINVAL from a call to pthread_cond_timedwait.</span></div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">The interesting bit is that the issue can be reproduced in each test run within (mostly) less than 10 minutes on an iMac18,3/i7 and on a MacBookPro15,1/i7 but never on a MacBookPro15,2/i5. I only have one machine of each of those available so I cannot be sure how these results hold up.</div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">1. Is there something fundamentally wrong with my code, i.e. how I use the shared_future?</div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">2. Is this likely to be a bug in libc++ or is it more likely to be an issue with the BSD level API and/or the hardware? In case of the latter option where should I seek contact?</div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">3. I would like to be able to step into the code for condition_variable::__do_timed_wait and get the debugger info for the local variables. Would this be simply a matter of pulling the libcxx repository, building and linking it? I am not a command line compilation guy so I was hoping for some good documentation on how to do this with and for Xcode. However, if must be, I am willing to accept my fate.</div></div></div></blockquote><div><br class=""></div>In order to do that with 100% reproduceability, you'd have to build libc++ exactly the same way it was built for the platform you're running on, which is not easily achievable at the moment. I'll take a look.</div><div><br class=""></div><div>I'll try running this program overnight to reproduce:<div><div><br class=""></div><div><font face="Monaco" class="">   cat <<EOF | clang++ -xc++ - -std=c++17 && ./a.out</font></div><div><font face="Monaco" class="">   #include <future></font></div><div><font face="Monaco" class="">   #include <thread></font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class="">   using namespace std;</font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class="">   int main(int argc, const char * argv[]) {</font></div><div><font face="Monaco" class="">      promise<void> thePromise = promise<void> {};</font></div><div><font face="Monaco" class="">      shared_future<void> sharedFuture = thePromise.get_future().share();</font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class="">      thread anotherThread = thread( [sharedFuture]</font></div><div><font face="Monaco" class="">      {</font></div><div><font face="Monaco" class="">         int debugCount = 0;</font></div><div><font face="Monaco" class="">         while (sharedFuture.wait_for(100ns) == future_status::timeout)</font></div><div><font face="Monaco" class="">         {</font></div><div><font face="Monaco" class="">            debugCount++;</font></div><div><font face="Monaco" class="">         }</font></div><div><font face="Monaco" class="">      });</font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class="">      sharedFuture.wait();</font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class="">      return 0;</font></div><div><font face="Monaco" class="">   }</font></div><div><font face="Monaco" class="">   EOF</font></div><div><br class=""></div><div>However, it would be useful for me to know the OSes you've been able to reproduce it on.</div><div><br class=""></div><div>Thanks,</div><div>Louis</div><div class=""><br class=""></div></div></div></body></html>