Skip to content

Commit

Permalink
[ANGLE] Workaround ASan false-positive stack-use-after-scope in Xcode…
Browse files Browse the repository at this point in the history
… 16.3

<https://bugs.webkit.org/show_bug.cgi?id=288308>
<rdar://144259986>

Reviewed by John Wilander and Kimmo Kinnunen.

* Configurations/Sanitizers.xcconfig:
(WK_ADDRESS_SANITIZER_OTHER_CFLAGS_YES):
(WK_NEEDS_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_WORKAROUND): Add.
(WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE): Add.
(WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_YES): Add.
- Include a command-line switch to define a macro if the workaround is
  needed.
* Configurations/WebKitTargetConditionals.xcconfig:
(WK_XCODE_BEFORE_16_3): Add.
(WK_XCODE_BEFORE_16_3_XCODE_BEFORE_16): Add.
(WK_XCODE_BEFORE_16_3_XCODE_SINCE_16): Add.
(WK_XCODE_BEFORE_16_3_1600): Add.
(WK_XCODE_BEFORE_16_3_1610): Add.
(WK_XCODE_BEFORE_16_3_1620): Add.
(WK_XCODE_16_3): Add.
(WK_XCODE_16_3_): Add.
(WK_XCODE_16_3_YES): Add.
- Add version checking variables for Xcode 16.3.
* Source/ThirdParty/ANGLE/src/compiler/translator/InfoSink.h:
(sh::fractionalPart):
- Disable ASan if the workaround is needed.

Canonical link: https://commits.webkit.org/290943@main
  • Loading branch information
David Kilzer authored and ddkilzer committed Feb 24, 2025
1 parent 48a664f commit e40b0da
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Configurations/Sanitizers.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023-2024 Apple Inc. All rights reserved.
// Copyright (C) 2023-2025 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -26,6 +26,8 @@

// Requires SDKVariant.xcconfig.

#include "WebKitTargetConditionals.xcconfig"

WK_SANITIZER_GCC_OPTIMIZATION_LEVEL = $(WK_SANITIZER_GCC_OPTIMIZATION_LEVEL_$(CONFIGURATION));
WK_SANITIZER_GCC_OPTIMIZATION_LEVEL_Debug = 0;
WK_SANITIZER_GCC_OPTIMIZATION_LEVEL_Production = 1;
Expand Down Expand Up @@ -64,11 +66,17 @@ WK_ANY_SANITIZER_LDFLAGS_YES = -Wl,-rpath,@executable_path/Frameworks;
// Address Sanitizer

// Add -fsanitize-address-use-after-return=never to disable ASan's "fake stack" to fix JSC garbage collection.
WK_ADDRESS_SANITIZER_OTHER_CFLAGS_YES = -fsanitize-address-use-after-return=never;
WK_ADDRESS_SANITIZER_OTHER_CFLAGS_YES = -fsanitize-address-use-after-return=never $(WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE);
WK_ADDRESS_SANITIZER_OTHER_LDFLAGS_YES = -fsanitize-address-use-after-return=never;

WK_ADDRESS_SANITIZER_OTHER_CPLUSPLUSFLAGS_YES = -U_LIBCPP_HAS_NO_ASAN;

// Workaround ASan stack-use-after-scope false positive in Xcode 16.3: <https://bugs.webkit.org/show_bug.cgi?id=288308>.
WK_NEEDS_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_WORKAROUND = $(WK_NOT_$(WK_XCODE_BEFORE_16_3));

WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE = $(WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_$(WK_NEEDS_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_WORKAROUND);
WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE_YES = -DWK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE;

// Undefined Behavior Sanitizer

// FIXME: <rdar://105760852> Tune list of Undefined Behavior (UBSan) checkers
Expand Down
13 changes: 12 additions & 1 deletion Configurations/WebKitTargetConditionals.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2018-2024 Apple Inc. All rights reserved.
// Copyright (C) 2018-2025 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -380,3 +380,14 @@ WK_XCODE_BEFORE_16_1500 = YES;
WK_XCODE_16 = $(WK_XCODE_16_$(WK_XCODE_BEFORE_16));
WK_XCODE_16_ = _XCODE_SINCE_16;
WK_XCODE_16_YES = _XCODE_BEFORE_16;

WK_XCODE_BEFORE_16_3 = $(WK_XCODE_BEFORE_16_3$(WK_XCODE_16));
WK_XCODE_BEFORE_16_3_XCODE_BEFORE_16 = YES;
WK_XCODE_BEFORE_16_3_XCODE_SINCE_16 = $(WK_XCODE_BEFORE_16_3_$(XCODE_VERSION_MINOR));
WK_XCODE_BEFORE_16_3_1600 = YES;
WK_XCODE_BEFORE_16_3_1610 = YES;
WK_XCODE_BEFORE_16_3_1620 = YES;

WK_XCODE_16_3 = $(WK_XCODE_16_3_$(WK_XCODE_BEFORE_16_3));
WK_XCODE_16_3_ = _XCODE_SINCE_16_3;
WK_XCODE_16_3_YES = _XCODE_BEFORE_16_3;
3 changes: 3 additions & 0 deletions Source/ThirdParty/ANGLE/src/compiler/translator/InfoSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class TSymbol;
class TType;

// Returns the fractional part of the given floating-point number.
#ifdef WK_WORKAROUND_RDAR_145268301_ASAN_STACK_USE_AFTER_SCOPE
__attribute__((no_sanitize_address))
#endif
inline float fractionalPart(float f)
{
float intPart = 0.0f;
Expand Down

0 comments on commit e40b0da

Please sign in to comment.