mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-01 05:10:41 +00:00
ImGui_ImplOpenGL3_init() returns a segfault with GLEW #4279
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#4279
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
imgui/1.83
glfw/3.3.4
glew/2.2.0
all pulled from Conan
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: clang(++)
Operating System: archlinux
My Issue/Question:
ImGui_ImplOpenGL3_init(); gives a segmentation fault when called
Main.cpp
output:

'output/Debug/amalgam' terminated by signal SIGSEGV (Address boundary error)output from lldb:
Should have probably included this, when stepping into the function with lldb:

Is the imgui_impl_opengl3 backend compiled to use Glew and not gl3w?
//
I just realized that adding the call here defeat the helper debug/test code added between line 230 and 270 to help people detect that the right loader is used. I will move them in the other order.Hello,
Can't strikeout the second sentence from my previous message (messages sent via email don't have markdown marketing) but you can ignore the second sentence.
Can you check the value of local variable
const char* gl_loaderat the time of the crash?Linking to #4170
@ocornut Printing gl_loader shows that it does detect it as GLEW and not GL3W
You need to use the right define so it that cpp will use glew then.
I will amend the commentary around that section with:
"Above" refer to:
You can add
#define IMGUI_IMPL_OPENGL_LOADER_GLEWin your imconfig file or make sure that the paths are setup in a way where the compile-time attempt at autodetection in imgui_impl_opengl3.cpp will succeed.Adding that define doesn't fix the issue, I'm using GLEW which means that it detects the right openGL loader
Can you confirm you are getting that crash and the value for gl_loader says “glew” and NOT anything else?
I'm not the author of the issue, but have the same crash in the same point in my code. My debugger prints gl_loader as "GLEW", not "glew", could that be that the problem?. I'll list all the variables that I assume are relevant (I really new to OpenGL and ImGui, so please correct me if I'm wrong):
The exact versions of glew and glfw that I use are the following:
https://github.com/Perlmint/glew-cmake/tree/883e35a3d493d93fa27da5abb6225654c360f9d0
https://github.com/glfw/glfw/tree/6876cf8d7e0e70dc3e4d7b0224d08312c9f78099
The exact error that I see is the following:
I also have all the initialization glfw and glew code in a shared library that I then use in my
Guiproject, and I am starting to believe that is the problem, maybe I am losing the current context or any other relevant init setup because I create it inside a shared library? I know this library works because I have aSandboxproject where I import it the same way and draw a couple triangles. But callingImGui_ImplOpenGL3_Init("#version 330");crashes.Please tell me if I can do anything else.
Ok so after testing a little more, I've found that the exact same code works fine when compiling with GCC on Pop_os and doesn't work on VS2019 on windows, compiles, but crashes when running. I am now sure the problem is not imgui, so I'll leave it here. Thank you :)
@mayuso Could you step in with a debugger and tell exactly which function call is crashing?
It is
glGetStringi()?Given the confirmation above, if you can help reproducing this we can work on a fix.
Ok, I've gone step by step and my problem wasn't actually
glGetStringi(), it wasGL_EXTENSIONS, it was null. I wasn't linking glew correctly on windows (I think?). CMake is hard I guess. The strange thing is that I've changed the windows code to build glew as shared library and just works, but that doesn't work on Pop_os. So right now I build differently for each OS, I hate it. I need to learn more so this kind of problems don't make everyone lose time.We now should have shot down this problem with #4445
It is possible that the extension polling mechanism may fail on some setup, in which case we can open that. But please first confirm the issue with latest code as posted in #4445