Bug 214346

Summary: ASAN builds of WebKit should not freeze when an EXC_RESOURCE is delivered
Product: WebKit Reporter: Tuomas Karkkainen <tuomas.webkit>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: macOS 10.15   
Attachments:
Description Flags
proposed patch
mark.lam: review+, mark.lam: commit-queue-
proposed patch none

Description Tuomas Karkkainen 2020-07-15 04:37:14 PDT
When a process instrumented with AddressSanitizer receives an EXC_RESOURCE, it is frozen for several minutes.
Comment 1 Tuomas Karkkainen 2020-07-15 05:06:40 PDT
Created attachment 404332 [details]
proposed patch
Comment 2 Mark Lam 2020-07-15 07:37:17 PDT
Comment on attachment 404332 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=404332&action=review

r=me with fix.

> Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:153
> +        // EXC_RESOURCE on ASAN builds freezes the process for several minutes: rdar://65027596
> +        if (char *disableFreezingOnExcResource = getenv("DISABLE_FREEZING_ON_EXC_RESOURCE")) {
> +            if (!strcasecmp(disableFreezingOnExcResource, "yes") || !strcasecmp(disableFreezingOnExcResource, "true") || !strcasecmp(disableFreezingOnExcResource, "1")) {
> +                int val = 1;
> +                int rc = sysctlbyname("debug.toggle_address_reuse", nullptr, 0, &val, sizeof(val));
> +                if (rc < 0)
> +                    WTFLogAlways("failed to set debug.toggle_address_reuse: %d\n", rc);
> +                else
> +                    WTFLogAlways("debug.toggle_address_reuse is now 1.\n");
> +            }
> +        }

Can you guard this with #if ASAN_ENABLED?  We don't need this for any other builds, right?
Comment 3 Tuomas Karkkainen 2020-07-15 09:02:35 PDT
Ok, will do.

I was thinking other sanitizers might be affected, but looking quickly at an UBSAN build, there are no giant mappings there, so limiting it to ASAN makes sense.
Comment 4 Tuomas Karkkainen 2020-07-16 01:22:18 PDT
Created attachment 404429 [details]
proposed patch

wraps the code in #if ASAN_ENABLED as requested
Comment 5 EWS 2020-07-16 02:11:35 PDT
Committed r264450: <https://trac.webkit.org/changeset/264450>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 404429 [details].
Comment 6 Radar WebKit Bug Importer 2020-07-16 02:12:15 PDT
<rdar://problem/65653827>