Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[release/9.0-staging] [wasm][AOT] fix codegen for small structs on stack - #118416

#118416
Merged
pavelsavara merged 6 commits into
release/9.0-stagingdotnet/runtime:release/9.0-stagingfrom
backport/pr-118355-to-release/9.0-stagingdotnet/runtime:backport/pr-118355-to-release/9.0-stagingCopy head branch name to clipboard
Aug 24, 2025
Merged

[release/9.0-staging] [wasm][AOT] fix codegen for small structs on stack#118416
pavelsavara merged 6 commits into
release/9.0-stagingdotnet/runtime:release/9.0-stagingfrom
backport/pr-118355-to-release/9.0-stagingdotnet/runtime:backport/pr-118355-to-release/9.0-stagingCopy head branch name to clipboard

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Backport of #118355 to release/9.0-staging

/cc @lewing @pavelsavara

Customer Impact

Fixes incorrect AOT codegen on Wasm that could lead to memory corruption and hard to isolate failures.

  • Customer reported
  • Found internally

[Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.]

Regression

  • Yes
  • No

[If yes, specify when the regression was introduced. Provide the PR or commit if known.]

This case regressed in 9.0 development.

Testing

  • Automated test System.Buffers.Text.Tests.Base64ValidationUnitTests.ValidateWithOnlyCharsToBeIgnoredChars
  • manual testing in chrome dev tools debugger

Risk

Medium - AOT codegen is complex but the change impacts WASM AOT only, and only in the case of an empty struct, the previous codegen is known to be incorrect.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@pavelsavara

Copy link
Copy Markdown
Member

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@pavelsavara pavelsavara added the Servicing-consider Issue for next servicing release review label Aug 20, 2025
@pavelsavara
pavelsavara requested a review from lewing August 20, 2025 16:09
@rbhanda rbhanda added this to the 9.0.10 milestone Aug 21, 2025
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 21, 2025
@pavelsavara

Copy link
Copy Markdown
Member

The fix worked
image

System.Text.RegularExpressions.Tests failure is known #117557
DiagnosticMethodInfoTests.Create_StackFrame is #117165
NaN in System.Tests.HalfTests is #103347
There are also some infra failures.

Log

[20:51:53] info: Starting:    System.Runtime.Intrinsics.Tests.dll
[20:51:55] info: [FAIL] System.Runtime.Intrinsics.Wasm.Tests.PackedSimdTests.ComparisonWithNaNTest
[20:51:55] info: Assert.Equal() Failure: Values differ
[20:51:55] info: Expected: -Infinity
[20:51:55] info: Actual:   1
[20:51:55] info:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[20:51:55] info: [FAIL] System.Runtime.Intrinsics.Wasm.Tests.PackedSimdTests.ComparisonOperationsTest
[20:51:55] info: Assert.Equal() Failure: Values differ
[20:51:55] info: Expected: <1, 2, 2, 1>
[20:51:55] info: Actual:   <4, 3, 3, 4>
[20:51:55] info:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[20:51:55] info: [FAIL] System.Runtime.Intrinsics.Wasm.Tests.PackedSimdTests.MinMaxSignedUnsignedTest
[20:51:55] info: Assert.Equal() Failure: Values differ
[20:51:55] info: Expected: -1
[20:51:55] info: Actual:   0
[20:51:55] info:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

I don't know about packed SIMD, @lewing does it ring any bell ?

@pavelsavara

Copy link
Copy Markdown
Member

/ba-g known CI issues for Net9

@pavelsavara
pavelsavara merged commit 76ece90 into release/9.0-staging Aug 24, 2025
35 of 48 checks passed
@jkotas
jkotas deleted the backport/pr-118355-to-release/9.0-staging branch August 28, 2025 21:06
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 28, 2025
@pavelsavara

Copy link
Copy Markdown
Member

Validation

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices.JavaScript;
using System.Threading.Tasks;
using System.Text;
using System.Buffers.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;


class Program
{
    public static void Main()
    {
        Test(new string('\u0009', 1));
        Test(new string('\u0009', 3));
        Test(new string('\u000A', 1));
        Test(new string('\u000A', 3));
        Test(new string('\u000D', 1));
        Test(new string('\u000D', 3));
        Test(new string(' ', 1));
        Test(new string(' ', 3));
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static void Test(string utf8WithByteToBeIgnored){
        ReadOnlySpan<char> utf8BytesWithByteToBeIgnored = utf8WithByteToBeIgnored.AsSpan();
        bool isValid2 = Base64.IsValid(utf8BytesWithByteToBeIgnored, out int decodedLength);
        Console.WriteLine($"IsValid2: {isValid2}, DecodedLength: {decodedLength}");
    }
}
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <RunAOTCompilation>true</RunAOTCompilation>
    <WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
    <WasmNativeStrip>false</WasmNativeStrip>
  </PropertyGroup>
</Project>

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

Labels

arch-wasm WebAssembly architecture area-Codegen-AOT-mono os-browser Browser variant of arch-wasm Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.