Bug 57563 - Crash in debug_backtrace_capture (src/gallium/auxiliary/util/u_debug_stack.c) when running mesa-demos using drm backend
Summary: Crash in debug_backtrace_capture (src/gallium/auxiliary/util/u_debug_stack.c)...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-26 17:18 UTC by Sergey Matyukevich
Modified: 2013-02-22 16:22 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Sergey Matyukevich 2012-11-26 17:18:01 UTC
Mesa crashes in function debug_backtrace_capture (src/gallium/auxiliary/util/u_debug_stack.c) when running mesa-demos using drm backend.

* Mesa version
git revision 97747ac88fe9207dde83b275a93ebcee3a84dc01

* Host/OS
Debian-7.0 (wheezy) running in VMwarePlayer-4.0.4 build-744019

* Mesa configuration command
# ./autogen.sh --enable-debug --enable-openvg --enable-gles1 --enable-gles2 --enable-gbm --enable-gallium-loader --enable-gallium-drm-loader --enable-gallium-gbm --enable-gallium-egl --with-gallium-drivers=swrast,svga --with-egl-platforms=wayland,fbdev,drm --with-dri-drivers= --enable-shared-glapi --disable-driglx-direct

* Mesa configuration output

        prefix:          /usr/local
        exec_prefix:     ${prefix}
        libdir:          ${exec_prefix}/lib
        includedir:      ${prefix}/include

        OpenGL:          yes (ES1: yes ES2: yes)
        OpenVG:          yes

        OSMesa:          no
        DRI drivers:     no
        DRI driver dir:  ${libdir}/dri
        GLX:             DRI-based

        EGL:             yes
        EGL platforms:   wayland fbdev drm
        EGL drivers:     builtin:egl_glx builtin:egl_dri2 egl_gallium
        EGL Gallium STs: $(VG_LIB) $(GL_LIB)

        llvm:            yes
        llvm-config:     /usr/local/bin/llvm-config
        llvm-version:    3.0

        Gallium:         yes
        Gallium dirs:    auxiliary drivers state_trackers
        Target dirs:     dri-swrast dri-vmwgfx egl-static gbm 
        Winsys dirs:     svga/drm sw sw/dri sw/fbdev sw/null sw/wayland 
        Driver dirs:     galahad identity llvmpipe noop rbug softpipe svga trace 
        Trackers dirs:   dri egl gbm vega 

        Shared libs:     yes
        Static libs:     no
        Shared-glapi:    yes

        CFLAGS:          -g -O2 -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-strict-aliasing -fno-builtin-memcmp -g -fPIC
        CXXFLAGS:        -g -O2 -Wall -fno-strict-aliasing -fno-builtin-memcmp -g -fPIC
        Macros:          -D_GNU_SOURCE -DHAVE_PTHREAD -DDEBUG -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN -DIN_DRI_DRIVER -DGLX_INDIRECT_RENDERING -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LIBUDEV -DHAVE_LLVM=0x0300

        PYTHON2:         python

        Run 'make' to build Mesa

* Demo application output

Environement variables: 

LIBGL_DEBUG=verbose
EGL_PLATFORM=drm
EGL_LOG_LEVEL=debug

Demo application output

# torus_screen
libEGL debug: Native platform type: drm (environment overwrite)
libEGL debug: EGL search path is /usr/local/lib/egl
libEGL debug: added /usr/local/lib/egl/egl_gallium.so to module array
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
libEGL debug: dlopen(/usr/local/lib/egl/egl_gallium.so)
libEGL info: use DRM for display (nil)
libEGL debug: the best driver is Gallium
EGL_VERSION = 1.4 (Gallium)
libEGL debug: the value (0x0) of attribute 0x3025 did not meet the criteria (0x1)
libEGL debug: the value (0x0) of attribute 0x3025 did not meet the criteria (0x1)
Segmentation fault

* Demo application gdb stacktrace

(gdb) run
Starting program: /root/graphics-experiments/mesa-demos/src/egl/opengles1/torus_screen 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
libEGL debug: Native platform type: drm (environment overwrite)
libEGL debug: EGL search path is /usr/local/lib/egl
libEGL debug: added /usr/local/lib/egl/egl_gallium.so to module array
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
libEGL debug: dlopen(/usr/local/lib/egl/egl_gallium.so)
libEGL info: use DRM for display (nil)
libEGL debug: the best driver is Gallium
EGL_VERSION = 1.4 (Gallium)
libEGL debug: the value (0x0) of attribute 0x3025 did not meet the criteria (0x1)
libEGL debug: the value (0x0) of attribute 0x3025 did not meet the criteria (0x1)

Program received signal SIGSEGV, Segmentation fault.
debug_backtrace_capture (backtrace=backtrace@entry=0x80c01fc, start_frame=start_frame@entry=1, nr_frames=nr_frames@entry=8) at util/u_debug_stack.c:52
52	   __asm__ __volatile__("mov (%%ebp),%0": "=r" (frame_pointer));
(gdb) bt
#0  debug_backtrace_capture (backtrace=backtrace@entry=0x80c01fc, start_frame=start_frame@entry=1, nr_frames=nr_frames@entry=8) at util/u_debug_stack.c:52
#1  0xb4856790 in pb_debug_manager_create_buffer (_mgr=0x8055310, size=1024, desc=0xbffff608) at pipebuffer/pb_bufmgr_debug.c:417
#2  0xb4805704 in vmw_svga_winsys_buffer_create (sws=0x8054e20, alignment=1, usage=0, size=1024) at vmw_screen_svga.c:75
#3  0xb480ed7e in svga_winsys_buffer_create (svga=svga@entry=0x8069de8, alignment=alignment@entry=1, usage=usage@entry=0, size=1024)
    at svga_resource_buffer_upload.c:61
#4  0xb480d082 in svga_texture_transfer_map (pipe=0x8069de8, texture=0x80c0090, level=0, usage=2, box=0xbffff7b0, ptransfer=0xbffff7ac)
    at svga_resource_texture.c:272
#5  0xb48751e8 in u_transfer_map_vtbl (context=0x8069de8, resource=0x80c0090, level=0, usage=2, box=0xbffff7b0, transfer=0xbffff7ac) at util/u_resource.c:35
#6  0xb483c17f in aaline_create_texture (aaline=0x80be6a0) at draw/draw_pipe_aaline.c:454
#7  draw_install_aaline_stage (draw=0x8082a60, pipe=pipe@entry=0x8069de8) at draw/draw_pipe_aaline.c:949
#8  0xb481ffe2 in svga_init_swtnl (svga=svga@entry=0x8069de8) at svga_swtnl_draw.c:164
#9  0xb481352c in svga_context_create (screen=0x8055660, priv=0x0) at svga_context.c:159
#10 0xb6440320 in st_api_create_context (stapi=0xb783f3e0, smapi=0x80623a0, attribs=0xbffff9b4, error=0xbffff9b0, shared_stctxi=0x0)
    at ../../src/mesa/state_tracker/st_manager.c:633
#11 0xb63d7389 in egl_g3d_create_context (drv=0x8051ff8, dpy=0x804d008, conf=0x8068d88, share=0x0, attribs=0xbffffa80) at common/egl_g3d_api.c:176
#12 0xb7f8c0ae in eglCreateContext (dpy=0x804d008, config=0x8068d88, share_list=share_list@entry=0x0, attrib_list=attrib_list@entry=0xbffffa80) at eglapi.c:437
#13 0x0804a687 in _eglutCreateWindow (h=300, w=300, title=0x804aee5 "torus", x=<optimized out>, y=<optimized out>) at eglut.c:162
#14 eglutCreateWindow (title=title@entry=0x804aee5 "torus") at eglut.c:317
#15 0x080493c7 in main (argc=1, argv=0xbffffbe4) at torus.c:435


Additional notes.

The following fixes/workaround have been found: 

0. to build mesa without debug support :-)

1. to build with explicit compiler flag -fno-omit-frame-pointer

2. to apply the following patch

diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c
index 558b911..0a1e4e5 100644
--- a/src/gallium/auxiliary/util/u_debug_stack.c
+++ b/src/gallium/auxiliary/util/u_debug_stack.c
@@ -49,8 +49,7 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
       return;
 
 #if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
-   __asm__ __volatile__("mov (%%ebp),%0": "=r" (frame_pointer));
-   frame_pointer = (const void **)frame_pointer[0];
+   frame_pointer = ((const void **)__builtin_frame_address(1));
 #elif defined(PIPE_CC_GCC)
    frame_pointer = ((const void **)__builtin_frame_address(1));
 #elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
Comment 1 Brian Paul 2012-11-26 17:41:18 UTC
FWIW, I think I ran into this bug earlier in the year in a VM that I was testing.  I never found the cause though.  At the time I just disabled the code and forgot about it.
Comment 2 Jose Fonseca 2013-02-22 16:22:50 UTC
(In reply to comment #0)
> The following fixes/workaround have been found: 
> 
> 0. to build mesa without debug support :-)
> 
> 1. to build with explicit compiler flag -fno-omit-frame-pointer

Yes, debug build without frame pointers is rather useless combination IMHO. Our autotools build should take care of that automatically.

> 2. to apply the following patch

Thanks. I've pushed it now.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.