имела мысль, что ему есть чем заняться с использованием std :: exception_ptr , поскольку я рефактировал какой -то код, чтобы использовать его до того, как сбой начал произойти
, мне удалось воспроизвести аналогичный сбой, используя следующий код, но только при использовании Malloctype = Debug mallocdebug = postfree_checking
Код: Выделить всё
#include
#include
#include
#include
#include
std::future GetExceptionFromDeadThread()
{
return std::async(std::launch::async, []() {
try
{
throw std::invalid_argument("Some string long enough to allocate on the heap? ");
}
catch (...)
{
return std::current_exception();
}
});
}
int main()
{
try
{
constexpr size_t numThreads(100);
std::vector futures;
while (true)
{
for (size_t i = 0; i < numThreads; ++i)
{
futures.push_back(GetExceptionFromDeadThread());
}
while (!futures.empty())
{
auto& future(futures.back());
future.wait();
try
{
std::rethrow_exception(future.get());
}
catch (std::invalid_argument&)
{
std::fputs(".", stdout);
}
catch (...)
{
std::fprintf(stderr, "'std::rethrow_exception(future.get())' threw unexpected exception");
abort();
}
futures.pop_back();
}
}
}
catch (...)
{
std::fprintf(stderr, "Caught unexpected exception");
abort();
}
}
< /code>
Я собираю программу, используя команду xlclang ++ -std = c ++ 11 -d_reentrant -qfullpath -qmaxmem = -1 -q32 -qroconst -dndebug -o2 -g test8.cpp Код: Выделить всё
bash-5.2$ xlclang++ --version
IBM XL C/C++ for AIX, V16.1.0 (5725-C72, 5765-J12)
Version: 16.01.0000.0010
bash-5.2$ MALLOCTYPE=debug MALLOCDEBUG=postfree_checking ./a.out
.Segmentation fault (core dumped)
bash-5.2$ dbx ./a.out core
Type 'help' for help.
[using memory image in core]
reading symbolic information ...
Segmentation fault in __cxa_end_catch at 0xd0ead49c ($t1)
0xd0ead49c (__cxa_end_catch+0x1fc) 801e003c lwz r0,0x3c(r30)
(dbx) where
__cxa_end_catch() at 0xd0ead49c
main(), line 46 in "test8.cpp"
(dbx)
Кто -нибудь видит любой вид ub /ошибки в моем коде, которые «оправдывают» этот сбой?
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-xlclang
Мобильная версия