|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Uninitialized class members.
Uninitialized class members. [message #15725] |
Tue, 06 May 2008 17:31 |
Novo
Messages: 1363 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 |
|
mirek
Messages: 13984 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 #15738 is a reply to message #15735] |
Tue, 06 May 2008 21:27 |
|
mirek
Messages: 13984 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.
|
OK, thanks for clarification, you are right (and I am wrong, once again
Mirek
|
|
|
|
|
|
|
|
Re: Uninitialized class members. [message #15751 is a reply to message #15748] |
Wed, 07 May 2008 04:10 |
Novo
Messages: 1363 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 #15774 is a reply to message #15770] |
Wed, 07 May 2008 17:38 |
Novo
Messages: 1363 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 |
Novo
Messages: 1363 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
|
Could you please also check on integration of callgrind?
Regards,
Novo
[Updated on: Wed, 07 May 2008 17:40] Report message to a moderator
|
|
|
|
|
Re: Uninitialized class members. [message #15788 is a reply to message #15777] |
Wed, 07 May 2008 22:47 |
|
mirek
Messages: 13984 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 |
Novo
Messages: 1363 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 |
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
Anyway, right now I see (as usual 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
Max
|
|
|
Goto Forum:
Current Time: Mon Jun 10 13:12:22 CEST 2024
Total time taken to generate the page: 0.01641 seconds
|
|
|