f



Crash when using wxTextCtrl with xwGTK-2.4.1 and wxGTK-2.4.2 Suse Linux 8.2


I am using trying to add some wxTextCtrl to a frame with the result that
the program crashes when starting it. 
On console the errormessage is (in german) Speicherzugriffsfehler (Don't
know what an english Linux would give out-> It means imho that an 
address is accessed that does not depend to the applications memory
space.)
It compiles without errors, I tried GTK-2.4.1 & 2.4.2 with the same 
result. (wxWindows is compiled without GTK2 support !)
The code that doesn't work with Linux works on Windows. (9x)

I found out that for any strange reason when I add the line marked with 
**** the program runs. (Dont ask me why, found out by accident)

Maybe someone can look over the code and tell me if I have something
overseen regarding the sizers.

(I have checked the samples, that came with wxWindows, most of them runs
 after building them, but it gave me no clue..
Another point with the samples is, they all crash when they exit ->
does this depend on my machine ? Maybe on the gtk 1.x libs that Suse
bundled to the distri ? [Maybe all of this is some error in the GTK ?] )

Thnx in advance,

P.

Here comes the code:




IMPLEMENT_APP(myApp)

bool MyApp::OnInit()
{
  FrameMain *frame = new FrameMain(100, 100, 300, 550);

  
 
	wxBoxSizer* TopSizer = new wxBoxSizer(wxVERTICAL);

	wxStaticLine* Line1 = new wxStaticLine(frame, -1,
 wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
    TopSizer->Add(Line1, 0, wxGROW|wxALL, 5);

	myTextCtrl = new wxTextCtrl(frame, -1, _T(""), wxPoint(0,0),
wxSize(22,22), wxTE_MULTILINE);
    TopSizer->Add(myTextCtrl, 0, wxGROW|wxALL, 5);

	wxStaticLine* Line2 = new wxStaticLine(frame, wxID_STATIC,
wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
    TopSizer->Add(Line2, 0, wxGROW|wxALL, 5);

	

// **** The App only runs if this line is in here
// **** when commended out, app crash when starting
// ****
	wxStaticLine* Line00 = new wxStaticLine(frame, -1, wxDefaultPosition,
wxDefaultSize, wxLI_HORIZONTAL );
// **** END of depending code

	
	myTextCtrl2 = new wxTextCtrl(frame, -1, _T(""), wxPoint(0,0),
wxSize(22,22), wxTE_MULTILINE);
    TopSizer->Add(myTextCtrl2, 01, wxGROW|wxALL, 5);

	wxStaticLine* Line3 = new wxStaticLine(frame, -1, wxDefaultPosition,
wxDefaultSize, wxLI_HORIZONTAL );
    TopSizer->Add(Line3, 0, wxGROW|wxALL, 5);
	

	
	myTextCtrl3 = new wxTextCtrl(frame, -1, _T(""), wxPoint(0,0),
wxSize(22,22), wxTE_MULTILINE);
    TopSizer->Add(myTextCtrl3, 0, wxGROW|wxALL, 5);

	wxStaticLine* Line4 = new wxStaticLine(frame, -1, wxDefaultPosition,
wxDefaultSize, wxLI_HORIZONTAL );
    TopSizer->Add(Line4, 0, wxGROW|wxALL, 5);

	
 frame->SetSizer(TopSizer);
 frame->SetAutoLayout(TRUE);
  
  frame->Show(TRUE);
  SetTopWindow(frame);
  return true;
}



---------------------------------------------------------------------
Please read http://www.wxwindows.org/mlhowto.htm before posting.

To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wx-users-help@lists.wxwindows.org

0
pommes
1/27/2004 2:34:59 PM
comp.soft-sys.wxwindows 21076 articles. 0 followers. Post Follow

4 Replies
816 Views

Similar Articles

[PageSpeed] 46

> On console the errormessage is (in german) Speicherzugriffsfehler (Don't
> know what an english Linux would give out

:) you're using SUSE. That's a segmentation fault, you're right.

> It compiles without errors, I tried GTK-2.4.1 & 2.4.2 with the same 
> result. (wxWindows is compiled without GTK2 support !)
> The code that doesn't work with Linux works on Windows. (9x)
> 
> I found out that for any strange reason when I add the line marked with 
> **** the program runs. (Dont ask me why, found out by accident)
> 
> Maybe someone can look over the code and tell me if I have something
> overseen regarding the sizers.

I'm not sure, but normally you don't add controls directly into a frame. 
First you get a panel for this frame, e.g.

   toppanel = (wxPanel *)NULL;
   // adding panel to frame
   toppanel = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize, 
wxTAB_TRAVERSAL, wxString("Panel"));

that's all, you don't have to add it explicitely to the frame. Than if 
you add a control, tell the constructor that the panel is the parent not 
the frame, e.g.

  	myTextCtrl = new wxTextCtrl(toppanel, -1, _T(""), wxPoint(0,0), 
wxSize(22,22), wxTE_MULTILINE);

instead of

  	myTextCtrl = new wxTextCtrl(frame, -1, _T(""), wxPoint(0,0),
  wxSize(22,22), wxTE_MULTILINE);

just worth to try it, maybe I'm completely wrong (altough for frames you 
should use a panel, for a dialog you don't need that).
and try to use debugger, like DDD or GVD (There must be a package on the 
suse discs or already installed). run your program inside the debugger 
and after the crash make view/stack or view/backtrace and look at the 
local variables. at least you know where exactly your program crashed.

HTH,
Werner



0
Werner
1/27/2004 3:59:42 PM
Werner Smekal wrote:

> and try to use debugger, like DDD or GVD (There must be a package on the
> suse discs or already installed). run your program inside the debugger
> and after the crash make view/stack or view/backtrace and look at the
> local variables. at least you know where exactly your program crashed.

Always worth a try on linux-i386 is to use 'valgrind' on strange
segmentation faults. Often, it makes finding errors very easy when the
program was compiled with debug symbols.

HS

0
Hendrik
1/27/2004 4:08:24 PM
Hi,


adding a Panel doesnt helped, it even made the situation more worst.
(Does the english language allows such a construct ? ;) )
The app won't start up.
> Always worth a try on linux-i386 is to use 'valgrind' on strange
> segmentation faults. Often, it makes finding errors very easy when the
> program was compiled with debug symbols.
> 
> HS

I gave it a try, but I dont know what to do with the output.
Here is some of it, if you have experience, you can maybe show the fault:

==8399== Using valgrind-2.0.0, a program supervision framework for x86-linux.
==8399== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==8399== Estimated CPU clock rate is 1918 MHz
==8399== For more details, rerun with: -v
==8399==
==8399== Invalid write of size 4
==8399==    at 0x405C8487: wxTextCtrlBase::wxTextCtrlBase() (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
==8399==    by 0x404B9DB4: wxTextCtrl::wxTextCtrl(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
==8399==    by 0x804CA75: wxZapDvbR::OnInit() (wxZapDvbR.cpp:43)
==8399==    by 0x4046B104: wxEntry(int, char**) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
==8399==    Address 0x4332522C is 4 bytes after a block of size 396 alloc'd
==8399==    at 0x40027C77: __builtin_new (vg_replace_malloc.c:172)
==8399==    by 0x40027CCE: operator new(unsigned) (vg_replace_malloc.c:185)
==8399==    by 0x804C9F8: wxZapDvbR::OnInit() (wxZapDvbR.cpp:43)
==8399==    by 0x4046B104: wxEntry(int, char**) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
==8399==

....cutted... it is repeated a lot of times.
(Could I please somebody to test if the executable runs on a non Suse system ?
Just to be sure it doesn't depends on some Suse specific changes in librarys etc.)


Thnx 4 now

P.


---------------------------------------------------------------------
Please read http://www.wxwindows.org/mlhowto.htm before posting.

To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wx-users-help@lists.wxwindows.org

0
pommes
1/27/2004 8:02:22 PM
pommes wrote:
> Hi,
> 
> 
> adding a Panel doesnt helped, it even made the situation more worst.
> (Does the english language allows such a construct ? ;) )
> The app won't start up.
> 
>>Always worth a try on linux-i386 is to use 'valgrind' on strange
>>segmentation faults. Often, it makes finding errors very easy when the
>>program was compiled with debug symbols.
>>
>>HS
> 
> 
> I gave it a try, but I dont know what to do with the output.
> Here is some of it, if you have experience, you can maybe show the fault:
> 
> ==8399== Using valgrind-2.0.0, a program supervision framework for x86-linux.
> ==8399== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
> ==8399== Estimated CPU clock rate is 1918 MHz
> ==8399== For more details, rerun with: -v
> ==8399==
> ==8399== Invalid write of size 4
> ==8399==    at 0x405C8487: wxTextCtrlBase::wxTextCtrlBase() (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
> ==8399==    by 0x404B9DB4: wxTextCtrl::wxTextCtrl(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
> ==8399==    by 0x804CA75: wxZapDvbR::OnInit() (wxZapDvbR.cpp:43)
> ==8399==    by 0x4046B104: wxEntry(int, char**) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
> ==8399==    Address 0x4332522C is 4 bytes after a block of size 396 alloc'd
> ==8399==    at 0x40027C77: __builtin_new (vg_replace_malloc.c:172)
> ==8399==    by 0x40027CCE: operator new(unsigned) (vg_replace_malloc.c:185)
> ==8399==    by 0x804C9F8: wxZapDvbR::OnInit() (wxZapDvbR.cpp:43)
> ==8399==    by 0x4046B104: wxEntry(int, char**) (in /usr/X11R6/lib/libwx_gtk-2.4.so.0.0.0)
> ==8399==
> 

I think that means that 4 bytes (a pointer?) are written somewhere, 
where they shouldn't be written to, or? Since wxWindow* is the only 
pointer here, how is FrameMain defined? Maybe the frame structure is not 
valid?

> ...cutted... it is repeated a lot of times.
> (Could I please somebody to test if the executable runs on a non Suse system ?
> Just to be sure it doesn't depends on some Suse specific changes in librarys etc.)
> 

I have Fedora Core 1, so send me your executable

smekal_AT_iap.tuwien.ac.at

regards,
Werner



> 
> Thnx 4 now
> 
> P.
> 
> 
> ---------------------------------------------------------------------
> Please read http://www.wxwindows.org/mlhowto.htm before posting.
> 
> To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail: wx-users-help@lists.wxwindows.org
> 
0
Werner
1/28/2004 7:11:48 AM
Reply: