Skip to content

Fix rare segfaults#7350

Merged
akuzm merged 3 commits intomasterfrom
fix_rare_segfault_in_copier
Oct 17, 2019
Merged

Fix rare segfaults#7350
akuzm merged 3 commits intomasterfrom
fix_rare_segfault_in_copier

Conversation

@tavplubix
Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Category (leave one):

  • Bug Fix

Short description (up to few sentences):
Wait for all scheduled jobs, which are using local objects, if ThreadPool::schedule(...) throws an exception. Rename ThreadPool::schedule(...) to ThreadPool::scheduleOrThrowOnError(...) and fix comments to make obvious that it may throw.

@tavplubix tavplubix added the pr-bugfix Pull request with bugfix, not backported by default label Oct 16, 2019
@akuzm
Copy link
Copy Markdown
Contributor

akuzm commented Oct 16, 2019

Good catch, although I'm not sure that these changes would be sufficient to prevent future mistakes of this kind. Come to think of it, capturing the thread's stack to use it in another threads is perverse, but we don't have other way to represent return values with this API. Even if we had it, there's no way to prevent it with lambdas.

On a side note, I never liked how we work with exceptions in ThreadPool -- it's not like the caller can get anything useful from a particular exception, so there is no benefit in saving and rethrowing them: we might as well just log them and then throw our own. Combined with the wonderful template <typename ReturnType> pattern, finding out what scheduleImpl really does with exception is just hopeless. Maybe I should rewrite it to also fix the crazy msan failure there that I still haven't been able to debug.

@akuzm
Copy link
Copy Markdown
Contributor

akuzm commented Oct 17, 2019

@akuzm akuzm merged commit 0046b9f into master Oct 17, 2019
akuzm pushed a commit that referenced this pull request Oct 29, 2019
@alesapin
Copy link
Copy Markdown
Member

conflict in 19.15

@tavplubix tavplubix deleted the fix_rare_segfault_in_copier branch November 22, 2019 00:03
akuzm pushed a commit that referenced this pull request Jul 2, 2020
(cherry picked from commit 0046b9f)
(cherry picked from commit 69b3955)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants