« first day (888 days earlier)      last day (1948 days later) » 

4:31 AM
std::cout << "INPUT\n" << std::endl;
        for (int i = 0; i < num; i++) {
            std::cout << "CREATE\n" << std::endl;
            threads.emplace_back([] {
                std::cout << "THREAD A\n" << std::endl;
            });
        }
        std::cout << "OUTPUT\n" << std::endl;
If I remove threads.emplace_back, OUTPUT gets printed. Otherwise, only INPUT and CREATE is printed and then it's stuck.
What could make threads.emplace_back([]{}); get stuck?
 
5:28 AM
Welp, you understand that std threads need to be joined right?
Anyways at the end you need this: for (auto& thread: threads){thread.join();}
Mostly likely your program is not dying before the threads are std::cout -ing
 
 
9 hours later…
2:41 PM
@Mikhail it's a plugin for a server and the server keeps running unless asked to be shutdown
the server single-threaded and the code which I sent above is running in that thread
it seems to freeze it
even if it was a separate program, I should still expect to see OUTPUT before it quits (it's UB but I think this is what should mostly happen)
full code ^
and it freezes while constructing fixed_thread_pool object (gist.github.com/YashasSamaga/…)
the server prints that it's loading the plugin and then it never progresses forward
the CPU usage is also near 0%
I have VS17 but I don't know how to use it to debug this kind of problem
I tried attaching the debugger to the server but then I don't know how to make the debugger tell what the program is currently doing
 
3:05 PM
I added a breakpoint at the cout inside the thread and it's never being hit
 
3:18 PM
is there a problem if threads are created as the DLL is being loaded?
the threads are being created inside a constructor of a global object
 
3:33 PM
@Mikhail join actually fixed it but I don't understand why
the main thread keeps running
actually I'm not sure about anything now
there is an executable (abc.exe) and it loads some DLLs
in one of the DLLs, there is a constructor which creates threads
if it isn't joined (or detached I think), it gets stuck
10
Q: Creating a thread in DllMain?

soldIt seems that when a thread is created from within DllMain upon DLL_PROCESS_ATTACH it won't begin until all dll's have been loaded. Since I need to make sure the thread runs before I continue, I get a deadlock. Is there any way to force the thread to start?

 
3:56 PM
actually the join did not fix
it got fixed after I moved the thread creation out of the constructor
 
 
3 hours later…
jww
6:51 PM
Hi Everyone. A quick question on internal linkage. Is namespace A { namespace { int c=22; } } and then namespace B { namespace { int c=55; } } a common pattern? c should not cross-pollinate or escape the TU. A single source file is being used due to some related requirements.
 
 
1 hour later…
8:20 PM
@Yashas if std::threads aren't joined they will throw an exception on destruction. Now your case had tow problems. First, your main thread exited before the threads printed. Second, you destroyed the threads without joining them, so technically at the end of main, you threw an exception. To ensure the threads actuality run, you need to wait until they have terminated.
 

« first day (888 days earlier)      last day (1948 days later) »