D2X-XL Bug Reports - Linux

D2X-XL - Descent II update for modern systems with many new features and enhanced graphics. Home Page

Moderators: Grendel, Aus-RED-5

_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

The game has write permission to everything in my home directory. The game does not have write permission to /usr/local/share/d2x-xl/ where the datafiles are located. I have no idea where it tries to create the files, because it doesn't tell me anything. The -debug switch only outputs:

Built: Feb 17 2006 16:40:08
Compiler: 4.0.2 20050901 (prerelease) (SUSE Linux)

But that's a moot point. A far more serious problem appeared, and actually happens with 1.5.109 and 1.5.121 binary versions, as well as with the mixed version I managed to compile (I used GCC 3.3.6).

As soon as the pilot selection menu appears, the game starts hogging memory at 8 to 9 MB per second (in a 933MHz Pentium III), until it is killed. The CPU usage (of the d2x-gl binary, according to top) also goes to 90% and up, and stays there.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

Player profiles are created in /usr/local/share/d2x-xl, or /usr/local/share/d2x-xl/profiles if the latter folder exists and does already contain player files.

xstatica,

a tad late :) - you can always add trackers via d2x.ini. Thx for the info, btw. :)
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

I ran it as root. It worked, and it is beeeautiful!

Only problem is that while I am in any menu, the memory taken by d2x-xl keeps growing. As soon as I enter the game, the memory usage stays same. But as soon as I exit the game and enter the main menu, the memory usage starts growing again.

Update: All in-game menus have the same problem. Even the little menu that asks \"Abort game?\" and lets me choose between Yes and No. The memory usage grows continuously, by the second, even when I don't do anything.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

I will check this.

Edit:

The memory code does not constantly allocate memory.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

Compiled 1.5.125 source. Went perfectly, no problems.

Then, running the binary, the memory hog problem is still there. This is a part from /proc/6773/smaps (the d2x-gl process):

0813e000-196d3000 rw-p 0813e000 00:00 0 [heap]
Size: 284244 kB
Rss: 247736 kB
Shared_Clean: 12 kB
Shared_Dirty: 4980 kB
Private_Clean: 0 kB
Private_Dirty: 242744 kB

How can I know whether I am using the new or the old menu style?
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

New menu style displays the menus (except the main menu) on a blueish background with a blue frame.

I can only repeat what I said: Once D2X-XL is done allocating what it needs for a menu, it doesn't malloc any code it wouldn't release if it doesn't need it any more. There's one instance where the text display function allocates a temporary buffer, but that buffer always gets released. It could only be that that function doesn't work properly on your Linux distro. You can grab the alternative source file from my Descent site, unzip it over your D2X-XL source installation, recompile and see whether that helps you.
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Post by McMartin »

I just compiled 1.5.125 successfully, after a bit of a nightmare getting 1.5.121 to work.

AND.

I got MIDI working.

Of the .121 experience, two patches were still needed to get .125 to work.

First. My drivers don't allow #define RENDER2TEXTURE 2, but do allow it to be 1. However, when RENDER2TEXTURE is 1 and you aren't on Win32, a syntax error hits you in camera.c:

Code: Select all

--- src-orig/main/cameras.c     2006-02-17 05:08:52.000000000 -0800
+++ src/main/cameras.c  2006-02-20 17:02:21.000000000 -0800^M
@@ -266,7 +266,7 @@
 #      ifdef _WIN32
        wglMakeContextCurrentARB (hGlDC, hGlDC, hGlRC);
 #      else
-       glXMakeCurrent (hGlDC, hGlWindow, hGlRC))
+       glXMakeCurrent (hGlDC, hGlWindow, hGlRC);
 #      endif
 #endif
 for (i = Num_cameras; i; i--, pc++) {
Getting MIDI working kind of involves some fiddly bits with Timidity and SDL_mixer, but those aren't bugs, with one exception. The HMP-to-MIDI converter misreports the resulting MIDI as Format 0, when it is actually Format 1, and Timidity happily interprets the resulting file as about three seconds of silence. This is another one-line fix:

Code: Select all

--- src-orig/arch/linux/hmpfile.c       2006-01-16 07:18:24.000000000 -0800
+++ src/arch/linux/hmpfile.c    2006-02-20 16:58:34.000000000 -0800
@@ -539,7 +539,7 @@
 fwrite (\"MThd\", 4, 1, f);
 i = BE_INT (6);
 fwrite (&i, sizeof (i), 1, f);
-s = BE_INT (0);
+s = BE_SHORT (1);
 fwrite (&s, sizeof (s), 1, f); //format
 s = BE_SHORT (hmp->num_trks);
 fwrite (&s, sizeof (s), 1, f);
General squeeing over the project is presumably for other threads, but if not, consider that happening in the background.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

Wow! Thank you very much, your input is very much appreciated, particularly regarding midi support. :)

I will fix the compile error, too.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

About the memory hog problem. The cause of it is probably not in the menu code. Whereas displaying the in-game help (by pressing F1) caused a hogging speed of about one megabyte in two seconds, the credits screen (accessible from the main menu) made a record of 22 megabytes per second.

I really wish I could use some kind of debugger, to see which function causes these allocations. The problem could be related to libSDL or the X.org's mga driver. First problem is, I am unable to compile the game (linux source 1.5.127) with ./configure --without-opengl. The result is:

if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I ../include -I ../main -I ../arch/linux/include -I/usr/include/SDL -D_REENTRANT -pipe -O2 -Wall -Wno-char-subscripts -MT bitmap.o -MD -MP -MF \".deps/bitmap.Tpo\" -c -o bitmap.o bitmap.c; \then mv -f \".deps/bitmap.Tpo\" \".deps/bitmap.Po\"; else rm -f \".deps/bitmap.Tpo\"; exit 1; fi
bitmap.c: In function `gr_free_bitmap_data':
bitmap.c:340: error: structure has no member named `bm_frames'
bitmap.c:341: error: structure has no member named `bm_frames'
bitmap.c:341: error: structure has no member named `bm_frames'
bitmap.c:342: error: structure has no member named `bm_frames'
bitmap.c:343: error: structure has no member named `bm_curframe'
make[2]: *** [bitmap.o] Error 1

Also, I am unable to get commandline help from d2x-xl. It'd help me to see how to disable OpenGL or music or sound, like I could with original Descent or d2x 0.2.5
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

You cannot compile w/o OpenGL. To enable debugging, './configure --enable-debug=yes --enable-release=no'\".

How do you check memory consumption on Linux (Task manager like program?)

There's no memory hogging at all on WinXP.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

To chech memory consumption under linux, I run a program called 'top' in a terminal window. From another terminal windows I run d2x-xl. This would look better with a fixed width font.

top - 19:10:51 up 3 days, 1:33, 13 users, load average: 0.20, 0.39, 0.48
Tasks: 127 total, 1 running, 124 sleeping, 1 stopped, 1 zombie
Cpu(s): 0.8% us, 0.1% sy, 0.0% ni, 98.9% id, 0.1% wa, 0.1% hi, 0.0% si
Mem: 905768k total, 421912k used, 483856k free, 8732k buffers
Swap: 1941368k total, 179428k used, 1761940k free, 122508k cached

PID RES SWAP %CPU TIME+ COMMAND
23914 84m 63m 0.8 331:48.68 X :0 -auth /home/jaakko/.serverauth.23896 -deferglyphs 16
11155 46m 229m 0.0 0:04.78 ./d2x-gl
23328 44m 73m 0.0 14:34.30 /usr/lib/mozilla-firefox/firefox-bin
11053 22m 198m 0.0 0:02.34 java_vm

I'll try building with debug enabled.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

I am running a loop in newmenu.c and I have breakpoints at lines 3686, 3693, 3697 and 3731. The allocations happen between 3693 and 3731, both before and after the break at 3697.

Those lines come and go in an infinite loop, until I choose the pilot. Is this the way it should go?

I have two pilots. Lines 3704 and 3711 are in a loop that is repeated 5 times until 3731 is reached once. Within that loop there is no malicious allocations.

After the break at 3698, there is one malicious allocation before 3704 is reached.

The problem has to do, at least in part, with gr_rect or gr_string at 3729 and 3730. Nothing between 3718 and 3728 causes bad allocations.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

_sd,

get the 1.5.127 source and compile in debug mode. All allocation should be done via a function named mem/mem.c::mem_malloc().
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

Ok. It took me this night to figure out what is debugging and how to use a debugger. Going to sleep now, and will try that tomorrow. I knew it had to do with the placement of the breakpoints.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

A debugger is a program that can execute another program 'step by step' (i.e. assembly instruction by assembly instruction, or source line by source line). Good assemblers allow not only to set breakpoints, but also to examine the state of the programs variables and see the chains of function calls. Really good debuggers have a comfortable GUI.

What you can do here is to set a breakpoint on mem_malloc() once the menu code is being executed and check whether it's called at all, what code calls it, and whether the corresponding mem_free() calls are being made.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

The memory hogging allocations are not done through mem.c's mem_malloc. Either some part of the code (probably in font.c) do allocations some other way, or there is a leak in X's drivers or the SDL library.

mem_malloc doesn't get called at all after the pilot selection menu has appeared.

Update -- All the leaks happen in ogl.c:ogl_loadtexture

Update 2 -- The guilty call is one of these two (lines 1042 to 1045 in ogl.c):

// Generate OpenGL texture IDs.
glGenTextures (1, &tex->handle);
//set priority
glPrioritizeTextures (1, &tex->handle, &tex->prio);
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

It must be glGenTextures() then. I have checked that code though, and at least on my system (both OpenSUSE 10.0 Linux distro and WinXP pro) the textures are freed immediately when they're not needed any more (the caller here is ogl_ubitblit_i(), which generates a texture, renders it, and then frees it). I think your gfx driver might be to blame here.
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Post by McMartin »

I'm given to understand you got the HMP->MIDI converter from somewhere else, so I imagine this is extremely low priority, but for the record, the HMP->MIDI conversion is still pretty badly bugged on Descent 1 tracks.

In particular, something that I'm sure is supposed to be some kind of atomspheric background instrument in D1L2 is actually coming out as a playground whistle.

The D2 tracks seem reasonable (though I haven't played them as much) so this might be a D1/D2 thing.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

McMartin,

your post isn't particularly helpful. Feel free to investigate in the issue and come up with a solution. The source code is available on my D2 site.

FYI: The background sound is not midi, it's a 11 khz sound effect that gets resampled to 22 khz.
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6514
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Re:

Post by Jeff250 »

Diedel wrote:FYI: The background sound is not midi, it's a 11 khz sound effect that gets resampled to 22 khz.
If you're talking about the sound I think you're talking about, there are no Class 1 Drillers on lvl. 2. :P
McMartin wrote:Getting MIDI working kind of involves some fiddly bits with Timidity and SDL_mixer, but those aren't bugs, with one exception.
Could you explain what you did to get midi working? I already have a functional Timidity, the sdl mixer libs, and D2x XL 1.5.128--which I believe should have the D2x-side of MIDI taken care of at least.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

1.5.128 Linux has a bug in hmp to midi conversion. Get 1.5.130.
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Re:

Post by McMartin »

Diedel wrote:McMartin,

your post isn't particularly helpful. Feel free to investigate in the issue and come up with a solution. The source code is available on my D2 site.
Yeah. I tried to phrase it in the "this isn't a fully solved problem yet, oh well" level, as opposed to the "zomg fixplz" level.

I'll take a look when I can, but I've got an awful lot of other stuff on my plate at the moment. If anyone else wants to swoop in and come to the rescue, I won't mind :D
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

With 1.5.132 source, a linker error:

gcc -I ./arch/linux/include -I/usr/include/SDL -D_REENTRANT -pipe -O2 -Wall -Wno-char-subscripts -o d2x-gl main/libmain.a 3d/lib3d.a 2d/lib2d.a arch/linux/libarch_linux.a arch/ogl/libarch_ogl.a arch/sdl/libarch_sdl.a libmve/libmve.a mem/libmem.a iff/libiff.a texmap/libtexmap.a misc/libmisc.a maths/libmaths.a cfile/libcfile.a -lm -lGL -lGLU -lSDL_mixer -lSDL -lpthread
main/libmain.a(songs.o): In function `songs_play_song':
songs.c:(.text+0x535): undefined reference to `midi_volume'
songs.c:(.text+0x549): undefined reference to `midi_volume'
collect2: ld returned 1 exit status
make[2]: *** [d2x-gl] Error 1
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

I just compiled it w/o a hitch. Btw, I have made a small update to v1.5.132, so you may want to re-download it.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

gunzip: d2x-xl-src-1.5.132.tgz: unexpected end of file

File size 593920 bytes

Not a partial download. I tried refreshing the webpage, redownloading the file, and downloading the file with another browser. But it was always the same file. I'm not using proxies.

Update - It's ok now! (the file - the linker error is still there)
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

I had some trouble uploading the file because my web space is full. A complete source tgz should be online now.
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6514
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Re:

Post by Jeff250 »

_sd wrote:With 1.5.132 source, a linker error:

gcc -I ./arch/linux/include -I/usr/include/SDL -D_REENTRANT -pipe -O2 -Wall -Wno-char-subscripts -o d2x-gl main/libmain.a 3d/lib3d.a 2d/lib2d.a arch/linux/libarch_linux.a arch/ogl/libarch_ogl.a arch/sdl/libarch_sdl.a libmve/libmve.a mem/libmem.a iff/libiff.a texmap/libtexmap.a misc/libmisc.a maths/libmaths.a cfile/libcfile.a -lm -lGL -lGLU -lSDL_mixer -lSDL -lpthread
main/libmain.a(songs.o)In function `songs_play_song':
songs.c:(.text+0x535)undefined reference to `midi_volume'
songs.c:(.text+0x549)undefined reference to `midi_volume'
collect2ld returned 1 exit status
make[2]*** [d2x-gl] Error 1
I'm having the same trouble. I noticed that if I just change the midi_volume declaration immediately before the songs_play_song function to actually equal something, like =0 or =255, then it compiles fine. MIDI doesn't work then though, not that it would have worked otherwise. The only way I've gotten the MIDI to work so far on Linux is to just use the pre-compiled binary.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

Edit src/conf.h and see whether USE_SDL_MIXER is defined as 1. If not, change that to '#define USE_SDL_MIXER 1'
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

Setting the midi_volume to 4 enables me to compile the game (1.5.132), but when running, I get

Fatal signal: Segmentation Fault (SDL Parachute Deployed)

and nothing else. The 1.5.127 version still runs fine, with the exception of the memory hog problem, which I am still trying to solve. The binary 1.5.132 also segfaults.
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

1.5.132 segfaults if you haven't specified a default player profile in d2x.ini (-player <player name>).

Apart from that all I can say is that D2X-XL works on my Linux box with midi enabled. Sorry I cannot help more.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

I had \"-player jaakko\" in a file called .d2x-xl in my home dir. Still segfaulted. Tried putting the same string into /usr/local/share/d2x-xl/d2x.ini, with the same result.

Is there an automatic way the game will do this, or will every user need to know to put it there?
User avatar
Diedel
D2X Master
D2X Master
Posts: 5278
Joined: Thu Nov 05, 1998 12:01 pm
Contact:

Post by Diedel »

_sd,

what can I say?

All the things you find faulty work with my Linux distro, compiler, SDL installation, OpenGL driver and D2X-XL setup.

I don't know how to help you. I'd need to debug the application on your machine to help you.
_sd
DBB Ace
DBB Ace
Posts: 41
Joined: Sat Feb 04, 2006 3:41 pm
Location: Scandinavia

Post by _sd »

I'll try to compile d2x-xl tomorrow in an Ubuntu box. I also filed a bug in Freedesktop bugzilla about the memory leak. I still don't get the midi_volume thing. Should I define it or not? Or where is it supposed to come from? Do I have an outdated ALSA, or what else could it be?

If there is no default profile defined, the game could assume that the first profile it finds is the default. Also, I see next to no output on the terminal I run d2x-gl from. I'd like it to report to stderr when it doesn't find something. It could also report when it finds something if -debug is specified on the cmdline.
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Post by McMartin »

_sd: The sequence goes:

(1) run ./configure.
(2) edit conf.h. #define USE_SDL_MIXER 1 in it.
(3) make
(4) Should work. (if not, timidity and SDL-mixer have not been set up right for your distro; the instructions on the D2X-XL page should put you in decent stead.)
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Post by McMartin »

And, bug reports in 1.5.132.

I'm also seeing the segfault. It's appearing when the \"Select Player\" screen appears, and only if it's the first menu in the game. gdb gave me this backtrace:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 23059)]
0xb7c8b428 in strcmp () from /lib/libc.so.6
(gdb) bt
#0  0xb7c8b428 in strcmp () from /lib/libc.so.6
#1  0x08069ed1 in nm_load_background (filename=0x0, bg=0xbff8b890, bRedraw=0)
    at newmenu.c:888
#2  0x0806a33e in nm_init_background (filename=0x0, bg=0xbff8b890, x=143, y=64, w=354,
    h=352, bRedraw=0) at newmenu.c:1050
#3  0x0806a591 in nm_draw_background (bg=0x812a58f, x1=143, y1=31, x2=353, y2=351,
    bRedraw=135439759) at newmenu.c:957
#4  0x08070bdf in newmenu_get_filename (title=0xa853356 \"Select pilot\\n<Ctrl-D> deletes\",
    filespec=0xbff8bb20 \"/usr/local/share/d2x-xl/*.plr\",
    filename=0x812a58f \"\\001menub.pcx\", allow_abort_flag=0) at newmenu.c:3362
#5  0x080ea49e in SelectPlayer () at gameseq.c:1137
#6  0x0804eb5a in main (argc=1, argv=0xbff8bd60) at inferno.c:1974
Furthermore, it appears that any time I reload a game, the difficulty is reset to Hotshot. This seems to go at least back to .125.
User avatar
Suncho
DBB Defender
DBB Defender
Posts: 3222
Joined: Sat Jan 30, 1999 3:01 am
Location: Richmond, VT
Contact:

Post by Suncho »

McMartin, that was fixed in 1.5.133 (The Select Player Crash).
McMartin
DBB Cadet
DBB Cadet
Posts: 8
Joined: Mon Feb 20, 2006 3:08 pm

Post by McMartin »

Is there a CVS server or whatnot for later-than-latest Linux releases?
User avatar
Suncho
DBB Defender
DBB Defender
Posts: 3222
Joined: Sat Jan 30, 1999 3:01 am
Location: Richmond, VT
Contact:

Post by Suncho »

No (Actually yes. See Jeff's post =P ), but it also crashed in the Windows version. Here's the change list: http://www.descent2.de/d2x-history.html
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6514
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Post by Jeff250 »

Yes, SVN server here:
http://myxo.css.msu.edu:443/d2x-xl/trunk
I usually have trouble compiling the source on the SVN server though.
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6514
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Re:

Post by Jeff250 »

Diedel wrote:Edit src/conf.h and see whether USE_SDL_MIXER is defined as 1. If not, change that to '#define USE_SDL_MIXER 1'
Yep, this solved it.
Post Reply