From 366bcd0cbca43081fe58825fd463018e49b51740 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 27 Oct 2014 17:10:08 +0200 Subject: MAINT-4435 FIXED fix in llvolume.cpp Perform full build if number of vertices less than allowed. Changes in all other files relate auxiliary methods for catching similar bugs in future. --- indra/llcommon/llmemory.cpp | 78 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index e0b2aa87c2..9ed60ad121 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -63,13 +63,18 @@ LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sM void ll_assert_aligned_func(uintptr_t ptr,U32 alignment) { -#ifdef SHOW_ASSERT - // Redundant, place to set breakpoints. - if (ptr%alignment!=0) - { - LL_WARNS() << "alignment check failed" << LL_ENDL; - } - llassert(ptr%alignment==0); +#if defined(LL_WINDOWS) && defined(LL_DEBUG_BUFFER_OVERRUN) + //do not check + return; +#else + #ifdef SHOW_ASSERT + // Redundant, place to set breakpoints. + if (ptr%alignment!=0) + { + LL_WARNS() << "alignment check failed" << LL_ENDL; + } + llassert(ptr%alignment==0); + #endif #endif } @@ -2148,3 +2153,62 @@ void LLPrivateMemoryPoolTester::fragmentationtest() } #endif //-------------------------------------------------------------------- + +#if defined(LL_WINDOWS) && defined(LL_DEBUG_BUFFER_OVERRUN) + +#include + +struct mem_info { + std::map memory_info; + LLMutex mutex; + + static mem_info& get() { + static mem_info instance; + return instance; + } + +private: + mem_info(){} +}; + +void* ll_aligned_malloc_fallback( size_t size, int align ) +{ + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + + unsigned int for_alloc = sysinfo.dwPageSize; + while(for_alloc < size) for_alloc += sysinfo.dwPageSize; + + void *p = VirtualAlloc(NULL, for_alloc+sysinfo.dwPageSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); + if(NULL == p) { + // call debugger + __asm int 3; + } + memset(p, 0xaa, for_alloc); + memset((void*)((char*)p + for_alloc), 0xbb, sysinfo.dwPageSize); + DWORD old; + BOOL Res = VirtualProtect((void*)((char*)p + for_alloc), sysinfo.dwPageSize, PAGE_NOACCESS, &old); + if(FALSE == Res) { + // call debugger + __asm int 3; + } + + void* ret = (void*)((char*)p + for_alloc-size); + + { + LLMutexLock lock(&mem_info::get().mutex); + mem_info::get().memory_info.insert(std::pair(ret, p)); + } + + + return ret; +} + +void ll_aligned_free_fallback( void* ptr ) +{ + LLMutexLock lock(&mem_info::get().mutex); + VirtualFree(mem_info::get().memory_info.find(ptr)->second, 0, MEM_RELEASE); + mem_info::get().memory_info.erase(ptr); +} + +#endif -- cgit v1.2.3 From edb7e3450f16bbda7a30ff56a350e0060cb0e623 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 28 Oct 2014 17:12:49 +0200 Subject: MAINT-4435 FIXED build fix patchset2 --- indra/llcommon/llmemory.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 9ed60ad121..ae11988df8 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -2184,8 +2184,6 @@ void* ll_aligned_malloc_fallback( size_t size, int align ) // call debugger __asm int 3; } - memset(p, 0xaa, for_alloc); - memset((void*)((char*)p + for_alloc), 0xbb, sysinfo.dwPageSize); DWORD old; BOOL Res = VirtualProtect((void*)((char*)p + for_alloc), sysinfo.dwPageSize, PAGE_NOACCESS, &old); if(FALSE == Res) { -- cgit v1.2.3