[WASM] GL ES call to `GetProgramInfoLog` may throw unexpectedly
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp, wasm
- Domain
- computer-graphics, web-dev
Research direction
Start by reproducing the failure with the linked SilkCrashRepro and then inspect Silk.NET.OpenGLES.GL.GetShaderInfoLog and the related string-overload implementations. Check each reported Substring length against the returned string, and consider the issue resolved when GetProgramInfoLog returns the linker log without throwing and the repeated patterns have been assessed.
Written by the indexing model from the issue text.
Description
Summary
Retrieving the program info log on the browser-wasm platform may crash with ArgumentOutOfRangeException as a result of a string.Substring operation with mismatching length argument.
Steps to reproduce
- Platform: browser-wasm
- Framework: tested on DotNet 10.0
- API: WebGL 2.0 + GL ES 3.0
- Tested library version: Silk.Net.OpenGLES 2.23.0
- IDE: tested with Visual Studio 2026 Community Edition (Insiders [11918.235])
I've prepared a repository that sets up a minimal crash repro. To trigger the crash, please clone the repository and perform the following steps:
- Please ensure that WebAssembly build tools are installed as is described in the repo's
Readme.mdfile. - Open the solution and press F5 to enter Debug mode.
- Observe: the call to
gl.GetProgramInfoLog(program)inSilkProgramInfoLogRepro.TryStringOverloadthrows rather than returning the info log detailing the program linker fault. - The span overload of
GetProgramInfoLog?is not affected which can be shown by commenting the call toTryStringOverloadand stepping through the subsequent function call inTrySpanOverloadinstead.
Comments
The symptom for this fault could be easily fixed by changing the implementation in Silk.NET.OpenGLES.GL.GetShaderInfoLog(uint shader, out string info) from
info = info.Substring(0, (int) length);
to something like
info = info.Substring(0, Math.Min((int)length, info.Length));
At this time I can only speculate why the length argument is returned to us with a value exceeding the info log's length. At some point it seemed as if a trailing '\n' character was trimmed from the end of the info log (the debugger stated that the string was changed) but I can't show this conclusively.
The GL type repeats this pattern of calling string.Substring with a given length a few more times. I do wonder if these could also be affected.
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 476
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/Silk.NET
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
bug good first issue verify-3.0
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
bug verify-3.0
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·