0
0

Hello, Let me start by saying that I’m using the latest Fmod (3.5) and work in Linux.
To make a long story short, I have been sitting here the whole day trying to figure out why fmod crashes when I use it in my demo. The answer came to me when comparing the makefiles. I’m using elecric fence (a memory overrun detector) in my code. And when used together with fmod, fmod crashes. Let’s see this in action.

talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ cat Makefile
all: Main.cpp
gcc -g -O2 -D__linux__ -o stream Main.cpp ../../api/libfmod-3.5.so
clean:
rm -f stream
talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ make
gcc -g -O2 -D__linux__ -o stream Main.cpp ../../api/libfmod-3.5.so

talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ ./stream test.mp3

Press SPACE to pause/unpause
Press ‘f’ to fast forward 2 seconds

Press ESC to quit

Playing stream…

Name : test.mp3
Frequency : 44100

pos 48274/6285816 time 00:01/04:21 cpu 0.00% [

STREAM ENDED!!

— Making some changes in the Makefile —

talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ make
gcc -g -O2 -D__linux__ -lefence -o stream Main.cpp ../../api/libfmod-3.5.so
talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ ./stream test.mp3

Electric Fence 2.1 Copyright (C) 1987-1998 Bruce Perens.
Segmentation fault
talos@mastereve:~/work/demo/code/test/fmodapi/samples/stream$ gdb ./stream
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-linux”…
(gdb) r test.mp3
Starting program: /home/talos/work/demo/code/test/fmodapi/samples/stream/stream 01-moment_of_peace-interlude-etlmp3.mp3
[New Thread 1024 (LWP 4679)]

Electric Fence 2.1 Copyright (C) 1987-1998 Bruce Perens.
[New Thread 2049 (LWP 4680)]
[New Thread 1026 (LWP 4681)]
[New Thread 2051 (LWP 4682)]
[New Thread 3076 (LWP 4683)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 2051 (LWP 4682)]
0x4005926a in _FSOUND_MixerClipCopy_Int16MMX () from ../../api/libfmod-3.5.so
(gdb) where

0 0x4005926a in _FSOUND_MixerClipCopy_Int16MMX ()

from ../../api/libfmod-3.5.so

1 0x40055fac in FSOUND_Software_ClipAndCopy () from ../../api/libfmod-3.5.so

2 0x00000004 in ?? ()

(gdb)

I don’t know but it seems likely that the problem is here (given the name of the functions)…
Just thought I should bring it to your attention

Thanx, Marcus Hufvudsson

  • You must to post comments
0
0

I tend to disagree about your statement about memory debugers setting off false alarms. I have used electric fence for years and it has always come through.
The only thing electric fence does is wrap *alloc calls and fills the extra memory your get due to system alignment with known bits. If these bits changes during execution there has obvioulsy been a memory overrun. I don’t know much if the windows world but in UNIX this is a good memory overrun detector. I however do not say that you might be right.

I tried adding FSOUND_SetMemorySystem(malloc(410241024), 410241024, NULL, NULL, NULL); and it did infact work with electric fence.

However, since I don’t realy understand what SetMemorySystem does it’s hard to debug. Is it some kind of code that extends systembuffers even further? In that case it’s no wonder electic fence doesn’t complain since it only operates on the alignment bits. Maybe FMOD just overruns a buffer with a single byte, This is enough for the system to work on 32 bit platforms but might fail on others. Anyway, I’m not critizising, just bringing it to your attention. I think you know what you are doing. Release fmod as opensource so everyone can explore 😉
Thanx for a great Sound system

Marcus Hufvudsson

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.