boost::wave::context deadlocks when called from a DLL

Hi all,
I'm having some issue with boost::wave::context: I have a function
called PreProcessSource, which allocates a boost::wave::context and
does some preprocessing; nothing fancy at all.
std::string PreProcessSource(const std::string& instring, const
std::string& defines)
{
typedef boost::wave::cpplexer::lex_token<> token_type;
typedef boost::wave::cpplexer::lex_iterator

On Wed, Jun 20, 2012 at 9:39 PM, Julien Lebot
Here is the (cleaned up) stack trace of the deadlock:
ntdll.dll!0000000076dc135a() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] KernelBase.dll!000007fefd4f10dc() Nitro.dll!boost::call_once
(boost::once_flag & flag, void (void)* f) Line 197 + 0x18 bytes C++ Nitro.dll!boost::call_once(void (void)* func, boost::once_flag & flag) Line 28 C++ It seems boost::wave is trying to parse some time stamp, and by doing so instantiates a grammar and that's when things seem to go bad.
The deadlock happens inside the constructor of the context type, and the Visual Studio debugger points me to line 197 in boost\thread\win32\once.hpp
BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( event_handle,::boost::detail::win32::infinite));
It seems that call_once is not re-entrant; at least not in Win32, as indicated by the following ticket: https://svn.boost.org/trac/boost/ticket/3407 Any ideas on how to work around that issue ? Best Regards, Julien Lebot

On Wed, Jun 20, 2012 at 9:39 PM, Julien Lebot
wrote: Here is the (cleaned up) stack trace of the deadlock:
ntdll.dll!0000000076dc135a() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] KernelBase.dll!000007fefd4f10dc() Nitro.dll!boost::call_once
(boost::once_flag & flag, void (void)* f) Line 197 + 0x18 bytes C++ Nitro.dll!boost::call_once(void (void)* func, boost::once_flag & flag) Line 28 C++ It seems boost::wave is trying to parse some time stamp, and by doing so instantiates a grammar and that's when things seem to go bad.
The deadlock happens inside the constructor of the context type, and the Visual Studio debugger points me to line 197 in boost\thread\win32\once.hpp
BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject(
event_handle,::boost::detail::win32::infinite));
It seems that call_once is not re-entrant; at least not in Win32, as indicated by the following ticket: https://svn.boost.org/trac/boost/ticket/3407 Any ideas on how to work around that issue ?
Do you have a minimal test-case reproducing the problem? Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu

On Sat, Jun 23, 2012 at 6:19 PM, Hartmut Kaiser
Do you have a minimal test-case reproducing the problem?
I certainly tried; and through that process I've discovered that initializing DirectX is crucial to make the problem appear. I think call_once is working just fine, like the bug report says and I fixed my problem by adding a 3rd DLL that only hosts the preprocess function. Thanks again for you time. Best Regards, Julien Lebot
participants (2)
-
Hartmut Kaiser
-
Julien Lebot