renestein / Rstein.AsyncCpp

The RStein.AsyncCpp library is a set of types that should be familiar for anyone who knows the Task Parallel Library (TPL) for .NET (C#).
MIT License
31 stars 4 forks source link

`dynamic atexit destructor for 'threadPool' #35

Closed lawabider closed 3 years ago

lawabider commented 3 years ago

I'm getting a weird exception / crash at end of runtime.

This console program produces it:

#include <RStein.AsyncCpp/Tasks/TaskCompletionSource.h>

int main()
{
        RStein::AsyncCpp::Tasks::TaskCompletionSource<__int64> _tCS;
}

I had never heard of atexit() before this, and it was quite confusing. Should I ignore this crashing? Is there a work-around?

Here is the call stack for the above:

>   [Inline Frame] FolderOpenerTestConsole.exe!std::thread::{dtor}() Line 95    C++
    [Inline Frame] FolderOpenerTestConsole.exe!std::destroy_at(std::thread * const) Line 325    C++
    [Inline Frame] FolderOpenerTestConsole.exe!std::_Default_allocator_traits<std::allocator<std::thread>>::destroy(std::allocator<std::thread> &) Line 721 C++
    [Inline Frame] FolderOpenerTestConsole.exe!std::_Destroy_range(std::thread * _First, std::thread * const) Line 950  C++
    [Inline Frame] FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::_Destroy(std::thread * _First, std::thread * _Last) Line 1680  C++
    [Inline Frame] FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::_Tidy() Line 1764  C++
    FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::~vector<std::thread,std::allocator<std::thread>>() Line 712   C++
    [Inline Frame] FolderOpenerTestConsole.exe!RStein::AsyncCpp::Schedulers::SimpleThreadPool::{dtor}() Line 35 C++
    FolderOpenerTestConsole.exe!`RStein::AsyncCpp::Schedulers::Scheduler::initDefaultScheduler'::`2'::`dynamic atexit destructor for 'threadPool''()    C++
    ucrtbase.dll!00007ffb4f4cbea0() Unknown
    ucrtbase.dll!00007ffb4f4cbdb7() Unknown
    ucrtbase.dll!00007ffb4f4cbd6d() Unknown
    ucrtbase.dll!00007ffb4f4ca17a() Unknown
    ucrtbase.dll!00007ffb4f4ca10f() Unknown
    ucrtbase.dll!00007ffb4f4ca0af() Unknown
    FolderOpenerTestConsole.exe!__scrt_common_main_seh() Line 295   C++
    kernel32.dll!00007ffb4f5e54e0() Unknown
    ntdll.dll!00007ffb5174485b()    Unknown
renestein commented 3 years ago

Hi @lawabider , what version of the library do you use? Current master branch, VS 2010, Release/Debug X64 configuration.

My console application.

#include "../RStein.AsyncCpp/Tasks/TaskCompletionSource.h"
int main()
{
        RStein::AsyncCpp::Tasks::TaskCompletionSource<__int64> _tCS;
}

Result. image

Related issue.

27

lawabider commented 3 years ago

Thanks; I've downloaded the code again and it's working now.