[Ace-users] [ace-users] Crash releasing ACE_Message_Block allocated for asynchfile read

Steve Huston shuston at riverace.com
Mon Mar 3 17:41:55 CST 2008


Hi Bryan,

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
SP1
> 
>     THE $ACE_ROOT/ace/config.h FILE [if you use a link to a
platform-
>     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)
>     SYNOPSIS: 
> 
> My application crashes when I try to release() the ACE_Message_Block
I
> allocated to asynchronously read a file.
> 
>     DESCRIPTION:
> 
> I allocate an ACE_Message_Block and asynchronously try to read a
file
> (in the testcase, it is the testcase's own source file). When the
file
> read is completed, my handler signals the main thread, which 
> then tries
> to release() the message block. At this point, the testcase crashes
in
> _CrtIsValidHeapPointer (called while deleting the
ACE_Message_Block()
> 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
handler's
> 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
...end_event_loop).

>     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

--
Steve Huston, Riverace Corporation
Want to take ACE training on YOUR schedule?
See http://www.riverace.com/training.htm




More information about the Ace-users mailing list