Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) Stack Overflow Exception occurs in GameWindow after about 387,000 loops when running on x86 #1582

Open
sebagamesdev opened this issue Mar 23, 2023 · 10 comments
Labels
4.x bug glfw needs verification Indicates that this bug needs to be reproduced again becaus of a major/breaking change.
Milestone

Comments

@sebagamesdev
Copy link

Description

Stack Overflow Exception occurs in GameWindow after about 387,000 loops when running on x86.
It seems that this issue does not occur on x64.

Repro steps

  1. Create a .NET 6.0 Console Application
  2. Add the latest stable OpenTK (4.7.7)
  3. Write minimal GameWindow code
  4. Compile and run it on the x86 platform

Minimal code:

using OpenTK.Windowing.Desktop;

var settings = new GameWindowSettings();

var nativeSetting = new NativeWindowSettings {
    Vsync = OpenTK.Windowing.Common.VSyncMode.Off
};

var window = new GameWindow(settings, nativeSetting);

window.Run();

Expected & Actual behavior

The program will crash with a Stack Overflow Exception after about 387,000 loops.
(This could take about 10~100 seconds, depending on the speed of your system.)

Related information

The exact same issue occurred every time I tried it, on at least 2 computers (desktop and laptop).

  • Operating system: Windows 10 Home
  • Version of OpenTK via NuGet
  • Runtime (.NET 6.0)

image

@sebagamesdev sebagamesdev changed the title (bug) Stack Overflow Exception on GameWindow after about 387000 loops when Runs on x86 (bug) Stack Overflow Exception occurs in GameWindow after about 387,000 loops when running on x86 Mar 23, 2023
@NogginBops NogginBops added bug needs verification Indicates that this bug needs to be reproduced again becaus of a major/breaking change. 4.x glfw labels Mar 24, 2023
@NogginBops NogginBops added this to the 4.8.0 milestone Mar 24, 2023
@NogginBops
Copy link
Member

Yeah I think we've seen this error pop up before when running OpenTK in 32-bit mode. I don't remember the exact issue, but it's likely some issue related to interop. I'll try look up the issues this has been mentioned in and link them here.

@NogginBops
Copy link
Member

It seems like I'm unable to reproduce this bug. I'm running the repro you provided as a 32-bit application and it seems to be running fine. If you have any more information that could help to diagnose the issue that would be great.
Are you running a 32-bit version of windows? or are you just compiling the program as 32-bit?
Are you able to see the stack trace when the exception occurs? if so, could you share it?

@Avibah
Copy link

Avibah commented Jun 8, 2023

I was able to reproduce this bug on my machine and it happens relatively quickly when running. I am on 64-bit Windows 10 compiling as 32-bit. I seem to get different stack traces depending on whether or not I have a controller plugged in but the thrown error is the same. Attached are both stack traces I was able to obtain using identical source code as the provided picture, although the error seems to still happen if VSync is enabled.

(Without controller)
image

(With controller)
image

Update:
I tried Visual Studio's Decompile Source Code option after the error was thrown, resulting in these lines being given as the exact location of their respective errors:

(Without controller)
image

(With controller)
image

Something else to note is I tried running Console.WriteLine(GL.GetError()); in the OnRenderFrame event of NativeWindow to try seeing if it would yield anything useful, resulting in a completely different location for the same error, this time being entirely separate from OpenTK:

image
image

@NogginBops
Copy link
Member

@Avibah What version of OpenTK.redist.glfw are you using? Can you print the GLFW version at runtime with Console.WriteLine(GLFW.GetVersionString())?

@Avibah
Copy link

Avibah commented Jun 12, 2023

@NogginBops Doing so printed this: 3.3.8 Win32 WGL EGL OSMesa VisualC DLL

@NogginBops
Copy link
Member

This issue is still at large and no further info has been collected. It's likely some native interop where the ABI doesn't match 100% while running the application as a 32-bit application.

I can't reproduce the issue so not sure what to do here. Postponing this to 4.8.1.

@NogginBops NogginBops modified the milestones: 4.8.0, 4.8.1 Jul 17, 2023
@NogginBops
Copy link
Member

As nothing has happened with this issue I'm going to more this for 4.8.2.

@NogginBops NogginBops modified the milestones: 4.8.1, 4.8.2 Sep 25, 2023
@MV10
Copy link
Contributor

MV10 commented Oct 8, 2023

Maybe #1494 is where this was seen before?

I couldn't reproduce this, either. I used the very simple LocalTest project in the repository, at various times running a release build, a stand-alone debug build, and debug in VS2022 (v17.7.4). I added a frame counter so I could keep track, and let it loop for very long periods of time all morning while I worked on other things. Some tests ran for more than ten million frames.

Same GLFW version string mentioned above, and .NET 6.0.317, Win11 22H2, NVIDIA driver 531.79.

@NogginBops
Copy link
Member

I'm likely going to more this issue to OpenTK 4.8.3 unless a repro can be made.
Does this still happen for you in 4.8.1 @sebagamesdev and @Avibah ?

@NogginBops
Copy link
Member

Moving this to 4.8.3.

@NogginBops NogginBops modified the milestones: 4.8.2, 3.3.4, 4.8.3 Dec 2, 2023
@NogginBops NogginBops modified the milestones: 4.8.3, 4.9.0 Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x bug glfw needs verification Indicates that this bug needs to be reproduced again becaus of a major/breaking change.
Projects
None yet
Development

No branches or pull requests

4 participants