sokol: sapp_init never returns when linked against glibc
The following code within sapp_init never returns when linked against glibc:
const char* exts = _sapp.glx.QueryExtensionsString(_sapp.x11.display, _sapp.x11.screen);
It works fine under musl libc.
The main function:
sapp_desc sokol_main(int argc, char **argv) {
(void)argv;
(void)argc;
return (sapp_desc) {
.width = 640,
.height = 480,
.window_title = "Zany80 v" STR(PROJECT_VERSION),
.init_cb = init,
.frame_cb = frame,
.cleanup_cb = deinit,
.event_cb = event,
.sample_count = 4,
.gl_force_gles2 = false,
.fullscreen = true,
.alpha = true,
};
}
Compilation:
# AUTOGENERATED FILE; DO NOT MODIFY (use `build.py` instead)
CFLAGS+=-DPROJECT_VERSION=0.2.0-13 -DSOKOL_GLCORE33 -D_DEBUG -D_POSIX_C_SOURCE=200809L -Og -Wall -g -pedantic -std=c99
CXXFLAGS+=-DPROJECT_VERSION=0.2.0-13 -DSOKOL_GLCORE33 -D_DEBUG -D_POSIX_C_SOURCE=200809L -Og -Wall -g -pedantic -std=c++11
LDFLAGS+=-lGL -lX11 -ldl -lstdc++ -lm -lXcursor -lXi
INCLUDES+=-Ilib/ -Ilib/cimgui/
build/obj/%.o: %.c $(HEADERS)
$(CC) $< $(CFLAGS) $(INCLUDES) -c -o $@
build/obj/%.o: %.cpp $(HEADERS)
$(CXX) $< $(CXXFLAGS) $(INCLUDES) -c -o $@
### TARGET: sokol
sokol_OBJECTS = build/obj/lib/sokol/sokol.o build/obj/lib/sokol/sokol_cpp.o
sokol_HEADERS = lib/sokol/sokol_app.h lib/sokol/sokol_args.h lib/sokol/sokol_audio.h lib/sokol/sokol_fetch.h lib/sokol/sokol_gfx.h lib/sokol/sokol_glue.h lib/sokol/sokol_time.h lib/sokol/util/sokol_debugtext.h lib/sokol/util/sokol_fontstash.h lib/sokol/util/sokol_gfx_imgui.h lib/sokol/util/sokol_gl.h lib/sokol/util/sokol_imgui.h lib/sokol/util/sokol_memtrack.h
### TARGET: Zany80
Zany80: build/Zany80
Zany80_OBJECTS = build/obj/src/XML.o build/obj/src/graphics.o build/obj/src/graphics_legacy.o build/obj/src/license.o build/obj/src/main.o build/obj/src/ring_buffer.o build/obj/src/serial.o build/obj/src/z80.o build/obj/src/zexall.o
Zany80_HEADERS =
build/Zany80: $(Zany80_OBJECTS) $(TextEditor_OBJECTS) $(cimgui_OBJECTS) $(rapidxml_OBJECTS) $(scas_OBJECTS) $(sokol_OBJECTS) $(stb_OBJECTS) $(z80e_OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
(minified a bit)
#0 0x00007ffff754b49a in pthread_cond_broadcast@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007ffff7e1002b in _XReply () from /usr/lib64/libX11.so.6
#2 0x00007ffff7e05cd6 in XQueryExtension () from /usr/lib64/libX11.so.6
#3 0x00007ffff7df8d93 in XInitExtension () from /usr/lib64/libX11.so.6
#4 0x00007ffff7673c21 in __glXInitialize () from /usr/lib64/libGLX_mesa.so.0
#5 0x00007ffff766f6e4 in GetGLXPrivScreenConfig () from /usr/lib64/libGLX_mesa.so.0
#6 0x00007ffff766fcae in glXQueryExtensionsString () from /usr/lib64/libGLX_mesa.so.0
#7 0x0000555555620914 in _sapp_glx_init () at lib/sokol/sokol_app.h:7253
#8 0x0000555555628055 in _sapp_linux_run (desc=<optimized out>) at lib/sokol/sokol_app.h:8084
Valgrind shows this:
==22695== Conditional jump or move depends on uninitialised value(s)
==22695== at 0x56C16AE: pthread_mutex_lock (in /lib64/libpthread-2.31.so)
==22695== by 0x5598B8B: __glXInitialize (in /usr/lib64/libGLX_mesa.so.0.0.0)
==22695== by 0x55946E3: GetGLXPrivScreenConfig (in /usr/lib64/libGLX_mesa.so.0.0.0)
==22695== by 0x5594CAD: glXQueryExtensionsString (in /usr/lib64/libGLX_mesa.so.0.0.0)
==22695== by 0x1D4913: _sapp_glx_init (sokol_app.h:7253)
==22695== by 0x1DC054: _sapp_linux_run (sokol_app.h:8084)
==22695== by 0x1DC4E6: main (sokol_app.h:8129)
EDIT: added main EDIT 2: add Makefile
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
😃