[Ace-users] [ace-users] Crash releasing ACE_Message_Block allocated for asynchfile read
shuston at riverace.com
Mon Mar 3 17:41:55 CST 2008
Thanks for the PROBLEM-REPORT-FORM.
> ACE VERSION: 5.5
> HOST MACHINE and OPERATING SYSTEM: Windows XP
> COMPILER NAME AND VERSION (AND PATCHLEVEL): Visual Studio 2005
> THE $ACE_ROOT/ace/config.h FILE [if you use a link to a
> specific file, simply state which one]:
> #include "ace/config-win32.h"
> AREA/CLASS/EXAMPLE AFFECTED: Proactor, ACE_Asynch_Read_File.
> DOES THE PROBLEM AFFECT: EXECUTION (my application)
> My application crashes when I try to release() the ACE_Message_Block
> allocated to asynchronously read a file.
> I allocate an ACE_Message_Block and asynchronously try to read a
> (in the testcase, it is the testcase's own source file). When the
> read is completed, my handler signals the main thread, which
> then tries
> to release() the message block. At this point, the testcase crashes
> _CrtIsValidHeapPointer (called while deleting the
> inside release()).
> Is it not safe to release() the message block like this? I
> couldn't find
> anywhere ACE could be releasing it, and the ACE Programmer's Guide
> implies this should be safe, since it releases() within the
> handle_*() function...
Yes, it should be safe.
On quick inspection, your code looks ok, modulo the recommendation
that you call ACE_Proactor::instance::proactor_run_event_loop() (and
> REPEAT BY: See attached aio_testcase.cpp. Build using attached
> aio_testcase.vcproj. Run in the same directory as the source file.
> SAMPLE FIX/WORKAROUND: Don't release() the message block, but
> wouldn't that be a memory leak?
Yes, it would.
I suspect a heap corruption - I recommend you run this with Purify or
another memory checker to see if that can pinpoint anything.
Steve Huston, Riverace Corporation
Want to take ACE training on YOUR schedule?
More information about the Ace-users