14
14
import sys
15
15
16
16
17
- def get_fuzz_env (* , target ):
17
+ def get_fuzz_env (* , target , source_dir ):
18
18
return {
19
19
'FUZZ' : target ,
20
+ 'UBSAN_OPTIONS' :
21
+ f'suppressions={ source_dir } /test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1' ,
20
22
'ASAN_OPTIONS' : # symbolizer disabled due to https://github.com/google/sanitizers/issues/1364#issuecomment-761072085
21
23
'symbolize=0:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1' ,
22
24
}
@@ -137,7 +139,7 @@ def main():
137
139
os .path .join (config ["environment" ]["BUILDDIR" ], 'src' , 'test' , 'fuzz' , 'fuzz' ),
138
140
'-help=1' ,
139
141
],
140
- env = get_fuzz_env (target = test_list_selection [0 ]),
142
+ env = get_fuzz_env (target = test_list_selection [0 ], source_dir = config [ 'environment' ][ 'SRCDIR' ] ),
141
143
timeout = 20 ,
142
144
check = True ,
143
145
stderr = subprocess .PIPE ,
@@ -154,6 +156,7 @@ def main():
154
156
if args .generate :
155
157
return generate_corpus_seeds (
156
158
fuzz_pool = fuzz_pool ,
159
+ src_dir = config ['environment' ]['SRCDIR' ],
157
160
build_dir = config ["environment" ]["BUILDDIR" ],
158
161
seed_dir = args .seed_dir ,
159
162
targets = test_list_selection ,
@@ -164,6 +167,7 @@ def main():
164
167
fuzz_pool = fuzz_pool ,
165
168
corpus = args .seed_dir ,
166
169
test_list = test_list_selection ,
170
+ src_dir = config ['environment' ]['SRCDIR' ],
167
171
build_dir = config ["environment" ]["BUILDDIR" ],
168
172
merge_dir = args .m_dir ,
169
173
)
@@ -173,12 +177,13 @@ def main():
173
177
fuzz_pool = fuzz_pool ,
174
178
corpus = args .seed_dir ,
175
179
test_list = test_list_selection ,
180
+ src_dir = config ['environment' ]['SRCDIR' ],
176
181
build_dir = config ["environment" ]["BUILDDIR" ],
177
182
use_valgrind = args .valgrind ,
178
183
)
179
184
180
185
181
- def generate_corpus_seeds (* , fuzz_pool , build_dir , seed_dir , targets ):
186
+ def generate_corpus_seeds (* , fuzz_pool , src_dir , build_dir , seed_dir , targets ):
182
187
"""Generates new corpus seeds.
183
188
184
189
Run {targets} without input, and outputs the generated corpus seeds to
@@ -192,7 +197,7 @@ def job(command, t):
192
197
' ' .join (command ),
193
198
subprocess .run (
194
199
command ,
195
- env = get_fuzz_env (target = t ),
200
+ env = get_fuzz_env (target = t , source_dir = src_dir ),
196
201
check = True ,
197
202
stderr = subprocess .PIPE ,
198
203
universal_newlines = True ,
@@ -213,7 +218,7 @@ def job(command, t):
213
218
future .result ()
214
219
215
220
216
- def merge_inputs (* , fuzz_pool , corpus , test_list , build_dir , merge_dir ):
221
+ def merge_inputs (* , fuzz_pool , corpus , test_list , src_dir , build_dir , merge_dir ):
217
222
logging .info ("Merge the inputs from the passed dir into the seed_dir. Passed dir {}" .format (merge_dir ))
218
223
jobs = []
219
224
for t in test_list :
@@ -231,7 +236,7 @@ def job(t, args):
231
236
output = 'Run {} with args {}\n ' .format (t , " " .join (args ))
232
237
output += subprocess .run (
233
238
args ,
234
- env = get_fuzz_env (target = t ),
239
+ env = get_fuzz_env (target = t , source_dir = src_dir ),
235
240
check = True ,
236
241
stderr = subprocess .PIPE ,
237
242
universal_newlines = True ,
@@ -244,7 +249,7 @@ def job(t, args):
244
249
future .result ()
245
250
246
251
247
- def run_once (* , fuzz_pool , corpus , test_list , build_dir , use_valgrind ):
252
+ def run_once (* , fuzz_pool , corpus , test_list , src_dir , build_dir , use_valgrind ):
248
253
jobs = []
249
254
for t in test_list :
250
255
corpus_path = os .path .join (corpus , t )
@@ -261,7 +266,7 @@ def job(t, args):
261
266
output = 'Run {} with args {}' .format (t , args )
262
267
result = subprocess .run (
263
268
args ,
264
- env = get_fuzz_env (target = t ),
269
+ env = get_fuzz_env (target = t , source_dir = src_dir ),
265
270
stderr = subprocess .PIPE ,
266
271
universal_newlines = True ,
267
272
)
0 commit comments