Opened 7 years ago

Last modified 7 years ago

#11861 new Bugs

windows - Using boost thread crash winrt store app on start on Windows 10 Phone devices

Reported by: Mathieu <mvillegas@…> Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.60.0 Severity: Showstopper
Keywords: Cc:

Description

When using boost thread in a Windows 10 (UAP) store app on a phone device, the app can't be started (it works well on desktop computers).

How to reproduce the issue:

  • Build boost thread and date_time (date_time seems required to link) from the command line with: b2 --with-thread --with-date_time toolset=msvc-14.0 variant=debug link=static architecture=x86 windows-api=store cxxflags="/AIC:/winrt" Note that "C:/winrt" is a junction to "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\store\references" where platform.winmd is (since it seems required to build)
  • Create a Blank C++ Windows 10 Universal app using Visual studio 2015.
  • Edit Mainpage.xaml.cpp and add a call to boost::thread like: boost::thread workerThread(workerFunc); where "workerFunc" is whatever function you want. Add the required include file ( #include <boost/thread/thread.hpp> ). In the link option, add boost thread lib.
  • Now run the app in a phone emulator.
  • Result: the app will crash at load time.

This happens on real phones with arm CPU too (with boost built with option "architecture=arm"). This issue can't be reproduced on desktop computers using the same app built for the emulator. Just run the app on your locale machine and it will work.

Strange behavior we have found on Windows 10 phone emulator which may or may not help you in your investigation:

  • clean build the projet created above.
  • run it on the emulator => the app crashes at load time
  • comment the line with "boost::thread workerThread(workerFunc);"
  • run the app => the app doesn't crash and works as expected
  • uncomment the line, and run the app again (without rebuilding, just click on the "run" button) => the app starts, and the thread works. You are able to set a breakpoint and step into boost::thread constructor.
  • rebuild the project (clean build) and run the app: => the app crashes at load time.

I can't reproduce this strange behavior on real phones with arm CPU.

Change History (8)

comment:1 by viboes, 7 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

Hi, unfortunately I'm unable to reproduce the fault, as I don't have access to such environment. You will need to provide more information, analyze what happens using a debugger, ...

comment:2 by Mathieu <mvillegas@…>, 7 years ago

Hi, Actually, based on my knowledge, I can't debug the code.

In a 100% C++ app, the application crashes on load, before the debugger can attach to the process. I start with a "step in", and it crashes before it can break on the first line.

Using a C# app which load and uses the dll compiled with boost thread in it, it seems to crash when it loads the dll (the first time I access a managed C++ class of the DLL). If I debug native only, it porposes to break on the exception, and open the assembly code where it broke (in what look like the exception code (imp_RtlRaiseException@4)). The call stack to this exception is:

KernelBase.dll!_RaiseException@16()
msvcrt.dll__CxxThrowException@8()
coreclr.dll!6aa05ad9()
[Frames below may be incorrect and/or missing, no symbols loaded for coreclr.dll]
coreclr.dll!6a8dfc09()
coreclr.dll!6a9ef3f5()
[External Code]
coreclr.dll!6aaf30cf()
coreclr.dll!6a8c83f3()
coreclr.dll!6a8c8662()
coreclr.dll!6a9efe97()
coreclr.dll!6a9eff43()
coreclr.dll!6a9f0ae2()
mscorlib.ni.dll!6a2f272e()
mscorlib.ni.dll!6a2f28b4()
mscorlib.ni.dll!6a31dc84()
mscorlib.ni.dll!6a31dbfc()
[External Code]
mscorlib.ni.dll!6a441b29()
[External Code]
coreclr.dll!6aaf33cc()
[External Code]
coreclr.dll!6aaf33cc()
[External Code]

There is no reference to my own DLL which can't be loaded in this stack.

The app crash when the Cpp code is loaded, before "boost::thread workerThread(workerFunc);" is called, maybe because boost thread or one of the other libs used by boost thread ( chrono, date_time, regex or system) try to load a dll which doesn't exists, or because it tries to use a banned API. I've run microsoft test suite used to validate app for store, and it reported no call to a banned API. However, I don't know if test validate used dll and API for phones (it runs only on desktop environment), and if it checks all the dll dynamically loaded.

In the build command, I set compilation for store, but there is no specific parameter to say it is for Windows 10 (UAP) and not Windows 8.1 or 8.0. I tried to use the compile parameter "/D_WIN32_WINNT=0x0A00", but it seems it changes nothing. BOOST_WINAPI_VERSION_WIN10 is set to 0x0A00 in config.hpp, but it seems it is never used in boost.

I tried to build for Windows Phone with the parameter windows-api=phone, but it crashes the same way. Note that I had to remove the parameter /Zm800 in msvc.jam since it was not recognized.

This is where I am right now. If you have any suggestions regarding build parameters or ways to check a specific thing, I will be pleased to try them.

comment:3 by Mathieu <mvillegas@…>, 7 years ago

I've made a test, and it seems clear that the issue comes from a DLL not available on widows phone.
Here is a log from Visual Studio console:
'BoostThreadDemo.exe' (Win32): Loaded 'U:\SharedData\PhoneTools\AppxLayouts\ffec28b4-325a-4223-9b52-a54e8c5eb872VS.Debug_Win32.aaaaaa\BoostThreadDemo.exe'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\System32\kernel32legacy.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'U:\PROGRAMS\WINDOWSAPPS\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x868wekyb3d8bbwe\vccorlib140d_app.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'U:\PROGRAMS\WINDOWSAPPS\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x86
8wekyb3d8bbwe\msvcp140d_app.dll'. Symbols loaded.
The thread 0xcd0 has exited with code -1073741515 (0xc0000135).
The program '[3272] BoostThreadDemo.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.

Unfortunately, at this time, I don't know how to find which dll is not available on Phones.

As a comparison, here is the Visual studio console log when the same app is executed on the PC, where it works as expected:

'BoostThreadDemo.exe' (Win32): Loaded 'D:\BoostThreadDemo\Debug\BoostThreadDemo\AppX\BoostThreadDemo.exe'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x868wekyb3d8bbwe\vccorlib140d_app.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x86
8wekyb3d8bbwe\msvcp140d_app.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x868wekyb3d8bbwe\vcruntime140d_app.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.23506.0_x86
8wekyb3d8bbwe\ucrtbased.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptsp.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rsaenh.dll'. Symbols loaded.
The thread 0x3e14 has exited with code 0 (0x0).
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.UI.Xaml.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinTypes.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\BCP47Langs.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreMessaging.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ninput.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\iertutil.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\SHCore.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\twinapi.appcore.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\userenv.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Symbols loaded.
Exception thrown at 0x77413E28 (KernelBase.dll) in BoostThreadDemo.exe: 0x40080201: WinRT originate error (parameters: 0x8000000B, 0x00000040, 0x0088E920).
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\actxprxy.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\CoreUIComponents.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rmclient.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\rmclient.dll'
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvumdshim.dll'. Cannot find or open the PDB file.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\MrmCoreR.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvinit.dll'. Cannot find or open the PDB file.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.UI.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igd10iumd32.dll'. Cannot find or open the PDB file.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ncrypt.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntasn1.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file.
The thread 0x27ac has exited with code 0 (0x0).
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d2d1.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dcomp.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Users\MVILLE~1\AppData\Local\Temp\VisualStudio.XamlDiagnostics.ffec28b4-325a-4223-9b52-a54e8c5eb872_1.0.2.0_x86zdm4v6wyg95st\XamlDiagnostics.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Users\MVILLE~1\AppData\Local\Temp\VisualStudio.XamlDiagnostics.ffec28b4-325a-4223-9b52-a54e8c5eb872_1.0.2.0_x86
zdm4v6wyg95st\WindowsXamlDiagnosticsTap.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mscoree.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\DataExchange.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\threadpoolwinrt.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\directmanipulation.dll'. Symbols loaded.
The thread 0xf8c has exited with code 0 (0x0).
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\DWrite.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.Globalization.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.Graphics.dll'. Symbols loaded.
'BoostThreadDemo.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.Shell.ServiceHostBuilder.dll'. Symbols loaded.
The thread 0x242c has exited with code 0 (0x0).
The thread 0x3fcc has exited with code 0 (0x0).
The thread 0x3f04 has exited with code 0 (0x0).
The thread 0x3e1c has exited with code 0 (0x0).
The thread 0x1ac0 has exited with code 1 (0x1).
The thread 0x2cf0 has exited with code 1 (0x1).
The thread 0x3614 has exited with code 1 (0x1).
The thread 0x16d0 has exited with code 1 (0x1).
The thread 0x1f84 has exited with code 1 (0x1).
The thread 0x3208 has exited with code 1 (0x1).
The thread 0x33e4 has exited with code 1 (0x1).
The thread 0xe8 has exited with code 1 (0x1).
The thread 0x544 has exited with code 1 (0x1).
The thread 0x143c has exited with code 1 (0x1).
The thread 0x29ec has exited with code 1 (0x1).
The thread 0x2ba4 has exited with code 1 (0x1).
The thread 0x1f00 has exited with code 1 (0x1).
The thread 0x3618 has exited with code 1 (0x1).

comment:4 by Mathieu <mvillegas@…>, 7 years ago

It seems the issue comes from Windows UAP projects which by default link with default libs like ole32.lib which are note available on phones. It seems that using /NODEFAULTLIB:ole32.lib fixes the issue.

comment:5 by viboes, 7 years ago

Owner: changed from viboes to Niall Douglas
Status: assignednew
Summary: Using boost thread crash winrt store app on start on Windows 10 Phone deviceswindows - Using boost thread crash winrt store app on start on Windows 10 Phone devices

Niall could you help here?

comment:6 by Niall Douglas, 7 years ago

Niall could you help here?

The chances I can look at this any time in the next six months are extremely low, sorry. I no longer use the Boost libraries either at work nor outside work.

Niall

comment:7 by viboes, 7 years ago

Owner: changed from Niall Douglas to viboes

Thanks Niall for all your help fixing Boost.Thread on windows.

I will look for another Boost.Thread maintainer for windows. :(

comment:8 by viboes, 7 years ago

Please let me know if this is a regression.

Note: See TracTickets for help on using tickets.