-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Segmentation fault in glColor3ub on macOS #858
Comments
Hey @pftbest, Are you saying it doesn't crash with values |
It's working fine for values >= 0 and <= 127. My guess that in native part of lwjgl the lwjgl3/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_GL11.c Lines 387 to 391 in b44ba7a
|
glColor3ub is causing SEGFAULT on negative values, use glColor3i instead. See LWJGL/lwjgl3#858 This call is rarely used so performance impact should be minimal.
glColor3ub is causing SEGFAULT on negative values, use glColor3i instead. See LWJGL/lwjgl3#858 This call is rarely used so performance impact should be minimal.
@Spasi If you look carefully at the register values in the crash log:
You can clearly see that the value of |
Found the root cause: On macOS the Caller is responsible for truncating or sign extending the value before passing it to Callee. See Pass-arguments-to-functions-correctly. In this case the value must be truncated because But native code in lwjgl does not truncate the values properly because the function is declared as if it expects signed arguments: typedef void (APIENTRY *glColor3ubPROC) (jbyte, jbyte, jbyte); instead of unsigned: typedef void (APIENTRY *glColor3ubPROC) (GLubyte, GLubyte, GLubyte);
or
typedef void (APIENTRY *glColor3ubPROC) (uint8_t, uint8_t, uint8_t);
or
typedef void (APIENTRY *glColor3ubPROC) (unsigned char, unsigned char, unsigned char); So compiler doesn't know that it should convert the values. Specifying the correct data types in the glColor3ubPROC function declaration should fix the issue. |
Thank you @pftbest for the information above (especially the godbolt repro!), this issue should hopefully be fixed in the next snapshot. |
Hey @pftbest, LWJGL |
Thanks, I'll try it tomorrow. |
@Spasi The issue is resolved now, my demo app runs just file. I also see new AND instructions in the disassembly, so it's all good, thank you. |
Version
3.3.2 (nightly)
Platform
macOS x64, macOS arm64
JDK
OpenJDK Runtime Environment (19.0.2+7) (build 19.0.2+7-44)
Module
OpenGL
Bug description
Passing negative value to glColor3ub causes SIGSEGV in opengl.
Steps to reproduce:
-XstartOnFirstThread
VM flagReproduced both in rosetta emulated x86_64 jdk and with native aarch64 jdk.
JDK Versions:
Full crash logs:
hs_err_pid37760.log
hs_err_pid37929.log
Stacktrace or crash log output
No response
The text was updated successfully, but these errors were encountered: