Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Uninitialized class members.
Uninitialized class members. [message #15725] Tue, 06 May 2008 17:31 Go to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
There are many uninitialized class members in U++. Valgrind complains about them a lot.

I’ve attached a diff file, which fixes several of them.

If you are thinking such fixes are important to U++ I can submit more …


Regards,
Novo
Re: Uninitialized class members. [message #15728 is a reply to message #15725] Tue, 06 May 2008 19:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Not sure what valgrind really tests...

-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar() :
+style(NULL)
+{

"style" is initialized by SetStyle call in constructor.

-TreeCtrl::TreeCtrl()
+TreeCtrl::TreeCtrl() :
+ selectcount(0)

"selectcount" is initialized by Clear call in constructor.

Stopped there.... Finding them in .diff is too time consuming, maybe you could just post me the list of problems instead of .diff?

Mirek

P.S.: Do not get me wrong, valgrind is perhaps a good idea! But looks like it produces some false alarms too...

[Updated on: Tue, 06 May 2008 19:45]

Report message to a moderator

Re: Uninitialized class members. [message #15735 is a reply to message #15728] Tue, 06 May 2008 20:34 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Tue, 06 May 2008 13:44

Not sure what valgrind really tests...

-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar() :
+style(NULL)
+{

"style" is initialized by SetStyle call in constructor.



Valgrind:
==30773==    at 0x5A10E3: Upp::ScrollBar::SetStyle(Upp::ScrollBar::Style const&)
==30773==    by 0x5DDB88: Upp::ScrollBar::ScrollBar() (in /export/home/ssikorsk/
==30773==    by 0x5F4699: Upp::ColumnList::ColumnList() (in /export/home/ssikors
==30773==    by 0x5F4A87: Upp::FileList::FileList() (in /export/home/ssikorsk/dv
==30773==    by 0x44A7D3: WorkspaceWork::WorkspaceWork() (in /export/home/ssikor
==30773==    by 0x45C1DB: Ide::Ide() (in /export/home/ssikorsk/dvlp/upp/svn/upp/
==30773==    by 0x482D8C: GuiMainFn_() (in /export/home/ssikorsk/dvlp/upp/svn/up
==30773==    by 0x484171: main (in /export/home/ssikorsk/dvlp/upp/svn/upp/out/GC
==30773== 


Code:
ScrollBar& ScrollBar::SetStyle(const Style& s)
{
	if(style != &s) {
		style = &s;
		RefreshLayout();
		Refresh();
	}
	return *this;
}


That "if(style != &s)" looks very suspicious to me ...

Quote:


-TreeCtrl::TreeCtrl()
+TreeCtrl::TreeCtrl() :
+ selectcount(0)

"selectcount" is initialized by Clear call in constructor.



Valgrind:
==31285==    at 0x672D10: Upp::TreeCtrl::Dirty(int) (in /export/home/ssikorsk/dv
==31285==    by 0x67545A: Upp::TreeCtrl::Clear() (in /export/home/ssikorsk/dvlp/
==31285==    by 0x6756A8: Upp::TreeCtrl::TreeCtrl() (in /export/home/ssikorsk/dv
==31285==    by 0x6142BF: Upp::HelpWindow::HelpWindow() (in /export/home/ssikors
==31285==    by 0x42EE02: TopicCtrl::TopicCtrl() (in /export/home/ssikorsk/dvlp/
==31285==    by 0x45C91F: Ide::Ide() (in /export/home/ssikorsk/dvlp/upp/svn/upp/
==31285==    by 0x482D8C: GuiMainFn_() (in /export/home/ssikorsk/dvlp/upp/svn/up
==31285==    by 0x484171: main (in /export/home/ssikorsk/dvlp/upp/svn/upp/out/GC
==31285==


Code:
void   TreeCtrl::Clear()
{
	item.Clear();
	item.Add();
	item[0].linei = -1;
	item[0].parent = -1;
	item[0].canopen = true;
	freelist = -1;
	Dirty();
	cursor = anchor = -1;
	selectcount = 0;
}


Dirty() is called before initialization of select count.

Quote:


Stopped there.... Finding them in .diff is too time consuming, maybe you could just post me the list of problems instead of .diff?



I can post either diff or results of valgrind processing, which you can produce yourself ...

Quote:


P.S.: Do not get me wrong, valgrind is perhaps a good idea! But looks like it produces some false alarms too...


As you can see from examples above, valgrind is not giving false alarms. Wink


Regards,
Novo
Re: Uninitialized class members. [message #15738 is a reply to message #15735] Tue, 06 May 2008 21:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Tue, 06 May 2008 14:34

luzr wrote on Tue, 06 May 2008 13:44

Not sure what valgrind really tests...

-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar() :
+style(NULL)
+{

"style" is initialized by SetStyle call in constructor.



Valgrind:
==30773==    at 0x5A10E3: Upp::ScrollBar::SetStyle(Upp::ScrollBar::Style const&)
==30773==    by 0x5DDB88: Upp::ScrollBar::ScrollBar() (in /export/home/ssikorsk/
==30773==    by 0x5F4699: Upp::ColumnList::ColumnList() (in /export/home/ssikors
==30773==    by 0x5F4A87: Upp::FileList::FileList() (in /export/home/ssikorsk/dv
==30773==    by 0x44A7D3: WorkspaceWork::WorkspaceWork() (in /export/home/ssikor
==30773==    by 0x45C1DB: Ide::Ide() (in /export/home/ssikorsk/dvlp/upp/svn/upp/
==30773==    by 0x482D8C: GuiMainFn_() (in /export/home/ssikorsk/dvlp/upp/svn/up
==30773==    by 0x484171: main (in /export/home/ssikorsk/dvlp/upp/svn/upp/out/GC
==30773== 


Code:
ScrollBar& ScrollBar::SetStyle(const Style& s)
{
	if(style != &s) {
		style = &s;
		RefreshLayout();
		Refresh();
	}
	return *this;
}


That "if(style != &s)" looks very suspicious to me ...

Quote:


-TreeCtrl::TreeCtrl()
+TreeCtrl::TreeCtrl() :
+ selectcount(0)

"selectcount" is initialized by Clear call in constructor.



Valgrind:
==31285==    at 0x672D10: Upp::TreeCtrl::Dirty(int) (in /export/home/ssikorsk/dv
==31285==    by 0x67545A: Upp::TreeCtrl::Clear() (in /export/home/ssikorsk/dvlp/
==31285==    by 0x6756A8: Upp::TreeCtrl::TreeCtrl() (in /export/home/ssikorsk/dv
==31285==    by 0x6142BF: Upp::HelpWindow::HelpWindow() (in /export/home/ssikors
==31285==    by 0x42EE02: TopicCtrl::TopicCtrl() (in /export/home/ssikorsk/dvlp/
==31285==    by 0x45C91F: Ide::Ide() (in /export/home/ssikorsk/dvlp/upp/svn/upp/
==31285==    by 0x482D8C: GuiMainFn_() (in /export/home/ssikorsk/dvlp/upp/svn/up
==31285==    by 0x484171: main (in /export/home/ssikorsk/dvlp/upp/svn/upp/out/GC
==31285==


Code:
void   TreeCtrl::Clear()
{
	item.Clear();
	item.Add();
	item[0].linei = -1;
	item[0].parent = -1;
	item[0].canopen = true;
	freelist = -1;
	Dirty();
	cursor = anchor = -1;
	selectcount = 0;
}


Dirty() is called before initialization of select count.

Quote:


Stopped there.... Finding them in .diff is too time consuming, maybe you could just post me the list of problems instead of .diff?



I can post either diff or results of valgrind processing, which you can produce yourself ...

Quote:


P.S.: Do not get me wrong, valgrind is perhaps a good idea! But looks like it produces some false alarms too...


As you can see from examples above, valgrind is not giving false alarms. Wink



OK, thanks for clarification, you are right (and I am wrong, once again Smile

Mirek
Re: Uninitialized class members. [message #15739 is a reply to message #15738] Tue, 06 May 2008 21:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
LineEdit::LineEdit() {
+ isdrag = true;

Why true? IMO should be false.

Mirek
Re: Uninitialized class members. [message #15740 is a reply to message #15739] Tue, 06 May 2008 21:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
--- uppsrc/Core/Core.upp	(revision 226)
+++ uppsrc/Core/Core.upp	(working copy)
@@ -141,3 +141,4 @@
 mainconfig
 	"Normal" = "",
 	"Remote shared" = "SHARED";
+


I should ignore this, rigth? Smile

Mirek
Re: Uninitialized class members. [message #15741 is a reply to message #15740] Tue, 06 May 2008 21:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, thank you Novo, all patches applied.

Please, continue running these diag tools, it seems really helpful Smile

Mirek
Re: Uninitialized class members. [message #15742 is a reply to message #15741] Tue, 06 May 2008 21:50 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Tue, 06 May 2008 15:42

Well, thank you Novo, all patches applied.

Please, continue running these diag tools, it seems really helpful Smile

Mirek


Thanks.

I'm glad to be helpful Smile


Regards,
Novo
Re: Uninitialized class members. [message #15748 is a reply to message #15742] Tue, 06 May 2008 23:18 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
It would be quite interesting to integrate Valgrind inside the ide....

Max
Re: Uninitialized class members. [message #15751 is a reply to message #15748] Wed, 07 May 2008 04:10 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



That would be useful. Especially because there is no adequate GUI tool for valgrind at the moment. I've been using valkyrie, which is QT-based, but it doesn't work with valgrind 3.3.0. vim is pretty good in handling of valgrind's output (as usual).

I'd like to mention that valgrind is just a framework. I was running a tool called memcheck, which is based on valgrind. There are other valgrind-based tools. Most popular beside memcheck are callgrind and helgrind.

memcheck can produce XML output. So, the only thing left is to parse that XML and put data into a grid or a tree.

There is a cool example of GUI for callgrind called kcachegrind.


Regards,
Novo

[Updated on: Wed, 07 May 2008 04:27]

Report message to a moderator

Re: Uninitialized class members. [message #15756 is a reply to message #15748] Wed, 07 May 2008 09:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



Yep, I already started checking this Wink

Anyway, right now I see (as usual Smile the problem with output in console apps...

Mirek
Re: Uninitialized class members. [message #15766 is a reply to message #15756] Wed, 07 May 2008 14:20 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
luzr wrote on Wed, 07 May 2008 09:57

mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



Yep, I already started checking this Wink

Anyway, right now I see (as usual Smile the problem with output in console apps...

Mirek


Which problem ?

Max
Re: Uninitialized class members. [message #15770 is a reply to message #15766] Wed, 07 May 2008 16:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mdelfede wrote on Wed, 07 May 2008 08:20

luzr wrote on Wed, 07 May 2008 09:57

mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



Yep, I already started checking this Wink

Anyway, right now I see (as usual Smile the problem with output in console apps...

Mirek


Which problem ?

Max



That the output is mixed (normal output from the app and valgrind output). Same as with gdb.

But now thinking about it, maybe this is what error output is for, right?

Mirek
Re: Uninitialized class members. [message #15774 is a reply to message #15770] Wed, 07 May 2008 17:38 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Wed, 07 May 2008 10:32


That the output is mixed (normal output from the app and valgrind output). Same as with gdb.



Options below could be useful ...

    --log-fd=<number>         log messages to file descriptor [2=stderr]
    --log-file=<file>         log messages to <file>
    --xml=yes                 all output is in XML (some tools only)




Regards,
Novo

[Updated on: Wed, 07 May 2008 17:42]

Report message to a moderator

Re: Uninitialized class members. [message #15775 is a reply to message #15756] Wed, 07 May 2008 17:40 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Wed, 07 May 2008 03:57

mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



Yep, I already started checking this Wink



Could you please also check on integration of callgrind?

Wink


Regards,
Novo

[Updated on: Wed, 07 May 2008 17:40]

Report message to a moderator

Re: Uninitialized class members. [message #15776 is a reply to message #15775] Wed, 07 May 2008 17:55 Go to previous messageGo to next message
cocob is currently offline  cocob
Messages: 156
Registered: January 2008
Experienced Member
Oh yes !, i'am really interested by these features !
Re: Uninitialized class members. [message #15777 is a reply to message #15741] Wed, 07 May 2008 19:51 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Tue, 06 May 2008 15:42

Well, thank you Novo, all patches applied.

Please, continue running these diag tools, it seems really helpful Smile

Mirek


Another diff-file.

Sometimes it is really hard to find out which member is not initialized, so I moved initialization of all class members to initialization list instead of assignment in many cases.

Opening TheIDE and loading a project looks almost clean now.


Regards,
Novo
Re: Uninitialized class members. [message #15788 is a reply to message #15777] Wed, 07 May 2008 22:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar() 
+: style(NULL)
+, pagepos(0)
+, pagesize(0)
+, totalsize(0)
+{
 	minthumb = 16;
-	pagepos = pagesize = totalsize = 0;
 	linesize = 1;


?

Same for ArrayCtrl, RichTextView, TopWindow, Ide, Browser....

Mirek

[Updated on: Wed, 07 May 2008 22:54]

Report message to a moderator

Re: Uninitialized class members. [message #15792 is a reply to message #15788] Wed, 07 May 2008 23:05 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
luzr wrote on Wed, 07 May 2008 16:47

-ScrollBar::ScrollBar() {
+ScrollBar::ScrollBar() 
+: style(NULL)
+, pagepos(0)
+, pagesize(0)
+, totalsize(0)
+{
 	minthumb = 16;
-	pagepos = pagesize = totalsize = 0;
 	linesize = 1;


?

Same for ArrayCtrl, RichTextView, TopWindow, Ide, Browser....

Mirek


I personally would move all initialization of members into initialization lists, if I understand you correctly.

I traced only several classes. And it took me two or three hours to understand what is wrong with ArrayCtrl. It is just easier to use initialization lists from very beginning.

BTW, helgrind doesn't complain about TheIDE.


Regards,
Novo

[Updated on: Wed, 07 May 2008 23:08]

Report message to a moderator

Re: Uninitialized class members. [message #15799 is a reply to message #15770] Thu, 08 May 2008 00:06 Go to previous messageGo to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
luzr wrote on Wed, 07 May 2008 16:32

mdelfede wrote on Wed, 07 May 2008 08:20

luzr wrote on Wed, 07 May 2008 09:57

mdelfede wrote on Tue, 06 May 2008 17:18

It would be quite interesting to integrate Valgrind inside the ide....

Max



Yep, I already started checking this Wink

Anyway, right now I see (as usual Smile the problem with output in console apps...

Mirek


Which problem ?

Max



That the output is mixed (normal output from the app and valgrind output). Same as with gdb.

But now thinking about it, maybe this is what error output is for, right?

Mirek


Uhmmmm.... I don't know, but I guess there should be a way to redirect GDB/Valgrind output to a different stream than app output... or, you could attach user app output to a different stream than stdout/stderr.
I'll investigate that one, maybe Smile

Max

Previous Topic: Display problem with Splitter, GLCtrl and MenuBar
Next Topic: Ide console
Goto Forum:
  


Current Time: Thu Mar 28 17:03:47 CET 2024

Total time taken to generate the page: 0.01670 seconds