Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit 481d682

Browse files
authored
Merge pull request #1157 from hernanponcedeleon/master
Fixing data races and new benchmarks for no-data-race category
2 parents d6d29d1 + aa70faa commit 481d682

File tree

156 files changed

+25562
-1174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+25562
-1174
lines changed

c/ldv-races/race-1_1-join.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ input_files: 'race-1_1-join.i'
66
properties:
77
- property_file: ../properties/unreach-call.prp
88
expected_verdict: true
9+
- property_file: ../properties/no-data-race.prp
10+
expected_verdict: true
911

1012
options:
1113
language: C

c/ldv-races/race-2_1-container_of.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ input_files: 'race-2_1-container_of.i'
66
properties:
77
- property_file: ../properties/unreach-call.prp
88
expected_verdict: true
9-
9+
- property_file: ../properties/no-data-race.prp
10+
expected_verdict: true
11+
1012
options:
1113
language: C
1214
data_model: ILP32

c/ldv-races/race-2_2-container_of.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
extern void abort(void);
1313
#include <assert.h>
1414
void reach_error() { assert(0); }
15+
extern void __VERIFIER_atomic_begin(void);
16+
extern void __VERIFIER_atomic_end(void);
1517
int __VERIFIER_nondet_int(void);
1618
void ldv_assert(int expression) { if (!expression) { ERROR: {reach_error();abort();}}; return; }
1719

@@ -39,9 +41,13 @@ void *my_callback(void *arg) {
3941

4042
//race
4143
//pthread_mutex_lock (&data->lock);
42-
data->shared.a = 1;
43-
data->shared.b = data->shared.b + 1;
44-
//pthread_mutex_unlock (&data->lock);
44+
__VERIFIER_atomic_begin();
45+
data->shared.a = 1;
46+
__VERIFIER_atomic_end();
47+
__VERIFIER_atomic_begin();
48+
data->shared.b = data->shared.b + 1;
49+
__VERIFIER_atomic_end();
50+
//pthread_mutex_unlock (&data->lock);
4551
return 0;
4652
}
4753

c/ldv-races/race-2_2-container_of.i

Lines changed: 85 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,32 @@ typedef signed int __int32_t;
1010
typedef unsigned int __uint32_t;
1111
__extension__ typedef signed long long int __int64_t;
1212
__extension__ typedef unsigned long long int __uint64_t;
13+
typedef __int8_t __int_least8_t;
14+
typedef __uint8_t __uint_least8_t;
15+
typedef __int16_t __int_least16_t;
16+
typedef __uint16_t __uint_least16_t;
17+
typedef __int32_t __int_least32_t;
18+
typedef __uint32_t __uint_least32_t;
19+
typedef __int64_t __int_least64_t;
20+
typedef __uint64_t __uint_least64_t;
1321
__extension__ typedef long long int __quad_t;
1422
__extension__ typedef unsigned long long int __u_quad_t;
1523
__extension__ typedef long long int __intmax_t;
1624
__extension__ typedef unsigned long long int __uintmax_t;
17-
__extension__ typedef __u_quad_t __dev_t;
25+
__extension__ typedef __uint64_t __dev_t;
1826
__extension__ typedef unsigned int __uid_t;
1927
__extension__ typedef unsigned int __gid_t;
2028
__extension__ typedef unsigned long int __ino_t;
21-
__extension__ typedef __u_quad_t __ino64_t;
29+
__extension__ typedef __uint64_t __ino64_t;
2230
__extension__ typedef unsigned int __mode_t;
2331
__extension__ typedef unsigned int __nlink_t;
2432
__extension__ typedef long int __off_t;
25-
__extension__ typedef __quad_t __off64_t;
33+
__extension__ typedef __int64_t __off64_t;
2634
__extension__ typedef int __pid_t;
2735
__extension__ typedef struct { int __val[2]; } __fsid_t;
2836
__extension__ typedef long int __clock_t;
2937
__extension__ typedef unsigned long int __rlim_t;
30-
__extension__ typedef __u_quad_t __rlim64_t;
38+
__extension__ typedef __uint64_t __rlim64_t;
3139
__extension__ typedef unsigned int __id_t;
3240
__extension__ typedef long int __time_t;
3341
__extension__ typedef unsigned int __useconds_t;
@@ -38,11 +46,11 @@ __extension__ typedef int __clockid_t;
3846
__extension__ typedef void * __timer_t;
3947
__extension__ typedef long int __blksize_t;
4048
__extension__ typedef long int __blkcnt_t;
41-
__extension__ typedef __quad_t __blkcnt64_t;
49+
__extension__ typedef __int64_t __blkcnt64_t;
4250
__extension__ typedef unsigned long int __fsblkcnt_t;
43-
__extension__ typedef __u_quad_t __fsblkcnt64_t;
51+
__extension__ typedef __uint64_t __fsblkcnt64_t;
4452
__extension__ typedef unsigned long int __fsfilcnt_t;
45-
__extension__ typedef __u_quad_t __fsfilcnt64_t;
53+
__extension__ typedef __uint64_t __fsfilcnt64_t;
4654
__extension__ typedef int __fsword_t;
4755
__extension__ typedef int __ssize_t;
4856
__extension__ typedef long int __syscall_slong_t;
@@ -52,12 +60,18 @@ typedef char *__caddr_t;
5260
__extension__ typedef int __intptr_t;
5361
__extension__ typedef unsigned int __socklen_t;
5462
typedef int __sig_atomic_t;
55-
static __inline unsigned int
56-
__bswap_32 (unsigned int __bsx)
63+
__extension__ typedef __int64_t __time64_t;
64+
static __inline __uint16_t
65+
__bswap_16 (__uint16_t __bsx)
66+
{
67+
return __builtin_bswap16 (__bsx);
68+
}
69+
static __inline __uint32_t
70+
__bswap_32 (__uint32_t __bsx)
5771
{
5872
return __builtin_bswap32 (__bsx);
5973
}
60-
static __inline __uint64_t
74+
__extension__ static __inline __uint64_t
6175
__bswap_64 (__uint64_t __bsx)
6276
{
6377
return __builtin_bswap64 (__bsx);
@@ -670,10 +684,7 @@ extern int pthread_atfork (void (*__prepare) (void),
670684
void (*__child) (void)) __attribute__ ((__nothrow__ , __leaf__));
671685

672686

673-
struct _IO_FILE;
674-
typedef struct _IO_FILE __FILE;
675-
struct _IO_FILE;
676-
typedef struct _IO_FILE FILE;
687+
typedef __builtin_va_list __gnuc_va_list;
677688
typedef struct
678689
{
679690
int __count;
@@ -683,41 +694,36 @@ typedef struct
683694
char __wchb[4];
684695
} __value;
685696
} __mbstate_t;
686-
typedef struct
697+
typedef struct _G_fpos_t
687698
{
688699
__off_t __pos;
689700
__mbstate_t __state;
690-
} _G_fpos_t;
691-
typedef struct
701+
} __fpos_t;
702+
typedef struct _G_fpos64_t
692703
{
693704
__off64_t __pos;
694705
__mbstate_t __state;
695-
} _G_fpos64_t;
696-
typedef __builtin_va_list __gnuc_va_list;
697-
struct _IO_jump_t; struct _IO_FILE;
706+
} __fpos64_t;
707+
struct _IO_FILE;
708+
typedef struct _IO_FILE __FILE;
709+
struct _IO_FILE;
710+
typedef struct _IO_FILE FILE;
711+
struct _IO_FILE;
712+
struct _IO_marker;
713+
struct _IO_codecvt;
714+
struct _IO_wide_data;
698715
typedef void _IO_lock_t;
699-
struct _IO_marker {
700-
struct _IO_marker *_next;
701-
struct _IO_FILE *_sbuf;
702-
int _pos;
703-
};
704-
enum __codecvt_result
716+
struct _IO_FILE
705717
{
706-
__codecvt_ok,
707-
__codecvt_partial,
708-
__codecvt_error,
709-
__codecvt_noconv
710-
};
711-
struct _IO_FILE {
712718
int _flags;
713-
char* _IO_read_ptr;
714-
char* _IO_read_end;
715-
char* _IO_read_base;
716-
char* _IO_write_base;
717-
char* _IO_write_ptr;
718-
char* _IO_write_end;
719-
char* _IO_buf_base;
720-
char* _IO_buf_end;
719+
char *_IO_read_ptr;
720+
char *_IO_read_end;
721+
char *_IO_read_base;
722+
char *_IO_write_base;
723+
char *_IO_write_ptr;
724+
char *_IO_write_end;
725+
char *_IO_buf_base;
726+
char *_IO_buf_end;
721727
char *_IO_save_base;
722728
char *_IO_backup_base;
723729
char *_IO_save_end;
@@ -731,51 +737,21 @@ struct _IO_FILE {
731737
char _shortbuf[1];
732738
_IO_lock_t *_lock;
733739
__off64_t _offset;
734-
void *__pad1;
735-
void *__pad2;
736-
void *__pad3;
737-
void *__pad4;
740+
struct _IO_codecvt *_codecvt;
741+
struct _IO_wide_data *_wide_data;
742+
struct _IO_FILE *_freeres_list;
743+
void *_freeres_buf;
738744
size_t __pad5;
739745
int _mode;
740746
char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
741747
};
742-
typedef struct _IO_FILE _IO_FILE;
743-
struct _IO_FILE_plus;
744-
extern struct _IO_FILE_plus _IO_2_1_stdin_;
745-
extern struct _IO_FILE_plus _IO_2_1_stdout_;
746-
extern struct _IO_FILE_plus _IO_2_1_stderr_;
747-
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
748-
typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
749-
size_t __n);
750-
typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
751-
typedef int __io_close_fn (void *__cookie);
752-
extern int __underflow (_IO_FILE *);
753-
extern int __uflow (_IO_FILE *);
754-
extern int __overflow (_IO_FILE *, int);
755-
extern int _IO_getc (_IO_FILE *__fp);
756-
extern int _IO_putc (int __c, _IO_FILE *__fp);
757-
extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
758-
extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
759-
extern int _IO_peekc_locked (_IO_FILE *__fp);
760-
extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
761-
extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
762-
extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
763-
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
764-
__gnuc_va_list, int *__restrict);
765-
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
766-
__gnuc_va_list);
767-
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
768-
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
769-
extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
770-
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
771-
extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
772748
typedef __gnuc_va_list va_list;
773749
typedef __off_t off_t;
774750
typedef __ssize_t ssize_t;
775-
typedef _G_fpos_t fpos_t;
776-
extern struct _IO_FILE *stdin;
777-
extern struct _IO_FILE *stdout;
778-
extern struct _IO_FILE *stderr;
751+
typedef __fpos_t fpos_t;
752+
extern FILE *stdin;
753+
extern FILE *stdout;
754+
extern FILE *stderr;
779755
extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
780756
extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
781757
extern int renameat (int __oldfd, const char *__old, int __newfd,
@@ -863,14 +839,14 @@ extern int putw (int __w, FILE *__stream);
863839
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
864840
;
865841
extern __ssize_t __getdelim (char **__restrict __lineptr,
866-
size_t *__restrict __n, int __delimiter,
867-
FILE *__restrict __stream) ;
842+
size_t *__restrict __n, int __delimiter,
843+
FILE *__restrict __stream) ;
868844
extern __ssize_t getdelim (char **__restrict __lineptr,
869-
size_t *__restrict __n, int __delimiter,
870-
FILE *__restrict __stream) ;
845+
size_t *__restrict __n, int __delimiter,
846+
FILE *__restrict __stream) ;
871847
extern __ssize_t getline (char **__restrict __lineptr,
872-
size_t *__restrict __n,
873-
FILE *__restrict __stream) ;
848+
size_t *__restrict __n,
849+
FILE *__restrict __stream) ;
874850
extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
875851
extern int puts (const char *__s);
876852
extern int ungetc (int __c, FILE *__stream);
@@ -906,6 +882,8 @@ extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
906882
extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
907883
extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
908884
extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
885+
extern int __uflow (FILE *);
886+
extern int __overflow (FILE *, int);
909887

910888
typedef long int wchar_t;
911889

@@ -998,10 +976,10 @@ typedef __int8_t int8_t;
998976
typedef __int16_t int16_t;
999977
typedef __int32_t int32_t;
1000978
typedef __int64_t int64_t;
1001-
typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
1002-
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
1003-
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
1004-
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
979+
typedef __uint8_t u_int8_t;
980+
typedef __uint16_t u_int16_t;
981+
typedef __uint32_t u_int32_t;
982+
typedef __uint64_t u_int64_t;
1005983
typedef int register_t __attribute__ ((__mode__ (__word__)));
1006984
typedef struct
1007985
{
@@ -1031,11 +1009,6 @@ extern int pselect (int __nfds, fd_set *__restrict __readfds,
10311009
const struct timespec *__restrict __timeout,
10321010
const __sigset_t *__restrict __sigmask);
10331011

1034-
1035-
extern unsigned int gnu_dev_major (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1036-
extern unsigned int gnu_dev_minor (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1037-
extern __dev_t gnu_dev_makedev (unsigned int __major, unsigned int __minor) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
1038-
10391012
typedef __blksize_t blksize_t;
10401013
typedef __blkcnt_t blkcnt_t;
10411014
typedef __fsblkcnt_t fsblkcnt_t;
@@ -1116,16 +1089,21 @@ extern int seed48_r (unsigned short int __seed16v[3],
11161089
extern int lcong48_r (unsigned short int __param[7],
11171090
struct drand48_data *__buffer)
11181091
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
1119-
extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
1092+
extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__))
1093+
__attribute__ ((__alloc_size__ (1))) ;
11201094
extern void *calloc (size_t __nmemb, size_t __size)
1121-
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
1095+
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (1, 2))) ;
11221096
extern void *realloc (void *__ptr, size_t __size)
1123-
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
1097+
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2)));
1098+
extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
1099+
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__))
1100+
__attribute__ ((__alloc_size__ (2, 3)));
11241101
extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));
11251102

11261103
extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));
11271104

1128-
extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
1105+
extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__))
1106+
__attribute__ ((__alloc_size__ (1))) ;
11291107
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
11301108
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
11311109
extern void *aligned_alloc (size_t __alignment, size_t __size)
@@ -1675,6 +1653,8 @@ extern void *sbrk (intptr_t __delta) __attribute__ ((__nothrow__ , __leaf__));
16751653
extern long int syscall (long int __sysno, ...) __attribute__ ((__nothrow__ , __leaf__));
16761654
extern int lockf (int __fd, int __cmd, __off_t __len) ;
16771655
extern int fdatasync (int __fildes);
1656+
extern char *crypt (const char *__key, const char *__salt)
1657+
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
16781658
int getentropy (void *__buffer, size_t __length) ;
16791659

16801660
extern void abort(void);
@@ -1689,6 +1669,8 @@ extern void __assert (const char *__assertion, const char *__file, int __line)
16891669
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
16901670

16911671
void reach_error() { ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "race-2_2-container_of.c", 14, __extension__ __PRETTY_FUNCTION__); })); }
1672+
extern void __VERIFIER_atomic_begin(void);
1673+
extern void __VERIFIER_atomic_end(void);
16921674
int __VERIFIER_nondet_int(void);
16931675
void ldv_assert(int expression) { if (!expression) { ERROR: {reach_error();abort();}}; return; }
16941676
pthread_t t1,t2;
@@ -1707,8 +1689,12 @@ void *my_callback(void *arg) {
17071689
struct device *dev = (struct device*)arg;
17081690
struct my_data *data;
17091691
data = ({ const typeof( ((struct my_data *)0)->dev ) *__mptr = (dev); (struct my_data *)( (char *)__mptr - ((unsigned long) &((struct my_data *)0)->dev) );});
1710-
data->shared.a = 1;
1711-
data->shared.b = data->shared.b + 1;
1692+
__VERIFIER_atomic_begin();
1693+
data->shared.a = 1;
1694+
__VERIFIER_atomic_end();
1695+
__VERIFIER_atomic_begin();
1696+
data->shared.b = data->shared.b + 1;
1697+
__VERIFIER_atomic_end();
17121698
return 0;
17131699
}
17141700
int my_drv_probe(struct my_data *data) {

c/ldv-races/race-2_2-container_of.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ input_files: 'race-2_2-container_of.i'
66
properties:
77
- property_file: ../properties/unreach-call.prp
88
expected_verdict: false
9+
- property_file: ../properties/no-data-race.prp
10+
expected_verdict: true
911

1012
options:
1113
language: C

0 commit comments

Comments
 (0)