Skip to content

Conversation

@cconvey
Copy link
Contributor

@cconvey cconvey commented Jun 7, 2022

Add missing virtual destructor for derived class
tvm::relay::transforms::ExistingGlobalSymbolCache.
Fixes a potential problem when deleting an instance
using a pointer-to-base-class.

@cconvey
Copy link
Contributor Author

cconvey commented Jun 7, 2022

CC: @vinx13 @mbs-octoml

@cconvey
Copy link
Contributor Author

cconvey commented Jun 7, 2022

FYI, I only noticed this because of a compiler warning from clang-10, not because of a manifested bug.

@vinx13
Copy link
Member

vinx13 commented Jun 7, 2022

It might be better to have a virtual default destructor defined in the base class GlobalSymbolCache since otherwise every derived class need a virtual destructor.

Add a default virtual destructor to
`tvm::relay::transforms::GlobalSymbolCache`, so that
correct destructors run when destroying
subclass instances.
@cconvey cconvey force-pushed the fix-nonvirtual-dtor branch from c34b468 to e383338 Compare June 7, 2022 19:40
@cconvey
Copy link
Contributor Author

cconvey commented Jun 7, 2022

@vinx13 : Mind giving this a Review?

*/
class GlobalSymbolCache {
public:
virtual ~GlobalSymbolCache();
Copy link
Member

Choose a reason for hiding this comment

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

nit: for simplicity, we have the implmentation inlined here

Suggested change
virtual ~GlobalSymbolCache();
virtual ~GlobalSymbolCache() = default;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: for simplicity, we have the implmentation inlined here

Thanks, I did consider that. Normally I prefer to keep as many details in the .cc file as possible, for better modularity.

@vinx13 vinx13 merged commit 774ee96 into apache:main Jun 7, 2022
Kathryn-cat pushed a commit to Kathryn-cat/tvm that referenced this pull request Jun 10, 2022
Add a default virtual destructor to
`tvm::relay::transforms::GlobalSymbolCache`, so that
correct destructors run when destroying
subclass instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants