-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix build failure when using TBB_USE_EXCEPTIONS=0 #1219
base: master
Are you sure you want to change the base?
Conversation
We get a link error from 'task_dispatcher.h's reference to 'do_throw_noexcept(...)', which is not defined when building with 'TBB_USE_EXCEPTIONS=0'. Since any throw from a 'noexcept' function results in a 'std::terminate', and all current uses of 'do_throw_noexcept' do nothing more than throw a custom exception, 'do_throw_noexcept' is equivalent to 'std::terminate', and replacing with 'std::terminate' makes things a bit clearer & cleaner. Signed-off-by: Dan Hawson <[email protected]>
It might make sense to keep |
OK. That is going a bit further than fixing the issue and keeping the same behaviour; this initial change just keeps the exact same behaviour but fixes the TBB_USE_EXCEPTIONS==0 problem. If you prefer, I don't object to going a step further and writing out a message in the cases that have otherwise always quietly terminated. See the recent Better exception error reporting commit for my interpretation of your suggestion. ... I've just seen it's upset the tests
This looks like the test is expecting something like a terminate instead of an abort. I'll look in to that when I get time but, ignoring that for now, do the added reporting mechanisms look like what you're after? A couple of things to note about the additions -
The table shows the 3 different |
In the cases of TBB_USE_EXCEPTIONS==0 or with 'terminate_on_exception()' enabled, we now print more useful error info instead of the previous std:terminate behaviour. Note: The current tests expect any run-time 'terminate_on_exception' behaviour to 'terminate', not 'abort', so we also 'terminate' for all exception throws when using TBB_USE_EXCEPTIONS==1. Signed-off-by: Dan Hawson <[email protected]>
... Yes, the tests are understandably expecting terminate, not abort, when using the ... Whether that's preferable from a user's point of view is a separate question that I don't think should be addressed here; changing that in this PR would go even further beyond the intended scope of just fixing a broken build configuration while keeping the originally intended behaviour (i.e. it's always essentially been a std::terminate in all cases). |
@GertyP Thank you for the update. It turned out this place is tricky. (It will take some time for me to figure out how we can proceed with this) |
Thanks for having a look at this @pavelkumbrasev It only got a little more tricky to consider the matrix of uses and build/run combinations at your request to try to get more useful error info out to the user 😄 , which I think is perfectly reasonable and which hopefully I've managed to do in the latest commit... But if you're unwilling to take both together (and we can't agree on what else might need further changes), then perhaps consider just taking just the first change. |
I have tried to clarify whether oneTBB (library part) should be build with |
This is a documented feature macro here. I can sympathise that it would suggest the need for additional build tests if you really wanted to be rigorous ... but a phrase also comes to mind: "Don't let perfection be the enemy of good". In other words, I fear that there's a possibility that you find testing a full and complete set of tests with configuration 'TBB_USE_EXCEPTIONS=0' far too much of a burden and so decide it's easer to drop it than to implement an exhaustive set of extra tests. But there is another practical compromise alternative, which is to add minimal testing that hits this link error at least. E.g. -
which takes just a few seconds before revealing this issue as a link error. But even if there aren't any auto-tests to cover the build and/or run-time testing of this configuration, it's still preferable, from my point of view, if you're still willing to take fixes for cases which you've decided to no longer officially support but which can technically still be used. I think the vast majority of TBB users would not blame you for not covering absolutely 100% of all build and run-time config permutations, so it would be a shame to not take small fixes when they are discovered. It would also be a shame to remove a fairly simple, quite well isolated feature like this (it's all quite nicely contained within
Need may be too strong a word but, in addition to another answer to this question, I think that, in some circumstances, use of exceptions can facilitate worse code to read and understand as well as well as facilitating worse system design decisions. It's a big topic and a bit philosophical but I think throwing and catching exceptions too easily promotes "exceptional circumstances as normal cases" to be considered and handled throughout more code than usually necessary, encouraging programmers think at a very zoomed in level about how to try to gracefully handle and 'soldier on' with things like bad inputs, bad results, out-of-memory, misuse of an interface, etc. instead of being confronted by the clean simplicity of a hard break/abort/crash, where you're forced to better understand the systems you use, the assumptions you have, and as a result, usually come up with a better designed system (e.g. more comprehensive and careful up-front partitioning and budgeting of memory given to various systems instead of lower-level run-time code that's polluted with bloated retry flailing upon failure to allocate memory). |
I'd be interested to know if there's any update on this. At least a follow-up decision (with some rationale, depending on the decision) would be more satisfactory than an open, ignored PR. As I mentioned above, the first commit really is a minimal change that fixes this build config while keeping the same behaviour in the usual However, your suggestion to improve the error reporting has resulted in the follow-up commit, which I think not only improves the |
Hi @GertyP, there is still no decision regarding this problem. I'm concerned with such a solution because it's just hides the problem. |
I'm unclear on what you mean by this. "The problem" in this case would seem to be just for me, but maybe others too, who try to use something that's documented but which doesn't build. This "solution" fixes the broken build when using this feature. What problem is being hidden by this solution that doesn't already exist? I wonder if you mean that this solution does not add new tests to cover this use case, leaving the possibility that some future change again breaks the ability to build with I don't see how you're losing anything by taking this. In fact, as I said above, the follow-up commit not only fixes something (even if it's something you don't care about), it also improves the existing functionality in use cases you do care about (actual error messages instead of quiet terminates by throwing from noexcept funcs) as well, I'd argue, as improving the code readability.
That still leaves a lot of places/scenarios where nothing useful is shown to the user upon an error: It currently doesn't do anything useful and will quietly terminate, without any useful info, if catching an error from the Because it seems like there are only things to gain/improve from these changes and nothing to lose (no new regressions, no new loss of test coverage), it feels like I must be missing something or I haven't explained something so perhaps it'll help both/either of us better understand if you could try to answer these, please? -
I promise I'm not trying to be objectionable or argumentative here; I'm genuinely confused and of the opinion that there's a big misunderstanding that I'm now intrigued to better understand 😕 |
Description
This is just an alternative (arguably simplifying) fix in comparison to PR 864 and also discussed in issue 1208. I did comment in PR 864, to describe what I've done here, but since 864 has been open for a long time, I thought it might be useful to show my suggested changes here and see if it gains any traction.
We get a link error from 'task_dispatcher.h's reference to 'do_throw_noexcept(...)', which is not defined when building with 'TBB_USE_EXCEPTIONS=0'. E.g. -
Since any throw from a 'noexcept' function results in a 'std::terminate', and all current uses of 'do_throw_noexcept' do nothing more than throw a custom exception, 'do_throw_noexcept' is equivalent to 'std::terminate', and replacing with 'std::terminate' makes things a bit clearer & cleaner.
Fixes # - 1208
Type of change
Choose one or multiple, leave empty if none of the other choices apply
Add a respective label(s) to PR if you have permissions
Tests
Documentation
Breaks backward compatibility
Notify the following users
List users with
@
to send notificationsOther information