Opened 5 years ago
#5556 new defect
Undefined behavior in OpenModelicaScriptingAPIQt.cpp
Reported by: | Anatoly Trosinenko | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Susan (Templates) | Version: | v1.14.0-dev-nightly |
Keywords: | Cc: |
Description
According to Clang Static Analyzer reports, the OpenModelicaScriptingAPIQt.cpp
file contains lots of exception handling triggering Undefined Behavior such as this one.
On the first glance, it looks like harmless rethrowing, but OMEdit contains the code that handles this throwException
signal with showException
slot. This suggests that it is not a noreturn function, so the execution flows to the line
responseLog.append(result ? "true" : "false");
This, again, looks harmless (just slightly misleading random true
or false
in log), but precisely this pattern was observed as crasing the program instead of just showing garbage: the compiler spotted, that
strlen(flag ? "true" : "false") == 1 - flag
I have tried to rewrite this file but have not succeeded: looks like one bootstrapping iteration was not enough in my case... Though, there are examples of commits successfully changing this template. This shows some non-triviality of contributing to this file.