mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025396: Crash occurs when using TBB allocator on an Intel architecture not supporting SSE2 instructions
During initialization of memory manager, check if SSE2 instructions are supported, when MMGT_OPT=2 is in effect. If not then use MMgrRaw instead of MMgrTBBalloc. It is to avoid runtime crash when running on a CPU that supports SSE but does not support SSE2 (some modifications of AMD Sempron). Fix broken compilation on MSVC for x64 platform Correct the last fix.
This commit is contained in:
@@ -78,6 +78,38 @@ Standard_MMgrFactory::Standard_MMgrFactory()
|
||||
char* aVar;
|
||||
aVar = getenv ("MMGT_OPT");
|
||||
Standard_Integer anAllocId = (aVar ? atoi (aVar): OCCT_MMGT_OPT_DEFAULT);
|
||||
|
||||
#if defined(_WIN32) && !defined(_WIN64)
|
||||
static const DWORD _SSE2_FEATURE_BIT(0x04000000);
|
||||
if ( anAllocId == 2 )
|
||||
{
|
||||
// CR25396: Check if SSE2 instructions are supported, if not then use MMgrRaw
|
||||
// instead of MMgrTBBalloc. It is to avoid runtime crash when running on a
|
||||
// CPU that supports SSE but does not support SSE2 (some modifications of
|
||||
// AMD Sempron).
|
||||
DWORD volatile dwFeature;
|
||||
_asm
|
||||
{
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
|
||||
// get the CPU feature bits
|
||||
mov eax, 1
|
||||
cpuid
|
||||
mov dwFeature, edx
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
}
|
||||
if ((dwFeature & _SSE2_FEATURE_BIT) == 0)
|
||||
anAllocId = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
aVar = getenv ("MMGT_CLEAR");
|
||||
Standard_Boolean toClear = (aVar ? (atoi (aVar) != 0) : Standard_True);
|
||||
|
||||
|
Reference in New Issue
Block a user