@@ -47,7 +47,7 @@ class NonReentrantOperation extends TNonReentrantOperation {
47
47
)
48
48
}
49
49
50
- Expr getARead ( ) {
50
+ Expr getAReadExpr ( ) {
51
51
exists ( SubObject object |
52
52
this = TReadWrite ( object ) and
53
53
result = object .getAnAccess ( )
@@ -56,7 +56,7 @@ class NonReentrantOperation extends TNonReentrantOperation {
56
56
this = TStdFunctionCall ( result )
57
57
}
58
58
59
- Expr getAWrite ( ) {
59
+ Expr getAWriteExpr ( ) {
60
60
exists ( SubObject object , Assignment assignment |
61
61
this = TReadWrite ( object ) and
62
62
result = assignment and
@@ -94,39 +94,43 @@ class NonReentrantOperation extends TNonReentrantOperation {
94
94
95
95
class WritingThread extends ThreadedFunction {
96
96
NonReentrantOperation aWriteObject ;
97
- Expr aWrite ;
97
+ Expr aWriteExpr ;
98
98
99
99
WritingThread ( ) {
100
- aWrite = aWriteObject .getAWrite ( ) and
101
- this .calls * ( aWrite .getEnclosingFunction ( ) ) and
102
- not aWrite instanceof LockProtectedControlFlowNode and
103
- not aWrite .getEnclosingFunction ( ) .getName ( ) .matches ( [ "%init%" , "%boot%" , "%start%" ] )
100
+ aWriteExpr = aWriteObject .getAWriteExpr ( ) and
101
+ // This function directly contains the write expression, or transitively calls the function
102
+ // that contains the write expression.
103
+ this .calls * ( aWriteExpr .getEnclosingFunction ( ) ) and
104
+ // The write isn't synchronized with a mutex or condition object.
105
+ not aWriteExpr instanceof LockProtectedControlFlowNode and
106
+ // The write doesn't seem to be during a special initialization phase of the program.
107
+ not aWriteExpr .getEnclosingFunction ( ) .getName ( ) .matches ( [ "%init%" , "%boot%" , "%start%" ] )
104
108
}
105
109
106
- Expr getAWrite ( ) { result = aWrite }
110
+ Expr getAWriteExpr ( ) { result = aWriteExpr }
107
111
}
108
112
109
113
class ReadingThread extends ThreadedFunction {
110
114
Expr aReadExpr ;
111
115
112
116
ReadingThread ( ) {
113
117
exists ( NonReentrantOperation op |
114
- aReadExpr = op .getARead ( ) and
118
+ aReadExpr = op .getAReadExpr ( ) and
115
119
this .calls * ( aReadExpr .getEnclosingFunction ( ) ) and
116
120
not aReadExpr instanceof LockProtectedControlFlowNode
117
121
)
118
122
}
119
123
120
- Expr getARead ( ) { result = aReadExpr }
124
+ Expr getAReadExpr ( ) { result = aReadExpr }
121
125
}
122
126
123
127
predicate mayBeDataRace ( Expr write , Expr read , NonReentrantOperation operation ) {
124
128
exists ( WritingThread wt |
125
- wt .getAWrite ( ) = write and
126
- write = operation .getAWrite ( ) and
129
+ wt .getAWriteExpr ( ) = write and
130
+ write = operation .getAWriteExpr ( ) and
127
131
exists ( ReadingThread rt |
128
- read = rt .getARead ( ) and
129
- read = operation .getARead ( ) and
132
+ read = rt .getAReadExpr ( ) and
133
+ read = operation .getAReadExpr ( ) and
130
134
(
131
135
wt .isMultiplySpawned ( ) or
132
136
not wt = rt
@@ -141,18 +145,18 @@ from
141
145
where
142
146
not isExcluded ( write , Concurrency9Package:: possibleDataRaceBetweenThreadsQuery ( ) ) and
143
147
mayBeDataRace ( write , read , operation ) and
144
- wt = min ( WritingThread f | f .getAWrite ( ) = write | f order by f .getName ( ) ) and
145
- rt = min ( ReadingThread f | f .getARead ( ) = read | f order by f .getName ( ) ) and
148
+ wt = min ( WritingThread f | f .getAWriteExpr ( ) = write | f order by f .getName ( ) ) and
149
+ rt = min ( ReadingThread f | f .getAReadExpr ( ) = read | f order by f .getName ( ) ) and
146
150
writeString = operation .getWriteString ( ) and
147
151
readString = operation .getReadString ( ) and
148
152
if wt .isMultiplySpawned ( )
149
153
then
150
154
message =
151
155
"Threaded " + writeString +
152
- " $@ not synchronized, for example from thread function $@ spawned from a loop."
156
+ " $@ not synchronized from thread function $@ spawned from a loop."
153
157
else
154
158
message =
155
159
"Threaded " + writeString +
156
- " $@, for example from thread function $@, not synchronized with $@, for example from thread function $@."
160
+ " $@ from thread function $@ is not synchronized with $@ from thread function $@."
157
161
select write , message , operation .getSourceElement ( ) , operation .toString ( ) , wt , wt .getName ( ) , read ,
158
162
"concurrent " + readString , rt , rt .getName ( )
0 commit comments