size==1 Too many writes to wake-up pipe?

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
michael76
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Nov 08, 2011 1:19 am

size==1 Too many writes to wake-up pipe?

Post by michael76 » Wed Sep 20, 2017 11:56 am

Sometimes my linux console app (compiled with 3.1.0) prints this assert message
size==1 Too many writes to wake-up pipe?


Soon after it seems that my app deadlocks.

Looking through the wxWidgets code, i notice that the flag preventing this situation m_pipeIsEmpty and this is protected by the m_pipeLock mutex. I cannot seem to figure out how multiple writes to the wakeuppipe WakeUpNoLock() is possible without a call to onReadWaiting() since WakeUpNoLock will check if the pipe is empty before writing something.

I notice the patch for all this code was created here https://groups.google.com/d/msg/wx-comm ... UABlE3ehoJ back in 2012

Does anyone know how this could be possible?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Wed Sep 20, 2017 1:38 pm

Hi,
Could you please post some code? Or even better - try to reproduce the behavior in one of the samples.

Thank you.

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Mon Jun 29, 2020 4:05 pm

Hello,

sorry to the reply to an old thread, but I'm facing the same issue.

I'm coding a program to get the status from multiple devices.

To get the information, I'm calling custom script with wxExceute, and handling the result of the process at the end of the event.

After the collection of the information, with the help of some work threads, the application computes the datas.

The datas computed, then get merged in the main loop (in one routine atm the gui is not responding cos the cpu usage, for about 5 seconds).

I think in one of the step the assert message appears, (can happen after some days of running), and the program stop.

Where should I look to prevent this assert? I surely mess in some part of my code, but with the time range, it is hard to track it down.

Thanks for the help.

Best Regards,

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Mon Jun 29, 2020 5:01 pm

Hi,
As I last replied - can you reproduce the issue in the sample?
Also - what platform and wx version you are trying it on?

Thank you.

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Mon Jun 29, 2020 5:32 pm

Hi ONEEYEMAN,

thanks for the reply,

I'm using centos-release-7-7.1908.0.el7.centos.x86_64 with wxWidgets 3.1.2.

I'm not sure I can reproduce the behavior with a small sample, the code is a bit wide.

I was searching in the meaning of the wake-up pipe, if it is linked to the call to the script or maybe to the thread.

If there is something where I can look, it would be awesome.

Thanks again.

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Mon Jun 29, 2020 5:55 pm

Hi,
Can you try to isolate an issue?

Thank you.

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Tue Jun 30, 2020 7:31 am

Hi ONEEYEMAN,

I would love to isolate the issue, but with the gap time so wide, it is difficult to point it out where the assert come from.

I have the back trace for the error, but in this case I don't think is clear enough:

ASSERT INFO:
../src/unix/wakeuppipe.cpp(102): assert "size == 1" failed in OnReadWaiting(): Too many writes to wake-up pipe?

BACKTRACE:
[1] g_main_context_dispatch
[2] g_main_loop_run
[3] gtk_main
[4] wxGUIEventLoop::DoRun()
[5] wxEventLoopBase::Run()
[6] wxAppConsoleBase::MainLoop()
[7] wxEntry(int&, wchar_t**)
[8] main /home/user/Documents/DevCollector/DevCollectorApp.cpp:17
[9] __libc_start_main
[10] _start

Is this assert related to some kind of event process?

Thanks for the support,

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Tue Jun 30, 2020 2:24 pm

Hi,
You need to build the debug version of the library and your application to be useful.

And try to reproduce it in a sample.

Or create a minimal, reproducible example.

Thank you.

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Tue Jun 30, 2020 3:52 pm

Hi ONEEYEMAN,

The application is built in debug mode.

I understand your point of view in reducing the project in a minimal and reproducible example, and I usually do this to discover the issues, but this time I can not do it in a "simple way".

I asked this question if anybody knew the meaning of the assert error, hoping in a simple response about the possible source of the problem.

Thanks anyway for your time.

Best Regards,

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Tue Jun 30, 2020 4:32 pm

Hi
Did you find where this assert is coming from? Maybe a look at the code will help?

Thank you.

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Wed Jul 01, 2020 7:35 am

Hi,

the assertion error come from this code line:

Code: Select all

IMPLEMENT_APP(DevCollectorApp);
The app call 30+ script a time and wait till all are finish before the next round.

Maybe they are to much and need to be reduced.

Thanks for the help.

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Wed Jul 01, 2020 1:52 pm

Hi,
Are you trying to call wxExecute() from a thread?

Try to execute those scripts one by one

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 14881
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: size==1 Too many writes to wake-up pipe?

Post by doublemax » Wed Jul 01, 2020 4:15 pm

Ruro wrote:
Wed Jul 01, 2020 7:35 am
the assertion error come from this code line:

Code: Select all

IMPLEMENT_APP(DevCollectorApp);
That usually means that the crash happens before wxApp::OnInit() is called. Can you confirm that?

If yes, check if you have any global variables that use wxWidgets classes. These are constructed before wxWidgets itself is initialized, which can cause all kind of problems (= don't do this).
Use the source, Luke!

Ruro
Experienced Solver
Experienced Solver
Posts: 69
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: size==1 Too many writes to wake-up pipe?

Post by Ruro » Mon Jul 06, 2020 5:20 pm

Hi,

sorry for the late Reply and thanks for the suggestions:
ONEEYEMAN wrote:
Wed Jul 01, 2020 1:52 pm
Hi,
Are you trying to call wxExecute() from a thread?

Try to execute those scripts one by one

Thank you.
I'm calling the script one by one in the main thread, usually I'm binding the process to an event handler, and there I check the result of the script.

I'm usually launch 30 + script at the same time, maybe it is the problem they are too much.
doublemax wrote:
Wed Jul 01, 2020 4:15 pm
That usually means that the crash happens before wxApp::OnInit() is called. Can you confirm that?

If yes, check if you have any global variables that use wxWidgets classes. These are constructed before wxWidgets itself is initialized, which can cause all kind of problems (= don't do this).
Hi doublemax,

the program start fine, actually the scripts don't start until I press a button.

Here the snipped code where I call the scipts:

Code: Select all

bool DevCollectorFrame::CallScript(wxString sIP, int id)
{
    
    if(sIP==_(""))
        return false;
        
    wxString cmd = _("home/user/pydev/py36-venv/bin/python3 /home/user/Documents/Scripts/dev_col.py ") + sIP;

    wxProcess *ObjProcess = new wxProcess(this,id);

    ObjProcess->Bind(wxEVT_END_PROCESS ,&DevCollectorFrame::HandlerEndScriptRequest,this);
    int pidProcess = wxExecute(cmd,32,ObjProcess);

    if ( pidProcess != -1 )
    {
    
        wxString sDebug=_("\n-Started script for ")+sIP;
        TextDebug->AppendText(sDebug);
        return true;
    }//fine if
    else
    {
        return false;
    }
    
}
I cleared the code a bit for readability.
I call the scripts every 10 min, do I need to clear the Bind Event?

Thanks you for the help,

Best Regards,

Nicola.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4160
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: size==1 Too many writes to wake-up pipe?

Post by ONEEYEMAN » Mon Jul 06, 2020 5:55 pm

Hi,
What kind of script they are? Bsh/shell script? wxPython? Perl/Python/Lua?
Are they different scripts or it is the same script launched multiple times?
What are they doing? Maybe you can try to launch just one script and not 30+ and see if you get an error?

Thank you.

Post Reply