You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A segmentation fault occurs when starting the engine, specifically when tries to start the render device (openGL).
The problem is not consistent, happens most of the time, but not always.
Occurs in XrCore.so
To Reproduce
Compile rpm package in debug mode.
Install.
Execute xd_3da (on linux and default openGL render)
Desktop (please complete the following information):
OS: Fedora 41
OpenXRay dev version
Additional context
Engine compiled in debug mode.
When debugging, I get this info:
#0 __GI_getenv (name=name@entry=0x7ffff4182d1c "EGL_KHR_create_context") at getenv.c:50
#1 0x00007ffff40dc510 in SDL_getenv_REAL (name=0x7ffff4182d1c "EGL_KHR_create_context") at /usr/src/debug/SDL2-2.30.9-1.fc41.x86_64/src/stdlib/SDL_getenv.c:183
#2 SDL_EGL_HasExtension (_this=_this@entry=0x437ed0, type=type@entry=SDL_EGL_DISPLAY_EXTENSION, ext=ext@entry=0x7ffff4182d1c "EGL_KHR_create_context")
at /usr/src/debug/SDL2-2.30.9-1.fc41.x86_64/src/video/SDL_egl.c:193
#3 0x00007ffff40df489 in SDL_EGL_CreateContext (_this=0x437ed0, egl_surface=0x1c22440) at /usr/src/debug/SDL2-2.30.9-1.fc41.x86_64/src/video/SDL_egl.c:994
#4 0x00007ffff412d811 in Wayland_GLES_CreateContext (_this=0x437ed0, window=<optimized out>) at /usr/src/debug/SDL2-2.30.9-1.fc41.x86_64/src/video/wayland/SDL_waylandopengles.c:54
#5 0x00007ffff40ec615 in SDL_GL_CreateContext_REAL (window=0x4b58b0) at /usr/src/debug/SDL2-2.30.9-1.fc41.x86_64/src/video/SDL_video.c:4094
#6 0x00007fffbf25d3b0 in CHW::CreateDevice(SDL_Window*) () from /lib64/xrRender_GL.so
Only function 6, CHW::CreateDevice(SDL_Window*) () is from the engine, 5 to 0 are all SDL internal functions.
The problem seems to occur because a memory address is being passed as if were a valid pointer to a char. This occurs in SDL_getenv_REAL, which is receiving name=0x7ffffff4182d1c “EGL_KHR_create_context”. SDL_getenv expects a const char * as a parameter.
I suspect somewhere in the stack the pointer gets invalid or corrupted.
The text was updated successfully, but these errors were encountered:
Investigating these, it seems that CreateDevice() has not just one but several instances where it can segfault.
For the error when calling SDL_GL_CreateContext I've found a workaround. For some reason this function does not like to work with global variables, but a locally created variable can call the function without problems and then assign its value to m_context.
// Create the primary context workaround
SDL_GLContext m_glcontext{};
m_glcontext = SDL_GL_CreateContext(m_window);
m_context = m_glcontext; // copy the value
// Local variable no longer needed
SDL_GL_DeleteContext(m_glcontext);
m_glcontext = nullptr;
// Assert
if (m_context == nullptr)
{
Log("! Could not create openGL context:", SDL_GetError());
}
The errors don't end there. I've also found that the it's best to avoid call MakeContextCurrent(IRender::PrimaryContext and instead make the call directly.:
if (! (SDL_GL_MakeCurrent(m_window, m_context)))
{
Log("! Could not assign primary context as current:", SDL_GetError());
}
Finally, frequent errors also occur when openGL functions are called, for example glDebugMessageCallback if in DEBUG mode, or with glGetIntegerv.
I suspect this has to do with requiring GLAD to be able to be used, but I'm not sure.
Describe the bug
A segmentation fault occurs when starting the engine, specifically when tries to start the render device (openGL).
The problem is not consistent, happens most of the time, but not always.
Occurs in XrCore.so
To Reproduce
xd_3da
(on linux and default openGL render)Expected behavior
Engine starts
Screenshots, videos
N/A
BugTrap error report
Desktop (please complete the following information):
Additional context
When debugging, I get this info:
CHW::CreateDevice(SDL_Window*) ()
is from the engine, 5 to 0 are all SDL internal functions.SDL_getenv_REAL
, which is receivingname=0x7ffffff4182d1c “EGL_KHR_create_context”
.SDL_getenv
expects aconst char *
as a parameter.The text was updated successfully, but these errors were encountered: