Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 96407

Summary: Freecraft SDLCD address space leak
Product: Gentoo Linux Reporter: qube99
Component: [OLD] GamesAssignee: Gentoo Games <games>
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Attachments: Makes freecraft use one sdl thread for SDLCD CDRomCheck
Update patch. The address leak is due to not calling SDL_WaitThread. This resolves this while using the new signalling mechanism.

Description qube99 2005-06-17 12:46:18 UTC
If Freecraft is compiled with SDLCD support then every second about 2MB of  
virtual address space is allocated; eventually this causes Freecraft to be 
unplayable until it's restarted.  This is because of a bug in 
SDL_CreateThread.  The following patch doesn't fix SDL_CreateThread but  
instead makes Freecraft use a more sane threading approach (make the thread  
once and signal it to do its job instead of recreating the thread once a  

Reproducible: Always
Steps to Reproduce:
1. Compile Freecraft.  USE flag should include "sdl" (it does by default in  
most profiles)  
2. Run Freecraft.  
3. Look at the Freecraft process in ps or top and notice the VSZ increases. 

Gentoo Base System version 1.4.16 
Portage (default-linux/x86/2005.0, gcc-3.3.5-20050130, 
glibc-, 2.6.11-gentoo-r9 i686) 
System uname: 2.6.11-gentoo-r9 i686 AMD Athlon(tm) Processor 
Python:              dev-lang/python-2.3.5 [2.3.5 (#1, May 12 2005, 00:28:03)] 
ccache version 2.2 [enabled] 
dev-lang/python:     2.3.5 
sys-apps/sandbox:    [Not Present] 
sys-devel/autoconf:  2.13, 2.59-r6 
sys-devel/automake:  1.9.5, 1.5, 1.7.9-r1, 1.4_p6, 1.6.3, 1.8.5-r3 
sys-devel/binutils:, 2.16-r1 
sys-devel/libtool:   1.5.16 
CFLAGS="-march=athlon-xp -O2 -pipe" 
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.1/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" 
CXXFLAGS="-march=athlon-xp -O2 -pipe" 
FEATURES="autoaddcvs autoconfig ccache distlocks fixpackages sandbox sfperms 
strict userpriv" 
USE="x86 3dnow 3dnowex X Xaw3d a52 aac aalib aim alsa apm arts asm avi berkdb 
bitmap-fonts bonobo bzlib cdparanoia cdr crypt cscope curl divx4linux doc dv 
dvd dvdr eds emboss encode esd evo examples exif fam fbcon ffmpeg flac 
foomaticdb fortran gb gcj gd gdbm ggi gif gmp gnome gnustep gpm gstreamer gtk 
gtk2 gtkhtml guile icq imagemagick imlib java jpeg junit kde kdeenablefinal 
kdexdeltas ldap lesstif libg++ libwww live lzo mad mikmod mjpeg mmx mmxext mng 
motif mozcalendar mozilla mozsvg mp3 mpeg mysql mythtv nas ncurses network nls 
objc offensive ogg oggvorbis opengl oscar oss pam pdflib perl pic pie png 
python qt quicktime readline real rtc ruby samba scanner sdl slang softmmu sox 
spell sse ssl svg svga tcltk tcpd tetex theora threads tiff truetype 
truetype-fonts type1-fonts unicode usb v4l v4l2 vcd videos vorbis win32codecs 
wxwindows xine xinerama xml xml2 xmms xv xvid xvmc yahoo zlib userland_GNU 
kernel_linux elibc_glibc" 
Comment 1 qube99 2005-06-17 12:47:25 UTC
Created attachment 61409 [details, diff]
Makes freecraft use one sdl thread for SDLCD CDRomCheck
Comment 2 qube99 2005-06-24 20:10:20 UTC
Created attachment 61886 [details, diff]
Update patch.  The address leak is due to not calling SDL_WaitThread.  This resolves this while using the new signalling mechanism.
Comment 3 SpanKY gentoo-dev 2006-09-03 22:22:21 UTC
no, the saner fix would be to:
 - have a global var 'cdrom_check_thread' and init it to NULL
 - before creating the new thread, if 'cdrom_check_thread' is not NULL, then call SDL_KillThread(cdrom_check_thread)
 - create new thread: cdrom_check_thread = SDL_CreateThread(CDRomCheck, NULL);