--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/20170514162029.GA17552%40diavel.
Please see the style guide for this. You should not put NOTREACHED() in a condition that can sometimes occur.
There's additional rules on adding logging but the general rule is to avoid it unless really necessary.On Sun, May 14, 2017 at 12:20 PM, Thiago Farina <tfa...@chromium.org> wrote:Hello,
If a function [1] can fail, even if it is unlikely, is
NOTREACHED() usage correct?
One example is:
if (!getcwd(system_buffer, sizeof(system_buffer))) {
NOTREACHED();
return false;
}
Do have guidelines for logging code path errors?
[1] - http://pubs.opengroup.org/onlinepubs/009695399/functions/getcwd.html
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/20170514162029.GA17552%40diavel.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CADjAqN6Bgp5Rf_6YZ%3D-9U2pm0gUUKKCFi7QbeLb0Fut3yX61nw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
--
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/20170514162029.GA17552%40diavel.
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
On Sun, May 14, 2017 at 9:30 AM Charles Harrison <cshar...@chromium.org> wrote:Please see the style guide for this. You should not put NOTREACHED() in a condition that can sometimes occur.Hmm, there is a use case which, I think, doesn't seem covered by the style guide and I'd like to have some though on: a public method where the intent is:- NOTREACHED(): signal that the client code calling this has a bug and should be fixed.- return: the actual API can deal with that failure without security/stability implications.Essentially for cases where I want a bug to be filed if the condition happens but are not critical enough to justify impacting the user experience with a hard crash. Specific example for me: [1]In this regard the style guide says:- A DCHECK() means “this condition must always be true”, not “this condition is normally true, but perhaps not in exceptional cases.”. Which holds in this case, i am signaling that the client code has a bug and should never hit that code path.- Use CHECK() if the consequence of a failed assertion would be a security vulnerability: there is no security side-effect here, no-oping the api solves the issue.the NOTREACHED is to prevent that client to expensive operations to produce data that we'll drop on the floor in MemoryDumpLevelOfDetail::BACKGROUND dumps. It's not a drama if it happens (I don't feel I should cause a crash) but I'd like to know and fix the client code when it happens (ironically just happened today crbug.com/722052).Thoughts?
On Sun, May 14, 2017 at 9:44 PM, Primiano Tucci <prim...@chromium.org> wrote:On Sun, May 14, 2017 at 9:30 AM Charles Harrison <cshar...@chromium.org> wrote:Please see the style guide for this. You should not put NOTREACHED() in a condition that can sometimes occur.Hmm, there is a use case which, I think, doesn't seem covered by the style guide and I'd like to have some though on: a public method where the intent is:- NOTREACHED(): signal that the client code calling this has a bug and should be fixed.- return: the actual API can deal with that failure without security/stability implications.Essentially for cases where I want a bug to be filed if the condition happens but are not critical enough to justify impacting the user experience with a hard crash. Specific example for me: [1]In this regard the style guide says:- A DCHECK() means “this condition must always be true”, not “this condition is normally true, but perhaps not in exceptional cases.”. Which holds in this case, i am signaling that the client code has a bug and should never hit that code path.- Use CHECK() if the consequence of a failed assertion would be a security vulnerability: there is no security side-effect here, no-oping the api solves the issue.the NOTREACHED is to prevent that client to expensive operations to produce data that we'll drop on the floor in MemoryDumpLevelOfDetail::BACKGROUND dumps. It's not a drama if it happens (I don't feel I should cause a crash) but I'd like to know and fix the client code when it happens (ironically just happened today crbug.com/722052).Thoughts?I think this code should be written as:DCHECK_NE(MemoryDumpLevelOfDetail::BACKGROUND,process_memory_dump_->dump_args().level_of_detail);... continue execution, do not return
This is equivalent to the existing code in terms of when it crashes, but it does not write "handler" code for the case where the assertion fails. Such handler code is banned by our team style guide.
AIUI, lacking that handler will not lead to the rest of the code crashing or something, just to doing more work than is necessary;
On Mon, May 15, 2017 at 10:18 AM Peter Kasting <pkas...@chromium.org> wrote:On Sun, May 14, 2017 at 9:44 PM, Primiano Tucci <prim...@chromium.org> wrote:On Sun, May 14, 2017 at 9:30 AM Charles Harrison <cshar...@chromium.org> wrote:Please see the style guide for this. You should not put NOTREACHED() in a condition that can sometimes occur.Hmm, there is a use case which, I think, doesn't seem covered by the style guide and I'd like to have some though on: a public method where the intent is:- NOTREACHED(): signal that the client code calling this has a bug and should be fixed.- return: the actual API can deal with that failure without security/stability implications.Essentially for cases where I want a bug to be filed if the condition happens but are not critical enough to justify impacting the user experience with a hard crash. Specific example for me: [1]In this regard the style guide says:- A DCHECK() means “this condition must always be true”, not “this condition is normally true, but perhaps not in exceptional cases.”. Which holds in this case, i am signaling that the client code has a bug and should never hit that code path.- Use CHECK() if the consequence of a failed assertion would be a security vulnerability: there is no security side-effect here, no-oping the api solves the issue.the NOTREACHED is to prevent that client to expensive operations to produce data that we'll drop on the floor in MemoryDumpLevelOfDetail::BACKGROUND dumps. It's not a drama if it happens (I don't feel I should cause a crash) but I'd like to know and fix the client code when it happens (ironically just happened today crbug.com/722052).Thoughts?I think this code should be written as:DCHECK_NE(MemoryDumpLevelOfDetail::BACKGROUND,process_memory_dump_->dump_args().level_of_detail);... continue execution, do not returnContinuing the execution will have some undesirable side effects like potentially leaking PII in traces that are not supposed to contain any PII.
From my viewpoint the only feasible options are CHECK() (hard crash) or DCHECK()/NOTREACHED() + returnThis is equivalent to the existing code in terms of when it crashes, but it does not write "handler" code for the case where the assertion fails. Such handler code is banned by our team style guide.This is the question I am having. I can't figure out if that is banned in general or only when trying to catch cases that shouldn't happen % exceptional cases (I/O errors or such).
Mine is not a matter of "% exceptional cases". Shouldn't happen, period. Just, if it happens,
AIUI, lacking that handler will not lead to the rest of the code crashing or something, just to doing more work than is necessary;Oh, I definitely omitted some context sorry. There is an extra problem:there would be PII implications without that return. Essentially for BAKGROUND level I have to consider anything which is not a memory size as something that could potentially leak URLs or similar.
With that return, the client code will do some more work than necessary (hence the NOTREACHED() to warn them)
If I remove the notreached nobody will never realize that the client code is doing useless work and nobody is ever going to fix it.
I think if the concern is indeed "leak of PII" then it should be a CHECK.Don't think of the problem of crashing the user - instead consider that the CHECK guarantees that you find about any issues in the wild. When you find them and fix them, then the concern about crashing the user becomes moot - because now it won't trigger.Again above applies because the consequence otherwise as you've said is leaking PII which is very severe.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAAHOzFA9ipsMFkOTY7Eh7ATVpq_8CWvn%2BdXKD6qADDeZLDGOZg%40mail.gmail.com.
On Mon, May 15, 2017 at 9:04 PM, Primiano Tucci <prim...@chromium.org> wrote:On Mon, May 15, 2017 at 10:18 AM Peter Kasting <pkas...@chromium.org> wrote:On Sun, May 14, 2017 at 9:44 PM, Primiano Tucci <prim...@chromium.org> wrote:On Sun, May 14, 2017 at 9:30 AM Charles Harrison <cshar...@chromium.org> wrote:Please see the style guide for this. You should not put NOTREACHED() in a condition that can sometimes occur.Hmm, there is a use case which, I think, doesn't seem covered by the style guide and I'd like to have some though on: a public method where the intent is:- NOTREACHED(): signal that the client code calling this has a bug and should be fixed.- return: the actual API can deal with that failure without security/stability implications.Essentially for cases where I want a bug to be filed if the condition happens but are not critical enough to justify impacting the user experience with a hard crash. Specific example for me: [1]In this regard the style guide says:- A DCHECK() means “this condition must always be true”, not “this condition is normally true, but perhaps not in exceptional cases.”. Which holds in this case, i am signaling that the client code has a bug and should never hit that code path.- Use CHECK() if the consequence of a failed assertion would be a security vulnerability: there is no security side-effect here, no-oping the api solves the issue.the NOTREACHED is to prevent that client to expensive operations to produce data that we'll drop on the floor in MemoryDumpLevelOfDetail::BACKGROUND dumps. It's not a drama if it happens (I don't feel I should cause a crash) but I'd like to know and fix the client code when it happens (ironically just happened today crbug.com/722052).Thoughts?I think this code should be written as:DCHECK_NE(MemoryDumpLevelOfDetail::BACKGROUND,process_memory_dump_->dump_args().level_of_detail);... continue execution, do not returnContinuing the execution will have some undesirable side effects like potentially leaking PII in traces that are not supposed to contain any PII....if the DCHECK is violated. Which it isn't, because that's the point of the DCHECK.
If you think it could conceivably be violated, you cannot use any of DCHECK, CHECK, or NOTREACHED; you must use a conditional.
The assertion can be violated or it can't, there is no "it can't, but handle when it can".
From my viewpoint the only feasible options are CHECK() (hard crash) or DCHECK()/NOTREACHED() + returnThis is equivalent to the existing code in terms of when it crashes, but it does not write "handler" code for the case where the assertion fails. Such handler code is banned by our team style guide.This is the question I am having. I can't figure out if that is banned in general or only when trying to catch cases that shouldn't happen % exceptional cases (I/O errors or such).It is always banned.
(Note that I/O errors are an explicit case that should be considered as "can happen", and one should never have a DCHECK that could be violated due to an I/O error.)
Mine is not a matter of "% exceptional cases". Shouldn't happen, period. Just, if it happens,The style guide bans arguments that put those last three words after the previous three :)
AIUI, lacking that handler will not lead to the rest of the code crashing or something, just to doing more work than is necessary;Oh, I definitely omitted some context sorry. There is an extra problem:there would be PII implications without that return. Essentially for BAKGROUND level I have to consider anything which is not a memory size as something that could potentially leak URLs or similar.This is so obscure it's not really different (IMO) than "well, any memory corruption bug could potentially leak PII to something".
I would consider this Don't Care.
If you think I am wrong, I think the counterargument you should make is that this is so likely to leak PII that it deserves to be a CHECK.
I don't think you should make that argument though. (And note that "leaks PII" is not a condition listed as rationale for upgrading to CHECK.)With that return, the client code will do some more work than necessary (hence the NOTREACHED() to warn them)NOTREACHED and DCHECK are not meant to serve the purpose of warning anyone anything or catching errors. They are not intended to alert developers to problems
they're intended as documentation to readers that something Shall Not Happen.
If you want a mechanism to find and catch potential errors, you need something outside this family of functions,
or a time-limited CHECK.
If I remove the notreached nobody will never realize that the client code is doing useless work and nobody is ever going to fix it.The intent is that developers assume no one will ever catch that with a NOTREACHED either, since, again, it's not preventative.
On Mon, May 15, 2017 at 10:49 PM Peter Kasting <pkas...@chromium.org> wrote:On Mon, May 15, 2017 at 9:04 PM, Primiano Tucci <prim...@chromium.org> wrote:Mine is not a matter of "% exceptional cases". Shouldn't happen, period. Just, if it happens,The style guide bans arguments that put those last three words after the previous three :)Well, if there is agreement about this, I think we should have a presubmit. One thing that I noticed only now is that there are 440 instances of this pattern in the codebase.
On Mon, May 15, 2017 at 10:49 PM Peter Kasting <pkas...@chromium.org> wrote:...if the DCHECK is violated. Which it isn't, because that's the point of the DCHECK.Whether the DCHECK is violated is not up to me but to clients.
If you think it could conceivably be violated, you cannot use any of DCHECK, CHECK, or NOTREACHED; you must use a conditional.How am I going know then that clients are burning cpu and memory to do useless stuff that my conditional is going to drop on the dloor?
Mine is not a matter of "% exceptional cases". Shouldn't happen, period. Just, if it happens,The style guide bans arguments that put those last three words after the previous three :)Well, if there is agreement about this, I think we should have a presubmit. One thing that I noticed only now is that there are 440 instances of this pattern in the codebase.
If you think I am wrong, I think the counterargument you should make is that this is so likely to leak PII that it deserves to be a CHECK.Yup it seems this is the only way then.
If you want a mechanism to find and catch potential errors, you need something outside this family of functions,such as?
or a time-limited CHECK.What happens if people regress this again after I remove the CHECK?
If I remove the notreached nobody will never realize that the client code is doing useless work and nobody is ever going to fix it.The intent is that developers assume no one will ever catch that with a NOTREACHED either, since, again, it's not preventative.This doesn't seem to be the case for most DHCEKS I hit.
Random example:(warn develoeprs that pass 0 as |count|)
PK
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAAHOzFAXXP31dWYk3yGV7fQW9%2BTx-5BJ8%2ByCpWRmnd0m3WLh8g%40mail.gmail.com.
--PK
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAAHOzFAXXP31dWYk3yGV7fQW9%2BTx-5BJ8%2ByCpWRmnd0m3WLh8g%40mail.gmail.com.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CABdZ6yDMFZR83pUkovZdOZQfLq%3DWX%3D8uHW5q-NfZn5WMVrQqBQ%40mail.gmail.com.
ISTM the API contract was changed to accept 0 (making the API more useful, since "it's always going to be an easy mistake to make"), and the NOTREACHED shouldn't be there. The semantics are well defined for a count of 0.The status-quo seems the worst of both worlds, because the callers need to explicitly test for 0, and the implementation also ends up explicitly testing for 0.