Adding one wxString causes the application to crash !?!?!?!?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
zmau
Knows some wx things
Knows some wx things
Posts: 47
Joined: Wed Jun 15, 2016 11:41 am

Adding one wxString causes the application to crash !?!?!?!?

Post by zmau »

Hello all,

I have a "pretty big" wxWidgets dialog based application (not huge, but certainly not simple).
This week I have had a really funny phenomena, I have added some code, and the application had crashed upon exiting.
It took me some time to realize that it's enough that I add a wxString member to cause this crash (not a stable crash).
The class that operates the main dialog is derived from wxDialog.

Is it really possible that this derived class can have "this number of members", and no more ?

Some more data :
  • The application is running on Windows_7 32/64 bits.
  • I am using wxWidgets version 3.0.3.
Any advice as to where should I look for this problem ?

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

Re: Adding one wxString causes the application to crash !?!?!?!?

Post by doublemax »

Was that the first wxString in that class? If yes, and if you're using threads like mentioned in your other post, you're probably modifying the wxString in a non-thread-safe way.

Basically, if you transfer a wxString accross threads, make sure to create a "deep" copy by using wxString::Clone()
Use the source, Luke!
zmau
Knows some wx things
Knows some wx things
Posts: 47
Joined: Wed Jun 15, 2016 11:41 am

Re: Adding one wxString causes the application to crash !?!?!?!?

Post by zmau »

Thanks a lot.
  • This is a different application
  • This is not the first wxString (maybe the 50th in this class)
  • There are no threads in this appication
The funny thing is that it seems to be enough just to add this new wxString to my class (without even doing with it anything).


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

Re: Adding one wxString causes the application to crash !?!?!?!?

Post by doublemax »

This is not enough information to go on. Can you post a call stack/backtrace from the crash?
Use the source, Luke!
jpo234
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Feb 25, 2020 11:34 am

Re: Adding one wxString causes the application to crash !?!?!?!?

Post by jpo234 »

My first suspicion in cases like this: a corrupted heap. This can happen at a completely unrelated place and manifests itself when a new heap operation (like the creation of a new string) takes place.

Run your application through a memory checker and see whether this finds something.
Post Reply