Replies: 7 comments
-
Hi @gh2375, Thanks for reporting this issue. Actually, clang wraps the call to ~MyStruct() {
try {
free(data);
} catch (...) {
__clang_call_terminate();
}
} The ikos report is actually about |
Beta Was this translation helpful? Give feedback.
-
Given free can't throw.. is this not a clang/llvm codegen issue? |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, Since ikos doesn't handle multithreading and pthread, it assumes that free doesn't throw. |
Beta Was this translation helpful? Give feedback.
-
I still don't know how to better handle this situation. Suggestions are welcome. |
Beta Was this translation helpful? Give feedback.
-
With regard to free:
I am not entirely sure if I understand that Stack Overflow thread correctly. The last answer says that
LLVM is generating a landingpad and a terminate call whenever a function is called in a destructor, except when that function has the One thing I saw was that with MSYS2 one gets a unreachable code warning, whereas on Debian 9 that is not the case. Looking into the respective C standard libraries one sees: mingw-64: glibc: So on MSYS2 LLVM sees that However, I think the problem is more general than this. Already the following example
yielding
will trigger the unreachable code warning. The behavior of ikos is correct in this case. The core problem from a user point of view is that in C++ destructors are very commonly used and ikos' behavior leads to a lot of noise which furthermore is in this case not of any help to the programmer, as the programmer cannot influence this specific part of the source code, as the programmer has not written it in the first place. So my suggestion would be: If LLVM is generating special code (inserting a call to
|
Beta Was this translation helpful? Give feedback.
-
Regarding free: It's not entirely clear to me either. It looks like this is an implementation detail in glibc for thread cancellation, see man7.org. On my work laptop (macOS High Sierra), Regarding the example: Actually, since The call to Regarding your suggestion: I agree, but it will be a bit tricky to implement. |
Beta Was this translation helpful? Give feedback.
-
It looks like this is a matter for further discussion, and there's no agreement on whether IKOS is reporting this correctly or not (can free throw or not). I'm moving this to a discussion for now, and we can revisit when we have a clear plan in the future. Please feel free to continue the discussion. Thanks! |
Beta Was this translation helpful? Give feedback.
-
ikos produces false positives with regard to dead code in destructors.
Minimal working example:
Output:
System:
MSYS2
Version:
Beta Was this translation helpful? Give feedback.
All reactions