@@ -234,63 +234,63 @@ static void ReExecIfNeeded() {
234
234
reexec = true ;
235
235
}
236
236
237
- if (!AddressSpaceIsUnlimited ()) {
238
- Report (
239
- " WARNING: Program is run with limited virtual address space,"
240
- " which wouldn't work with ThreadSanitizer.\n " );
241
- Report (" Re-execing with unlimited virtual address space.\n " );
242
- SetAddressSpaceUnlimited ();
243
- reexec = true ;
244
- }
237
+ if (!AddressSpaceIsUnlimited ()) {
238
+ Report (
239
+ " WARNING: Program is run with limited virtual address space,"
240
+ " which wouldn't work with ThreadSanitizer.\n " );
241
+ Report (" Re-execing with unlimited virtual address space.\n " );
242
+ SetAddressSpaceUnlimited ();
243
+ reexec = true ;
244
+ }
245
245
246
- // ASLR personality check.
247
- int old_personality = personality (0xffffffff );
248
- bool aslr_on =
249
- (old_personality != -1 ) && ((old_personality & ADDR_NO_RANDOMIZE) == 0 );
246
+ // ASLR personality check.
247
+ int old_personality = personality (0xffffffff );
248
+ bool aslr_on =
249
+ (old_personality != -1 ) && ((old_personality & ADDR_NO_RANDOMIZE) == 0 );
250
250
251
251
# if SANITIZER_ANDROID && (defined(__aarch64__) || defined(__x86_64__))
252
- // After patch "arm64: mm: support ARCH_MMAP_RND_BITS." is introduced in
253
- // linux kernel, the random gap between stack and mapped area is increased
254
- // from 128M to 36G on 39-bit aarch64. As it is almost impossible to cover
255
- // this big range, we should disable randomized virtual space on aarch64.
252
+ // After patch "arm64: mm: support ARCH_MMAP_RND_BITS." is introduced in
253
+ // linux kernel, the random gap between stack and mapped area is increased
254
+ // from 128M to 36G on 39-bit aarch64. As it is almost impossible to cover
255
+ // this big range, we should disable randomized virtual space on aarch64.
256
+ if (aslr_on) {
257
+ VReport (1 ,
258
+ " WARNING: Program is run with randomized virtual address "
259
+ " space, which wouldn't work with ThreadSanitizer on Android.\n "
260
+ " Re-execing with fixed virtual address space.\n " );
261
+ CHECK_NE (personality (old_personality | ADDR_NO_RANDOMIZE), -1 );
262
+ reexec = true ;
263
+ }
264
+ # endif
265
+
266
+ if (reexec) {
267
+ // Don't check the address space since we're going to re-exec anyway.
268
+ } else if (!CheckAndProtect (false , false , false )) {
256
269
if (aslr_on) {
270
+ // Disable ASLR if the memory layout was incompatible.
271
+ // Alternatively, we could just keep re-execing until we get lucky
272
+ // with a compatible randomized layout, but the risk is that if it's
273
+ // not an ASLR-related issue, we will be stuck in an infinite loop of
274
+ // re-execing (unless we change ReExec to pass a parameter of the
275
+ // number of retries allowed.)
257
276
VReport (1 ,
258
- " WARNING: Program is run with randomized virtual address "
259
- " space, which wouldn't work with ThreadSanitizer on Android.\n "
260
- " Re-execing with fixed virtual address space.\n " );
277
+ " WARNING: ThreadSanitizer: memory layout is incompatible, "
278
+ " possibly due to high-entropy ASLR.\n "
279
+ " Re-execing with fixed virtual address space.\n "
280
+ " N.B. reducing ASLR entropy is preferable.\n " );
261
281
CHECK_NE (personality (old_personality | ADDR_NO_RANDOMIZE), -1 );
262
282
reexec = true ;
283
+ } else {
284
+ VReport (1 ,
285
+ " FATAL: ThreadSanitizer: memory layout is incompatible, "
286
+ " even though ASLR is disabled.\n "
287
+ " Please file a bug.\n " );
288
+ Die ();
263
289
}
264
- # endif
265
-
266
- if (reexec) {
267
- // Don't check the address space since we're going to re-exec anyway.
268
- } else if (!CheckAndProtect (false , false , false )) {
269
- if (aslr_on) {
270
- // Disable ASLR if the memory layout was incompatible.
271
- // Alternatively, we could just keep re-execing until we get lucky
272
- // with a compatible randomized layout, but the risk is that if it's
273
- // not an ASLR-related issue, we will be stuck in an infinite loop of
274
- // re-execing (unless we change ReExec to pass a parameter of the
275
- // number of retries allowed.)
276
- VReport (1 ,
277
- " WARNING: ThreadSanitizer: memory layout is incompatible, "
278
- " possibly due to high-entropy ASLR.\n "
279
- " Re-execing with fixed virtual address space.\n "
280
- " N.B. reducing ASLR entropy is preferable.\n " );
281
- CHECK_NE (personality (old_personality | ADDR_NO_RANDOMIZE), -1 );
282
- reexec = true ;
283
- } else {
284
- VReport (1 ,
285
- " FATAL: ThreadSanitizer: memory layout is incompatible, "
286
- " even though ASLR is disabled.\n "
287
- " Please file a bug.\n " );
288
- Die ();
289
- }
290
- }
290
+ }
291
291
292
- if (reexec)
293
- ReExec ();
292
+ if (reexec)
293
+ ReExec ();
294
294
}
295
295
# endif
296
296
0 commit comments