Skip to content

[Skia macOS] Intermittent SIGSEGV in Given_WebView2 runtime tests on macOS 26 (x64) #23641

Open

Description

@ajpinedam

Current behavior 🐛

The macOS Skia runtime-test leg (macOS 26, x64) intermittently crashes with a native segmentation fault (SIGSEGV, process exit code 139) while running the Given_WebView2.When_ExecuteScriptAsync* tests. The crash aborts the whole test run.

The failure surfaces at a test-to-test transition. The last log lines before the crash:

Running test When_ExecuteScriptAsync_Non_String()
build/test-scripts/macos-skia-runtime-tests.sh: line 21: NNNNN Segmentation fault: 11  dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$TEST_RESULTS_FILE
##[error]Bash exited with code '139'.

The crash is in the native macOS WebView2 layer (Uno.UI.Runtime.Skia.MacOS, MacOSNativeWebView / UNOWebView). The CI log contains no backtrace — Release native code currently has no diagnostic channel, so the fault is a bare "Segmentation fault: 11" with no symbols.

Expected behavior 🎯

The Given_WebView2 runtime tests run to completion without a native crash.

How to reproduce it (as minimally and precisely as possible) 🔬

Observed only on the CI macOS 26 / x64 Skia runtime-test leg; intermittent. No minimal repro app — this is a framework-internal runtime-test crash.

It has not been reproducible locally: ~65 runs of the When_ExecuteScriptAsync* family on a matching macOS 26.4.1 / x64 machine (plain Release, plus NSZombieEnabled and MallocScribble) all passed. The narrow race appears to need the load/timing of a CI runner.

Workaround 🛠️

None required for end users — this affects the CI runtime-test run, not app runtime behavior.

Renderer 🎨

  • Skia

Affected platforms 📱💻🖥️

Desktop (macOS)

Uno.Sdk version (and other relevant versions) 📦

Framework master. Toolchain: .NET SDK 10.0.201, Xcode 26.0.1 (macOS 26.0 SDK), macOS 26.4.1 x64.

IDE version 🧑‍💻

N/A (CI / dotnet CLI).

Anything else we need to know? 💬

Investigation notes (leading suspect, not yet confirmed):

  • uno_webview_get_title does strdup(webview.title.UTF8String). WKWebView.title is nullable; if it is nil, [nil UTF8String] returns NULL and strdup(NULL) dereferences null → SIGSEGV. It is the only unguarded raw-pointer-from-nil in UNOWebView.m (URL callbacks pass NULL safely to null-checking managed code). It is reachable via DocumentTitle → CheckForTitleChange on title-change KVO / navigation finish.
  • However, this could not be reproduced locally: reading DocumentTitle on a fresh web view returns "" (title is not nil), and instrumentation showed title was never nil across ~70 navigations. So the nil-title path is a real latent defect but is not confirmed to be this crash; the true cause remains open (candidates include a teardown use-after-free or the evaluateJavaScript completion/GCHandle path).

A defensive PR guards the nullable title (webview.title ?: @"") and adds a When_DocumentTitle_Before_Navigation behavior test. Because the crash cannot be reproduced locally, that PR is hardening — CI will indicate whether the crash recurs. Improving native diagnosability (a backtrace / DiagnosticReports capture on the macOS runtime-test leg) would make the next occurrence actionable.

Activity

  1. MartinZikmund commented on Oct 11, 2026

    @MartinZikmund
    Member

    Root cause for this crash is now known, and it is still present on the 6.x branches.

    Cause (code inspection plus CI evidence, not reproduced locally): uno_webview_execute_script and uno_webview_invoke_script in UNOWebView.m pass UTF8String pointers of temporary NSStrings to the managed callback, for example r = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] UTF8String];, r = quoted.UTF8String; and e = error.description.UTF8String;. Under ARC the temporary string can be released before the callback copies the bytes, so the callback reads freed memory. That matches the intermittent SIGSEGV in When_ExecuteScriptAsync*, which is a use-after-free, not the nil title path.

    Master: fixed by #25093 (closes #25092), which keeps the strings alive until the callback returns (NS_VALID_UNTIL_END_OF_SCOPE) and completes the awaiting task asynchronously.

    6.x: release/stable/6.7 still has the old code (the UTF8String lines in uno_webview_execute_script and uno_webview_invoke_script). On the macOS 26 image, 3 of 3 runs of the Skia macOS runtime tests on the 6.7 backport PR (#24965) segfaulted right after MacOSNativeWebView LoadHtmlString, in When_ExecuteScriptAsync_Has_No_Result and When_ExecuteScriptAsync_Non_String. Backporting #24112 alone did not help. The same tests pass on master.

    #24964 and #24965 work around this by excluding the five ExecuteScriptAsync tests on SkiaMacOS. Backporting the #25093 native fix to servicing/6.8 and release/stable/6.7 should let those exclusions be dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions