имела мысль, что ему есть чем заняться с использованием 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 /ошибки в моем коде, которые «оправдывают» этот сбой?
Код: Выделить всё
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................Segmentation fault (core dumped)
You have new mail in /usr/spool/mail/bamboo
bash-5.2$ dbx ./a.out core
Type 'help' for help.
[using memory image in core]
reading symbolic information ...
warning: Unable to access address 0x2ff21d50 from core
Segmentation fault in extend_brk at 0xd01105c4 ($t1)
0xd01105c4 (extend_brk+0x2c4) 90040004 stw r0,0x4(r4)
(dbx) where
extend_brk(internal error: assertion failed at line 3915 in file frame.c
??, internal error: assertion failed at line 3915 in file frame.c
??, internal error: assertion failed at line 3915 in file frame.c
??) at 0xd01105c4
(dbx)
< /code>
Какого черта? Как у него заканчивается память? (И тьфу @ как buggy dbx Редактировать 2: запуск снова после выполнения экспорта ldr_cntrl = maxdata = 0x80000000 (делал это раньше, когда тестирование с фактической программой сбоя), не видел еще одного аварии, но очень странно, что использование памяти вообще будет расти? (... std :: async потоки выходят слишком медленно?) Br />
Код: Выделить всё
stopped in _event_sleep at 0xd0573254 ($t1)
0xd0573254 (_event_sleep+0x4f4) 80410014 lwz r2,0x14(r1)
(dbx) where
_event_sleep(??, ??, ??, ??, ??, ??) at 0xd0573254
_event_wait(??, ??) at 0xd0573f3c
_cond_wait_local(??, ??, ??) at 0xd05835dc
_cond_wait(??, ??, ??) at 0xd0583ef4
pthread_cond_wait(??, ??) at 0xd058494c
condition_variable.std::__1::condition_variable::wait(std::__1::unique_lock&)(??, ??) at 0xd09f2eac
future.std::__1::promise::set_exception_at_thread_exit(std::exception_ptr)._ZNSt3__117__assoc_sub_state10__sub_waitERNS_11unique_lockINS_5mutexEEE@AF111_20(??, ??) at 0xd09f99a8
std::__1::__assoc_sub_state::wait()(??) at 0xd09f7a28
std::__1::__async_assoc_state::__on_zero_shared()(this = 0x42242282), line 992 in "future"
test8.std::__1::future std::__1::__make_async_assoc_state(std::__1::__async_func&&)(__f = @0x30013418), line 3440 in "memory"
unnamed block in std::__1::future std::__1::async(std::__1::launch, GetExceptionFromDeadThread()::$_0&&)(__policy = async, __f = &(...)), line 2220 in "type_traits"
std::__1::future std::__1::async(std::__1::launch, GetExceptionFromDeadThread()::$_0&&)(__policy = async, __f = &(...)), line 2220 in "type_traits"
unnamed block in main(), line 9 in "test8.cpp"
unnamed block in main(), line 9 in "test8.cpp"
unnamed block in main(), line 9 in "test8.cpp"
main(), line 9 in "test8.cpp"
(dbx) thread
thread state-k wchan state-u k-tid mode held scope function
>$t1 run blocked 33360255 k no sys _event_sleep
$t2148206 terminated 36507643 no sys
$t7220275 terminated 123211641 no sys
$t10994266 terminated 15139439 no sys
(dbx) q
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-xlclang
Мобильная версия