Running app crashes if screensaver kick in

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.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Running app crashes if screensaver kick in

Post by Widgets »

I've ported a Windows app to Ubuntu 16/04. Compiled under Codelite with static libs from wxWidgets 3.1.0, compiled locally.
All is well until the screen saver kicks in; when I restore the screen, the app has crashed, though I have not figured out when exactly when: i.e. as soon as the screen goes blank, when I restore the screen or some time in between.

The app uses libcurl (linked as a DLL) in a multi-threaded slow loop, firing every so many minutes, to check for mail on a POP3 server.
If I disable the screen saver, the app has run for hours, without any sign of problem or crash.

My guess is that the crash happens when the mail check fires while the screen is blank, though I don't know enough about Ubuntu's screen saver to even guess at why it should cause such problems, much less how I can fix it or at least find a better work-around than turning off the screen saver.

When running under Windows, the screen save cn go on & off several time, without any issues at all.

TIA, for any hints or information.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Running app crashes if screensaver kick in

Post by doublemax »

I don't have a solution, just some ideas.

First of all i would write the current time into a logfile every second. Also when you start receiving mails etc. Knowing when exactly it crashes might be helpful in finding the cause.

Does your app behave gracefully when the internet connection goes down?

Also, are you sure it's just a screensaver and that the system doesn't go into sleep mode? Check if you receive a wxPowerEvent.
http://docs.wxwidgets.org/trunk/classwx ... event.html

As a workaround, maybe disabling the screen saver is an option:
http://docs.wxwidgets.org/trunk/classwx ... ocker.html
Use the source, Luke!
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Running app crashes if screensaver kick in

Post by eranon »

Hello,

Some additional ideas as it comes:
- Maybe you have something under /var/log/ (eg. in syslog)
- What if you launch your app from the terminal (maybe a chance to see some error output you don't see usually)?
- You can try to generate a core dump (eg. https://blog.xojo.com/2015/08/17/take-a ... -on-linux/)
- Every single function could express itself towards a log on disk (and you could enable this "feature" through a preprocessor definition for convenience)
- Go with backtrace() as expressed here (see tgamblin's answer below): https://stackoverflow.com/questions/770 ... am-crashes.
snap_0005524.png
snap_0005524.png (69.94 KiB) Viewed 2368 times
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Running app crashes if screensaver kick in

Post by ONEEYEMAN »

Hi,
You could also try to build wx, cURL and you application in debug mode and run it under gdb to obtain a backtrace.
This can give more info about the crash.

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Running app crashes if screensaver kick in

Post by Widgets »

Thank you all for your help and ideas.

After another day's testing, it seems like it may have been (a) problem(s) with the app itself and which ended up being resolved by addressing other issues - at least that is my hope ;-)
Yesterday it ran a good part of the day with the screen saver off. Today it has survived several screen saver on/off events successfully.

Still, in the process of getting this far, knowing and having implemented all or even some of your suggestions would have helped a great deal and I will implement them as a general rule and as both a precaution and aide towards prevention with other work.

The lack of a back or stack trace for some of the crashes was a real problem for me and having these new ideas to work with will make life easier down the road when working under Linux based OSes
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Running app crashes if screensaver kick in

Post by Widgets »

Finally did get the sig handler installed and by now only the release version crashes, but it seems that it crashes long before my sig handler even get a chance to be installed.; at least it never does get called.
In fact, now the screen saver has nothing to do with it,
It crashes as soon as it is invoked under Codelite.
If invoked directly, nothing at all happens & I never see any output, even if run from a terminal window.
my back trace in Codelite

Code: Select all

0  0x00007ffff45cf4a7  __memcpy_sse2  /build/glibc-Cl5G7W/glibc-2.23/string/../sysdeps/x86_64/multiarch/../memcpy.S  96
1  0x00007ffff517421a  std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::_M_assign(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)    
2  0x00000000004ea789  ??    
3  0x00000000004d4074  ??    
4  0x0000000000836e40  ??    
5  0x00000000004248e2  ??    
6  0x00007ffff455b830  __libc_start_main  /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c  291
7  0x0000000000442429  ??    
As far as I can tell, the compiler flags are identical, except for the debug/release differences.

For now, I can work around this problem by stripping the debug info from the debug version, but it would be nice to actually make the release version work as expected.
FWIW, I do have wxWidgets compiled locally and includes statically, only libcurl is linked dynamically, using the installed version.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Running app crashes if screensaver kick in

Post by eranon »

Hello,

Considering it's not an issue in your code (like dereferencement of a NULL pointer for example), I would say that crash in an SSE implementation of memcpy is sometime/often due to an issue about memory alignment. Also, I already seen some issues when several versions of glibc are mixed, but it doesn't seem to be the case here (glibc-2.23 everywhere).

So, some bulk ideas:
- What if you force the alignment using "-mpreferred-stack-boundary=4" and "-mstackrealign" ?
- What if you change (decrease) your level of optimization (eg. from -O3 to O2; pure assertion since I don't know your current build command)?
- What if you run your RELEASE build in another machine (in case you would have some compromised memory slot -- hardware, I mean)?

Also, you could take a look at line 96 of /build/glibc-Cl5G7W/glibc-2.23/string/../sysdeps/x86_64/multiarch/../memcpy.S to see what it says, but I guess it's the terminal point and the reason of the crash is far upstream (in the upstream code inducing a memcpy).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Running app crashes if screensaver kick in

Post by Widgets »

Thank you, reducing the optimization seems to have made all of the difference
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply