Add info about (D)CHECK and NOTREACHED crashing app or test
Change-Id: I54d38c258c3fe94ac7f71ad55f4dbdf8b8842a00 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6093573 Reviewed-by: Peter Kasting <pkasting@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Andrzej Sokolnicki <sokolnicki@google.com> Cr-Commit-Position: refs/heads/main@{#1398615}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
997cc1f211
commit
d13776f432
@@ -1,11 +1,15 @@
|
|||||||
# CHECK(), DCHECK() and NOTREACHED()
|
# CHECK(), DCHECK() and NOTREACHED()
|
||||||
|
|
||||||
`CHECK()`, `DCHECK()` and `NOTREACHED()` are all used to ensure that invariants
|
`CHECK()`, `DCHECK()` and `NOTREACHED()` are all used to ensure that invariants
|
||||||
hold. They document (and verify) programmer expectations that either some
|
hold. They document (and verify) programmer expectations that either some
|
||||||
statement *always* holds true at the point of `(D)CHECK`ing or that a piece of
|
statement *always* holds true at the point of `(D)CHECK`ing or that a piece of
|
||||||
code is unreachable. They should not be used to validate data that is provided
|
code is unreachable (for `NOTREACHED`). `CHECK` failures and reachable
|
||||||
by end-users or website developers. Such data is untrusted, and must be
|
`NOTREACHED`s result in an application crash (generating a crash report).
|
||||||
validated by standard control flow.
|
`DCHECK`s are only evaluated on developer builds, test infrastructure and a
|
||||||
|
minuscule in-the-wild population that does not currently represent all
|
||||||
|
platforms. None of these should be used to validate data that is provided by
|
||||||
|
end-users or website developers. Such data is untrusted, and must be validated
|
||||||
|
by standard control flow.
|
||||||
|
|
||||||
An invariant that does not hold should be seen as Undefined Behavior, and
|
An invariant that does not hold should be seen as Undefined Behavior, and
|
||||||
continuing past it puts the program into an unexpected state. This applies in
|
continuing past it puts the program into an unexpected state. This applies in
|
||||||
|
Reference in New Issue
Block a user