--
--
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/CAJBMYs4Tcp8udKVXuAs3UpMT59SwpmVh8A%3Ds4-OW43RDuTYqYw%40mail.gmail.com.
My personal understanding:
- DCHECK() and CHECK() are used to assert that something is always true. DCHECK() is preferred because CHECK() has a runtime cost. If something is always true, why pay the runtime cost for it?
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAF3XrKpDw53DU2e55-65M_X_PWKDOgwck%2BgUyfPn-TXCd5jdSQ%40mail.gmail.com.
But this may not true for OS APIs, which is my main concern. E.g. If an edge case happens only on a specific hardware configuration, but the logic failed to handle it properly. We may end up just ignore them at all and leave the users in unexpected or unusable states.
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/CAAHOzFB-ys8HmVRACVRkP2%3D3ox9NU90hzDX3%3Dtzztqw8Lxj9ow%40mail.gmail.com.
On Wed, Jun 7, 2017 at 9:29 PM, Peter Kasting <pkas...@chromium.org> wrote:On Wed, Jun 7, 2017 at 8:54 PM, 'Zijie He' via Chromium-dev <chromi...@chromium.org> wrote:But this may not true for OS APIs, which is my main concern. E.g. If an edge case happens only on a specific hardware configuration, but the logic failed to handle it properly. We may end up just ignore them at all and leave the users in unexpected or unusable states.If you have an OS API that can fail in real ways, even if unusual (e.g. disk read errors), the code must handle the failure in some appropriate way. [D]CHECKing that the API calls succeed would be incorrect unless those calls are actually guaranteed to succeed.A related case (which I think Zijie is concerned about) is when there are bugs in an OS API implementation. For example a function may succeed, but not set some returned values. It may allocates buffer of incorrect size. Callback may be called whet it's not expected. An unexpected value may be returned. The question is: should we try to handle such bugs in an OS API gracefully?In my opinion it makes sense only for specific OS bugs that we know exist in some configurations. Otherwise DCHECK is enough.
--
--
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/CAJBMYs4knR0aOFZJXndQiCYVRhUxmKUpOBBW9u6iA1ghYKARag%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAGLE5Tdk_9g62SiE2fEQ26RgtYaT6BVv%2BB9WkHQmOtREsRszPA%40mail.gmail.com.
Reviving this thread, I'm still confused.I've recently converted some CHECKs to DCHECKs, following documentation and a few DCHECK email chains, after we had a CHECK causing unnecessary crashes on Stable. However, in code review, it was brought up that there are some scenarios that are going to behave very poorly and inconsistently with just DCHECKs.
auto iter = vector.find(key);[D]CEHCK(iter != vector.end());// If iter == vector.end(), then it's pointing to the beggining of someone else's memory, right? Is it really better to continue with undefind behavior, potentailly setting someone else up to read/write to the wrong place?DoesUnknownStuff(*iter);andvoid FunctionName(SomeClassName* raw_ptr) {[D]CHECK(raw_ptr);// If this is not a virtual call, and if it doesn't access a member field, it may not crash, I think... If it is a large object and accesses only high memory members, those reads might succeed, and be from someone else's actual memory. Potentailly being platform dependant how high memory members would need to be.raw_ptr->NonVirtualMethod();}So I'm left confused and conflicted. In these scenarios, we'd probably maybe crash, eventaully, sometimes with confusing crash stacks with DCHECKs, but CHECKs would make that a lot more consistent and less confusing. Yes, CHECK has a runtime cost we'd have to pay forever. I'm curious what others think, and hoping we can clarify the documentation to make the right choice explicit in these cases.
Does that mean cases like https://cs.chromium.org/chromium/src/net/extras/sqlite/sqlite_persistent_cookie_store.cc?q=sqlite_persistent_cookie_store.cc&sq=package:chromium&dr&l=661 should be reported as bugs and fixed? The code there essentially does "if (database corrupted) { DCHECK(false); reset_database(); }".
I filed https://bugs.chromium.org/p/chromium/issues/detail?id=774056 for this specific sqlite db case.We only notice the cases that we do hit, I'm not scourging the code base for violations. They are thus not impossible and the reasonable solution from our perspective is to make the code always handle the error. In general it's difficult for us downstream to reason about such code beyond that/