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

Stack-buffer-overflow when creating a window #951

Closed
nnorwitz opened this Issue Feb 22, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@nnorwitz

nnorwitz commented Feb 22, 2017

When using AddressSanitizer (https://github.com/google/sanitizers) on GLFW code where long = 64 bits, there is a seg fault with this info:

==35010==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd022b0850 at pc 0x7effc37d0fa7 bp 0x7ffd022b0440 sp 0x7ffd022b0438
READ of size 8 at 0x7ffd022b0850 thread T0
    #0 0x7effc37d0fa6 in _XData32 Xorg/libX11-1.6.3/src/XlibInt.c:1608:15
    #1 0x7effc378e31a in XChangeProperty Xorg/libX11-1.6.3/src/ChProp.c:83:6
    #2 0x7effc372a82c in createWindow GLFW/src/x11_window.c:536:9
    #3 0x7effc372a82c in _glfwPlatformCreateWindow GLFW/src/x11_window.c:1527
    #4 0x7effc373cb5f in glfwCreateWindow GLFW/src/window.c:195:10

When disabling the pid section in:
https://github.com/glfw/glfw/blob/master/src/x11_window.c#L574
the problem goes away. I suspect if you cast the pid_t to a long it will avoid the problem.

This seems like a similar to this where the length was changed to a long:
https://chromium.googlesource.com/chromium/src.git/+/f09a3116b3c3bff8d4c98dd65d659471a7eeff6f%5E%21/#F0

There may be other problems, but avoiding the pid code solved the problem in my environment.

@kcc

This comment has been minimized.

Show comment
Hide comment
@kcc

kcc Feb 22, 2017

const pid_t pid = getpid(); should be replaced with const long pid = getpid() or some such

kcc commented Feb 22, 2017

const pid_t pid = getpid(); should be replaced with const long pid = getpid() or some such

@elmindreda elmindreda self-assigned this Feb 23, 2017

@elmindreda elmindreda added the verified label Feb 23, 2017

@elmindreda elmindreda changed the title from stack-buffer-overflow when creating an X11 window to Stack-buffer-overflow when creating a window Feb 23, 2017

@elmindreda elmindreda added this to the 3.3 milestone Feb 23, 2017

@elmindreda

This comment has been minimized.

Show comment
Hide comment
@elmindreda

elmindreda Feb 26, 2017

Member

This should be fixed now with 5352e2c. Thank you @nnorwitz and @kcc!

Member

elmindreda commented Feb 26, 2017

This should be fixed now with 5352e2c. Thank you @nnorwitz and @kcc!

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