Date: Fri, 12 Aug 2022 09:54:19 -0700
On Friday, 12 August 2022 09:24:34 PDT David Carter via Std-Discussion wrote:
> Dear C++ Standards People,
>
> I just wanted to check a situation with you, about what the various
> standards say, if anything, about a threading situation I've come across
> recently.
>
> - C++11 with VC14
> - Using std::threads in a threadpool type application.
> - Works perfectly within GoogleTest but when loaded from a DLL in a
> application, it hangs.
DLLs are beyond the scope of the standard. That means you've technically
chosen the wrong mailing list for your question. This one is supposed to
discuss the standard.
I'm not just being pedantic. DLLs do require several extensions that go much
beyond the standard and create unexpected situations (more than shared
libraries on Unix systems). For example, pointers to __declspec(dllimport)
symbols are NOT constant expressions. They are resolved during the dynamic
initialisation step of the loading, SIOF (static initialisation order fiasco)
does apply to them.
> I know the standard can't cover all the implementation details, and it's
> always possible to write pathological code which will always break, but
> something like this seems pretty fundamental, providing I'm not breaking
> the standard here?
Nothing is wrong from the C++ standard. This is just how DLLs are and will
continue to be. There's absolutely nothing the standard will do, because
attempting to do so would have as much success as trying to convince people
the sky is green or the Sun is blue.
> Dear C++ Standards People,
>
> I just wanted to check a situation with you, about what the various
> standards say, if anything, about a threading situation I've come across
> recently.
>
> - C++11 with VC14
> - Using std::threads in a threadpool type application.
> - Works perfectly within GoogleTest but when loaded from a DLL in a
> application, it hangs.
DLLs are beyond the scope of the standard. That means you've technically
chosen the wrong mailing list for your question. This one is supposed to
discuss the standard.
I'm not just being pedantic. DLLs do require several extensions that go much
beyond the standard and create unexpected situations (more than shared
libraries on Unix systems). For example, pointers to __declspec(dllimport)
symbols are NOT constant expressions. They are resolved during the dynamic
initialisation step of the loading, SIOF (static initialisation order fiasco)
does apply to them.
> I know the standard can't cover all the implementation details, and it's
> always possible to write pathological code which will always break, but
> something like this seems pretty fundamental, providing I'm not breaking
> the standard here?
Nothing is wrong from the C++ standard. This is just how DLLs are and will
continue to be. There's absolutely nothing the standard will do, because
attempting to do so would have as much success as trying to convince people
the sky is green or the Sun is blue.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2022-08-12 16:54:21