Skip to content
Permalink
Browse files Browse the repository at this point in the history
Remove a DCHECK-fail, log an error instead.
`DCHECK` in debug mode results in crashes. TensorFlow has had multiple vulnerabilities due to this.

Outside of debug mode, `DCHECK` is a no-op.

A better alternative is to report an error to the log buffer and continue. This should happen both in debug mode and in prod mode.

PiperOrigin-RevId: 408375925
Change-Id: Id5b3e19c73f3fbe0cc4bba26ca44ff9607bb6356
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Nov 8, 2021
1 parent 41424fd commit c2b31ff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tensorflow/core/framework/op_def_util.cc
Expand Up @@ -821,9 +821,10 @@ bool RepeatedAttrDefEqual(
const protobuf::RepeatedPtrField<OpDef::AttrDef>& a2) {
std::unordered_map<string, const OpDef::AttrDef*> a1_set;
for (const OpDef::AttrDef& def : a1) {
DCHECK(a1_set.find(def.name()) == a1_set.end())
<< "AttrDef names must be unique, but '" << def.name()
<< "' appears more than once";
if (a1_set.find(def.name()) != a1_set.end()) {
LOG(ERROR) << "AttrDef names must be unique, but '" << def.name()
<< "' appears more than once";
}
a1_set[def.name()] = &def;
}
for (const OpDef::AttrDef& def : a2) {
Expand Down

0 comments on commit c2b31ff

Please sign in to comment.