Octave uses assert() calls to check certain assumptions about variables before proceeding. The problem is that an assert() statement is a land mine in the code. When a user encounters such code Octave “blows up” and immediately exits without warning and without saving user data.
Recently I replaced an input validation check in
@audiorecorder which was using an
assert statement (octave: ff6e74a8f7ba). Philosophically, using an
assert in this instance is wrong because the consequences—instant abort and loss of data—are very much out of proportion to the severity of the problem—user mistyped an input parameter.
I think this merits a review of all of the
assert() statements to see which ones are for situations where immediately stopping Octave is required, and which might be better dealt with by simply stopping current execution and issuing an error message.
There aren’t so many instances to review. I count 52 in
liboctave/ and 79 in
libinterp/ and none at all in
libgui/. I’m uploading those lists here:
At the very least, in
libinterp there is a function
panic_impossible() which issues an error message and then calls
abort(). For this library it would be better to replace direct calls to the C++
assert function with
panic_impossible because we control the behavior of that function. For example, we could have Octave save data and do an orderly shutdown before calling abort() by coding
panic_impossible in a different way. But the first task is to make sure that all instances point to this function rather than