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

Simplify TSS cleanup routines. Fixes #236 #249

Merged
merged 1 commit into from
Jan 3, 2019

Conversation

Kojoley
Copy link
Contributor

@Kojoley Kojoley commented Nov 17, 2018

Instead of wrapping a default or user provided destructor into a virtual
class and placing it into a shared_ptr it is now stored directly with
an elided type, to not introduce UB it is not called directly but through
a helper function which casts it back to the original type before calling.

I tried to touch as little lines as possible to make the review simpler.

Instead of wrapping a default or user provided destructor into a virtual
class and placing it into a shared_ptr it is now stored directly with
an elided type, to not introduce UB it is not called directly but through
a helper function which casts it back to the original type before calling.
@viboes
Copy link
Collaborator

viboes commented Nov 18, 2018

Thanks for working on this.
I believed that the issue was the the sanitizer itself.
Please, could you describe where the UB reported in #236 was so that I understand better the PR?

@pdimov Please, could you check this and tell us what do you think?

Of course, I couldn't accept this change for boost.1.69, as it is too late.

@Kojoley
Copy link
Contributor Author

Kojoley commented Nov 18, 2018

I believed that the issue was the the sanitizer itself.

There is no consensus. GGC and Clang devs says that it is not a bug in sanitizer.

Please, could you describe where the UB reported in #236 was so that I understand better the PR?

The PR can be reviewed without thinking about #236, it is just a nice side effect.

You can check my bug report to LLVM https://bugs.llvm.org/show_bug.cgi?id=39191 for the simple example.

The problem is that virtual methods (operator() and destructor in the case) are called on objects (delete_data/run_custom_cleanup_function) that passes DSO boundaries as base (tss_cleanup_function), but their symbols are hidden. Making these symbols visible will solve the problem too, but as there is no consensus on the topic and because it is possible not to use virtual classes for solving the TSS needs.

@pdimov
Copy link
Member

pdimov commented Nov 18, 2018

The original code is a bit odd, I suspect it dates from premodern times when shared_ptr didn't have deleters and boost::function didn't exist. Nowadays you could just use shared_ptr<void>( value, func ), or boost::function.

The patch works too, I suppose. It's a matter of taste which one to pick.

@viboes
Copy link
Collaborator

viboes commented Nov 19, 2018

@Kojoley Could we summarize that there is no real bug and that the patch is just silencing the sanitizer? Are we on UB land?
Could you clarify what is this fixing aside #236?

@pdimov yes the code dates a lot.

@Kojoley
Copy link
Contributor Author

Kojoley commented Nov 19, 2018

The original code is a bit odd, I suspect it dates from premodern times when shared_ptr didn't have deleters and boost::function didn't exist. Nowadays you could just use shared_ptr( value, func ), or boost::function.

The code is now that old, it is from 2007, and it was using boost::function 332dd98.

@Kojoley Could we summarize that there is no real bug and that the patch is just silencing the sanitizer?

You can treat it like that.

Are we on UB land?

This case is not documented to be UB, even throwing and catching hidden symbols is not explicitly banned (see boostorg/function#24).

Again:

There is no consensus. GGC and Clang devs says that it is not a bug in sanitizer.

Could you clarify what is this fixing aside #236?

Nothing.

@viboes
Copy link
Collaborator

viboes commented Nov 21, 2018

If this is not fixing nothing clear yet, why do you want I apply this PR then?

@Kojoley
Copy link
Contributor Author

Kojoley commented Nov 21, 2018

OMG, you are killig me. The PR:

  1. Removes (potential) UB.
  2. Simplifies the code by reducing number of dependencies.
  3. Makes TSS faster by removing shared_ptr.

@viboes
Copy link
Collaborator

viboes commented Jan 3, 2019

I've decided to give it a chance to this PR. We have now the time to fix it if there will be some regressions.

@viboes viboes merged commit 758d087 into boostorg:develop Jan 3, 2019
@Kojoley Kojoley deleted the feature/simplify-tss-cleanup branch January 3, 2019 22:05
@viboes viboes added this to the 1.70 milestone Jan 20, 2019
@Kojoley Kojoley mentioned this pull request Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants