Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsound exception propagation analysis for functions never returning #130

Open
arthaud opened this issue Jul 9, 2019 · 0 comments
Open
Labels
C-unsound Category: Unsound L-c++ Language: C++ P-low Priority: Low

Comments

@arthaud
Copy link
Member

arthaud commented Jul 9, 2019

On the following code:

#include <stdio.h>
#include <ikos/analyzer/intrinsic.h>

int f() {
  throw "exception";
}

void g() {
  while(1) {
    f();
  }
}

int main() {
  try {
    g();
  } catch(...) {
    printf("exception caught\n");
  }
  return 0;
}

IKOS produces the following output:

test.cpp:18:5: unreachable: code is dead
    printf("exception caught\n");
    ^

IKOS is unsound because it thinks the catch block is unreachable. This is because the control flow graph of g doesn't have an exit block, see _Z1gv.pdf. The current design of the exception propagation analysis requires that all exit nodes are merged into one block, so that we can capture all the exceptions and propagate it to the caller.

We should investigate if LLVM could generate an invoke instead of a call and add a basic block that explicitly propagates the exception.

@arthaud arthaud added C-unsound Category: Unsound L-c++ Language: C++ P-low Priority: Low labels Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-unsound Category: Unsound L-c++ Language: C++ P-low Priority: Low
Projects
None yet
Development

No branches or pull requests

1 participant