Skip to content
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

__pthread_mutex_lock_full on Linux #404

Closed
CaiusTSM opened this issue Oct 18, 2020 · 3 comments
Closed

__pthread_mutex_lock_full on Linux #404

CaiusTSM opened this issue Oct 18, 2020 · 3 comments

Comments

@CaiusTSM
Copy link

Hi, I got this runtime error when trying to run the sokol_app.h example code on Manjaro x86_64.

The trace-back in GDB:

a.out: ../nptl/pthread_mutex_lock.c:428: __pthread_mutex_lock_full: Assertion `e != ESRCH || !robust' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7c1d615 in raise () from /usr/lib/libc.so.6
(gdb) backtrace
#0  0x00007ffff7c1d615 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7c06862 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff7c06747 in __assert_fail_base.cold () from /usr/lib/libc.so.6
#3  0x00007ffff7c15bf6 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007ffff77e44d4 in __pthread_mutex_lock_full () from /usr/lib/libpthread.so.0
#5  0x00007ffff7e7c9d4 in ?? () from /usr/lib/libX11.so.6
#6  0x00007ffff7e85389 in XQueryExtension () from /usr/lib/libX11.so.6
#7  0x00007ffff7e78884 in XInitExtension () from /usr/lib/libX11.so.6
#8  0x00007ffff7a44463 in ?? () from /usr/lib/libGLX_mesa.so.0
#9  0x00007ffff7a454ee in ?? () from /usr/lib/libGLX_mesa.so.0
#10 0x0000555555558e4d in _sapp_glx_init () at src/sokol_app.h:8499
#11 0x000055555555b076 in _sapp_linux_run (desc=0x7fffffffe0e0) at src/sokol_app.h:9337
#12 0x000055555555b24c in main (argc=1, argv=0x7fffffffe278) at src/sokol_app.h:9382

The code used was the example code from the README (with OpenGL core 33 selected):

#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_glue.h"

sg_pass_action pass_action;

void init(void) {
    sg_setup(&(sg_desc){
        .context = sapp_sgcontext()
    });
    pass_action = (sg_pass_action) {
        .colors[0] = { .action=SG_ACTION_CLEAR, .val={1.0f, 0.0f, 0.0f, 1.0f} }
    };
}

void frame(void) {
    float g = pass_action.colors[0].val[1] + 0.01f;
    pass_action.colors[0].val[1] = (g > 1.0f) ? 0.0f : g;
    sg_begin_default_pass(&pass_action, sapp_width(), sapp_height());
    sg_end_pass();
    sg_commit();
}

void cleanup(void) {
    sg_shutdown();
}

sapp_desc sokol_main(int argc, char* argv[]) {
    return (sapp_desc){
        .init_cb = init,
        .frame_cb = frame,
        .cleanup_cb = cleanup,
        .width = 400,
        .height = 300,
        .window_title = "Clear (sokol app)",
    };
}

Compiled with:
gcc src/*.c -o build/a.out -ldl -lX11 -lXi -lXcursor -lGL

@floooh
Copy link
Owner

floooh commented Oct 18, 2020

Hmm, hard to say what's wrong there to be honest, sokol_app.h is not multithreaded anywhere, so that's somewhere inside the GLX implementation. The X11/GLX initialization code should be identical to GLFW. Do you know if GLFW applications work on that machine?

@floooh
Copy link
Owner

floooh commented Oct 18, 2020

...ah wait! I think I know what's wrong. See this issue:

#376

Specifically this comment:

#376 (comment)

You need to compile with -pthread (note that this is different than -lpthread)

@CaiusTSM
Copy link
Author

Linking to pthread seems to have fixed it. Both -lpthread and -pthread seem to work. I am now compiling with: gcc src/*.c -o build/a.out -pthread -ldl -lX11 -lXi -lXcursor -lGL. Thank you for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants