Free.c throws an exception to "this program has stopped working"

When I run the program (server.exe) using the Visual C ++ 2010 Express debugger, it works fine, but when I run it as exe, it doesn’t; it crashes when the "Server.exe stops working" dialog.

Then I renamed exe to “ServerInstaller.exe” and it worked, so I decided that it was a permissions error, BUT it does not work with “Server.exe” in administrator mode.

Then I connected the debugger in VC ++ to the program "Server.exe", and an exception occurred in it in "free.c".

Code in this file

void __cdecl _free_base (void * pBlock) { int retval = 0; if (pBlock == NULL) return; RTCCALLBACK(_RTC_Free_hook, (pBlock, 0)); retval = HeapFree(_crtheap, 0, pBlock); // Exception thrown in this function if (retval == 0) { errno = _get_errno_from_oserr(GetLastError()); } } 

The exception is

Unhandled exception in 0x770ae3be in Server.exe: 0xC0000005: access location for reading errors 0x3765f8c7.

I checked the value for pBlock and it is 0x007f82c0.

My program.

My program is a RakNet server, and the player has just been successfully uninstalled. The server is checking messages from RakNet at this point.

Roll back stack

  ntdll.dll!770ae3be() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] ntdll.dll!770ae023() kernel32.dll!75e814dd() > msvcr100d.dll!_free_base(void * pBlock) Line 50 + 0x13 bytes C msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1431 + 0x9 bytes C++ msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 + 0xd bytes C++ msvcr100d.dll!free(void * pUserData) Line 49 + 0xb bytes C++ RakNetDebug.dll!RakNet::_RakFree_Ex(void * p, const char * file, unsigned int line) Line 165 + 0xc bytes C++ RakNetDebug.dll!RakNet::ReliabilityLayer::FreeInternalPacketData(RakNet::InternalPacket * internalPacket, const char * file, unsigned int line) Line 3766 + 0x17 bytes C++ RakNetDebug.dll!RakNet::ReliabilityLayer::RemovePacketFromResendListAndDeleteOlderReliableSequenced(RakNet::uint24_t messageNumber, unsigned __int64 time, DataStructures::List<RakNet::PluginInterface2 *> & messageHandlerList, const RakNet::SystemAddress & systemAddress) Line 2391 C++ RakNetDebug.dll!RakNet::ReliabilityLayer::HandleSocketReceiveFromConnectedPlayer(const char * buffer, unsigned int length, RakNet::SystemAddress & systemAddress, DataStructures::List<RakNet::PluginInterface2 *> & messageHandlerList, int MTUSize, unsigned int s, RakNet::RakNetRandom * rnr, unsigned short remotePortRakNetWasStartedOn_PS3, unsigned int extraSocketOptions, unsigned __int64 timeRead, RakNet::BitStream & updateBitStream) Line 776 C++ RakNetDebug.dll!RakNet::ProcessNetworkPacket(RakNet::SystemAddress systemAddress, const char * data, const int length, RakNet::RakPeer * rakPeer, RakNet::RakNetSmartPtr<RakNet::RakNetSocket> rakNetSocket, unsigned __int64 timeRead, RakNet::BitStream & updateBitStream) Line 5012 C++ RakNetDebug.dll!RakNet::RakPeer::RunUpdateCycle(unsigned __int64 timeNS, unsigned __int64 timeMS, RakNet::BitStream & updateBitStream) Line 5099 + 0x81 bytes C++ RakNetDebug.dll!RakNet::UpdateNetworkLoop(void * arguments) Line 5868 C++ msvcr100d.dll!_callthreadstartex() Line 314 + 0xf bytes C msvcr100d.dll!_threadstartex(void * ptd) Line 297 C kernel32.dll!75e833aa() ntdll.dll!770b9ef2() ntdll.dll!770b9ec5() 
+4
source share
3 answers

If your pointer matters and you get such an error, most likely this means that you are trying to free memory several times. Check the code and try to find how many times you free. One way to stop this is to set the pointer immediately after releasing the block it points to to zero.

Another possibility is that you are not using msvcrt, and you are loading a DLL that also does not use msvcrt, and distribution takes place either in the executable or in the DLL and freed up in another.

+6
source

I had this problem, and it was not for multiple deletions, but for a compilation problem (using VisualStudio2012) I recompiled the program, and the problem was resolved.

0
source

Restoring a project can help you. He worked for me

0
source

Source: https://habr.com/ru/post/1441114/


All Articles