Last active
May 20, 2016 04:01
-
-
Save technion/1b12c9b4581e915241d9483c5c2474c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct node { | |
int something; | |
struct node *next; | |
}; | |
void free_circularly_linked_list(struct node *head) { | |
struct node *tmp = head; | |
do { | |
struct node *next = tmp->next; | |
free(tmp); | |
tmp = next; | |
} while (tmp != head); | |
} | |
int main() { | |
struct node *somelist = malloc(sizeof(struct node)); | |
somelist->something = 7; | |
somelist->next = malloc(sizeof(struct node)); | |
struct node *tmp = somelist->next; | |
tmp->something = 9; | |
tmp->next = somelist; | |
printf("test\n"); | |
free_circularly_linked_list(somelist); | |
return EXIT_SUCCESS; | |
} | |
# UBSan | |
$ clang -Wall -Wextra list.c -o list -fsanitize=undefined | |
$ ./list | |
test | |
# Clang's analyzer | |
$ scan-build clang -Wall -Wextra list.c -o list -fsanitize=undefined | |
scan-build: Using '/usr/bin/clang-3.8' for static analysis | |
scan-build: Removing directory '/tmp/scan-build-2016-05-19-065614-1236-1' because it contains no reports. | |
scan-build: No bugs found. | |
# Facebook - infer | |
# infer -- clang -c -Wall list.c | |
Starting analysis (Infer version v0.6.0) | |
Computing dependencies... 100% | |
Creating clusters... 100% | |
Analyzing 1 clusters.Analysis finished in 0.014290s | |
Analyzed 2 procedures in 1 file | |
No issues found | |
# tis-interpreter | |
# sh tis-interpreter.sh /code/list.c | |
[value] Analyzing a complete application starting at main | |
[value] Computing initial state | |
[value] Initial state computed | |
test | |
/code/list.c:16:[kernel] warning: accessing left-value that contains escaping addresses: | |
assert ¬\dangling(&head); | |
stack: free_circularly_linked_list :: /code/list.c:29 <- main | |
[value] Stopping at nth alarm | |
[value] user error: Degeneration occurred: | |
results are not correct for lines of code that can be reached from the degeneration point. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment