Bug 7574

Summary: apps using openGL segfault.
Product: Mesa Reporter: Richard Hebert <hebertrich>
Component: Drivers/DRI/TDFXAssignee: Adam Jackson <ajax>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: high CC: flufetor, lam
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: The patch for Mesa 6.5 and tdfx_dri crash

Description Richard Hebert 2006-07-20 02:43:24 UTC
Gentoo bugs asked me to move this upstream : 
http://bugs.gentoo.org/show_bug.cgi?id=140471

What happens is this.DRM direct rendering is showing 
enabeled for the voodoo3 AGP card and has the expected
1360 fps after the update to modular X v 7.0 ( stable )
The other voodoo3 pci ( i got dual head ) is not accelerated
and has also the expected 250 fps or so with glxgears. 
But any application using GL crashes with "Segmentation
fault". ( on the accelerated card, they work but real slow
on the pci card ) 
I have managed to produce a backtrace for TuxRacer

(gdb) bt
#0  0xb79cc237 in free () from /lib/libc.so.6
#1  0xb76ba40d in _mesa_free () from /usr/lib/xorg/modules/dri/tdfx_dri.so
#2  0xb76ba470 in _mesa_align_free () from
/usr/lib/xorg/modules/dri/tdfx_dri.so
#3  0xb76e0f8d in _mesa_free_texmemory () from
/usr/lib/xorg/modules/dri/tdfx_dri.so
#4  0xb76e0fde in _mesa_free_texture_image_data ()
   from /usr/lib/xorg/modules/dri/tdfx_dri.so
#5  0xb76e0f21 in _mesa_delete_texture_image () from
/usr/lib/xorg/modules/dri/tdfx_dri.so
#6  0xb76e2875 in _mesa_delete_texture_object ()
   from /usr/lib/xorg/modules/dri/tdfx_dri.so
#7  0xb7665780 in _mesa_halve2x2_teximage2d () from
/usr/lib/xorg/modules/dri/tdfx_dri.so
#8  0xb76e1f90 in _mesa_DeleteTextures () from
/usr/lib/xorg/modules/dri/tdfx_dri.so
#9  0x080845c3 in ?? ()
#10 0x00000001 in ?? ()
#11 0x08852f58 in ?? ()
#12 0xbf8bca04 in ?? ()
#13 0xbf8bca08 in ?? ()
#14 0xb79cc272 in free () from /lib/libc.so.6
#15 0x0804b3f1 in ?? ()

Im lost .. i tried to upgrade to xorg 7.1 the results
were even less brilliant. glxgears just showed a black
screen , no gears .. so i downgraded to 7.0 

Help will be appreciated.Tell me what you need and ill
do my best :) 

Thank you.
Comment 1 Richard Hebert 2006-07-31 03:45:28 UTC
with 7.1 things are even worse .. 
i reinstalled the distro from scratch.
i installed 7.0 ( latest stable ) 
that didnt work .. so i went to 7.1 and then i experienced
complete server crashes.Cant even make a core dump file.
so .. 
I added option aiglx off in the xorg conf and the crashes 
leave me with a froxen screen but at least i can get out of X 
kill the application and come back in and pick up where i left
off . Still cant produce any core dumps though .

I really could use some help here.
Comment 2 Davide Cendron 2006-08-07 13:48:04 UTC
Hello, same problem here, with a Gentoo x86 system
Using
* xorg-7.0
* mesa-6.4 (i also tried mesa-6.5, with same results)
on a 3Dfx Voodoo3 2000

I'm trying to run Vavoom Engine (www.vavoom-engine.com)

This is a backtrace:

(gdb) bt
#0  0xb7b5bb39 in free () from /lib/tls/libc.so.6
#1  0xb6ae53ed in _mesa_free (ptr=0x8001) at imports.c:116
#2  0xb6ae54c0 in _mesa_align_free (ptr=0x8001) at imports.c:200
#3  0xb6b03aed in _mesa_free_texmemory (m=0x8001) at teximage.c:67
#4  0xb6b040d0 in _mesa_free_texture_image_data (ctx=0x84ad0e8, 
texImage=0x8ebeba0)
    at teximage.c:647
#5  0xb6b06d08 in _mesa_TexImage2D (target=3553, level=0, internalFormat=4, 
width=128,
    height=128, border=0, format=6408, type=5121, pixels=0x8001) at 
teximage.c:2314
#6  0x08160b53 in VOpenGLDrawer::WorldDrawing (this=0xb6ce3020) at 
gl_poly.cpp:524
#7  0x080b7591 in R_RenderWorld () at r_bsp.cpp:417
#8  0x080bda4d in R_RenderPlayerView () at r_main.cpp:620
#9  0x080f6603 in SCR_Update () at screen.cpp:494
#10 0x080925ce in Host_Frame () at host.cpp:353
#11 0x08158fa4 in main (argc=32769, argv=0x8001) at sys_sdl.cpp:685
#12 0xb7b0df14 in __libc_start_main () from /lib/tls/libc.so.6
#13 0x0804d6f1 in _start ()
(gdb)

I hope it helps :)
Comment 3 Leszek Matok 2006-08-21 17:28:40 UTC
This one was easy.

As we can see, _mesa_DeleteTextures( ) calls _mesa_free_texmemory( ), which
expects texImage->Data to be allocated using _mesa_align_malloc( ).
_mesa_align_free( ) expects texImage->Data to be prepended by one word with
actual address to pass to real free( ), but it's not, because tdfx driver uses
stock _mesa_malloc( ) without the alignment part. The bytes before
texImage->Data are garbage, so there's no way it could not crash.

I'll attach a patch in a moment, after I do some more testing (I mean play
QuakeForge, at last).

Oh, my card is PCI Voodoo3 2000. The bug happens in Mesa 6.4.2 (from FC5) and
6.5 (from AIGLX for FC5, both rebuilt for Xorg 7.0 with tdfx_dri.so enabled).
The patch will be against 6.5, because that's what I ended up with.
Comment 4 Leszek Matok 2006-08-21 17:38:57 UTC
Created attachment 6640 [details] [review]
The patch for Mesa 6.5 and tdfx_dri crash

Works for me.
Comment 5 Leszek Matok 2006-08-22 16:13:40 UTC
Ouch, all my work for nothing, this was fixed in Mesa CVS long time ago:

http://webcvs.freedesktop.org/mesa/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c?r1=1.32&r2=1.33&diff_format=u

(as ajax told me on irc)
Comment 6 Richard Hebert 2006-08-22 16:46:31 UTC
guess we needed to ask the right person :) 
unfortunately .. i have gone for a newer card since
i reported the bug.Still not fixed in gentoo though. So 
Thank you for the solution/fix.

It's very appreciated.

Richard Hebert
Comment 7 Javier Jardón 2006-11-04 10:14:03 UTC
*** Bug 8034 has been marked as a duplicate of this bug. ***
Comment 8 Francisco L. Fernandez 2008-02-20 15:32:52 UTC
I have to say for future reference that DRI 3D with tdfx driver has been broken for the following releases of UBUNTU:

Breezy
Dapper
Edgy
Feisty

And that it works again (first time since Hoary) whith Gutsy (Vodoo 3/banshee).
Also the MGA (Matrox G400) driver seems to work again (in some of the past ubuntu releases the image was corrupted in 3D).

The working driver combo information for Gutsy is as follows:
DDX:
(II) Module tdfx: vendor="X.Org Foundation"
        compiled for 7.2.0, module version = 1.3.0
        Module class: X.Org Video Driver
        ABI class: X.Org Video Driver, version 1.1
DRM:
(II) TDFX(0): [drm] loaded kernel module for "tdfx" driver
(II) TDFX(0): [drm] DRM interface version 1.3
DRI/MESA:
OpenGL renderer string: Mesa DRI VoodooBanshee 20061113 x86/MMX/SSE
OpenGL version string: 1.2 Mesa 7.0.1
OpenGL extensions:

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.