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

printf inside non-executed conditional branch is printed anyway #54

Open
noresistence opened this issue Mar 18, 2019 · 2 comments
Open

Comments

@noresistence
Copy link

noresistence commented Mar 18, 2019

This makes debugging even harder than it is already:

A printf inside an if condition is printed anyway, no matter if the condition is true or false.

Example

inputs

1

example.c

struct In { int in; }; // This should be 1
struct Out { int out; };

void compute(struct In *input, struct Out *output) {
    if(input->in > 42) {
        printf("This should not be printed.");
        output->out = 40;
    }
    output->out = input->in;
}

console output during proof

NUMBER OF CONSTRAINTS:  2
PRINTF in computation_p 0:
"This should not be printed."
reading proving key from file...
[...]

output after execution of proof

0
1
@maxhowald
Copy link
Contributor

Thanks for reporting this! Unfortunately, Pepper's printf implementation is a bit primitive, so this is expected behavior. I've added a bit of documentation on the limits in printf.txt.

Of course, it would be nice to improve the implementation, but I don't have much time to take this on myself at the moment. If you (or anyone else) is interested, we're always happy to accept pull requests though! Probably, this would require re-writing the way the frontend of the compiler emits PRINTF statements in the prover worksheet files, and the way the prover interprets these statements, to keep track of the conditionals at runtime.

@noresistence
Copy link
Author

Thank you very much for adding the documentation, and also for the note on how to print numbers; I didn't stumble upon that bit yet. That will be helpful for debugging actual calculations :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants