Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add missing virtual destructors #23215

Closed
wants to merge 3 commits into from

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Oct 2, 2018

This pull request contains three commit which add missing virtual destructors. Please see the individual commit messages for details.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Currently the Options class has a virtual function but no virtual
destructor which means that if delete is called on a Options pointer
to a derived instance, the derived destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on non-final 'node::PerIsolateOptions' that has
virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.
Currently the WorkerDelegate class has a virtual function
but no virtual destructor which means that if delete is called on a
WorkerDelegate pointer to a derived instance, the derived destructor
will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::inspector::WorkerDelegate' that is
abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;
    ^

This commit adds a virtual destructor.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Oct 2, 2018
@danbev
Copy link
Contributor Author

danbev commented Oct 2, 2018

@benjamingr
Copy link
Member

Can this be something we lint for?

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamingr The commit messages mention a compiler warning … I guess that might depend on the compiler version/flags?

@benjamingr
Copy link
Member

benjamingr commented Oct 2, 2018

Checked, I think cpplint can catch this ( https://stackoverflow.com/a/3906866/1348195 ) and so does gcc when building (and clang too probably).

It's just not a warning we have turned on by default probably or don't fail the build on - maybe that's the path forward.

I don't do much C++ for Node (yet!) - but in my own C++ I've found this exact issue to be quite insidious and to cause hard to debug bugs.

@joyeecheung
Copy link
Member

@benjamingr Our cpplint.py doesn't seen to catch missing virtual constructors (only redundant virtual specifiers that come before an override/final)

(Also, our cpplint does not seem to be able to handle cross-file analysis at all..)

@danbev
Copy link
Contributor Author

danbev commented Oct 3, 2018

@danbev
Copy link
Contributor Author

danbev commented Oct 4, 2018

Re-build of failing node-test-commit-linux-containered.
Re-build of failing node-test-commit-arm.

@danbev
Copy link
Contributor Author

danbev commented Oct 5, 2018

Landed in e5c7f10, a8c1458, and 1043660.

@danbev danbev closed this Oct 5, 2018
@danbev danbev deleted the add-missing-virtual-destructors branch October 5, 2018 03:18
danbev added a commit that referenced this pull request Oct 5, 2018
Currently the Options class has a virtual function but no virtual
destructor which means that if delete is called on a Options pointer
to a derived instance, the derived destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on non-final 'node::PerIsolateOptions' that has
virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
danbev added a commit that referenced this pull request Oct 5, 2018
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
danbev added a commit that referenced this pull request Oct 5, 2018
Currently the WorkerDelegate class has a virtual function
but no virtual destructor which means that if delete is called on a
WorkerDelegate pointer to a derived instance, the derived destructor
will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::inspector::WorkerDelegate' that is
abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;
    ^

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 5, 2018
Currently the Options class has a virtual function but no virtual
destructor which means that if delete is called on a Options pointer
to a derived instance, the derived destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on non-final 'node::PerIsolateOptions' that has
virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 5, 2018
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 5, 2018
Currently the WorkerDelegate class has a virtual function
but no virtual destructor which means that if delete is called on a
WorkerDelegate pointer to a derived instance, the derived destructor
will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::inspector::WorkerDelegate' that is
abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;
    ^

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 7, 2018
Currently the Options class has a virtual function but no virtual
destructor which means that if delete is called on a Options pointer
to a derived instance, the derived destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on non-final 'node::PerIsolateOptions' that has
virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 7, 2018
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Oct 7, 2018
Currently the WorkerDelegate class has a virtual function
but no virtual destructor which means that if delete is called on a
WorkerDelegate pointer to a derived instance, the derived destructor
will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::inspector::WorkerDelegate' that is
abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;
    ^

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
Currently the Options class has a virtual function but no virtual
destructor which means that if delete is called on a Options pointer
to a derived instance, the derived destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on non-final 'node::PerIsolateOptions' that has
virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell pushed a commit that referenced this pull request Oct 17, 2018
Currently the WorkerDelegate class has a virtual function
but no virtual destructor which means that if delete is called on a
WorkerDelegate pointer to a derived instance, the derived destructor
will not get called.

The following warning is currently being printed when
compiling:

warning: delete called on 'node::inspector::WorkerDelegate' that is
abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
    delete __ptr;
    ^

This commit adds a virtual destructor.

PR-URL: #23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants