It is a nice idea to try to recover from all DCHECKs, but what happens is that you end up with excessive and redundant checking at runtime. It leads to bloat, complexity, and degrades readability (obscuring the code). Those are not good things for a codebase. To be clear, I think we should always treat user input or input from the web with extreme care. I don't mean to imply playing fast-n-loose with that kind of stuff.
I think if we require everyone to handle every failed DCHECK, then what we will really do is compel people to write fewer DCHECKs, which means that we will lose some of the documentation benefits. That seems undesirable to me. I think there really is a balance here between adding DCHECKs for the sake of documentation / guidance to developers and dealing with runtime errors that we really need to worry about. People just have to use best judgment to decide when a failed DCHECK should also be handled in release builds. -Darin On Wed, May 27, 2009 at 12:09 PM, Greg Spencer <[email protected]> wrote: > On Wed, May 27, 2009 at 11:56 AM, Amanda Walker <[email protected]>wrote: > >> I'd be much happier if DCHECK exited immediately rather than relying on >> the code to crash, or we insisted that code using DCHECK *always* attempt >> to recover. >> > > Yeah, it seems that relying on the code to crash by itself after a DCHECK > is unreliable. It might crash, or it might just do some truly random things > (wiping out preferences or URLs or any other persistent data) that the user > might not notice until it was too late, not to mention security holes (well, > I guess Amanda already mentioned them :). I think that after a DCHECK you > should either recover completely (which is probably not possible unless the > DCHECK could be replaced by some automatic recovery code anyhow) or crash so > we get some info as to why it happened. > > -Greg. > > > > --~--~---------~--~----~------------~-------~--~----~ Chromium Developers mailing list: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---
