[FIXED] Problem using sunvox.so on Linux

Found a bug? Post it here.
Post Reply
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

[FIXED] Problem using sunvox.so on Linux

Post by Ats »

Hi. I'm using the awesome sunvox library with ZGameEditor. Everything is fine on Windows and Android, but it crashes on Linux.

Here's the debug log from ZGameEditor:

Code: Select all

Desired audio buffer size: 2048 frames
ALSA: pulse
ALSA HW Default rate: 44100
ALSA HW Rate: 44100 frames
ALSA HW Buffer size: 4096 frames
ALSA HW Period size: 227
ALSA HW Periods: 0
ALSA SW Avail min: 227
ALSA SW Start threshold: 1
ALSA SW Stop threshold: 4096
An unhandled exception occurred at $ECA8D1FE:
EAccessViolation: Access violation $ECA8D1FE
The address exception changes every time.

The problem occurs when I use either one of those two SunVox functions:
int sv_load(int slot, string name){}
int sv_load_from_memory(int slot, xptr data, int data_size) {}

The weird thing is that it works perfectly when I use sunvox_lofi.so instead. It's not coming from an old computer problem. I tried on an i386 and a recent x64 one. I also tried an older version of SunVox 1.9.4c and got the same problem.

Finally, here's the debug log using gdb:

Code: Select all

Starting program: /home/ats/Dropbox/Taf/Omeganaut/SunVox 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0xeeef0b40 (LWP 8503)]
[New Thread 0xee4ffb40 (LWP 8504)]
[New Thread 0xedaffb40 (LWP 8505)]
[New Thread 0xed2feb40 (LWP 8506)]
Desired audio buffer size: 2048 frames
[New Thread 0xe81ffb40 (LWP 8507)]
ALSA: pulse
ALSA HW Default rate: 44100
ALSA HW Rate: 44100 frames
ALSA HW Buffer size: 4096 frames
ALSA HW Period size: 227
ALSA HW Periods: 0
ALSA SW Avail min: 227
ALSA SW Start threshold: 1
ALSA SW Stop threshold: 4096
[New Thread 0xdb7ffb40 (LWP 8508)]

Thread 1 "SunVox" received signal SIGSEGV, Segmentation fault.
0xedc8d1fe in ?? () from ./sunvox.so
And the stack trace log:

Code: Select all

#0  0xedc8d1fe in ?? () from ./sunvox.so
#1  0xedc92667 in psynth_sampler(int, psynth_event*, psynth_net*) ()
   from ./sunvox.so
#2  0xedc7037a in psynth_add_module(int, unsigned int (*)(int, psynth_event*, psynth_net*), char const*, unsigned int, int, int, int, int, int, psynth_net*) ()
   from ./sunvox.so
#3  0xedc5fad5 in sunvox_load_proj_from_fd(unsigned int, unsigned int, sunvox_engine*) () from ./sunvox.so
#4  0xedc54861 in sv_load_from_memory () from ./sunvox.so
#5  0x0806de8c in ?? ()
#6  0x0806ba5f in ?? ()
What could cause that bug?

I'm also trying to compile the SunVox examples on Linux in order to check of sunvox.so is running or if the problem comes from ZGameEditor.
Last edited by Ats on Wed Apr 21, 2021 5:14 pm, edited 2 times in total.
User avatar
NightRadio
Site Admin
Posts: 3550
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Problem using sunvox.so on Linux

Post by NightRadio »

Thank you for the stack trace.
At least we see now that the crash point is somewhere in the sampler :)
1. Have you tried to load other SunVox project files? If this is a problem of only one specific project - could you send it to me?
2. Please show the whole program listing for the ZGameEditor
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

The problem appears on each and every tests made with ZGameEditor.
You can download my three examples here :
  • SunVox is my test which is crashing
  • SunVox_lofi is the same, but instead it is using sunvox_lofi.so and is working fine
  • SunVoxDemo3 is one of the demo that Rado1 put together in order to show how SunVox is working in ZGE years ago
  • , require sunvox.so and crash
Here's the code of my test. In that short example, I used sv_load instead of sv_load_from_memory, so it wouldn't be too long with the binaries of the sunvox music included into the xml file.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
  <OnLoaded>
    <ZExternalLibrary ModuleName="./sunvox.so" CallingConvention="1">
      <Source>
<![CDATA[//

int sv_init(string config, int freq, int channels, int flags){}
int sv_deinit(){}

int sv_open_slot(int slot){}
int sv_close_slot(int slot){}

int sv_load(int slot, string name){}
int sv_load_from_memory(int slot, xptr data, int data_size) {}

int sv_play(int slot){}
int sv_stop(int slot){}

]]>
      </Source>
    </ZExternalLibrary>
    <ZExpression>
      <Expression>
<![CDATA[//

sv_init("", 44100, 2, 0);
sv_open_slot(0);
sv_load(0, "./completedestruction.sunvox");
//sv_load_from_memory(0, MusicFile.FileEmbedded, MusicFile.Size);
sv_play(0);

]]>
      </Expression>
    </ZExpression>
  </OnLoaded>
  <OnClose>
    <ZExpression>
      <Expression>
<![CDATA[//

sv_stop(0);
sv_close_slot(0);
sv_deinit();

]]>
      </Expression>
    </ZExpression>
  </OnClose>
</ZApplication>
As you see, it's rather simple. I'm loading the external sunvox.so and defining the functions that I'm using in it.
Then I init sunvox, open a slot, load the external music and play it. But the crash occurs during the loading.

That's why I was trying to build the SunVox linux examples which are working fine...
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

1. Have you tried to load other SunVox project files? If this is a problem of only one specific project - could you send it to me?
Oh, you were talking about the musics... So I tried a few musics and, to surprise, some works and others just crash the program.

I'm currently making you a list of what musics are crashing.
Last edited by Ats on Sun Apr 11, 2021 10:26 pm, edited 2 times in total.
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

So I tested the first 10 musics in the sunvox/examples folder. Here are the results:

Working:
CsardasContinuum.sunvox
electrohouse.sunvox
Kiberaver - Hard Motor.sunvox
NightRadio - 1bit Song.sunvox
NightRadio - 8bit Tales.sunvox

Crashing:
AzZzX - Bipoliaro4ka.sunvox
Boomlinde - Caravan.sunvox
kostya_m - Midnight.sunvox
Manwe - Aquar.io Ambient.sunvox
Manwe - Early Fall remake (original by Tangrine).sunvox

But all those musics are playing fine with sunvox_lofi.so
User avatar
NightRadio
Site Admin
Posts: 3550
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Problem using sunvox.so on Linux

Post by NightRadio »

Ok, thank you!
It looks like there are some conflicts with ZGameEditor
I'll try to check it out soon.
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

Thanks. Tell me if you need the file Player_linux.bin needed by ZgameEditor to produce linux elf, as it needs to be compilated with Pascal, and it's not an easy task...
User avatar
NightRadio
Site Admin
Posts: 3550
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Problem using sunvox.so on Linux

Post by NightRadio »

Unfortunately i can't test your executables now...

Please try this version of the library (slow, for debug only):
https://warmplace.ru/soft/sunvox/sunvox ... 6debug.zip

Then do the following:
gdb ./yourapp
run

...wait for crash...
bt full
...send me the new detailed stack trace...

Thanks!
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

No problem. Thanks for the follow-up.
In the meantime, ZGameEditor is currently modified to use SDL2 instead of SDL1.2, so it can be compiled for x86_64 and aarch64 hardware. But the loading of external libraries seems to be broken. I'm keeping that sunvox debug library for the time when it will be useful.
User avatar
Ats
Posts: 9
Joined: Sat Apr 10, 2021 9:12 pm
Contact:

Re: Problem using sunvox.so on Linux

Post by Ats »

And it's repaired: http://www.emix8.org/forum/viewtopic.ph ... 9932#p9932
If I stumble on a music that give me the same problem as before, I'll let you know.
Thanks for your help!
Post Reply