Poco::ThreadImpl::runnableEntry(void *) bad allocation

Hi

I’m having a strange problem with a thread class I have. After some time (at least a few hours) the thread causes the application to crash. But the strange thing is that when Visual Studio debugger stops it doesn’t do that on any of my code. The call stack looks like this:

  
  
 	KernelBase.dll!76e13219()	Unknown  
 	[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]	  
 	app_debug.exe!Poco::Debugger::enter(void)	Unknown  
 	app_debug.exe!Poco::Debugger::enter(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *,int)	Unknown  
 	app_debug.exe!Poco::Bugcheck::debugger(char const *,char const *,int)	Unknown  
 	app_debug.exe!Poco::ErrorHandler::exception(class std::exception const &)	Unknown  
 	app_debug.exe!Poco::ErrorHandler::handle(class std::exception const &)	Unknown  
>	app_debug.exe!Poco::ThreadImpl::runnableEntry(void *)	Unknown  
 	kernel32.dll!7527336a()	Unknown  
 	ntdll.dll!777d9f72()	Unknown  
 	ntdll.dll!777d9f45()	Unknown  
  

And this shows in the console:

  
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%  
bad allocation [in file "src\ErrorHandler.cpp", line 66]  
%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  

Some time ago I had this problem but my application was just leaking memory but now it’s not the case and I’m quote clueless on cause of this error. Did anybody have such an error or knows how to fix this?

Best regards,
PB

It’s probably caused by running the application in debug mode. I used https://vld.codeplex.com/ to debug any leaks but most of them came from freeimage.dll and quicktime way below my code (in the dll’s, etc). When I launch the application in Release target I’m not getting any leakage errors (I’ve defined VLD_FORCE_ENABLE in C++ -> Preprocessor -> User Preprocessor Definitions so I assume it should report any leaks…).

Is it possible that running a debug target can cause some leaks while using dll’s even if the application itself isn’t leaking memory?

Well unfortunately it was not the case. After some time I’m still getting the errors:

  
  
First-chance exception at 0x7529D04C (kernel32.dll) in Application.exe: 0xC0000005: Access violation reading location 0x70747468.  
First-chance exception at 0x76E0C41F in application.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x058DF80C.  
The thread 0x20fc has exited with code 0 (0x0).  
WARNING: Visual Leak Detector: A module, glut32.dll, included in memory leak detection  
  does not have any debugging symbols available, or they could not be located.  
  Function names and/or line numbers for this module may not be available.  
WARNING: Visual Leak Detector: A module, freeimage.dll, included in memory leak detection  
  does not have any debugging symbols available, or they could not be located.  
  Function names and/or line numbers for this module may not be available.  
WARNING: Visual Leak Detector: A module, nvoglv32.dll, included in memory leak detection  
  does not have any debugging symbols available, or they could not be located.  
  Function names and/or line numbers for this module may not be available.  
WARNING: Visual Leak Detector: A module, msvcr90.dll, included in memory leak detection  
  does not have any debugging symbols available, or they could not be located.  
  Function names and/or line numbers for this module may not be available.  
  

I’m not sure why this happens. I’m loading images in the separate thread and it starts failing after some time which is quite strange since there is leakage but the problems start after 500-800 cycles of loading/unloading.

I got this same error when I was trying access std::queue front() function when the queue was empty. This resulted in bad allocation. This whole thing was being called on a thread.