This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Knows some wx things
Knows some wx things
Posts: 39
Joined: Thu Nov 25, 2004 10:10 am
Location: Germany


Post by ConnorMacLeod » Thu Jan 20, 2005 10:22 am

I'm using wxSocket in my App: writing and reading image data controlled by a wxTimer, and if i strongly stress the gui (like moving the frame in circles) the following error occur (in debug mode):

\Development\packages\wxWidgets\src\msw\app.cpp(711): assert "wxAssertFailure" failed: wxYield called recursively

If i do a release compilation the application just stops running.

I tried wxSocketBase::Initialize() in my App::OnInit() but that's no help (i'm not using threading).

What can i do?

[wxMSW 2.6.1/VC7.1 .NET 2003/WinXP]

Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands

Post by Jorg » Thu Jan 20, 2005 12:43 pm

When wxYield is called twice, it probably means you enter the same event loop where you already called wxYield. This is potentially dangerous because it is a recursive loop (which explains why your app 'freezes')

Make sure you are not entering the same method twice by some kind of mutex or flag. If all events you receive do need handling, consider a wxThread (worker thread) in which you queue the actions which happen too fast after achother to be handled within the timespan of your event.

It is not advised to call wxYield if the danger exists that the same events can reoccur. As example, when wxYield is called from a wxCommandEvent and the user happens to press the same button, you are also stuck.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
Jorg's WasteBucket

Knows some wx things
Knows some wx things
Posts: 39
Joined: Thu Nov 25, 2004 10:10 am
Location: Germany

Post by ConnorMacLeod » Thu Jan 20, 2005 1:00 pm

Thanks for the answer Jorg but i still have some open issues ;-):

1) I dont call wxYield myself. I think it's some kind of wxWidgets gui calling. See the error-message:
It's in wx-code.

2) I found something in the manual:

"The wxSOCKET_BLOCK flag controls whether the GUI blocks during IO operations. If this flag is specified, the socket will not yield during IO calls, so the GUI will remain blocked until the operation completes. If it is not used, then the application must take extra care to avoid unwanted reentrance."

I am using/setting this flag:
m_sock->SetFlags( wxSOCKET_WAITALL | wxSOCKET_BLOCK );

So is it a wxWidgets-bug or do i still miss something?
[wxMSW 2.6.1/VC7.1 .NET 2003/WinXP]

User avatar
Ryan Norton
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton » Fri Jan 28, 2005 3:55 am

Hopefully this helps -

Basically what you need to do is make sure a socket method is not called twice in the same thread.

I.E. what you are experiencing is probably something like this -

1) You call ::Read

2) wxWidgets calls wxYield from wxSocket::Read

3) wxYeild waits for event

4) Event recieved (another user connects, mayhaps)

5) Event handling function calls ::Read/Write of a socket again

6) wxWidgets calls wxYeild ....

And this is where it happens.

A way around this is to make a thread for each connected socket, or just using blocking mode.

If you are using sockets in blocking mode and still getting it something beforehand may have yeilded also..
[Mostly retired moderator, still check in to clean up some stuff]

In need of some credit
In need of some credit
Posts: 7
Joined: Wed May 25, 2005 1:20 pm
Location: The Netherlands

wxYield problem

Post by TheMadButcher » Wed May 25, 2005 2:43 pm


I have the same problem.
It is reproducable with the standard samples for ipc.
When turned to DDE there is no problem, but when TCP is used, then the problem arises...

There are several things here; at first the timeout in the socket _wait() is set to 6000 (10 minutes) which means that you have to wait at least 10 minutes before a connection fails!
Because there is a loop around this connect() it will take effectively around 40 minutes before you'll get the error back (connect failed)

Further; the wxYield() function is called by the event handler and wxYield() via-via starts the eventhandler again where another wxYield() can occour..

Maybe somebody with enough knowledge of the socket classes can check it out?


(Ps. sorry if the text above sounds a bit confusing.. i had to retype it 7 times again due to some network problems)

BTW i have tested this with wx2.6.0 stable and the cvs-build of 24-5-2005

The problem is the same one as in HERE... But is is not resolved yet..
I'm not bad. I'm just drawn that way.

Post Reply