Opened 8 years ago

Closed 7 years ago

#10657 closed Bugs (wontfix)

Win32 first time call to GetTimeZoneInformation crashes in launched coroutines

Reported by: vinnie.falco@… Owned by: olli
Milestone: To Be Determined Component: coroutine
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

When an application's first call GetTimeZoneInformation is from a launched coroutine, an unhandled exception is generated. A workaround is to call GetTimeZoneInformation at least once before launching any coroutines. This sample program compiles under Visual Studio and crashes:

#define _WIN32_WINNT 0x6000
#include <boost/asio/io_service.hpp>
#include <boost/asio/spawn.hpp>
#include <functional>
#include <Windows.h>

TIME_ZONE_INFORMATION tzi;

void die(boost::asio::yield_context yield)
{
    GetTimeZoneInformation(&tzi);
}

int main()
{
    // Uncommenting the following line eliminates the crash
    //GetTimeZoneInformation(&tzi);

    boost::asio::io_service ios;
    boost::asio::spawn (ios,
        std::bind (&die, std::placeholders::_1));
    ios.run();
}

Change History (3)

comment:1 by vinnie.falco@…, 8 years ago

Stack:

KernelBase.dll!TlsGetValue
KernelBase.dll!BaseGetProcessDllPath
KernelBase.dll!LoadLibraryExW
KernelBase.dll!ConvertTimeZoneMuiString
KernelBase.dll!ConvertTimeZoneMuiStrings
KernelBase.dll!GetTimeZoneInformation
sandbox.exe!die(boost::asio::basic_yield_context<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand,void (__cdecl*)(void),boost::asio::detail::is_continuation_if_running> > yield) Line 12	C++
sandbox.exe!boost::asio::detail::coro_entry_point<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand,void (__cdecl*)(void),boost::asio::detail::is_continuation_if_running>,std::_Bind<1,void,void (__cdecl*const)(boost::asio::basic_yield_context<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand,void (__cdecl*)(void),boost::asio::detail::is_continuation_if_running> >),std::_Ph<1> & __ptr64> >::operator()(boost::coroutines::pull_coroutine<void> & ca) Line 257	C++
sandbox.exe!boost::coroutines::detail::push_coroutine_object<boost::coroutines::pull_coroutine<void>,void,boost::asio::detail::coro_entry_point<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand,void (__cdecl*)(void),boost::asio::detail::is_continuation_if_running>,std::_Bind<1,void,void (__cdecl*const)(boost::asio::basic_yield_context<boost::asio::detail::wrapped_handler<boost::asio::io_service::strand,void (__cdecl*)(void),boost::asio::detail::is_continuation_if_running> >),std::_Ph<1> & __ptr64> > & __ptr64,boost::coroutines::basic_standard_stack_allocator<boost::coroutines::stack_traits> >::run() Line 306	C++
 	[External Code]	

comment:2 by anonymous, 8 years ago

I believe GetTimeZoneInformation calls LoadLibraryEx which calls BaseGetProcessDllPath which dies in TlsGetValue. TlsGetValue can die if the TLS slot is uninitialized.

comment:3 by olli, 7 years ago

Resolution: wontfix
Status: newclosed

Unfortunately I got the info from Microsoft that some parts of the TIB have to be swapped during context switch too - but Microsoft refused to share which parts.

Note: See TracTickets for help on using tickets.