@@ -409,21 +409,21 @@ __nsan_dump_shadow_mem(const u8 *addr, size_t size_bytes, size_t bytes_per_line,
409409 }
410410}
411411
412- alignas (16 ) SANITIZER_INTERFACE_ATTRIBUTE
412+ alignas (64 ) SANITIZER_INTERFACE_ATTRIBUTE
413413 thread_local uptr __nsan_shadow_ret_tag = 0 ;
414414
415- alignas (16 ) SANITIZER_INTERFACE_ATTRIBUTE
415+ alignas (64 ) SANITIZER_INTERFACE_ATTRIBUTE
416416 thread_local char __nsan_shadow_ret_ptr[kMaxVectorWidth *
417417 sizeof (__float128)];
418418
419- alignas (16 ) SANITIZER_INTERFACE_ATTRIBUTE
419+ alignas (64 ) SANITIZER_INTERFACE_ATTRIBUTE
420420 thread_local uptr __nsan_shadow_args_tag = 0 ;
421421
422422// Maximum number of args. This should be enough for anyone (tm). An alternate
423423// scheme is to have the generated code create an alloca and make
424424// __nsan_shadow_args_ptr point ot the alloca.
425425constexpr const int kMaxNumArgs = 128 ;
426- alignas (16 ) SANITIZER_INTERFACE_ATTRIBUTE
426+ alignas (64 ) SANITIZER_INTERFACE_ATTRIBUTE
427427 thread_local char __nsan_shadow_args_ptr[kMaxVectorWidth * kMaxNumArgs *
428428 sizeof (__float128)];
429429
@@ -445,6 +445,32 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT CheckType,
445445 const InternalFT check_value = value;
446446 const InternalFT check_shadow = Shadow;
447447
448+ // We only check for NaNs in the value, not the shadow.
449+ if (flags ().check_nan && isnan (check_value)) {
450+ GET_CALLER_PC_BP;
451+ BufferedStackTrace stack;
452+ stack.Unwind (pc, bp, nullptr , false );
453+ if (GetSuppressionForStack (&stack, CheckKind::Consistency)) {
454+ // FIXME: optionally print.
455+ return flags ().resume_after_suppression ? kResumeFromValue
456+ : kContinueWithShadow ;
457+ }
458+ Decorator D;
459+ Printf (" %s" , D.Warning ());
460+ Printf (" WARNING: NumericalStabilitySanitizer: NaN detected\n " );
461+ Printf (" %s" , D.Default ());
462+ stack.Print ();
463+ if (flags ().halt_on_error ) {
464+ if (common_flags ()->abort_on_error )
465+ Printf (" ABORTING\n " );
466+ else
467+ Printf (" Exiting\n " );
468+ Die ();
469+ }
470+ // Performing other tests for NaN values is meaningless when dealing with numbers.
471+ return kResumeFromValue ;
472+ }
473+
448474 // See this article for an interesting discussion of how to compare floats:
449475 // https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
450476 static constexpr const FT Eps = FTInfo<FT>::kEpsilon ;
0 commit comments