Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 81247 - log4cxx-0.9.7 adjustments related to missing virtual destructors and wrong deletition of new objects using simple delete
Summary: log4cxx-0.9.7 adjustments related to missing virtual destructors and wrong de...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Aaron Walker (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-08 08:47 UTC by Juraj Hercek
Modified: 2005-03-16 03:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
The fix for virtual destructor + correct delete[] operator (log4cxx-0.9.7.diff,906 bytes, patch)
2005-02-08 08:49 UTC, Juraj Hercek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Juraj Hercek 2005-02-08 08:47:40 UTC
2 issues:
(1) While compiling applications that use log4cxx library, I get bunch of warnings when I specify   -Wall warning option to g++ (g++-3.3.X, maybe also older ones...) - something related to usage of virtual functions in classes that do not have virtual destructors (sorry, I don't have original warning listing...).

(2) When using valgrind (memory debugger, version 2.2.0, but older versions complain as well), I get errors regarding mismatched delete/delete[] on memory.

Reproducible: Always
Steps to Reproduce:
1. prepare some testing file that uses log4cxx, include log4cxx/logger.h
2. compile with -Wall flags
3. run using valgrind and check error output

Actual Results:  
Basically nothing, just got bunch of warnings which can cause I miss other, more
important warnings. And there is a memory leak when deleting with simple delete
(and not delete[]) - it's not fatal since it's at the aplication exit, so
nothing fatal, actually.

Expected Results:  
no warnings from g++, no memory leak reports from valgrind.

All the problems described above can be solved by this patch, it's a patch
against original log4cxx-0.9.7 as you get by untgzing original distribution tarball:

diff -ur log4cxx-0.9.7/include/log4cxx/helpers/class.h
log4cxx-0.9.7-adjusted/include/log4cxx/helpers/class.h
--- log4cxx-0.9.7/include/log4cxx/helpers/class.h	2004-05-10 14:41:02.000000000
+0200
+++ log4cxx-0.9.7-adjusted/include/log4cxx/helpers/class.h	2004-09-10
16:41:28.000000000 +0200
@@ -53,6 +53,7 @@
 		{
 		public:
 			Class(const String& name);
+			virtual ~Class() {};
 			virtual ObjectPtr newInstance() const;
 			const String& toString() const;
 			const String& getName() const;
diff -ur log4cxx-0.9.7/src/stringtokenizer.cpp
log4cxx-0.9.7-adjusted/src/stringtokenizer.cpp
--- log4cxx-0.9.7/src/stringtokenizer.cpp	2004-05-10 14:38:08.000000000 +0200
+++ log4cxx-0.9.7-adjusted/src/stringtokenizer.cpp	2004-09-17 19:58:37.000000000
+0200
@@ -39,7 +39,7 @@
 
 StringTokenizer::~StringTokenizer()
 {
-	delete this->str;
+	delete[] this->str;
 }
 
 bool StringTokenizer::hasMoreTokens() const
Comment 1 Juraj Hercek 2005-02-08 08:49:55 UTC
Created attachment 50738 [details, diff]
The fix for virtual destructor + correct delete[] operator
Comment 2 unlord 2005-03-15 16:40:53 UTC
I am seeing this problem currently.  Any idea when this patch will be applied to the ebuild?
Comment 3 Aaron Walker (RETIRED) gentoo-dev 2005-03-16 03:12:21 UTC
Juraj, apologies are due.  I thought I had commented on this bug when it first came in but was mistaken.

negge@vt.edu
> I am seeing this problem currently.  Any idea when this patch will be applied to the ebuild?

Sure, how about now :)  I would have done this a lot sooner had I not forgotten about it.

-r2 is in cvs.