2011-12-07 12 views
6

मैंने बस अपने यूबंटू 10.04 पर क्लैंग + llvm 3.0 संकलित और स्थापित किया है, और svn से libC++ भी स्थापित किया है। चूंकि libC++ में स्थिति थ्रेड समर्थन पूर्ण हो जाती है, इसलिए मैं std :: async को आजमा देना चाहता था। इसलिए मैंstd :: asangc clang 3.0 + libC++ में काम नहीं करता है?

http://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-8-futures-and-promises.html

में उदाहरण एंथनी विलियम्स द्वारा दिए गए का पालन करें और बस यह संकलन करने के लिए मामूली परिवर्तन कर:

#include <future> 
#include <iostream> 

int calculate_the_answer_to_LtUaE() 
{ 
    return 42; 
} 

void do_stuff() 
{ 
    std::cout << "doing stuff" << std::endl; 
} 

int main() 
{ 
    std::future<int> the_answer=std::async(calculate_the_answer_to_LtUaE); 
    do_stuff(); 
    std::cout<<"The answer to life, the universe and everything is " 
    <<the_answer.get()<<std::endl; 
} 

और मैं संकलन के साथ

बजना ++ --std = ग ++ 0x -stdlib = libC++ -lpthread async.cpp

हालांकि, यह कोर डंप के साथ चलता है और हमेशा समाप्त होता है:

सामान कर जीवन, ब्रह्मांड और सब कुछ का जवाब निरस्त किया जाता है (कोर फेंक दिया)

मैं कोर डंप की जाँच करें और इसे इस तरह ढेर (जो मैं काफी एक संकेत नहीं मिलता है)

से पता चलता
 
#0 0x00007fd0a1a7ba75 in raise() from /lib/libc.so.6 
#1 0x00007fd0a1a7f5c0 in abort() from /lib/libc.so.6 
#2 0x00007fd0a22a735b in std::exception_ptr::~exception_ptr (this=) at ../src/exception.cpp:130 
#3 0x0000000000404178 in void std::__1::__assoc_state::set_value(int&&)() 
#4 0x00000000004051ae in _ZNSt3__119__async_assoc_stateIiNS_12__async_funcIPFivEJEEEE9__executeEv() 
#5 0x0000000000404e00 in _ZNSt3__114__thread_proxyINS_5tupleIJMNS_19__async_assoc_stateIiNS_12__async_funcIPFivEJEEEEEFvvEPS7_EEEEEPvSC_() 
#6 0x00007fd0a250f9ca in start_thread() from /lib/libpthread.so.0 
#7 0x00007fd0a1b2e70d in clone() from /lib/libc.so.6 
#8 0x0000000000000000 in ??() 

किसी को भी एक विचार है क्यों?

+2

एक गर्भपात का अर्थ है कि एक दावा विफल हो गया है। लाइन 130 के पास अपवाद.cpp में assert() s को देखें। निरस्त करने और स्थानीय लोगों का विश्लेषण करने के लिए जीडीबी का उपयोग दृढ़ता से अनुशंसित किया जाता है। – moshbear

उत्तर

7

मैं पर ओएस एक्स शेर अपने उदाहरण भाग गया, का उपयोग करते हुए:

clang++ -std=c++0x -stdlib=libc++ async.cpp 

और कार्यक्रम उत्पादन:

doing stuff 
The answer to life, the universe and everything is 42 

libC++ का स्रोत निरीक्षण के रूप में moshbear की टिप्पणी ने सुझाव दिया मैं देख रहा हूँ:

exception_ptr::~exception_ptr() _NOEXCEPT 
{ 
#if HAVE_DEPENDENT_EH_ABI 
    __cxa_decrement_exception_refcount(__ptr_); 
#else 
    #warning exception_ptr not yet implemented 
    ::abort(); 
#endif // __APPLE__ 
} 

ऐसा लगता है कि ~exception_ptr() को उबंटू 10.04 पर पोर्ट नहीं किया गया है। यह पोर्टेबल सी ++ में लागू नहीं होने वाली निम्न-स्तरीय सुविधा है। इस स्तर के जीपीएल मुक्त कार्यान्वयन को बनाने पर काम libc++abi पर चल रहा है। मैं आपको आश्वस्त कर सकता हूं कि libC++ abi इस समय प्राइम टाइम के लिए तैयार नहीं है।

इस निम्न-स्तरीय पुस्तकालय में https://github.com/pathscale/libcxxrt पर भी एक स्वतंत्र प्रयास रहा है। मुझे इस पुस्तकालय की स्थिति नहीं पता है और न ही इसे उबंटू में भेज दिया गया है।

संबंधित मुद्दे