@@ -276,6 +276,33 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts
276276run-time checks to keep track of which locks are held and adds warnings to the
277277` debug.log ` file if inconsistencies are detected.
278278
279+ ### Assertions and Checks
280+
281+ The util file ` src/util/check.h ` offers helpers to protect against coding and
282+ internal logic bugs. They must never be used to validate user, network or any
283+ other input.
284+
285+ * ` assert ` or ` Assert ` should be used to document assumptions when any
286+ violation would mean that it is not safe to continue program execution. The
287+ code is always compiled with assertions enabled.
288+ - For example, a nullptr dereference or any other logic bug in validation
289+ code means the program code is faulty and must terminate immediately.
290+ * ` CHECK_NONFATAL ` should be used for recoverable internal logic bugs. On
291+ failure, it will throw an exception, which can be caught to recover from the
292+ error.
293+ - For example, a nullptr dereference or any other logic bug in RPC code
294+ means that the RPC code is faulty and can not be executed. However, the
295+ logic bug can be shown to the user and the program can continue to run.
296+ * ` Assume ` should be used to document assumptions when program execution can
297+ safely continue even if the assumption is violated. In debug builds it
298+ behaves like ` Assert ` /` assert ` to notify developers and testers about
299+ nonfatal errors. In production it doesn't warn or log anything, though the
300+ expression is always evaluated.
301+ - For example it can be assumed that a variable is only initialized once,
302+ but a failed assumption does not result in a fatal bug. A failed
303+ assumption may or may not result in a slightly degraded user experience,
304+ but it is safe to continue program execution.
305+
279306### Valgrind suppressions file
280307
281308Valgrind is a programming tool for memory debugging, memory leak detection, and
0 commit comments