[Webkit-unassigned] [Bug 23014] New: Virtual destructors missing

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Dec 28 14:15:23 PST 2008


https://bugs.webkit.org/show_bug.cgi?id=23014

           Summary: Virtual destructors missing
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: dvice_null at yahoo.com


I'm seeing a lot of base classes without proper virtual destructors. If the
inherited class is destroyed via interface, the destructor of the inherited
class is not called and e.g. memory released in destructor is not released. 

http://en.wikipedia.org/wiki/Virtual_method#Virtual_destructors

It is quite a lot of work to check all cases, especially since there is so many
of these situations, so easy fix is to add a virtual destructor (It is
important that the destructor has also a body, empty {} or non-empty.) to each
of the base classes that are inherited by others. IMHO if there is no good
reason not to use virtual destructors in base classes, it should be used there
to prevent problems that could be really hard to find.  

I am posting here a list of examples of such situations where virtual
destructor should probably be added. Note that some base classes are inherited
by multiple classes, so some base classes are listed multiple times in the
list. The list was generated by cppcheck: http://cppcheck.wiki.sourceforge.net/

[../WebKit/JavaScriptCore/runtime/JSVariableObject.h:43]: Class
JSVariableObject which is inherited by class JSStaticScopeObject does not have
a virtual destructor
[../WebKit/JavaScriptCore/bytecode/CodeBlock.h:221]: Class CodeBlock which is
inherited by class ProgramCodeBlock does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ArrayNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:123]: Class Node which is inherited by
class PropertyListNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ObjectLiteralNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class BracketAccessorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class BracketAccessorNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class DotAccessorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class DotAccessorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:123]: Class Node which is inherited by
class ArgumentListNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class NewExprNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class NewExprNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class EvalFunctionCallNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class EvalFunctionCallNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class FunctionCallValueNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class FunctionCallValueNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class FunctionCallResolveNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class FunctionCallResolveNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class FunctionCallBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class FunctionCallBracketNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class FunctionCallDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class FunctionCallDotNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PostfixBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class PostfixBracketNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PostfixDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class PostfixDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PostfixErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class PostfixErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class DeleteBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class DeleteBracketNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class DeleteDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class DeleteDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class DeleteValueNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class VoidNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class TypeOfValueNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PrefixBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:336]: Class
ThrowablePrefixedSubExpressionData which is inherited by class
PrefixBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PrefixDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:336]: Class
ThrowablePrefixedSubExpressionData which is inherited by class PrefixDotNode
does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class PrefixErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class PrefixErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class UnaryOpNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class BinaryOpNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class LogicalOpNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ConditionalNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ReadModifyResolveNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class ReadModifyResolveNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class AssignResolveNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class AssignResolveNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ReadModifyBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class ReadModifyBracketNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class AssignBracketNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class AssignBracketNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class AssignDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class AssignDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ReadModifyDotNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:306]: Class ThrowableSubExpressionData
which is inherited by class ReadModifyDotNode does not have a virtual
destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class AssignErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class AssignErrorNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class CommaNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class ConstDeclNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ConstStatementNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class BlockNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class VarStatementNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class IfNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class DoWhileNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class WhileNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ForNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ForInNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class ForInNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ReturnNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class ReturnNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class WithNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class LabelNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class LabelNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ThrowNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:269]: Class ThrowableExpressionData
which is inherited by class ThrowNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class TryNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class ScopeNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:157]: Class ExpressionNode which is
inherited by class FuncExprNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class FuncDeclNode does not have a virtual destructor
[../WebKit/JavaScriptCore/parser/Nodes.h:186]: Class StatementNode which is
inherited by class SwitchNode does not have a virtual destructor
[../WebKit/JavaScriptCore/runtime/JSWrapperObject.h:31]: Class JSWrapperObject
which is inherited by class DateInstance does not have a virtual destructor
[../WebKit/JavaScriptCore/runtime/JSVariableObject.h:43]: Class
JSVariableObject which is inherited by class JSActivation does not have a
virtual destructor
[../WebKit/JavaScriptCore/runtime/InternalFunction.h:34]: Class
InternalFunction which is inherited by class JSFunction does not have a virtual
destructor
[../WebKit/JavaScriptCore/runtime/JSVariableObject.h:43]: Class
JSVariableObject which is inherited by class JSGlobalObject does not have a
virtual destructor


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list