RetroDebugger icon indicating copy to clipboard operation
RetroDebugger copied to clipboard

OpenGL2 Backend

Open fieserWolF opened this issue 3 years ago • 9 comments

Describe the bug Segmentation fault on Debian 5.14.9-2 (2021-10-03) x86_64 GNU/Linux .

I compiled RetroDebugger and MTEngineSDL. Then started with gdb.

(gdb) r
Starting program: /home/wolf/git/RetroDebugger/build/retrodebugger 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff627d640 (LWP 10873)]
[New Thread 0x7ffff43af640 (LWP 10875)]
[New Thread 0x7fffebfff640 (LWP 10876)]
[New Thread 0x7ffff3bae640 (LWP 10877)]
[New Thread 0x7ffff33ad640 (LWP 10878)]
[New Thread 0x7ffff2b64640 (LWP 10892)]
[New Thread 0x7ffff2b23640 (LWP 10893)]

Thread 1 "retrodebugger" received signal SIGSEGV, Segmentation fault.
CSlrMutex::Lock (this=0x0) at /home/wolf/git/MTEngineSDL/src/Engine/Core/SYS_Threading.cpp:179
179		SDL_LockMutex(mutex);

The same happens with the pre-compiled release alpha v0.64.60.04E.

fieserWolF avatar Jan 08 '22 12:01 fieserWolF

Thanks, please provide whole backtrace (bt command in gdb)

slajerek avatar Jan 08 '22 15:01 slajerek

Thread 1 "retrodebugger" received signal SIGSEGV, Segmentation fault.
CSlrMutex::Lock (this=0x0) at /home/wolf/git/MTEngineSDL/src/Engine/Core/SYS_Threading.cpp:179
179		SDL_LockMutex(mutex);
(gdb) bt
#0  CSlrMutex::Lock (this=0x0) at /home/wolf/git/MTEngineSDL/src/Engine/Core/SYS_Threading.cpp:179
#1  0x0000555555afd509 in VID_LockImageBindingMutex () at /home/wolf/git/MTEngineSDL/src/Engine/Core/VID_ImageBinding.cpp:49
#2  VID_PostImageBinding (image=0x55555878f8b0, dest=0x0) at /home/wolf/git/MTEngineSDL/src/Engine/Core/VID_ImageBinding.cpp:97
#3  0x0000555555af59b6 in RES_GetImageAsync (imageNameConst=<optimized out>, linearScaling=<optimized out>, resourceLevel=100, 
    fromResources=<optimized out>) at /home/wolf/git/MTEngineSDL/src/Engine/Core/RES_ResourceManager.cpp:334
#4  0x0000555555b2d935 in CGuiMain::CGuiMain (this=0x555558a3d5f0) at /home/wolf/git/MTEngineSDL/src/Engine/GUI/CGuiMain.cpp:31
#5  0x0000555555b2dd71 in GUI_Init () at /home/wolf/git/MTEngineSDL/src/Engine/GUI/GUI_Main.cpp:12
#6  0x0000555555afb7a6 in SYS_MTEngineStartup () at /home/wolf/git/MTEngineSDL/src/Engine/Core/SYS_Startup.cpp:83
#7  0x000055555564d140 in main (argc=1, argv=0x7fffffffe288) at /home/wolf/git/MTEngineSDL/platform/Linux/src.Linux/main.cpp:27

Hope this helps.

fieserWolF avatar Jan 08 '22 22:01 fieserWolF

This should not be possible, it says the bindingMutex is NULL, when Lock is performed from SYS_Startup.cpp line 83, but it was init and created in VID_Init which is run from SYS_Startup line 71. Looks like more general problem and will require more investigation. I will create a branch with more debug logs to review what is going on.

slajerek avatar Jan 09 '22 11:01 slajerek

Please pull most recent MTEngineSDL, and apply change in platform/Linux/Linux/src.Linux/DBG_Log.h, comment out line 15: #define GLOBAL_DEBUG_OFF (i.e. change to // #define GLOBAL_DEBUG_OFF or remove that line). Then please paste here all log which is printed before the crash.

slajerek avatar Jan 09 '22 12:01 slajerek

11:48:11,057 0000 [MAIN] MTEngineSDL v3.06 compiled on Jan 16 2022 10:25:06 11:48:11,057 0000 [DEBUG] SYS_SetCommandLineArguments: argc=1 argv=f2385ef8 11:48:11,057 0000 [MAIN] SYS_InitFileSystem 11:48:11,057 0000 [DEBUG] gPathToCurrentDirectory=/home/wolf/git/RetroDebugger/build 11:48:11,057 0000 [DEBUG] pathToResources=./Documents/ 11:48:11,057 0000 [DEBUG] pathToDocuments=./Documents/ 11:48:11,057 0000 [DEBUG] gPathToTemp=./Documents/ 11:48:11,057 0000 [DEBUG] pathToSettings=/home/wolf/.RetroDebugger/ 11:48:11,057 0000 [MAIN] SYS_InitApplicationPauseResume() 11:48:11,057 0000 [DEBUG] C64DebuggerInitStartupTasks 11:48:11,057 0000 [DEBUG] C64DebuggerParseCommandLine0 11:48:11,057 0000 [MAIN] MTEngineSDL compiled SDL 2.0.18, linked with 2.0.18 11:48:11,074 0000 [MAIN] Resource manager INIT 11:48:11,075 0000 [TODO] SYS_SetThreadName 11:48:11,075 0000 [MAIN] RES_InitDeployFile 11:48:11,075 0000 [ERROR] CSlrFileFromDocuments: failed to open ./Documents/deploy/deploy 11:48:11,075 0000 [ERROR] CByteBuffer: file does not exist 11:48:11,075 0000 [WARN] Deploy file does not exist. 11:48:11,075 0000 [MAIN] RES_InitEmbeddedData 11:48:11,075 0000 [DEBUG] RES_AddFileToDeploy: /Engine/console-plain 3 11:48:11,075 0000 [DEBUG] RES_AddFileToDeploy: /Engine/console-inverted-plain 3 11:48:11,075 0000 [DEBUG] RES_AddFileToDeploy: /Engine/default-font 6 11:48:11,075 0000 [DEBUG] RES_AddFileToDeploy: /Engine/default-font 3 11:48:11,075 0000 [DEBUG] VID_GetGlSlVersion 11:48:11,075 0000 [DEBUG] VID_GetGlSlVersion: Linux: version 130 11:48:11,075 0000 [DEBUG] request #version 130 11:48:11,086 0000 [DEBUG] gMainWindow is 77f2a9b0 11:48:11,087 0000 [ERROR] Failed to create SDL GL Context. This is fatal! Error=Could not create GL context: GLXBadFBConfig

11:48:11,087 0000 [DEBUG] CSoundEngine::DebugPrintAudioDevices 11:48:11,087 0000 [DEBUG] ...SDL_GetNumAudioDevices returned -1 11:48:11,087 0000 [MAIN] CSoundEngine::SetOutputAudioDevice: deviceName=NULL 11:48:11,090 0000 [MAIN] CSoundEngine::SetOutputAudioDevice: opened device 1 Speicherzugriffsfehler

fieserWolF avatar Jan 16 '22 10:01 fieserWolF

Thanks. The problem you experiencing is due to this:

Failed to create SDL GL Context. This is fatal! Error=Could not create GL context: GLXBadFBConfig

It seems your Linux does not support OpenGL 3. I will add a better information message box and not just crash, but this is fatal error, please check your Linux configuration.

slajerek avatar Jan 16 '22 12:01 slajerek

You are right, this is an older laptop which uses the onboard Intel Graphics Chip. This is the output of glxinfo | grep OpenGL:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics (ILK)
OpenGL version string: 2.1 Mesa 21.2.6
OpenGL shading language version string: 1.20
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 2.0 Mesa 21.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 1.0.16
OpenGL ES profile extensions:

Maybe it is possible to create the GUI without OpenGL 3? Some users might want to use it on older hardware as well. (On my more up-to-date desktop PC RetroDebugger works.)

fieserWolF avatar Jan 18 '22 14:01 fieserWolF

This is actually a matter of selecting Backend for ImGui. There's a Backend for OpenGL2, I will check if it's easy to integrate: https://github.com/ocornut/imgui/tree/master/backends

slajerek avatar Jan 19 '22 17:01 slajerek

I have now separated OpenGL3 and refactored so we can select backend, there's OpenGL3 and a draft Metal implementation (unfortunately not working due a bug in ImGui). It should be rather easy to add OpenGL2 now, I'll have a look.

slajerek avatar Apr 24 '23 09:04 slajerek