i.MX6 glXChooseFBConfig Segmentation Fault (Segfault)

Hello.

I work with Freescale i.MX6 processor-based board (next, i’m going to call it TARGET) with Linux. Now I am trying to run on the TARGET a Java application, which uses OpenGL through JOGL.
I faced an issue and figured out that it is in glXChooseFBConfig function.

I wrote a simple code i(n C) in two variations: with and without third argument in glXChooseFBConfig

#include <GL/glx.h>
#include <GL/gl.h>
#include <unistd.h>
#include <stdio.h>

int main (int argc, char ** argv)
{
	Display *dpy = XOpenDisplay(0);
	int nelements;
 
	static int attributeList[] = {GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None};

	GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), NULL, &nelements);
	printf("OK!
");
	return 0;
}

Let’s say that version with
glXChooseFBConfig(dpy, DefaultScreen(dpy), attributeList, &nelements); is test-1
and
glXChooseFBConfig(dpy, DefaultScreen(dpy), NULL, &nelements); is test-2

When I run both test on the HOST-machine (Linux 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 GNU/Linux), I see OK!
When I run test-1 on the TARGET, I see OK!
But when I run test-2 on the TARGET, I see Segmentation fault.

In the OpenGL documentation:

If attrib_list is NULL, then glXChooseFBConfig returns an array of GLX frame buffer configurations that are available on the specified screen. If an error occurs, no frame buffer configurations exist on the specified screen, or if no frame buffer configurations match the specified attributes, then NULL is returned.

I have fb, fb0, fb1 devices in the TARGET’s /dev directory.
glxgears run perfectly.
glxinfo:

name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
    GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig, 
    GLX_SGIX_pbuffer, GLX_SGI_make_current_read
client glx vendor string: Vivante Corp
client glx version string: 1.4
client glx extensions:
    GLX_ARB_get_proc_address, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
    GLX_SGI_make_current_read
GLX version: 1.4
GLX extensions:
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGI_make_current_read
OpenGL vendor string: Vivante Corporation
OpenGL renderer string: Vivante GC2000
OpenGL version string: 2.1 2.0.1
OpenGL shading language version string: 1.20
OpenGL extensions:
    GL_ARB_depth_texture, GL_ARB_fragment_program_shadow, 
    GL_ARB_fragment_shader, GL_ARB_imaging, GL_ARB_multisample, 
    GL_ARB_multitexture, GL_ARB_pixel_buffer_object, GL_ARB_shader_objects, 
    GL_ARB_texture_compression, GL_ARB_texture_env_add, 
    GL_ARB_texture_env_combine, GL_ARB_texture_non_power_of_two, 
    GL_ARB_texture_rectangle, GL_ARB_vertex_buffer_object, 
    GL_ARB_vertex_shader, GL_ARB_window_pos, GL_ATI_draw_buffers, 
    GL_ATI_element_array, GL_ATI_separate_stencil, 
    GL_ATI_texture_env_combine3, GL_ATI_vertex_array_object, GL_EXT_abgr, 
    GL_EXT_bgra, GL_EXT_blend_color, GL_EXT_blend_equation_separate, 
    GL_EXT_blend_func_separate, GL_EXT_color_table, GL_EXT_convolution, 
    GL_EXT_draw_buffers2, GL_EXT_draw_instanced, GL_EXT_draw_range_elements, 
    GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, 
    GL_EXT_framebuffer_object, GL_EXT_histogram, GL_EXT_packed_depth_stencil, 
    GL_EXT_pixel_buffer_object, GL_EXT_polygon_offset, GL_EXT_rescale_normal, 
    GL_EXT_secondary_color, GL_EXT_separate_specular_color, 
    GL_EXT_stencil_two_side, GL_EXT_subtexture, GL_EXT_texture, 
    GL_EXT_texture3D, GL_EXT_texture_array, GL_EXT_texture_buffer_object, 
    GL_EXT_texture_compression_s3tc, GL_EXT_texture_cube_map, 
    GL_EXT_texture_env_add, GL_EXT_texture_env_combine, 
    GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias, 
    GL_EXT_texture_object, GL_EXT_texture_rectangle, GL_EXT_timer_query, 
    GL_EXT_vertex_array, GL_NV_texture_rectangle, GL_SGIS_generate_mipmap, 
    GL_SGIS_texture_lod, GL_SGI_color_matrix, WGL_ARB_extensions_string, 
    WGL_EXT_extensions_string, WGL_EXT_swap_control

24 GLX Visuals
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x021 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x0a5 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x0a6 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 None
0x0a7 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x0a8 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 None
0x0ad 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x0ae 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 None
0x0af 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x0b0 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 None
0x0b1 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x0b2 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 None
0x0b3 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 None
0x0b4 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x0b5 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 None
0x0b6 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x0b7 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 None
0x0bc 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x0bd 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 None
0x0be 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x0bf 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 None
0x0c0 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x0c1 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 None
0x0c2 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x0c3 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 None

24 GLXFBConfigs:
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x045 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x046 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 Slow
0x047 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x048 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 Slow
0x04d 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x04e 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x04f 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x050 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x051 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x052 16 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 Slow
0x053 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x054 16 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 Slow
0x075 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x076 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 Slow
0x077 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x078 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0 16 16 16  0  0 0 Slow
0x07d 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x07e 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x07f 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x080 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x081 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x082 16 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 Slow
0x083 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8  0  0  0  0  0 0 None
0x084 16 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  8 16 16 16  0  0 0 Slow

Please tell me the way to solve this problem.
Best Regards.

Have you tried passing an empty attribute list (i.e. where the first element is None)?

That should have the same effect as passing a null pointer, i.e. returning all configurations.

[QUOTE=GClements;1275981]Have you tried passing an empty attribute list (i.e. where the first element is None)?

That should have the same effect as passing a null pointer, i.e. returning all configurations.[/QUOTE]

Hi!

Thank you for your responce!

I just tried this code and it works - I see “OK!”

static int attributeList[] = {None};

GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), attributeList, &nelements);

What does it mean?
Do I understand correctly, that I have “frame buffer configurations existing on the specified screen”?

Yes. Well, assuming that nelements isn’t zero (it shouldn’t be, but then passing a null pointer for the attribute list is supposed to work).

I tested this code:

int nelements=100;
static int attributeList[] = {None};
GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), attributeList, &nelements);
printf("OK! nelements=%d
", nelements);

and got OK! nelements=24.

But
int nelements=100;
static int attributeList[] = {None};
GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), NULL, &nelements);
printf("OK! nelements=%d
", nelements);
crushes anyway.

Please help me to understand the reason of this bug, because the application I need to run uses exactly NULL as a third argument.

[QUOTE=Unbeliever;1277427]GLXFBConfig *fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), NULL, &nelements);

[crashes]
Please help me to understand the reason of this bug, because the application I need to run uses exactly NULL as a third argument.[/QUOTE]
Who implemented the X11 bindings for your platform (Freescale i.MX6 processor-based board)? You probably need to talk with them. It’s possible they didn’t properly implement the interface for glXChooseFBConfig() to handle the NULL 3rd argument case. It’s also possible that under-the-hood it’s crashing on something else not directly caused by the 3rd argument being NULL.

You can perhaps get more insight into where it’s crashing by (since you’re running on Linux) running your application under valgrind (it’s easy: run “valgrind <yourapp>”). It’ll give you more detail on the cause of the crash and where it is happening. You could also get much of this by running your app compiled for debug under a debugger like gdb. Then when it crashes, do a “where” to get a full stack trace for the crash.

Hello Dark Photon!

There is my gdb stacktrace:
Program received signal SIGSEGV, Segmentation fault.
0x76f99ae8 in __glXInitializeVisualConfigFromTags (config=0x7efffa70,
config[at]entry=0x7efffa68, count=count[at]entry=512, bp=0x0,
tagged_only=tagged_only[at]entry=1,
fbconfig_style_tags=fbconfig_style_tags[at]entry=1) at glxext.c:684
684 glxext.c: No such file or directory.
(gdb) where
#0 0x76f99ae8 in __glXInitializeVisualConfigFromTags (config=0x7efffa70,
config[at]entry=0x7efffa68, count=count[at]entry=512, bp=0x0,
tagged_only=tagged_only[at]entry=1,
fbconfig_style_tags=fbconfig_style_tags[at]entry=1) at glxext.c:684
#1 0x76f8e458 in ChooseFBConfig (fbconfig_style_tags=1 ‘\001’,
attribList=<optimized out>, num_configs=24, configs=0x27860)
at glxcmds.c:1869
#2 glXChooseFBConfig (dpy=<optimized out>, screen=<optimized out>,
attribList=<optimized out>, nitems=0x7efffb6c) at glxcmds.c:1915
#3 0x000086a0 in main (argc=1, argv=0x7efffcd4) at test-2.c:15

Unfortunately, valgrind dead with Fatal error at startup: a function redirection… bla-bla-bla and I could not find an offhand solution.

I’ll try to find out the developers of the X11 bindings, but I would be grateful if you help me articulate the problem.
Do I understand correctly, that it is a Freescale’s implementation of libGL bug?

It’s likely that whoever wrote libGL didn’t read the documentation carefully enough. If you can’t get an updated driver which doesn’t have this problem, you might be able to “patch” the program by using LD_PRELOAD to load a shared library containing something like.


#include <GL/glx.h>
typedef GLXFBConfig func_t(Display *, int, const int *, int *);
GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
{
    static func_t *func;
    static const int attribs[] = {None};
    if (!func) {
         void *library = dlopen("libGL.so", RTLD_GLOBAL);
         func = (func_t *) dlsym(library, "glXChooseFBConfig");
    }
    if (!attribList)
        attribList = attribs;
    return (*func)(dpy, screen, attribList, nitems);
}

I’ve used this approach in the past to work around similar issues, but I have no idea whether it will work for your particular problem on that particular platform.

Hmm… A few websearch hits:

The first suggests you might want to check your device permissions to ensure that your current user can open critical files (possibly in /dev). See if you have a “video” group in /etc/group. If your username is not in it, add yourself to it (via “vigr”). Here on an NVidia GPU, the files I have in /dev which are owned by group “video” are:


> ls -l /dev | grep video
crw-rw----   1 root video    29,   0 Aug  3 17:51 fb0
crw-rw----+  1 root video   248,   0 Aug  3 17:51 nvidia-uvm
crw-rw----+  1 root video   195,   0 Aug  3 17:51 nvidia0
crw-rw----+  1 root video   195, 255 Aug  3 17:51 nvidiactl

Also suggests you might make sure your X implementation exposes the GLX extension (looks like it does above) and the Render extension (check your “xdpyinfo” output to see if it looks reasonable and to verify that it lists the GLX and RENDER extensions).

Thank you for your support!

I checked this links before posting this thread. Unfortunately, it doesn’t help me.

root-imx6qsabresd:~# ls -l /dev/ | grep video
crw-rw----    1 root     video      29,   0 Jan  1  1970 fb0
crw-rw----    1 root     video      29,   1 Jan  1  1970 fb1
crw-rw----    1 root     video     199,   0 Jan  1  1970 galcore
crw-rw----    1 root     video      81,   2 Jan  1  1970 video0
crw-rw----    1 root     video      81,   0 Jan  1  1970 video16
crw-rw----    1 root     video      81,   1 Jan  1  1970 video17

root-imx6qsabresd:~# cat /etc/group

video:x:44:

root-imx6qsabresd:~# xdpyinfo 
name of display:    :0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    11603000
X.Org version: 1.16.3
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    7
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 15, bits_per_pixel 16, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0xe00003, revert to PointerRoot
number of extensions:    27
    BIG-REQUESTS
    Composite
    DAMAGE
    DOUBLE-BUFFER
    DPMS
    DRI2
    GLX
    Generic Event Extension
    MIT-SCREEN-SAVER
    MIT-SHM
    Present
    RANDR
    RENDER
    SGI-GLX
    SHAPE
    SYNC
    X-Resource
    XC-MISC
    XFIXES
    XFree86-DGA
    XFree86-DRI
    XFree86-VidModeExtension
    XInputExtension
    XKEYBOARD
    XTEST
    XVideo
    vivext
default screen number:    0
number of screens:    1
<next there are screen parameters>

It seems to me that it is libGL.so bug.
I posted a bugreport, but not allowed to post a link on it here.

[QUOTE=Unbeliever;1277836]# cat /etc/group

video:x:44:

[/QUOTE]

The above confirms that no one is in the video group. I would add your username to the video group, log out, and log back in. That very well might solve your problem, if in fact it’s due to device permissions.

Hi!

Unfortunately, adding video:x:44:root to /etc/group by vigr -g
and video:*::root to /etc/gshadow by vigr -s changes nothing.

Thank you.

Ok, I meant the username that you are logged into your GUI desktop with. Typically you don’t log into that with root but an ordinary user.

Typically, in the embedded Linux one have an only root user for easier embedded system configuraton. It makes no sense to create user without root privileges.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.