<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>81247</bug_id>
          
          <creation_ts>2005-02-08 08:47 0000</creation_ts>
          <short_desc>log4cxx-0.9.7 adjustments related to missing virtual destructors and wrong deletition of new objects using simple delete</short_desc>
          <delta_ts>2005-03-16 03:12:21 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Ebuilds</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>gprtg@hck.sk</reporter>
          <assigned_to>ka0ttic@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>gprtg@hck.sk</who>
            <bug_when>2005-02-08 08:47:40 0000</bug_when>
            <thetext>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&apos;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&apos;s not fatal since it&apos;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&apos;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&amp; name);
+			virtual ~Class() {};
 			virtual ObjectPtr newInstance() const;
 			const String&amp; toString() const;
 			const String&amp; 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-&gt;str;
+	delete[] this-&gt;str;
 }
 
 bool StringTokenizer::hasMoreTokens() const</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gprtg@hck.sk</who>
            <bug_when>2005-02-08 08:49:55 0000</bug_when>
            <thetext>Created an attachment (id=50738)
The fix for virtual destructor + correct delete[] operator
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>nathanegge@yahoo.com</who>
            <bug_when>2005-03-15 16:40:53 0000</bug_when>
            <thetext>I am seeing this problem currently.  Any idea when this patch will be applied to the ebuild?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-03-16 03:12:21 0000</bug_when>
            <thetext>Juraj, apologies are due.  I thought I had commented on this bug when it first came in but was mistaken.

negge@vt.edu
&gt; 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.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>50738</attachid>
            <date>2005-02-08 08:49 0000</date>
            <desc>The fix for virtual destructor + correct delete[] operator</desc>
            <filename>log4cxx-0.9.7.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtdXIgbG9nNGN4eC0wLjkuNy9pbmNsdWRlL2xvZzRjeHgvaGVscGVycy9jbGFzcy5oIGxv
ZzRjeHgtMC45LjctYWRqdXN0ZWQvaW5jbHVkZS9sb2c0Y3h4L2hlbHBlcnMvY2xhc3MuaAotLS0g
bG9nNGN4eC0wLjkuNy9pbmNsdWRlL2xvZzRjeHgvaGVscGVycy9jbGFzcy5oCTIwMDQtMDUtMTAg
MTQ6NDE6MDIuMDAwMDAwMDAwICswMjAwCisrKyBsb2c0Y3h4LTAuOS43LWFkanVzdGVkL2luY2x1
ZGUvbG9nNGN4eC9oZWxwZXJzL2NsYXNzLmgJMjAwNC0wOS0xMCAxNjo0MToyOC4wMDAwMDAwMDAg
KzAyMDAKQEAgLTUzLDYgKzUzLDcgQEAKIAkJewogCQlwdWJsaWM6CiAJCQlDbGFzcyhjb25zdCBT
dHJpbmcmIG5hbWUpOworCQkJdmlydHVhbCB+Q2xhc3MoKSB7fTsKIAkJCXZpcnR1YWwgT2JqZWN0
UHRyIG5ld0luc3RhbmNlKCkgY29uc3Q7CiAJCQljb25zdCBTdHJpbmcmIHRvU3RyaW5nKCkgY29u
c3Q7CiAJCQljb25zdCBTdHJpbmcmIGdldE5hbWUoKSBjb25zdDsKZGlmZiAtdXIgbG9nNGN4eC0w
LjkuNy9zcmMvc3RyaW5ndG9rZW5pemVyLmNwcCBsb2c0Y3h4LTAuOS43LWFkanVzdGVkL3NyYy9z
dHJpbmd0b2tlbml6ZXIuY3BwCi0tLSBsb2c0Y3h4LTAuOS43L3NyYy9zdHJpbmd0b2tlbml6ZXIu
Y3BwCTIwMDQtMDUt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