Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Malloc check failed : (6 Items)
   
Malloc check failed  
I am getting a random crash with the following error :
Malloc Check Failed: :/builds/660_SDP/svn/lib/c/alloc/band.c:492
I am using Momentics 5.0 & Qnx 6.6 .

from the core dump I can see that malloc is failing is for std::string objects & operations which I am using in my code 
. 

Is this purely a memory fragmentation which is very unlikely since the application doesn't show any leak & crash occurs 
also after it has been running for a short time ? or some sort of memory corruption ? 

Momentics memory analysis tool doesn't show up anything .
any pointers wud be helpful ? looking for points to investigate ?
Re: Malloc check failed  
It's not fragmentation, it's that when it got a chunk of memory the memory was corrupt. You will need to check your code
 carefully, static analysis tools can help. Also take a look at:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.prog%2Ftopic%2Fhat.html
Re: Malloc check failed  
Also when I run the exe in debug mode with memory analysis tool added to its debug configuration , no crash / memory 
error occurs . What may be the reason of this ? 
Re: Malloc check failed  
> Also when I run the exe in debug mode in Momentics IDE with memory analysis tool added to its 
> debug configuration , no crash / memory error occurs . What may be the reason 
> of this ? 


Re: Malloc check failed  
I tried to run the exe in debug mode with memory analysis tool added from Momentics IDE. I also enabled all the memory 
check options in memory analysis tool tab. But in all these debug runs no crash occurs in the scenario .Also the memory 
analysis view doesnt show any memory problems with the exe after several runs. 

When i execute the same code in non debug mode or debug mode without memory analysis tool , I get the same memory 
allocation crash . It occurs randomly at different places in the code where I am doing std::string operations for which 
memory allocations are required . Below is a call stack :

                        SignalKill() at 0xb034cf5d	
			raise() at 0xb0336348	
			__malloc_panic_str() at 0xb033020a	
			__malloc_panic() at 0xb03302ed	
			_band_get_aligned() at 0xb032ea19	
			_band_get() at 0xb032ebeb	
			__malloc_lock.constprop.2() at 0xb0332c00	
			malloc() at 0xb033289b	
			operator new() at 0xb825f7ca	
			std::_Allocate<char>() at xmemory0:18 0x8052df4	
			std::allocator<char>::allocate() at xmemory0:741 0x8052ca9	
			std::_Wrap_alloc<std::allocator<char> >::allocate() at xmemory0:1,067 0x80529ae	
			std::string::_Copy() at xstring:2,310 0x8051dde	
			std::string::_Grow() at xstring:2,341 0x80515a1	
			std::string::append() at xstring:1,171 0x8050de7	
			std::string::append() at xstring:1,182 0x805013b	
			std::string::operator+=() at xstring:1,124 0x8060d16	
			QNXCommonUtils::readLineBuffered() at QNXCommonUtils.cpp:158 0x806ab4d	
			SystemConfig::readIniFileInMem() at SystemConfig.cpp:461 0x80562cb	
			SystemConfig::mergeNVPData() at SystemConfig.cpp:2,176 0x805d86e	
			SystemConfig::updateIniFile() at SystemConfig.cpp:938 0x8057e73	
			SystemConfig::UpdateAllIni() at SystemConfig.cpp:866 0x8057b6e	
			CQNXUpgradeManager::processIPSPolicyUpdate() at CQNXUpgradeManager.cpp:501 0x807ae6f	
			CQNXUpgradeManager::applyThePackage() at CQNXUpgradeManager.cpp:896 0x807cc73	
			CQNXUpgradeManager::run() at CQNXUpgradeManager.cpp:1,377 0x807f258	
			Thread<CQNXUpgradeManager>::ThreadFunc() at Thread.h:59 0x8051330

Any pointers wud be very helpful to find the root cause of malloc failure .
Re: Malloc check failed  
have you identified the root cause of this issue? I face it too. 
it is inconsistent and the code dump doesn't point to the error.