Bug 261297 - [Win] stack overflow in ANGLE for webgl/2.0.y/conformance/glsl/bugs/complex-glsl-does-not-crash.html
Summary: [Win] stack overflow in ANGLE for webgl/2.0.y/conformance/glsl/bugs/complex-g...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks: 171618
  Show dependency treegraph
 
Reported: 2023-09-07 15:17 PDT by Fujii Hironori
Modified: 2023-09-18 19:52 PDT (History)
1 user (show)

See Also:


Attachments
Patch to reduce complex-glsl-does-not-crash.html (3.95 KB, patch)
2023-09-12 14:08 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2023-09-07 15:17:59 PDT
[Win] Infinite loop in ANGLE if compiled by clang-cl

Windows port clang-cl release builds are crashing for the following tests.
I'm using LLVM 16.0.6.

Regressions: Unexpected crashes (2)
  webgl/2.0.y/conformance/glsl/bugs/complex-glsl-does-not-crash.html [ Crash ]
  webgl/2.0.y/conformance/glsl/misc/shader-uniform-packing-restrictions.html [ Crash ]

It's an infinite loop.

Callstack

> libGLESv2.dll!sh::TIntermBinary::propagatePrecision(sh::TPrecision precision) Line 2031	C++
> [Inline Frame] libGLESv2.dll!sh::`anonymous namespace'::PropagatePrecisionIfApplicable(sh::TIntermTyped * node, sh::TPrecision precision) Line 192	C++
> libGLESv2.dll!sh::TIntermBinary::propagatePrecision(sh::TPrecision precision) Line 2039	C++
> [Inline Frame] libGLESv2.dll!sh::`anonymous namespace'::PropagatePrecisionIfApplicable(sh::TIntermTyped * node, sh::TPrecision precision) Line 192	C++
> libGLESv2.dll!sh::TIntermBinary::propagatePrecision(sh::TPrecision precision) Line 2039	C++
> (...)

Is this a compiler optimizer bug?
Comment 1 Fujii Hironori 2023-09-12 14:08:38 PDT
Created attachment 467668 [details]
Patch to reduce complex-glsl-does-not-crash.html

In webgl/2.0.y/conformance/glsl/bugs/complex-glsl-does-not-crash.html,
"test: vertex shader with 16384 uniforms of bool" causes the stack overflow.
Comment 2 Fujii Hironori 2023-09-12 20:17:15 PDT
The test is hosted online there.
https://registry.khronos.org/webgl/sdk/tests/conformance/glsl/bugs/complex-glsl-does-not-crash.html

The test vertex shader contains a very long expression.

>    v_varying = vec4(u_uniform0, 0, 0, 0) + 
>            vec4(u_uniform1, 0, 0, 0) + 
>            vec4(u_uniform2, 0, 0, 0) + 
>            (...)          
>            vec4(u_uniform16382, 0, 0, 0) + 
>            vec4(u_uniform16383, 0, 0, 0);
Comment 3 Fujii Hironori 2023-09-12 22:46:30 PDT
This is not clang-cl release build specific.
clang-cl and MSVC debug builds are also the case.
But, MSVC release build isn't.

MSVC release build consumes 48 bytes for each
TIntermBinary::propagatePrecision funciton call,
while clang-cl release build consumes 64 bytes.

The test case has 16384 additions.

64 * 16384 = 1M
1M is the default stack size of Windows program.
Comment 4 Fujii Hironori 2023-09-12 22:51:56 PDT
WinCairo Debug is skipping the test cases.
> [ Debug ] webgl/2.0.y/conformance/glsl/bugs/complex-glsl-does-not-crash.html [ Skip ] # Slow
> [ Debug ] webgl/2.0.y/conformance/glsl/misc/shader-uniform-packing-restrictions.html [ Skip ] # Slow
https://github.com/WebKit/WebKit/blob/20ce50e23068f44e6025e5d6c4196d8aa1116add/LayoutTests/platform/wincairo/TestExpectations#L1908
Comment 5 Fujii Hironori 2023-09-12 23:17:30 PDT
I run the test with STP 178 on my Mac mini (2018).
"test: vertex shader with 4096 uniforms of bool"
Only 4096 uniforms.
Comment 6 Fujii Hironori 2023-09-12 23:45:24 PDT
I tested the latest Epiphany Tech Preview too. It has only 4096 uniforms.
Comment 7 Fujii Hironori 2023-09-13 00:00:30 PDT
267933@main skips the tests for Windows port temporarily.
Comment 8 Fujii Hironori 2023-09-13 21:42:18 PDT
PR for WebGL: https://github.com/KhronosGroup/WebGL/pull/3591
Comment 9 Radar WebKit Bug Importer 2023-09-14 15:18:18 PDT
<rdar://problem/115521906>
Comment 10 Fujii Hironori 2023-09-18 18:43:21 PDT
Pull request: https://github.com/WebKit/WebKit/pull/17892
Comment 11 EWS 2023-09-18 19:52:38 PDT
Committed 268108@main (7c14f48e920c): <https://commits.webkit.org/268108@main>

Reviewed commits have been landed. Closing PR #17892 and removing active labels.