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

glfw backend crash #4124

Closed
huwpascoe opened this issue May 11, 2021 · 4 comments
Closed

glfw backend crash #4124

huwpascoe opened this issue May 11, 2021 · 4 comments
Labels

Comments

@huwpascoe
Copy link

Strange bug where holding a certain key and clicking causes exception.
g_PrevUserCallbackMousebutton is clobbered by an out of bounds write to g_KeyOwnerWindows.

if (action == GLFW_PRESS)
io.KeysDown[key] = true;
if (action == GLFW_RELEASE)
io.KeysDown[key] = false;

Proposed fix:

    if(key >= 0 && key < IM_ARRAYSIZE(g_KeyOwnerWindows))
    {
        if (action == GLFW_PRESS)
        {
            io.KeysDown[key] = true;
            g_KeyOwnerWindows[key] = window;
        }
        if (action == GLFW_RELEASE)
        {
            io.KeysDown[key] = false;
            g_KeyOwnerWindows[key] = NULL;
        }
    }
@ocornut
Copy link
Owner

ocornut commented May 17, 2021

Hello,

Strange bug where holding a certain key

Which keys? What are the value of key ? Is key == -1 ?
Which Operating System and GLFW version?

@huwpascoe
Copy link
Author

huwpascoe commented May 19, 2021

Yes, key is -1

In my keyboard's case, it's right shift

edit:
windows 10, docking branch

@ocornut
Copy link
Owner

ocornut commented May 19, 2021

That's absolutely very strange and surprising but I am going to add the bound check...

If you can compile GLFW yourself and set breakpoint in win32_window.c, function windowProc(), message WM_KEYDOWN` it would be interesting to see how it is possible that you get a value of -1 there.

createKeyTables() fills _glfw.win32.keycode[] with -1 default value so it mean your value of scancode in that function ends up not being setup in the keycode[] array. Would be good to investigate because maybe there is a bug to fix in GLFW.

What's your GLFW version?

ocornut added a commit that referenced this issue May 19, 2021
@ocornut
Copy link
Owner

ocornut commented May 19, 2021

Pushed fix!
Would be helpful for us and GLFW if you can keep investigating the things discussed above and post your results.
Thank you very much!

@ocornut ocornut closed this as completed May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants