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

Exception with function calls wrapped in ConstExpr #12

Open
mchalupa opened this issue Nov 9, 2017 · 1 comment
Open

Exception with function calls wrapped in ConstExpr #12

mchalupa opened this issue Nov 9, 2017 · 1 comment
Assignees
Labels

Comments

@mchalupa
Copy link
Contributor

mchalupa commented Nov 9, 2017

Running angie on this code:

  1 int main(void)
  2 {
  3         int *p = malloc(sizeof *p);
  4         free(p); 
  5         free(p);
  6 
  7         return 0;
  8 }

Results in

terminate called after throwing an instance of 'NotSupportedException'
  what():  attempted to call unknown function -- either an unsupported stdlib function or missing definition

The problem is that #include <stdlib.h> is missing and calls to free are wrapped in ConstExpr due to unknown prototype, e.g.:

call i32 (i32*, ...) bitcast (i32 (...)* @free to i32 (i32*, ...)*)(i32* %7)

Adding #include<stdlib.h> fixes the problem:

$./angie -f db.ll

Error: Program tried to free an already freed memory.
@michkot michkot self-assigned this Nov 10, 2017
@michkot
Copy link
Member

michkot commented Nov 10, 2017

Well, as you noted, free is neither defined nor declared in the snippet... Although C allows using an implicit prototype, it is highly discouraged :) But yes, should be fixed so that it is detected as direct function call, not indirect (which happens now and later results in the described error which -- witch luck -- provides a reasonable error message).

@michkot michkot added the bug label Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants