cbmc-starter-kit icon indicating copy to clipboard operation
cbmc-starter-kit copied to clipboard

Makefile silent when addone function doesn't exist

Open pennyan opened this issue 2 years ago • 5 comments

When addone function is not defined but used in UNWINDSET like below: UNWINDSET += somefunction.0:$(call addone,$(SOME_LEN)) The Makefile won't generate an error, instead I observe that the proof will not terminate. I'm guessing it is because the unwinding level is treated as infinite and CBMC just keeps unwinding the loop.

It will be nicer if an error is generated saying addone is not defined. Or another fix is to add the addone definition into the Makefiles generated by cbmc-started-kit, since it is probably needed for loop unwinding proofs.

pennyan avatar Jul 18 '22 19:07 pennyan

We could ponder adding MAKEFLAGS=--warn-undefined-variables to Makefile.common, but I'm not sure whether this would break anything. (Perhaps you could give make --warn-undefined-variables a try, which accomplishes the same, just on the command line?)

tautschnig avatar Jul 20 '22 12:07 tautschnig

I tried make --warn-undefined-variables with both addone defined and not defined. In the case addone is defined, the proof is successful. In the case it is not defined, I do get several warnings about undefined variable addone. So it seems like adding that flag won't break anything (in the single case I tried).

The only problem is that, the output is not user friendly. First there already exists variables in Makefile.common that are not defined, so those get reported too. Second, each occurrence of an undefined variable gets a warning. So I got a ton of repeated ones.

pennyan avatar Jul 20 '22 22:07 pennyan

What is addone? Is this a Makefile macro that you would like to define? A reasonable place to put this definition would be in the Makefile-project-defines.

markrtuttle avatar Aug 10 '22 12:08 markrtuttle

It's a macro used in e.g. ESDK-C

Defined here: https://github.com/aws/aws-encryption-sdk-c/blob/2743a977b3959e23131903b1a70dbc4749632a5f/verification/cbmc/proofs/Makefile.local_default#L23

Used e.g. here: https://github.com/aws/aws-encryption-sdk-c/blob/2743a977b3959e23131903b1a70dbc4749632a5f/verification/cbmc/proofs/aws_cryptosdk_enc_materials_destroy/Makefile#L64

danielsn avatar Aug 10 '22 13:08 danielsn

Let's use this as an example in the training material of something that would be useful to add to the makefile project defines.

jimgrundy avatar Aug 10 '22 14:08 jimgrundy