Skip to content

[wasm?] Mono interpreter vector argument alignment issue #85071

Description

@kg

This may be a dupe of some existing issues, and is probably what's blocking the interp PackedSimd PR.

A reduced repro is to run the SIMD version of pavel's raytracer in the browser with interp simd turned on. Scene creation fails, and with logging added we can see that the arguments to the ctor seem to be misaligned (the args are vectors with references and scalars mixed in):

calling InfinitePlane(position=0,1,0,0, material=CheckerboardMaterial(White, Grey, 1f, .1f, 0f, 2f), normalDirection=Util.UpVector(0f, 1f, 0f, 0f), cellWidth=10f
InfinitePlane(position=<0, 0, 0, 1>, material=, normalDirection=<1, 1, 0, 1>, cellWidth=0
calling InfinitePlane(position=1,2,3,4, material=CheckerboardMaterial(White, Grey, 1f, .1f, 0f, 12f), normalDirection=-Util.UpVector(0f, -1f, 0f, 0f), cellWidth=7f
dotnet.wasm:0x1700f Uncaught RuntimeError: memory access out of bounds
    at dotnet.wasm:0x1700f

Based on this it looks like the vector elements are packed with extra space between them, and one of the zeroes from the first position vector crowds into the material slot, turning it into a null. The second position has no zeroes so it becomes a garbage pointer and we get a crash.

How to run:

dotnet.sh publish -c Release /bl /p:TargetOS=browser /p:TargetArchitecture=wasm RayTracer.csproj /p:EnableAOTAndTrimming=false
dotnet.sh serve --directory bin/Release/AppBundle/

dotnet-wasm-raytracer-simd.zip

Since interp simd is disabled for wasm right now, you'll want to use the current HEAD of my SIMD PR #82773, which is configured for testing (a bunch of stuff is disabled).

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions