probcomp / Venturecxx

Primary implementation of the Venture probabilistic programming system
http://probcomp.csail.mit.edu/venture/
GNU General Public License v3.0
28 stars 6 forks source link

Increase politeness of C++ asserts #458

Open axch opened 8 years ago

axch commented 8 years ago

When a C++ assert fails, the user sees the location and message (if any), and "Aborted (core dumped)". No stack trace; no ability for an enclosing Python wrapper to recover. throw behaves better -- it turns into a RuntimeException on the Python side, which is worth at least some context.

I am generally of the opinion that asserts should either be eliminated entirely because of this unfortunate behavior, or restricted to situations that represent bugs in Venture as opposed to bugs in user programs. And those that remain should have meaningful messages.

git grep indicates 375 asserts in Puma. Someone^TM ought to audit them in light of this desired policy.

riastradh-probcomp commented 8 years ago

asserts should absolutely be restricted to situations that represent bugs in Venture. Abusing assert for any other purpose is itself a bug.

axch commented 8 years ago

Perhaps this could be viewed as a code style issue and thus linked to #429.