You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using CBMC to verify a C program that checks whether an input string starts with the letter 'H'. My goal is to extract the exact concrete input string that triggers an assertion failure when the first character of the string is 'H'.
My C Program
#include<stdio.h>#include<assert.h>#include<string.h>voidcheck_starting_letter(constchar*input) {
size_tlen=strlen(input);
// Accept only strings that start with "H"if (len>0&&input[0] =='H') {
assert(0); // Force CBMC failure when input starts with 'H'
}
}
CBMC itself does not know how to generate (suitable) objects for pointer-type inputs. Please use the goto-harness tool (as documented here: https://diffblue.github.io/cbmc/man/goto-harness.html) to produce a suitable environment.
Thank you. I have not yet been fruitful with go to harness. But thank you for the pointer. Related to this discussion, is the following a bug or perhaps, I misused the tool?
Potential Bug Report: CBMC Enters If-Branch with Incorrect Condition Evaluation
Description
While using CBMC to verify a simple C program, I encountered unexpected behavior where CBMC prints an empty string with length 1 (which is likely '\0') while entering an if-branch that requires at least three characters (including \0).
Minimal Reproducible Example
#include<assert.h>#include<stdio.h>#include<stdlib.h>#include<string.h>voidcheck_starting_letter(constchar*input) {
size_tlen=strlen(input);
// Accept only strings that start with "HI"if (len >=3&&input[0] =='H'&&input[1] =='I') {
printf("CBMC executing check_starting_letter with input: %s\n", input);
printf("CBMC executing check_starting_letter with input length: %zu\n", strlen(input));
assert(0); // Force CBMC failure when input starts with "HI"
}
}
Hello CBMC Developers and Community,
I am currently using CBMC to verify a C program that checks whether an input string starts with the letter
'H'
. My goal is to extract the exact concrete input string that triggers an assertion failure when the first character of the string is'H'
.My C Program
My CBMC Command
I am running CBMC with the following command:
**CBMC Output **
CBMC successfully finds a counterexample that causes the assertion failure:
Thank you in advance for your help!
Best regards,
Zhoulai
The text was updated successfully, but these errors were encountered: