| From: redr...@gmail.com Sent: Saturday, July 30, 2016 8:14 PM To: ISO C++ Standard - Future Proposals Reply To: std-pr...@isocpp.org Subject: [std-proposals] Exception stack trace information. |
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20160731004107.4898897.76636.14874%40gmail.com.
How can I correct the problem or bug if I do not know where the problem happened.
It is impossible or I need put try ... catch statement in every place of my program.
throw socket_error("Cannot open socket !");To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/237863cb-3569-4784-b6f5-db80ac069ff6%40isocpp.org.
воскресенье, 31 июля 2016 г., 19:09:51 UTC+3 пользователь Thiago Macieira написал:
> On domingo, 31 de julho de 2016 02:57:35 PDT Денис Котов wrote:
> > > You misunderstand what exceptions are for. You're not supposed to catch
> >
> > them
> >
> > > to find out where the error occurred. You catch them so you handle the
> > > condition wherever it happened, then continue execution because you've
> > > corrected the problem.
>> >
> > > I think this is incorrect.
> > > How can I correct the problem or bug if I do not know where the problem
> > > happened.
> There was no bug. Exceptions are not used to signal bugs. They are used to
> signal perfectly fine, if exceptional, conditions. A file not being found is not
> a bug.
I said problem or bug. If somebody try get element using arr.at(1000) it will throw exception.
Is it bug or problem ?
If we want to show user that something goes wrong we throw exception (for example file not found as you wrote) we need show user where it happened.
воскресенье, 31 июля 2016 г., 20:23:21 UTC+3 пользователь Nicol Bolas написал:On Sunday, July 31, 2016 at 12:38:26 PM UTC-4, Денис Котов wrote:воскресенье, 31 июля 2016 г., 19:09:51 UTC+3 пользователь Thiago Macieira написал:
> On domingo, 31 de julho de 2016 02:57:35 PDT Денис Котов wrote:
> > > You misunderstand what exceptions are for. You're not supposed to catch
> >
> > them
> >
> > > to find out where the error occurred. You catch them so you handle the
> > > condition wherever it happened, then continue execution because you've
> > > corrected the problem.
>> >
> > > I think this is incorrect.
> > > How can I correct the problem or bug if I do not know where the problem
> > > happened.
> There was no bug. Exceptions are not used to signal bugs. They are used to
> signal perfectly fine, if exceptional, conditions. A file not being found is not
> a bug.
I said problem or bug. If somebody try get element using arr.at(1000) it will throw exception.
Is it bug or problem ?
If we want to show user that something goes wrong we throw exception (for example file not found as you wrote) we need show user where it happened.
If I'm using a GUI application, I don't know or care what function caused a "file not found as you wrote" exception. I don't want a stack trace; it would be of utterly no value to me. I don't have the code; I don't know what those functions mean. What I care about is whether the application can handle that circumstance or not.
Crashing because of a missing file may be reasonable for some applications. In those cases, a stack trace would still not be helpful. Simply stopping, perhaps with an error message, is sufficient.
Stack traces are only of value to programmers, and generally, only to the programmers who wrote the system in question. So what you show to "the user" is irrelevant.> If I'm using a GUI application, I don't know or care what function caused a "file not found as you wrote" exception. I don't want a stack trace; it would be of utterly > no value to me. I don't have the code; I don't know what those functions mean. What I care about is whether the application can handle that circumstance or not.
It is not needed for you, but do not say in general that this is useless. If C++ has exceptions we should make them more frendly for users.
In Embedded programming this is very helpful feature (stack trace).
Modern Programming Languages have had already it (Java, C#, Python and so on).
Guys has already mentioned that stack trace will be usefull,
but only you do not like this idea, because you do not use it.
How can you know whether it usefull or not if you have never use this feature in C++ ?
1. We should standardize them in some way.
2. Every exception should bear the weight of a stack trace.
воскресенье, 31 июля 2016 г., 21:49:40 UTC+3 пользователь Nicol Bolas написал:
No, we should. Please, count number of questions about stack trace on StackOverflow.> Yes, stack traces are useful. That doesn't mean that:
> 1. We should standardize them in some way.
If something become so needed it is time to standardize it, otherwise we would code a class without keyword "class", but using keyword "struct" right now.
And somebody would say: "Why should we standatize keyword "class" ? "struct" is enough for long term."
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0b73ccc1-a873-441b-ad74-8bb44d6b28e0%40isocpp.org.
In C++17 will be added a lot of new features, but no of them features improve quality of code and quickly fixing of the code.
If in program exist a bug then the best that program can do is crash. Exception is a good conception for error handling, but is useless in C++ implementation, 'cause we do not know where the problem happens. That mean catching of exception is useless, because additional information is so small that better allow program simple crash.
This is the main reason that even in debug mode exception is used not often.
PROBLEM is no standard on it about providing to user backtrace.
Operation system can get stack trace when exception was used. We can implement getting stack trace even in dummy implementation by adding to every function in compile time meta information with name of this function and code that will put this name in stack object that implicitly exists from starting the program. We can add scpecial flag BACK_TRACE or BTRACE.
Sorry for straightforward speech but I tired. In we can implement backtrace, but are thinking about coroutine. Without strong base we cannot implement something good.
Thanks,
Best regards.
The idea has merit to me. But why is debug mode anything other than slightly relevant to tbe proposal let alone a reason to derail it? Even if debug mode is relevant, won't the Standard have to wakeup to debug mode anyway for Contracts, so what's the big deal?
So why can't the Standard suggest something like what the OP says e.g.: "if BTRACE is defined as 1, the compiler might emit extra trace information that might aid debugging. If that information is generated, an exit via an unhandled exception will cause std::dump_stacktrace to be automatically called. If BTRACE==0 or not defined, std::dump_stacktrace will not be called."
Enabling the facility in "release mode" seems to be another reason why debug mode seems mostly irrelevant to the debate.
If this means someone could configure a program to get a basic stack trace on program failure and also be able to dump that on demand and all without having to know anything special about the platform or compiler or debug options and without a lot of stress on vendors to power it, what's so unreasonable?
It looks like this thread started just like this one: https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/A17G1ram9nsTo quote:To find the root cause of bugs easier, it is very helpful to have stack trace from the location where the exception is thrown.Surely I can throw an exception class derived from std:exception and use backtrace on Linux or StackWalk64 on Windows, with the appropriate symbols (=> not portable),or have a try catch "everywhere" and add file and line information (=> too much code to add),or not to catch the exception at all and let the Operation System write the dump file(=>not portable, some exceptions can be handled inside the program).I thought there should be an easy portable way to add stack information to a std::exception. Does anybody have some ideas?(end)It then morphed into a discussion of just getting the stack trace, not necessarily in an exception context, but some of what we discussed there, in particular the separation of capture/parse functionality, is applicable in any case.In this new thread, more than one participant have mentioned they they find it undesirable to have exceptions carry the weight of stack tracing.This sentiment is understandable, but I have the following two points to be considered in this respect:1. Is the performance of exception handling really an overriding concern?
What's NDEBUG? I never set that in my programs, since I almost never need
them. I'm being serious, I never set them. Qt doesn't react to NDEBUG and
since all my programs are written with Qt...
No, Nicol is right: there's no such thing as "debug mode" in the standard.
Please find some other condition to enable your feature in.
On Mon, Aug 1, 2016 at 4:52 PM, Tom Honermann <t...@honermann.net> wrote:
> So, you would require dynamic memory allocation, or require a thread specific statically sized buffer (multiple buffers actually since exceptions can nest) that limits the number of supported frames, in order to throw an exception?
Memory allocation for exception objects is already explicitly unspecified by [except.throw], so discussing this further would be discussing how a hypothetical implementation could optimise that.
Are we going to achieve anything substantial by going there?
On Mon, Aug 1, 2016 at 6:24 PM, Tom Honermann <t...@honermann.net> wrote:
> Yes, but today, the amount of memory required for the exception object is statically knowable.
True, but at least one major implementation does not seem to use that and allocates memory dynamically anyway [1, 2, search for __cxa_allocate_exception in both].
void*
__cxa_allocate_exception(size_t
thrown_size)--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg2iON%2BcuqzWkN%3DCQVz5x9_iAEako_SmxCD48GMh6GSxbA%40mail.gmail.com.
On Mon, Aug 1, 2016 at 6:38 PM, Tom Honermann <t...@honermann.net> wrote:
> The signature for that function follows. Note that it is invoked with the statically known size.
Your earlier argument was about the need for dynamic allocation, which I interpreted as if you had thought that existing implementations could dispense with that. I mentioned that was unspecified by the standard, and I have demonstrated that at least one major implementation does perform dynamic memory allocation when an exception is thrown.
I am not really sure what you argument is now.
Is it about that more than one dynamic memory allocation may be required? But many, if not all, standard exception classes would need that, too, because they have to hold arbitrary strings passed into their constructors. So is it now three allocations vs two? I'm pretty sure the implementation could trivially collapse subsequent memory allocations into one, but even if we assume they are dumb, is that really a deal breaker at this stage?
On segunda-feira, 1 de agosto de 2016 07:19:23 PDT Wil Evers wrote:
> You should know what NDEBUG is; it is a standard C++ feature. #defining
> NDEBUG disables assertions.
I was slightly exagerating my ignorance. But it has happened, more than once,
that I see assert() left in my release code until I remember that I needed to
set it.
> Given that, it seems quite reasonable to think of a build where NDEBUG is
> not defined as a "debug build". Even if Qt doesn't react to NDEBUG,
> conforming user code can.
We could have inline features and other macros that react to NDEBUG. But that
can't affect code generation by the compiler.
We could have the opposite though: compiler switches that affect code
generation get a predefined macro added or suppressed.
At worst, someone could #define throw and do something "evil" with it, to
accomplish what was discussed.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4176746.l6UKp6CGP7%40tjmaciei-mobl1.
On segunda-feira, 1 de agosto de 2016 12:13:10 PDT Wil Evers wrote:
> On Monday, August 1, 2016 at 5:34:11 PM UTC+2, Thiago Macieira wrote:
> Sounds like you need to fix your build system. Since the effect of NDEBUG
> is defined in the standard, I would expect any build system, on any
> platform, do #define NDEBUG in release builds, it it makes such a
> distinction. If it doesn't, you have more serious problems to worry about.
I disagree. The standard only talks about assert.h, not other features. That
has nothing to do with release mode and debug mode. And maybe I want
assertions left in my code, even in release mode, so automatically doing it is
not a good idea.
The buildsystem should be agnostic and not define things I don't want it to.
And besides, in a Qt-centric buildsystem (like qmake), it would define
QT_NO_DEBUG, not NDEBUG.
> The point of NDEBUG is to generate *different code* in different
> build configurations.
And so is QT_NO_DEBUG, QT_NO_DEBUG_OUTPUT, QT_FORCE_ASSERTS,
QT_NO_CAST_FROM_ASCII, QT_NO_CAST_TO_ASCII, and many other flags.
On segunda-feira, 1 de agosto de 2016 15:34:41 PDT gmis...@gmail.com wrote:
> > a) add a function std::dump_backtrace, whose behaviour is suggested by the
> > standard, but a compliant implementation could simply do nothing.
> >
> > b) let the user do:
> > std::set_terminate_handler(std::dump_backtrace);
> a) is exactly what I was proposing.
>
> b) would come under what I referred to as spicing things up. But I agree.
>
> But to elaborate I purposely didn't dig into b) yet - spicing things up
> - because I wanted to avoid people using it to prove that a minimum viable
> product was not possible. Because I think it is and the start of this
> thread was beginning to go like most of the threads on here go with people
> saying "oh that's not possible" because they are overly focusing on what
> people say rather than helping them achieve what they are trying to achieve
> or inching towards their goal.
That's not how I read it. This thread started talking about exceptions and
adding stack frame information to the exceptions, which adds cost and violates
the "don't pay for what you don't use" rule. Adding the function above has
nothing to do with exceptions and doesn't add cost if you don't ever use it.
Moreover, it's based on existing practice, tested and tried.
> I know everyone has bad days (me too) but I'd generally like to see this
> forum adopt a more nurturing tone to posters. I think that starts by more
> people embracing the concept that you can nurture an idea without having to
> adopt it, nor kill it or even agree with it. And not getting overly tied up
> nit picking too early. Perhaps it's like interviewing with the style of
> helping people find out what people know by giving them the answers to what
> they don't know instead of just going "ding, wrong answer, you fired" at
> the first hurdle.
You mean the OP that contained many factually incorrect statements and
insulted to the intelligence of the people in this list and the committee
members?
"In *C++17* will be added a lot of new features, but no of them features
improve quality of code and quickly fixing of the code."
"Exception is a good conception for error handling, but is useless in C++
implementation"
"This is the main reason that even in debug mode exception is used not often."
"In we can implement *backtrace*, but are thinking about coroutine. Without
strong *base *we cannot implement something good." (implies that the base
isn't strong and that coroutines are not good)
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
On segunda-feira, 1 de agosto de 2016 23:12:06 PDT Wil Evers wrote:
> I would argue that a library or build system that ignores common practice
> backed by a standard specification is harder to use than it need be.
What common practice? Like I said, NDEBUG is only used for assert.h. Aside
from that, I see absolutely zero uses in the standard C or C++ libraries, in
glibc as a whole (so, POSIX and GNU extensions), and a couple of uses in
sqlite3.h, eigen3, plus google log, test, and protobuf. That hardly looks like
common practice to me.
What common practice? Like I said, NDEBUG is only used for assert.h. Aside
from that, I see absolutely zero uses in the standard C or C++ libraries, in
glibc as a whole (so, POSIX and GNU extensions), and a couple of uses in
sqlite3.h, eigen3, plus google log, test, and protobuf. That hardly looks like
common practice to me.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a0969adb-38b1-450c-b4b7-2c5cf3bef4db%40isocpp.org.
On Mon, Aug 1, 2016 at 7:45 PM, Tom Honermann <t...@honermann.net> wrote:
> I do think that existing implementations can dispense with dynamic allocation, at least for non-nested exceptions.
As I indicated earlier, this moves the discussion into a hypothetical domain. If you think it acceptable to postulate that some implementations dispense with dynamic allocation through the use of magic allocation, then I could equally think it acceptable to postulate magic exceptions that need no memory allocation at all to capture a stack trace. I do not think either postulate is ultimately convincing.
Just to stay in the real domain, your postulate is true for one major implementation, and mine can also be true for the same implementation. It is MSVC, on the AMD64 architecture at least, where the underlying hardware stack (as opposed to the abstract machine's stack) is not unwound till an exception is fully handled (i.e., a catch clause exits normally), and the exception object is constructed on the stack. I cannot reference my sources, but this can be easily confirmed with a debugger.
Since the entire stack is present till exception handling is fully complete, it can be captured directly without any intermediate allocations.
> Such implementations would necessarily dynamically allocate for copying an exception object to satisfy lifetime requirements for std::current_exception(), so I do accept that dynamic allocation is required in some cases.
In which case an implementation can just have a statically-sized list that handles "most common cases", and an overflow list that handles everything else. Then your acceptance criterion is trivially met.
> There is a distinction between dynamic allocation performed by the constructor of a thrown object vs the allocation for the thrown object itself.
Does dynamic allocation solely in the constructor of a thrown object meet your criteria? This can, again, be trivially accomplished for a variable-length list of pointers.
In C++17 will be added a lot of new features, but no of them features improve quality of code and quickly fixing of the code.
If in program exist a bug then the best that program can do is crash. Exception is a good conception for error handling, but is useless in C++ implementation, 'cause we do not know where the problem happens. That mean catching of exception is useless, because additional information is so small that better allow program simple crash.
This is the main reason that even in debug mode exception is used not often.
PROBLEM is no standard on it about providing to user backtrace.
Operation system can get stack trace when exception was used. We can implement getting stack trace even in dummy implementation by adding to every function in compile time meta information with name of this function and code that will put this name in stack object that implicitly exists from starting the program. We can add scpecial flag BACK_TRACE or BTRACE.
Sorry for straightforward speech but I tired. In we can implement backtrace, but are thinking about coroutine. Without strong base we cannot implement something good.
Thanks,
Best regards.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3c73071d-76bc-4cc0-8d9b-155999d7ade2%40isocpp.org.
This list is for discussion, but nothing stopping you from preparing a proposal and coming to present it at a committee meeting, regardless of what's being discussed here. Take that feedback into account, it can only help you prepare yourself better. If you see a lot of resistance, try to see if you think you can convince people, including committee members (you'll have an advance perspective on what objections you might expect there).As has been pointed out previously, this is not the first time this has been discussed, so you might want to inspire yourself from prior exchanges to prepare yourself, should you wish to go forward.Not all feedback has been negative. You can build something from all this should you be inclined to.Cheers!
2016-08-05 17:44 GMT-04:00 Денис Котов <redr...@gmail.com>:
What is the result of our TOPIC ?
Result is ZERO !!!!! How many human*hours has been spent, but nothing !
Can somebody from сommittee help us ?
Will be it consider on standartization ?
We have different opinions. Some guys think it is usefull, another is not.
We need a look from outside !!!
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b5548c7a-933e-4a92-a2d4-77a1cca213c1%40isocpp.org.
In C++17 will be added a lot of new features, but no of them features improve quality of code and quickly fixing of the code.
If in program exist a bug then the best that program can do is crash. Exception is a good conception for error handling, but is useless in C++ implementation, 'cause we do not know where the problem happens. That mean catching of exception is useless, because additional information is so small that better allow program simple crash.
This is the main reason that even in debug mode exception is used not often.
On Sunday, July 31, 2016 at 12:38:26 PM UTC-4, Денис Котов wrote:воскресенье, 31 июля 2016 г., 19:09:51 UTC+3 пользователь Thiago Macieira написал:
> On domingo, 31 de julho de 2016 02:57:35 PDT Денис Котов wrote:
> > > You misunderstand what exceptions are for. You're not supposed to catch
> >
> > them
> >
> > > to find out where the error occurred. You catch them so you handle the
> > > condition wherever it happened, then continue execution because you've
> > > corrected the problem.
>> >
> > > I think this is incorrect.
> > > How can I correct the problem or bug if I do not know where the problem
> > > happened.
> There was no bug. Exceptions are not used to signal bugs. They are used to
> signal perfectly fine, if exceptional, conditions. A file not being found is not
> a bug.
I said problem or bug. If somebody try get element using arr.at(1000) it will throw exception.
Is it bug or problem ?
If we want to show user that something goes wrong we throw exception (for example file not found as you wrote) we need show user where it happened.
If I'm using a GUI application, I don't know or care what function caused a "file not found as you wrote" exception. I don't want a stack trace; it would be of utterly no value to me. I don't have the code; I don't know what those functions mean. What I care about is whether the application can handle that circumstance or not.
Crashing because of a missing file may be reasonable for some applications. In those cases, a stack trace would still not be helpful. Simply stopping, perhaps with an error message, is sufficient.
Stack traces are only of value to programmers, and generally, only to the programmers who wrote the system in question. So what you show to "the user" is irrelevant.
On domingo, 31 de julho de 2016 09:38:25 PDT Денис Котов wrote:
> I said problem or bug. If somebody try get element using *arr.at(1000)* it
> will throw exception.
> *Is it bug or problem ?*
> If we want to show user that something goes wrong we throw exception *(for
> example file not found as you wrote)* we need show user where it happened.
First of all, like Nicol replied, "showing to the user" is often an incorrect
step to do. The application should not display its problems to the user. If
they are unrecoverable, log it somewhere for the user to pass the information
along to the developer, then simply report to the user that the unrecoverable
error happened. If the error was recoverable, recover.
The whole point of catching exceptions is to *recover*. If at(1000) throws an
exception and that exception is caught, then the problem was recovered and you
don't need to know (much less display) where the exception was thrown from.
If the exception wasn't caught, then it was an unrecoverable error. In that
case, the uncaught exception handler is called and the program terminates.
Often, ABI-specific information is still available at this point to help
diagnose the issue, including the stack trace. But, as I said, stacks and
frames are concepts that exist only in the ABI, so the standard simply can't
say anything about them.
> > You put it around any place that can throw and that your founction isn't
> > expected to throw that exception.
>
> *Unfortunately big programs writes by many people and people make mistakes.*
> Every time somebody forgets put *try ... catch* and then happens weird
> things. You try finding problem place 2h, 4h, 1day or more ... depends how
> big project is.
I understand, but the point is remains: if a bug occurred, then you've stepped
outside the realm of the standard. The standard can't say what happens outside
of the standard.
Like I said above, though, most ABIs can log more ABI-dependent information in
the event of an uncaught exception. Yes, that often requires debug mode builds
and debugging symbols to be present.
Assuming that you've been using those facilities provided by your toolchain, I
have to ask: why do you want to standardise them? Why can't you continue to
use the ABI-dependent ones?