mirror of
https://github.com/Chuyu-Team/VC-LTL5.git
synced 2026-10-17 05:07:02 +08:00
Bug #49, msvcrt模式_beginthread创建的线程无法获取ptd
This commit is contained in:
@@ -139,7 +139,7 @@ jobs:
|
||||
$Env:PROCDUMP_PATH="$Env:GITHUB_WORKSPACE\Tools"
|
||||
|
||||
# 编译单元测试项目
|
||||
&msbuild UnitTest\UnitTest.vcxproj "-p:Configuration=Dynamic;Platform=Win32;SolutionDir=$Env:GITHUB_WORKSPACE\\"
|
||||
&msbuild UnitTest\UnitTest.vcxproj "-p:Configuration=Static;Platform=Win32;SolutionDir=$Env:GITHUB_WORKSPACE\\"
|
||||
if($lastexitcode -ne 0)
|
||||
{
|
||||
throw "单元测试编译失败!退出代码:$lastexitcode"
|
||||
@@ -147,7 +147,7 @@ jobs:
|
||||
|
||||
$RunFaild = 0
|
||||
|
||||
&vstest.console Dynamic\UnitTest.dll "/logger:trx;LogFileName=UnitTest.trx" --Parallel "/Blame:CollectDump;CollectAlways=false;DumpType=full"
|
||||
&vstest.console Static\UnitTest.dll "/logger:trx;LogFileName=UnitTest.trx" --Parallel "/Blame:CollectDump;CollectAlways=false;DumpType=full"
|
||||
if($lastexitcode -ne 0)
|
||||
{
|
||||
$RunFaild = 1
|
||||
@@ -217,9 +217,9 @@ jobs:
|
||||
path: |
|
||||
TestResults/**/*.dmp
|
||||
TestResults/**/Sequence_*.xml
|
||||
Dynamic\UnitTest.dll
|
||||
Dynamic\UnitTest.pdb
|
||||
Dynamic\*.log
|
||||
Static\UnitTest.dll
|
||||
Static\UnitTest.pdb
|
||||
Static\*.log
|
||||
UnitTest/SymbolBuildTest/.test/**/Build.log
|
||||
*.7z
|
||||
|
||||
|
||||
+5
-2
@@ -39,13 +39,16 @@
|
||||
</Target>
|
||||
|
||||
<Import Project="$(VCInstallDir)\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
|
||||
|
||||
<Target Name="Build">
|
||||
|
||||
<Target Name="DownloadTools" BeforeTargets="Build;PackRedist">
|
||||
<!--下载LibMaker-->
|
||||
<DownloadFile
|
||||
Condition="!Exists('$(MSBuildThisFileDirectory)Tools\LibMaker.exe')"
|
||||
SourceUrl="https://github.com/Chuyu-Team/LibMaker/releases/download/v1.0.2/LibMaker.exe"
|
||||
DestinationFolder="$(MSBuildThisFileDirectory)Tools" DestinationFileName="LibMaker.exe"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="Build">
|
||||
|
||||
<!--提取所有需要编译的配置-->
|
||||
<MSBuild Projects="%(ProjectReferenceWork.Identity)" StopOnFirstFailure="True" Properties="_GetProjectAllConfiguration=true;ForceImportAfterCppTargets=$(MSBuildThisFileFullPath)" Targets="_GetProjectAllConfiguration">
|
||||
|
||||
@@ -1489,23 +1489,70 @@ __declspec(dllimport) void __cdecl _amsg_exit(
|
||||
|
||||
__acrt_ptd* __cdecl __acrt_getptd_head(void);
|
||||
#ifdef __BuildWithMSVCRT
|
||||
__forceinline __acrt_ptd* __cdecl __acrt_getptd_noexit(void)
|
||||
__declspec(noinline) __inline __acrt_ptd* __cdecl __acrt_getptd_noexit(void)
|
||||
{
|
||||
__acrt_ptd* ptd = (__acrt_ptd*)(((unsigned char*)_errno()) - FIELD_OFFSET(__acrt_ptd, _terrno));
|
||||
// ptd->_thandle 一共有3中情况:
|
||||
// 当 _thandle = -1,这表明此线程的ptd通过msvcrt.dll _beginthreadex 或者 __getptd_noexit 创建。
|
||||
// 当 _thandle = 0,这表明此线程的ptd通过msvcrt.dll的DllMain创建。
|
||||
// 当 _thandle = 其他,这可能是通过_beginthread启动的线程,它是实际有效的线程句柄。但是也有可能是内存申请失败了。
|
||||
|
||||
/*
|
||||
当 _thandle = -1,这表明此线程的ptd通过msvcrt.dll begin_thread 或者 __getptd_noexit 创建。
|
||||
当 _thandle = 0,这表明此线程的ptd通过msvcrt.dll的DllMain创建。
|
||||
当 _thandle = 其他,这表明msvcrt.dll内部内存已经申请失败。
|
||||
*/
|
||||
return (ptd->_thandle == (uintptr_t)-1/*Current Thread Handle*/ || ptd->_thandle == 0) ? ptd : (__acrt_ptd*)NULL;
|
||||
// 我们不要再根据 ptd->_thandle 判断__getptd_noexit 内存是否申请失,因为我们必须考虑 _beginthread 创建的线程。
|
||||
// 这时必须借助GetThreadId,可是它开销是惊人的,不容易做到快速判断。
|
||||
// 结合总总情况,我们现在通过判断 _errno() 返回地址是否在msvcrt模块范围来判断 __getptd_noexit 是否发生内存申请失败。
|
||||
// 具体Bug请参考:https://github.com/Chuyu-Team/VC-LTL5/issues/49
|
||||
typedef struct _DllAddressInfo
|
||||
{
|
||||
uintptr_t uBaseAddress;
|
||||
uintptr_t uEndAddress;
|
||||
} DllAddressInfo;
|
||||
|
||||
static DllAddressInfo s_DllAddressCache;
|
||||
|
||||
if (s_DllAddressCache.uBaseAddress == 0)
|
||||
{
|
||||
DllAddressInfo _DllAddressInfo = { (uintptr_t)-1, (uintptr_t)-1};
|
||||
MEMORY_BASIC_INFORMATION _BaseInfo;
|
||||
if (VirtualQuery(&_amsg_exit, &_BaseInfo, sizeof(_BaseInfo)))
|
||||
{
|
||||
_DllAddressInfo.uBaseAddress = (uintptr_t)_BaseInfo.AllocationBase;
|
||||
_DllAddressInfo.uEndAddress = (uintptr_t)_BaseInfo.BaseAddress + _BaseInfo.RegionSize;
|
||||
|
||||
for (; VirtualQuery((void*)(_DllAddressInfo.uEndAddress + 1), &_BaseInfo, sizeof(_BaseInfo));)
|
||||
{
|
||||
if (_DllAddressInfo.uBaseAddress != (uintptr_t)_BaseInfo.AllocationBase)
|
||||
break;
|
||||
|
||||
_DllAddressInfo.uEndAddress = (uintptr_t)_BaseInfo.BaseAddress + _BaseInfo.RegionSize;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_X86_) || defined(_ARM_)
|
||||
static_assert(sizeof(s_DllAddressCache) == sizeof(LONGLONG), "");
|
||||
InterlockedCompareExchange64((volatile LONGLONG*)&s_DllAddressCache, *(LONGLONG*)&_DllAddressInfo, 0);
|
||||
#elif defined(_IA64_) || defined(_AMD64_) || defined(_ARM64_)
|
||||
// AMD 早期不支持 InterlockedCompareExchange128,所以不用……
|
||||
InterlockedCompareExchange64((volatile LONGLONG*)&s_DllAddressCache.uEndAddress, _DllAddressInfo.uEndAddress, 0);
|
||||
InterlockedCompareExchange64((volatile LONGLONG*)&s_DllAddressCache.uBaseAddress, _DllAddressInfo.uBaseAddress, 0);
|
||||
#else
|
||||
#error unsrpport!
|
||||
#endif
|
||||
}
|
||||
|
||||
uintptr_t _p_errno_value = (uintptr_t)_errno();
|
||||
if (_p_errno_value == 0 || (s_DllAddressCache.uBaseAddress <= _p_errno_value && _p_errno_value < s_DllAddressCache.uEndAddress))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__acrt_ptd* ptd = (__acrt_ptd*)(((unsigned char*)_p_errno_value) - FIELD_OFFSET(__acrt_ptd, _terrno));
|
||||
return ptd;
|
||||
}
|
||||
#else
|
||||
__acrt_ptd* __cdecl __acrt_getptd_noexit(void);
|
||||
#endif
|
||||
|
||||
#ifdef __BuildWithMSVCRT
|
||||
__forceinline __acrt_ptd* __cdecl __acrt_getptd(void)
|
||||
__declspec(noinline) __inline __acrt_ptd* __cdecl __acrt_getptd(void)
|
||||
{
|
||||
__acrt_ptd* ptd = __acrt_getptd_noexit();
|
||||
|
||||
|
||||
+39
-32
@@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="DDynamic|Win32">
|
||||
<Configuration>DDynamic</Configuration>
|
||||
<ProjectConfiguration Include="DStatic|Win32">
|
||||
<Configuration>DStatic</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Dynamic|Win32">
|
||||
<Configuration>Dynamic</Configuration>
|
||||
<ProjectConfiguration Include="Static|Win32">
|
||||
<Configuration>Static</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DDynamic|x64">
|
||||
<Configuration>DDynamic</Configuration>
|
||||
<ProjectConfiguration Include="DStatic|x64">
|
||||
<Configuration>DStatic</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Dynamic|x64">
|
||||
<Configuration>Dynamic</Configuration>
|
||||
<ProjectConfiguration Include="Static|x64">
|
||||
<Configuration>Static</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
@@ -27,14 +27,15 @@
|
||||
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|Win32'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WindowsTargetPlatformMinVersion>5.1.2600.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|Win32'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
@@ -42,14 +43,15 @@
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|x64'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WindowsTargetPlatformMinVersion>5.1.2600.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|x64'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Static|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||
@@ -62,32 +64,32 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='DDynamic|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='DStatic|Win32'">
|
||||
<Import Project="..\VC-LTL helper for Visual Studio.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Dynamic|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">
|
||||
<Import Project="..\VC-LTL helper for Visual Studio.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='DDynamic|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='DStatic|x64'">
|
||||
<Import Project="..\VC-LTL helper for Visual Studio.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Dynamic|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Static|x64'">
|
||||
<Import Project="..\VC-LTL helper for Visual Studio.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|Win32'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|x64'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|Win32'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|x64'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Static|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|Win32'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -95,13 +97,14 @@
|
||||
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)SymbolBuildTest\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";VC_LTL_ROOT=LR"($(ProjectDir)..\)";VCToolsInstallDir=LR"($(VCToolsInstallDir))";CurrentUniversalCRTSdkDir=LR"($(UniversalCRTSdkDir)Lib\$(WindowsTargetPlatformVersion)\)";WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DDynamic|x64'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DStatic|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -109,13 +112,14 @@
|
||||
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)SymbolBuildTest\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";VC_LTL_ROOT=LR"($(ProjectDir)..\)";VCToolsInstallDir=LR"($(VCToolsInstallDir))";CurrentUniversalCRTSdkDir=LR"($(UniversalCRTSdkDir)Lib\$(WindowsTargetPlatformVersion)\)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|Win32'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -125,6 +129,7 @@
|
||||
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)SymbolBuildTest\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";VC_LTL_ROOT=LR"($(ProjectDir)..\)";VCToolsInstallDir=LR"($(VCToolsInstallDir))";CurrentUniversalCRTSdkDir=LR"($(UniversalCRTSdkDir)Lib\$(WindowsTargetPlatformVersion)\)";WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -133,7 +138,7 @@
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Dynamic|x64'">
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Static|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -143,6 +148,7 @@
|
||||
<PreprocessorDefinitions>SymbolBuildTestPath=LR"($(ProjectDir)SymbolBuildTest\)";MSBuildBinPath=LR"($(MSBuildBinPath)\)";VC_LTL_ROOT=LR"($(ProjectDir)..\)";VCToolsInstallDir=LR"($(VCToolsInstallDir))";CurrentUniversalCRTSdkDir=LR"($(UniversalCRTSdkDir)Lib\$(WindowsTargetPlatformVersion)\)";NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -154,11 +160,12 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="detect_mismatch_UnitTest.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DDynamic|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DDynamic|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Dynamic|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Dynamic|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DStatic|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DStatic|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Static|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Static|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ptdTest.cpp" />
|
||||
<ClCompile Include="RCBuildUnitTest.cpp" />
|
||||
<ClCompile Include="UnitTest.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
<ClCompile Include="RCBuildUnitTest.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ptdTest.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "pch.h"
|
||||
#include "CppUnitTest.h"
|
||||
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
extern "C" void* __cdecl __acrt_getptd_noexit();
|
||||
|
||||
TEST_CLASS(PTD测试)
|
||||
{
|
||||
public:
|
||||
TEST_METHOD(主线程PTD测试)
|
||||
{
|
||||
Assert::IsNotNull(__acrt_getptd_noexit());
|
||||
}
|
||||
|
||||
TEST_METHOD(_beginthread_PTD测试)
|
||||
{
|
||||
HANDLE _hEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
||||
|
||||
_beginthread(
|
||||
[](void* _hEvent)
|
||||
{
|
||||
Assert::IsNotNull(__acrt_getptd_noexit());
|
||||
|
||||
SetEvent(_hEvent);
|
||||
|
||||
}, 0, _hEvent);
|
||||
|
||||
|
||||
Assert::AreEqual(WaitForSingleObject(_hEvent, 5 * 1000), (DWORD)WAIT_OBJECT_0);
|
||||
|
||||
CloseHandle(_hEvent);
|
||||
}
|
||||
|
||||
TEST_METHOD(_beginthreadex_PTD测试)
|
||||
{
|
||||
auto _hThread = (HANDLE)_beginthreadex(
|
||||
0,
|
||||
0,
|
||||
[](void*) -> unsigned
|
||||
{
|
||||
Assert::IsNotNull(__acrt_getptd_noexit());
|
||||
return 0;
|
||||
}, 0, 0, nullptr);
|
||||
|
||||
Assert::IsNotNull(_hThread);
|
||||
|
||||
Assert::AreEqual(WaitForSingleObject(_hThread, 5 * 1000), (DWORD)WAIT_OBJECT_0);
|
||||
|
||||
CloseHandle(_hThread);
|
||||
}
|
||||
|
||||
TEST_METHOD(CreateThread_PTD测试)
|
||||
{
|
||||
auto _hThread = (HANDLE)CreateThread(
|
||||
0,
|
||||
0,
|
||||
[](void*) -> DWORD
|
||||
{
|
||||
Assert::IsNotNull(__acrt_getptd_noexit());
|
||||
return 0;
|
||||
}, 0, 0, nullptr);
|
||||
|
||||
Assert::IsNotNull(_hThread);
|
||||
|
||||
Assert::AreEqual(WaitForSingleObject(_hThread, 5 * 1000), (DWORD)WAIT_OBJECT_0);
|
||||
|
||||
CloseHandle(_hThread);
|
||||
}
|
||||
};
|
||||
}
|
||||
+36
-36
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31515.178
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33712.159
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcruntime.msvcrt", "vcruntime.msvcrt\vcruntime.msvcrt.vcxproj", "{2D2789F9-1A04-4E94-8386-E5B2C8C93354}"
|
||||
EndProject
|
||||
@@ -77,8 +77,8 @@ Global
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|ARM64.Build.0 = Static|x64
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x64.ActiveCfg = Dynamic|x64
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x64.Build.0 = Dynamic|x64
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x86.ActiveCfg = DDynamic|Win32
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x86.Build.0 = DDynamic|Win32
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x86.ActiveCfg = DStatic|Win32
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DDynamic|x86.Build.0 = DStatic|Win32
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DStatic|ARM.ActiveCfg = Static|ARM
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DStatic|ARM.Build.0 = Static|ARM
|
||||
{089D1C58-7669-4916-B1A2-7BBF6EA236B4}.DStatic|ARM64.ActiveCfg = Static|ARM
|
||||
@@ -133,38 +133,38 @@ Global
|
||||
{81CACACB-0A7B-4392-BAA7-B1C18B71A80C}.Static|x64.Build.0 = Dynamic|x64
|
||||
{81CACACB-0A7B-4392-BAA7-B1C18B71A80C}.Static|x86.ActiveCfg = Dynamic|Win32
|
||||
{81CACACB-0A7B-4392-BAA7-B1C18B71A80C}.Static|x86.Build.0 = Dynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM.ActiveCfg = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM.Build.0 = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM64.ActiveCfg = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM64.Build.0 = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x64.ActiveCfg = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x64.Build.0 = Dynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x86.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x86.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM.ActiveCfg = Dynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM.Build.0 = Dynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM64.ActiveCfg = Dynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM64.Build.0 = Dynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x64.ActiveCfg = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x64.Build.0 = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x86.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x86.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM64.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM64.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x64.ActiveCfg = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x64.Build.0 = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x86.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x86.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM64.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM64.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x64.ActiveCfg = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x64.Build.0 = DDynamic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x86.ActiveCfg = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x86.Build.0 = DDynamic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM.ActiveCfg = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM.Build.0 = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM64.ActiveCfg = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|ARM64.Build.0 = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x64.ActiveCfg = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x64.Build.0 = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x86.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DDynamic|x86.Build.0 = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM.Build.0 = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM64.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|ARM64.Build.0 = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x64.ActiveCfg = DStatic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x64.Build.0 = DStatic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x86.ActiveCfg = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.DStatic|x86.Build.0 = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM.ActiveCfg = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM.Build.0 = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM64.ActiveCfg = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|ARM64.Build.0 = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x64.ActiveCfg = DStatic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x64.Build.0 = DStatic|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x86.ActiveCfg = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Dynamic|x86.Build.0 = DStatic|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM.Build.0 = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM64.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|ARM64.Build.0 = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x64.ActiveCfg = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x64.Build.0 = Static|x64
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x86.ActiveCfg = Static|Win32
|
||||
{A772FE5B-F91F-405F-A54C-BB12334A3C94}.Static|x86.Build.0 = Static|Win32
|
||||
{2A7AF6B9-03FD-4586-AC60-F9EDDF05DB4E}.DDynamic|ARM.ActiveCfg = Dynamic|ARM
|
||||
{2A7AF6B9-03FD-4586-AC60-F9EDDF05DB4E}.DDynamic|ARM.Build.0 = Dynamic|ARM
|
||||
{2A7AF6B9-03FD-4586-AC60-F9EDDF05DB4E}.DDynamic|ARM64.ActiveCfg = DDynamic|ARM64
|
||||
|
||||
Reference in New Issue
Block a user