ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
710 stars 160 forks source link

Rockchip (Mali-T760) Segmentation Fault #39

Closed bekker closed 7 years ago

bekker commented 7 years ago

es2_info and es2gears work well, but I can't get glxinfo working. Original lunixbochs/glshim branch worked well, but I'm going for OpenGL 2.0.

I compiled gl4es using ODROID option.

$ es2_info
EGL_VERSION: 1.4 Midgard-"r12p0-04rel0"
EGL_VENDOR: ARM
EGL_EXTENSIONS:
    , EGL_KHR_image_pixmap, EGL_KHR_partial_update,  EGL_KHR_config_attribs, 
    EGL_KHR_image, EGL_KHR_image_base, EGL_KHR_fence_sync, EGL_KHR_wait_sync, 
    EGL_KHR_gl_colorspace, EGL_KHR_get_all_proc_addresses, 
    EGL_IMG_context_priority, EGL_ARM_pixmap_multisample_discard, 
    EGL_KHR_gl_texture_2D_image, EGL_KHR_gl_renderbuffer_image, 
    EGL_KHR_create_context, EGL_KHR_surfaceless_context, 
    EGL_KHR_gl_texture_cubemap_image, EGL_EXT_create_context_robustness, 
    EGL_KHR_cl_event2
EGL_CLIENT_APIS: OpenGL_ES
GL_VERSION: OpenGL ES 3.2 v1.r12p0-04rel0.4280adac90751b4d03519963106fb083
GL_RENDERER: Mali-T760
GL_EXTENSIONS:
    GL_ARM_rgba8, GL_ARM_mali_shader_binary, GL_OES_depth24, 
    GL_OES_depth_texture, GL_OES_depth_texture_cube_map, 
    GL_OES_packed_depth_stencil, GL_OES_rgb8_rgba8, GL_EXT_read_format_bgra, 
    GL_OES_compressed_paletted_texture, GL_OES_compressed_ETC1_RGB8_texture, 
    GL_OES_standard_derivatives, GL_OES_EGL_image, GL_OES_EGL_image_external, 
    GL_OES_EGL_image_external_essl3, GL_OES_EGL_sync, GL_OES_texture_npot, 
    GL_OES_vertex_half_float, GL_OES_required_internalformat, 
    GL_OES_vertex_array_object, GL_OES_mapbuffer, 
    GL_EXT_texture_format_BGRA8888, GL_EXT_texture_rg, 
    GL_EXT_texture_type_2_10_10_10_REV, GL_OES_fbo_render_mipmap, 
    GL_OES_element_index_uint, GL_EXT_shadow_samplers, 
    GL_OES_texture_compression_astc, GL_KHR_texture_compression_astc_ldr, 
    GL_KHR_texture_compression_astc_hdr, 
    GL_KHR_texture_compression_astc_sliced_3d, GL_KHR_debug, 
    GL_EXT_occlusion_query_boolean, GL_EXT_disjoint_timer_query, 
    GL_EXT_blend_minmax, GL_EXT_discard_framebuffer, 
    GL_OES_get_program_binary, GL_OES_texture_3D, GL_EXT_texture_storage, 
    GL_EXT_multisampled_render_to_texture, GL_OES_surfaceless_context, 
    GL_OES_texture_stencil8, GL_EXT_shader_pixel_local_storage, 
    GL_ARM_shader_framebuffer_fetch, 
    GL_ARM_shader_framebuffer_fetch_depth_stencil, GL_ARM_mali_program_binary, 
    GL_EXT_sRGB, GL_EXT_sRGB_write_control, GL_EXT_texture_sRGB_decode, 
    GL_KHR_blend_equation_advanced, GL_KHR_blend_equation_advanced_coherent, 
    GL_OES_texture_storage_multisample_2d_array, GL_OES_shader_image_atomic, 
    GL_EXT_robustness, GL_EXT_draw_buffers_indexed, 
    GL_OES_draw_buffers_indexed, GL_EXT_texture_border_clamp, 
    GL_OES_texture_border_clamp, GL_EXT_texture_cube_map_array, 
    GL_OES_texture_cube_map_array, GL_OES_sample_variables, 
    GL_OES_sample_shading, GL_OES_shader_multisample_interpolation, 
    GL_EXT_shader_io_blocks, GL_OES_shader_io_blocks, 
    GL_EXT_tessellation_shader, GL_OES_tessellation_shader, 
    GL_EXT_primitive_bounding_box, GL_OES_primitive_bounding_box, 
    GL_EXT_geometry_shader, GL_OES_geometry_shader, 
    GL_ANDROID_extension_pack_es31a, GL_EXT_gpu_shader5, GL_OES_gpu_shader5, 
    GL_EXT_texture_buffer, GL_OES_texture_buffer, GL_EXT_copy_image, 
    GL_OES_copy_image, GL_EXT_color_buffer_half_float, 
    GL_EXT_color_buffer_float, GL_EXT_YUV_target, GL_OVR_multiview, 
    GL_OVR_multiview2, GL_OVR_multiview_multisampled_render_to_texture, 
    GL_KHR_robustness, GL_KHR_robust_buffer_access_behavior, 
    GL_EXT_draw_elements_base_vertex, GL_OES_draw_elements_base_vertex
$ es2gears
EGL_VERSION = 1.4 Midgard-"r12p0-04rel0"
vertex shader info: 
fragment shader info: 
info: 
280 frames in 5.0 seconds = 55.877 FPS

But glxinfo dies.

$ glxinfo
LIBGL: Initialising gl4es
LIBGL: v1.0.2 built on Nov  2 2017 12:30:52
LIBGL: Using GLES 1.1 backend
LIBGL:loaded: libGLESv1_CM.so
LIBGL:loaded: libEGL.so
LIBGL: Using GLES 1.1 backend
LIBGL: Extension GL_OES_blend_subtract detected and used
LIBGL: Extension GL_OES_blend_func_separate detected and used
LIBGL: Extension GL_OES_blend_equation_separate detected and used
LIBGL: Extension GL_EXT_blend_minmax detected and used
LIBGL: Extension GL_OES_framebuffer_object detected and used
LIBGL: Extension GL_OES_point_sprite detected and used
LIBGL: Extension GL_OES_point_size_array detected
LIBGL: Extension GL_OES_element_index_uint detected
LIBGL: Extension GL_OES_packed_depth_stencil detected and used
LIBGL: Extension GL_OES_depth24 detected and used
LIBGL: Extension GL_OES_rgb8_rgba8 detected and used
LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used
LIBGL: Extension GL_OES_texture_cube_map detected and used
LIBGL: Extension GL_OES_draw_texture detected and used
LIBGL: Max texture size: 8192
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 1
LIBGL: Implementation Read is GL_RGBA/GL_UNSIGNED_BYTE
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 1.5
LIBGL: Current folder is:/usr/lib/arm-linux-gnueabihf
name of display: :3.0
glXGetProcAddress: glGetProgramivARB not found.
glX stub: glGetStringi
glXGetProcAddress: glGetConvolutionParameteriv not found.
[1]    18019 segmentation fault (core dumped)  glxinfo

Libraries are properly linked. (glshim/libGL.so.1 is gl4es)

$ ldd /usr/bin/glxinfo
    libGL.so.1 => /usr/lib/glshim/libGL.so.1 (0xafc73000)
    libX11.so.6 (0xafb82000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xafa7d000)
    /lib/ld-linux-armhf.so.3 (0xafd30000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xafa05000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xaf9f2000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xaf9ca000)
    libxcb.so.1 (0xaf9a6000)
    libXau.so.6 (0xaf99b000)
    libXdmcp.so.6 (0xaf987000)

glxgears does not segfault, but with only black screen

$ glxgears
LIBGL: Initialising gl4es
LIBGL: v1.0.2 built on Nov  2 2017 12:30:52
LIBGL: Using GLES 1.1 backend
LIBGL:loaded: libGLESv1_CM.so
LIBGL:loaded: libEGL.so
LIBGL: Using GLES 1.1 backend
LIBGL: Extension GL_OES_blend_subtract detected and used
LIBGL: Extension GL_OES_blend_func_separate detected and used
LIBGL: Extension GL_OES_blend_equation_separate detected and used
LIBGL: Extension GL_EXT_blend_minmax detected and used
LIBGL: Extension GL_OES_framebuffer_object detected and used
LIBGL: Extension GL_OES_point_sprite detected and used
LIBGL: Extension GL_OES_point_size_array detected
LIBGL: Extension GL_OES_element_index_uint detected
LIBGL: Extension GL_OES_packed_depth_stencil detected and used
LIBGL: Extension GL_OES_depth24 detected and used
LIBGL: Extension GL_OES_rgb8_rgba8 detected and used
LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used
LIBGL: Extension GL_OES_texture_cube_map detected and used
LIBGL: Extension GL_OES_draw_texture detected and used
LIBGL: Max texture size: 8192
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 1
LIBGL: Implementation Read is GL_RGBA/GL_UNSIGNED_BYTE
LIBGL: sRGB surface supported
LIBGL: Targeting OpenGL 1.5
LIBGL: Current folder is:/usr/lib/arm-linux-gnueabihf
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.

When I try to launch other few programs, they segfault. lunixbochs/glshim branch did not segfault, but with an assertion error.

$ chromium-browser
LIBGL: Initialising gl4es
LIBGL: v1.0.2 built on Nov  2 2017 12:30:52
LIBGL: Using GLES 1.1 backend
LIBGL:loaded: libGLESv1_CM.so
LIBGL:loaded: libEGL.so
LIBGL: Using GLES 1.1 backend
[1]    19301 segmentation fault (core dumped)  chromium-browser

Any ideas??

bekker commented 7 years ago

Oh I forgot to mention. I'm using Poin2 Chromebook 11, with ubuntu crouton. xfce4 for desktop and x11 is hw-accelerated with armsoc driver.

ptitSeb commented 7 years ago

Can you try with the export LIBGL_FB=1 (lunixbochs version automaticaly use this). If that's not enough, a gdb backtrace would be helpfull.

bekker commented 7 years ago

Tried LIBGL_FB with no luck. Here's the stack trace.

Thread 1 "glxinfo" received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/arm/armv6t2/strlen.S:146
146 ../sysdeps/arm/armv6t2/strlen.S: No such file or directory.
(gdb) bt
#0  strlen () at ../sysdeps/arm/armv6t2/strlen.S:146
#1  0x00012e2a in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

And when I run blender without LIBGL_FB=1, it first opens without any font, then after 3 seconds talks about some 'stack smashing'.


*** stack smashing detected ***: blender terminated
[1]    12710 abort (core dumped)  LD_LIBRARY_PATH=/usr/lib/gl4es blender
ptitSeb commented 7 years ago

That mean I call strlen with a bad pointer. That backtrace doesn't help much. Be sure to compile gl4es with debug info (easy way is to use ccmake and choose RelWithDebInfo as build type). Also, you can uncomment this line: https://github.com/ptitSeb/gl4es/blob/master/src/glx/glx.c#L34 to get manu debug info in the glX part, were I assume the crash occurs.

bekker commented 7 years ago

The only strlen call in glxinfo.c was strlen(DisplayString(dpy)). I compiled glxinfo.c myself for debugging, and surprisingly, it worked well. The glxinfo.c source seems identitcal.

And then I compiled gl4es with RelWithDebInfo, by adding set(CMAKE_BUILD_TYPE "RelWithDebInfo") in CMakeLists.txt. Same segfault and backtrace, no additional info.

When I uncommented the debug line, fcntl.h started raising some weird errors, so I had to remove the optimization pragma right under it. And then, surprisingly, everything works perfectly just by turning the DBG macro on. :(

I have no idea what's happening.

bekker commented 7 years ago

Maybe I'll try deleting DBG macro lines one by one.

ptitSeb commented 7 years ago

maybe valgrind can help here.

bekker commented 7 years ago
$ LD_LIBRARY_PATH=/usr/lib/gl4es valgrind glxinfo
==13057== Memcheck, a memory error detector
==13057== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==13057== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==13057== Command: glxinfo
==13057== 
LIBGL: Initialising gl4es
LIBGL: v1.0.2 built on Nov  2 2017 17:56:05
LIBGL: Using GLES 1.1 backend
LIBGL:loaded: libGLESv1_CM.so
LIBGL:loaded: libEGL.so
LIBGL: Using GLES 1.1 backend
==13057== Syscall param ioctl(generic) points to uninitialised byte(s)
==13057==    at 0x4AADDA6: ioctl (syscall-template.S:84)
==13057==    by 0x5292619: uku_open (in /usr/lib/mali/libmali.so)
==13057==  Address 0xbd867a3c is on thread 1's stack
==13057== 
==13057== Syscall param ioctl(generic) points to uninitialised byte(s)
==13057==    at 0x4AADDA6: ioctl (syscall-template.S:84)
==13057==    by 0x529275D: uku_call (in /usr/lib/mali/libmali.so)
==13057==  Address 0xbd867aec is on thread 1's stack
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x4845DE8: memset (vg_replace_strmem.c:1224)
==13057==    by 0x5256E41: cframep_shared_pmem_init (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac317000 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Thread 9 mali-hist-dump:
==13057== Conditional jump or move depends on uninitialised value(s)
==13057==    at 0x4BA72FE: __udivmoddi4 (in /lib/arm-linux-gnueabihf/libgcc_s.so.1)
==13057== 
==13057== Use of uninitialised value of size 4
==13057==    at 0x4BA7300: __udivmoddi4 (in /lib/arm-linux-gnueabihf/libgcc_s.so.1)
==13057== 
==13057== Use of uninitialised value of size 4
==13057==    at 0x4BA5BF4: ??? (in /lib/arm-linux-gnueabihf/libgcc_s.so.1)
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x4BA5BE8: ??? (in /lib/arm-linux-gnueabihf/libgcc_s.so.1)
==13057==  Address 0xa20acf0 is on thread 9's stack
==13057==  16 bytes below stack pointer
==13057== 
==13057== Thread 1:
==13057== Invalid write of size 4
==13057==    at 0x4845DE8: memset (vg_replace_strmem.c:1224)
==13057==    by 0x52A50E1: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7000 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 4
==13057==    at 0x52A50E8: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7008 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A50F4: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7008 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 2
==13057==    at 0x52A5114: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A511E: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A5158: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7008 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A5174: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7008 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A5186: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7008 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A51D2: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A51F8: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A521E: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A5244: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7010 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 2
==13057==    at 0x52A5246: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d700c is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 2
==13057==    at 0x52A524E: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d700e is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A5258: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d700c is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A5266: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d700e is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 2
==13057==    at 0x52A5272: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7002 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A527E: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7000 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A528A: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7000 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A5290: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7004 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A52A4: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7006 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid read of size 2
==13057==    at 0x52A5388: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7042 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A5392: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7040 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A5398: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7044 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A53A0: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d7040 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 2
==13057==    at 0x52A53AA: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d70c4 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x52A53AE: cobjp_image_template_generate_descriptor (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2d70c0 is not stack'd, malloc'd or (recently) free'd
==13057== 
disInstr(thumb): unhandled instruction: 0xDEFF 0x682B
LIBGL: Extension GL_OES_blend_subtract detected and used
LIBGL: Extension GL_OES_blend_func_separate detected and used
LIBGL: Extension GL_OES_blend_equation_separate detected and used
LIBGL: Extension GL_EXT_blend_minmax detected and used
LIBGL: Extension GL_OES_framebuffer_object detected and used
LIBGL: Extension GL_OES_point_sprite detected and used
LIBGL: Extension GL_OES_point_size_array detected
LIBGL: Extension GL_OES_element_index_uint detected
LIBGL: Extension GL_OES_packed_depth_stencil detected and used
LIBGL: Extension GL_OES_depth24 detected and used
LIBGL: Extension GL_OES_rgb8_rgba8 detected and used
LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected and used
LIBGL: Extension GL_OES_texture_cube_map detected and used
LIBGL: Extension GL_OES_draw_texture detected and used
LIBGL: Max texture size: 8192
LIBGL: Texture Units: 8(8), Max lights: 8, Max planes: 1
LIBGL: Implementation Read is GL_RGBA/GL_UNSIGNED_BYTE
LIBGL: sRGB surface supported
==13057== Invalid write of size 4
==13057==    at 0x4845DE8: memset (vg_replace_strmem.c:1224)
==13057==    by 0x525E4C5: cframep_manager_reset (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2cf000 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== Invalid write of size 4
==13057==    at 0x4845DE8: memset (vg_replace_strmem.c:1224)
==13057==    by 0x525E629: cframep_manager_reset (in /usr/lib/mali/libmali.so)
==13057==  Address 0xac2cf000 is not stack'd, malloc'd or (recently) free'd
==13057== 
LIBGL: Targeting OpenGL 1.5
LIBGL: Current folder is:/home/north/project/gl4es/lib
name of display: :1.0
glXGetProcAddress: glGetProgramivARB not found.
glX stub: glGetStringi
glXGetProcAddress: glGetConvolutionParameteriv not found.
==13057== Conditional jump or move depends on uninitialised value(s)
==13057==    at 0x12E18: ??? (in /usr/bin/glxinfo)
==13057== 
==13057== Invalid read of size 1
==13057==    at 0x4842110: strlen (vg_replace_strmem.c:454)
==13057==    by 0x12E29: ??? (in /usr/bin/glxinfo)
==13057==  Address 0x1f03 is not stack'd, malloc'd or (recently) free'd
==13057== 
==13057== 
==13057== Process terminating with default action of signal 11 (SIGSEGV)
==13057==  Access not within mapped region at address 0x1F03
==13057==    at 0x4842110: strlen (vg_replace_strmem.c:454)
==13057==    by 0x12E29: ??? (in /usr/bin/glxinfo)
==13057==  If you believe this happened as a result of a stack
==13057==  overflow in your program's main thread (unlikely but
==13057==  possible), you can try to increase the size of the
==13057==  main thread stack using the --main-stacksize= flag.
==13057==  The main thread stack size used in this run was 8388608.
==13057== 
==13057== HEAP SUMMARY:
==13057==     in use at exit: 3,295,291 bytes in 1,669 blocks
==13057==   total heap usage: 2,272 allocs, 603 frees, 3,903,793 bytes allocated
==13057== 
==13057== LEAK SUMMARY:
==13057==    definitely lost: 4 bytes in 1 blocks
==13057==    indirectly lost: 0 bytes in 0 blocks
==13057==      possibly lost: 1,726,660 bytes in 479 blocks
==13057==    still reachable: 1,568,627 bytes in 1,189 blocks
==13057==                       of which reachable via heuristic:
==13057==                         stdstring          : 13,580 bytes in 599 blocks
==13057==                         newarray           : 13,884 bytes in 243 blocks
==13057==         suppressed: 0 bytes in 0 blocks
==13057== Rerun with --leak-check=full to see details of leaked memory
==13057== 
==13057== For counts of detected and suppressed errors, rerun with: -v
==13057== Use --track-origins=yes to see where uninitialised values come from
==13057== ERROR SUMMARY: 15965 errors from 38 contexts (suppressed: 115 from 15)

So I guess the mali driver does some nasty things on the stack, and gl4es gets a wrong pointer from it. That's why it worked when I added the macro, it somehow rearranged the stack so that it doesn't segfault, but still runs with a strange behavior.

I found out that it also writes at invalid location even on es2_info, so much invalid writes/reads but luckily within the segmentation.

I don't know whether this is a normal behavior. Maybe the driver is evil, or maybe I set up something wrong. I'll look into the X.org driver configs.

Thanks for the help.

ptitSeb commented 7 years ago

Ok.

(For testing purpose, you can also try LIBGL_FB=3 and also the ES2 backend with LIBGL_ES=2 , that may be is more stable?).

Also, don't forget that valgrind doesn't have access to kernel protected memory, but the Mali driver probably does. So some invalid access or unitialize warning are maybe false alarm because of that.