Re: CAsyncSocket behaving multithreaded

From: Jo (JoJoTwilligo_at_hotmail.com)
Date: 11/10/04


Date: 10 Nov 2004 11:42:25 -0800


"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message news:<esNBXZyxEHA.4028@TK2MSFTNGP15.phx.gbl>...
> Jo wrote:
> > I'm aware that CAsyncSocket is not supposed to be multithreaded, but
> > just uses the message pump. So why are some of my On*() overridables
> > being called when others haven't finished yet? It's been suggested
> > that an AfxMessageBox() might cause another overridable to be called.
> > That's not the case, but in one case, I'm having an overridable being
> > called after I step into a pointer assignment operation. Check it out:
> >
> > pNewNode->data = newElement; // line 843 in afxtempl.h
> >
> > Now, if I'm at that assignment, and I push F11, how is it that I next
> > find I'm at one of my breakpoints in OnReceive()? Especially when I've
> > already got an OnReceive() in progress? The last time I had this
> > problem I made a workaround, but now that this multithreaded behavior
> > is happening all the time, I need a real solution.
> >
>
> Examine the debugger stack display when the unexpected OnReceive is hit.
> One possibility here is that the pointer assignment operation causes
> an access violation or assert error, and that the debug environment
> attempts to display a message box about this error, and that the message
> box message pump permits the second OnReceive to be called. If the
> stack is not corrupt you would see evidence in the stack of various
> library routines attempting to display an error box.

   It looks like this is probably it. I wasn't able to test the
earlier problem with the pointer assignment, but your explanation
doesn't fit what I remember about it. However, in my current code, I
removed the extra calls to Receive(), which didn't clear up the
problem. But I found that in one case an assertion was indeed being
triggered, and before I could get the message, I was sent on a wild
goose chase away from the problem and into the OnReceive(). It's
probably worth remembering this the next time I have a problem like
this.

Thanks very much for your help. I seem to need a lot of it debugging
the unpredictable CAsyncSocket.



Relevant Pages

  • Re: A Brief Look at History
    ... Get an xt, display its name, display the stack, wait for a keystroke. ... bottom of its command window. ... I remember a Forth that put that in a vertical window that covered up ...
    (comp.lang.forth)
  • Re: A Brief Look at History
    ... separate window and show whenever it got updated. ... and work out how to debug it, you design the Forth animator and then ... and return stack, in a stack of views of in unsigned, signed and, if ... merrily around the source code display screen. ...
    (comp.lang.forth)
  • Re: Detailed Stack Information Patch [1/3]
    ... +#ifdef CONFIG_PROC_STACK ... the whole "display where the stack is" thing is ...
    (Linux-Kernel)
  • Stack Segment
    ... I'm trying to write a 16-bit DOS console app with MASM32 that converts ... It seems I need a STACK segment for the ... Converts a decimal digit input to binary and then display it ... Anyone know why the lines in the .stack segment aren't being ...
    (comp.lang.asm.x86)