esternin / eXtrema

https://www.physics.brocku.ca/Labs/extrema/
GNU General Public License v2.0
6 stars 1 forks source link

invalid special character strings cause a crash, need a graceful recovery #52

Closed esternin closed 3 years ago

esternin commented 3 years ago
text `<theta, degree>'

reports an invalid special character " DEGREE". This is correct, as the leading space is included, but dumb: we should just get rid of spaces in the special character strings.

But this:

set xlabel `<theta, degree>'
graph ...

causes a crash without an error popping up. So the validity check is not performed, and an invalid string gets assigned to the x-axis label, and graph command dies. This is wrong: error string should be detected and an error message and a graceful recovery should occur.

esternin commented 3 years ago

Commit https://github.com/esternin/eXtrema/commit/6a637e36722947de0c60a808ec865a654f93ca09 fixes this bug. Also makes reporting the offending special character string easier to identify, by surrounding it in quotes.

esternin commented 3 years ago

The issue persists under RHEL 7, and Debian on Chromebook, yields

Unhandled unknown exception; terminating the application.
esternin commented 3 years ago

not clear why, the same std::runtime_error( ) works fine under Ubuntu 20.04, but is unhandled under RHEL 7 and under Debian 10.11 (Chromebook). So far only shows up when unexpected whitespace is used inside the string formatting commands, e.g. set xlabel '<degree, theta>'. As a workaround, trim leading and trailing whitespace before processing each command: https://github.com/esternin/eXtrema/commit/4dcd32f52a2671dc76dcf7cf2906e2e7e6940a7f